Browse Source

applied clang-format

Eyck Jentzsch 2 years ago
parent
commit
a5c9101b71

+ 97
- 0
.clang-format View File

@@ -0,0 +1,97 @@
1
+---
2
+Language:        Cpp
3
+# BasedOnStyle:  LLVM
4
+# should be in line with IndentWidth
5
+AccessModifierOffset: -4
6
+AlignAfterOpenBracket: Align
7
+AlignConsecutiveAssignments: false
8
+AlignConsecutiveDeclarations: false
9
+AlignEscapedNewlinesLeft: false
10
+AlignOperands:   true
11
+AlignTrailingComments: true
12
+AllowAllParametersOfDeclarationOnNextLine: true
13
+AllowShortBlocksOnASingleLine: false
14
+AllowShortCaseLabelsOnASingleLine: false
15
+AllowShortFunctionsOnASingleLine: All
16
+AllowShortIfStatementsOnASingleLine: true
17
+AllowShortLoopsOnASingleLine: true
18
+AlwaysBreakAfterDefinitionReturnType: None
19
+AlwaysBreakAfterReturnType: None
20
+AlwaysBreakBeforeMultilineStrings: false
21
+AlwaysBreakTemplateDeclarations: false
22
+BinPackArguments: true
23
+BinPackParameters: true
24
+BraceWrapping:   
25
+  AfterClass:      false
26
+  AfterControlStatement: false
27
+  AfterEnum:       false
28
+  AfterFunction:   false
29
+  AfterNamespace:  false
30
+  AfterObjCDeclaration: false
31
+  AfterStruct:     false
32
+  AfterUnion:      false
33
+  BeforeCatch:     false
34
+  BeforeElse:      false
35
+  IndentBraces:    false
36
+BreakBeforeBinaryOperators: None
37
+BreakBeforeBraces: Attach
38
+BreakBeforeTernaryOperators: true
39
+BreakConstructorInitializersBeforeComma: false
40
+BreakAfterJavaFieldAnnotations: false
41
+BreakStringLiterals: true
42
+ColumnLimit:     120
43
+CommentPragmas:  '^ IWYU pragma:'
44
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
45
+ConstructorInitializerIndentWidth: 4
46
+ContinuationIndentWidth: 4
47
+Cpp11BracedListStyle: true
48
+DerivePointerAlignment: false
49
+DisableFormat:   false
50
+ExperimentalAutoDetectBinPacking: false
51
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
52
+IncludeCategories: 
53
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
54
+    Priority:        2
55
+  - Regex:           '^(<|"(gtest|isl|json)/)'
56
+    Priority:        3
57
+  - Regex:           '.*'
58
+    Priority:        1
59
+IncludeIsMainRegex: '$'
60
+IndentCaseLabels: false
61
+IndentWidth:     4
62
+IndentWrappedFunctionNames: false
63
+JavaScriptQuotes: Leave
64
+JavaScriptWrapImports: true
65
+KeepEmptyLinesAtTheStartOfBlocks: true
66
+MacroBlockBegin: ''
67
+MacroBlockEnd:   ''
68
+MaxEmptyLinesToKeep: 1
69
+NamespaceIndentation: None
70
+ObjCBlockIndentWidth: 2
71
+ObjCSpaceAfterProperty: false
72
+ObjCSpaceBeforeProtocolList: true
73
+PenaltyBreakBeforeFirstCallParameter: 19
74
+PenaltyBreakComment: 300
75
+PenaltyBreakFirstLessLess: 120
76
+PenaltyBreakString: 1000
77
+PenaltyExcessCharacter: 1000000
78
+PenaltyReturnTypeOnItsOwnLine: 60
79
+PointerAlignment: Right
80
+ReflowComments:  true
81
+SortIncludes:    true
82
+SpaceAfterCStyleCast: false
83
+SpaceAfterTemplateKeyword: true
84
+SpaceBeforeAssignmentOperators: true
85
+SpaceBeforeParens: ControlStatements
86
+SpaceInEmptyParentheses: false
87
+SpacesBeforeTrailingComments: 1
88
+SpacesInAngles:  false
89
+SpacesInContainerLiterals: true
90
+SpacesInCStyleCastParentheses: false
91
+SpacesInParentheses: false
92
+SpacesInSquareBrackets: false
93
+Standard:        Cpp11
94
+TabWidth:        4
95
+UseTab:          Never
96
+...
97
+

+ 20
- 0
cmake/clang-format.cmake View File

@@ -0,0 +1,20 @@
1
+# additional target to perform clang-format run, requires clang-format
2
+
3
+# get all project files
4
+file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
5
+foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
6
+    foreach(PROJECT_TRDPARTY_DIR  ${PROJECT_3PARTY_DIRS})
7
+        string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_EXTERNAL_DIR_FOUND)
8
+        if (NOT ${PROJECT_EXTERNAL_DIR_FOUND} EQUAL -1)
9
+            #message( STATUS "Skipping ${SOURCE_FILE} for clang-format." )
10
+            list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
11
+        endif ()
12
+    endforeach()
13
+endforeach ()
14
+
15
+add_custom_target(
16
+        clangformat
17
+        COMMAND clang-format
18
+        -i
19
+        ${ALL_SOURCE_FILES}
20
+)

+ 642
- 648
incl/scv4tlm/tlm2_recorder.h
File diff suppressed because it is too large
View File


+ 35
- 34
incl/scv4tlm/tlm2_recorder_module.h View File

@@ -24,47 +24,48 @@
24 24
 namespace scv4tlm {
25 25
 /*! \brief The TLM2 transaction recorder
26 26
  *
27
- * This module records all TLM transaction to a SCV transaction stream for further viewing and analysis.
28
- * The handle of the created transaction is storee in an tlm_extension so that another instance of the scv_tlm2_recorder
27
+ * This module records all TLM transaction to a SCV transaction stream for
28
+ * further viewing and analysis.
29
+ * The handle of the created transaction is storee in an tlm_extension so that
30
+ * another instance of the scv_tlm2_recorder
29 31
  * e.g. further down the opath can link to it.
30
- * The transaction recorder is simply bound between an existing pair of initiator and target sockets
32
+ * The transaction recorder is simply bound between an existing pair of
33
+ * initiator and target sockets
31 34
  */
32
-template<unsigned int BUSWIDTH = 32, typename TYPES=tlm::tlm_base_protocol_types>
33
-class tlm2_recorder_module: public sc_core::sc_module, public tlm2_recorder<TYPES> {
35
+template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types>
36
+class tlm2_recorder_module : public sc_core::sc_module, public tlm2_recorder<TYPES> {
34 37
 public:
35
-	SC_HAS_PROCESS(tlm2_recorder_module);
36
-	//! The target socket of the recorder to be bound to the initiator
37
-	tlm::tlm_target_socket<BUSWIDTH, TYPES, 1> target;
38
-	//! The initiator to be bound to the target socket
39
-	tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1> initiator;
38
+    SC_HAS_PROCESS(tlm2_recorder_module);
39
+    //! The target socket of the recorder to be bound to the initiator
40
+    tlm::tlm_target_socket<BUSWIDTH, TYPES, 1> target;
41
+    //! The initiator to be bound to the target socket
42
+    tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1> initiator;
40 43
 
44
+    /*! \brief The constructor of the component
45
+     *
46
+     * \param name is the SystemC module name of the recorder
47
+     * \param tr_db is a pointer to a transaction recording database. If none is
48
+     * provided the default one is retrieved.
49
+     *        If this database is not initialized (e.g. by not calling
50
+     * scv_tr_db::set_default_db() ) recording is disabled.
51
+     */
52
+    tlm2_recorder_module(sc_core::sc_module_name name, bool recording_enabled = true,
53
+                         scv_tr_db *tr_db = scv_tr_db::get_default_db())
54
+        : sc_module(name), tlm2_recorder<TYPES>(recording_enabled, tr_db) {
55
+        // bind the sockets to the module
56
+        target.bind(*this);
57
+        initiator.bind(*this);
58
+    }
41 59
 
42
-	/*! \brief The constructor of the component
43
-	 *
44
-	 * \param name is the SystemC module name of the recorder
45
-	 * \param tr_db is a pointer to a transaction recording database. If none is provided the default one is retrieved.
46
-	 *        If this database is not initialized (e.g. by not calling scv_tr_db::set_default_db() ) recording is disabled.
47
-	 */
48
-	tlm2_recorder_module(sc_core::sc_module_name name, bool recording_enabled = true, scv_tr_db* tr_db = scv_tr_db::get_default_db())
49
-	: sc_module(name)
50
-	, tlm2_recorder<TYPES>(recording_enabled, tr_db)
51
-	{
52
-		// bind the sockets to the module
53
-		target.bind(*this);
54
-		initiator.bind(*this);
55
-	}
56
-
57
-	virtual ~tlm2_recorder_module(){}
58
-
59
-	virtual tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>* get_fw_if() {
60
-		return initiator.get_base_port().operator->();
61
-	}
62
-	virtual tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types>* get_bw_if() {
63
-		return target.get_base_port().operator->();
64
-	}
60
+    virtual ~tlm2_recorder_module() {}
65 61
 
62
+    virtual tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types> *get_fw_if() {
63
+        return initiator.get_base_port().operator->();
64
+    }
65
+    virtual tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types> *get_bw_if() {
66
+        return target.get_base_port().operator->();
67
+    }
66 68
 };
67 69
 } // namespace
68 70
 
69
-
70 71
 #endif /* TLM2_RECORDER_MODULE_H_ */

+ 409
- 524
incl/scv4tlm/tlm_gp_data.h View File

@@ -17,550 +17,435 @@
17 17
 #ifndef TLM_GP_DATA_H_
18 18
 #define TLM_GP_DATA_H_
19 19
 
20
-#include <tlm>
21 20
 #include <assert.h>
21
+#include <tlm>
22 22
 
23 23
 namespace scv4tlm {
24 24
 
25 25
 struct tlm_gp_data {
26
-	//---------------
27
-	// Constructors
28
-	//---------------
29
-
30
-	// Default constructor
31
-	tlm_gp_data()
32
-	: address(0)
33
-	, command(tlm::TLM_IGNORE_COMMAND)
34
-	, data(0)
35
-	, data_length(0)
36
-	, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
37
-	, dmi(false)
38
-	, byte_enable(0)
39
-	, byte_enable_length(0)
40
-	, streaming_width(0)
41
-	, gp_option(tlm::TLM_MIN_PAYLOAD)
42
-	, m_extensions(tlm::max_num_extensions())
43
-	, m_ref_count(0)
44
-	{
45
-	}
46
-
47
-	explicit tlm_gp_data(tlm::tlm_mm_interface* mm)
48
-	: address(0)
49
-	, command(tlm::TLM_IGNORE_COMMAND)
50
-	, data(0)
51
-	, data_length(0)
52
-	, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
53
-	, dmi(false)
54
-	, byte_enable(0)
55
-	, byte_enable_length(0)
56
-	, streaming_width(0)
57
-	, gp_option(tlm::TLM_MIN_PAYLOAD)
58
-	, m_extensions(tlm::max_num_extensions())
59
-	, m_ref_count(0) {
60
-	}
61
-
62
-	int get_ref_count() const {
63
-		return m_ref_count;
64
-	}
65
-
66
-	void reset() {
67
-		//should the other members be reset too?
68
-		gp_option = tlm::TLM_MIN_PAYLOAD;
69
-		m_extensions.free_entire_cache();
70
-	}
71
-	;
72
-
73
-	tlm_gp_data(const tlm::tlm_generic_payload& x)
74
-	: address(x.get_address())
75
-	, command(x.get_command())
76
-	, data(x.get_data_ptr())
77
-	, data_length(x.get_data_length())
78
-	, response_status(x.get_response_status())
79
-	, dmi(x.is_dmi_allowed())
80
-	, byte_enable(x.get_byte_enable_ptr())
81
-	, byte_enable_length(x.get_byte_enable_length())
82
-	, streaming_width(x.get_streaming_width())
83
-	, gp_option(x.get_gp_option())
84
-	, m_extensions(tlm::max_num_extensions())
85
-	, m_ref_count(0)
86
-	{
87
-	}
26
+    //---------------
27
+    // Constructors
28
+    //---------------
29
+
30
+    // Default constructor
31
+    tlm_gp_data()
32
+        : address(0), command(tlm::TLM_IGNORE_COMMAND), data(0), data_length(0),
33
+          response_status(tlm::TLM_INCOMPLETE_RESPONSE), dmi(false), byte_enable(0), byte_enable_length(0),
34
+          streaming_width(0), gp_option(tlm::TLM_MIN_PAYLOAD), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {
35
+    }
36
+
37
+    explicit tlm_gp_data(tlm::tlm_mm_interface *mm)
38
+        : address(0), command(tlm::TLM_IGNORE_COMMAND), data(0), data_length(0),
39
+          response_status(tlm::TLM_INCOMPLETE_RESPONSE), dmi(false), byte_enable(0), byte_enable_length(0),
40
+          streaming_width(0), gp_option(tlm::TLM_MIN_PAYLOAD), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {
41
+    }
42
+
43
+    int get_ref_count() const { return m_ref_count; }
44
+
45
+    void reset() {
46
+        // should the other members be reset too?
47
+        gp_option = tlm::TLM_MIN_PAYLOAD;
48
+        m_extensions.free_entire_cache();
49
+    };
50
+
51
+    tlm_gp_data(const tlm::tlm_generic_payload &x)
52
+        : address(x.get_address()), command(x.get_command()), data(x.get_data_ptr()), data_length(x.get_data_length()),
53
+          response_status(x.get_response_status()), dmi(x.is_dmi_allowed()), byte_enable(x.get_byte_enable_ptr()),
54
+          byte_enable_length(x.get_byte_enable_length()), streaming_width(x.get_streaming_width()),
55
+          gp_option(x.get_gp_option()), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {}
56
+
88 57
 private:
89
-	//disabled copy ctor and assignment operator.
90
-	// Copy constructor
91
-	tlm_gp_data(const tlm_gp_data& x)
92
-	: address(x.get_address())
93
-	, command(x.get_command())
94
-	, data(x.get_data_ptr())
95
-	, data_length(x.get_data_length())
96
-	, response_status(x.get_response_status())
97
-	, dmi(x.is_dmi_allowed())
98
-	, byte_enable(x.get_byte_enable_ptr())
99
-	, byte_enable_length(x.get_byte_enable_length())
100
-	, streaming_width(x.get_streaming_width())
101
-	, gp_option(x.gp_option)
102
-	, m_extensions(tlm::max_num_extensions())
103
-	, m_ref_count(0)
104
-	{
105
-	}
106
-public:
107
-	// Assignment operator needed for SCV introspection
108
-	tlm_gp_data& operator=(const tlm_gp_data& x) {
109
-		command = x.get_command();
110
-		address = x.get_address();
111
-		data = x.get_data_ptr();
112
-		data_length = x.get_data_length();
113
-		response_status = x.get_response_status();
114
-		byte_enable = x.get_byte_enable_ptr();
115
-		byte_enable_length = x.get_byte_enable_length();
116
-		streaming_width = x.get_streaming_width();
117
-		gp_option = x.get_gp_option();
118
-		dmi = x.is_dmi_allowed();
119
-
120
-		// extension copy: all extension arrays must be of equal size by
121
-		// construction (i.e. it must either be constructed after C++
122
-		// static construction time, or the resize_extensions() method must
123
-		// have been called prior to using the object)
124
-		for (unsigned int i = 0; i < m_extensions.size(); i++) {
125
-			m_extensions[i] = x.get_extension(i);
126
-		}
127
-		return (*this);
128
-	}
129
-
130
-	// non-virtual deep-copying of the object
131
-	void deep_copy_from(const scv4tlm::tlm_gp_data & other) {
132
-		command = other.get_command();
133
-		address = other.get_address();
134
-		data_length = other.get_data_length();
135
-		response_status = other.get_response_status();
136
-		byte_enable_length = other.get_byte_enable_length();
137
-		streaming_width = other.get_streaming_width();
138
-		gp_option = other.get_gp_option();
139
-		dmi = other.is_dmi_allowed();
140
-
141
-		// deep copy data
142
-		// there must be enough space in the target transaction!
143
-		if (data && other.get_data_ptr()) {
144
-			memcpy(data, other.get_data_ptr(), data_length);
145
-		}
146
-		// deep copy byte enables
147
-		// there must be enough space in the target transaction!
148
-		if (byte_enable && other.get_byte_enable_ptr()) {
149
-			memcpy(byte_enable, other.get_byte_enable_ptr(), byte_enable_length);
150
-		}
151
-		// deep copy extensions (sticky and non-sticky)
152
-		for (unsigned int i = 0; i < other.m_extensions.size(); i++) {
153
-			if (other.get_extension(i)) {                       //original has extension i
154
-				if (!m_extensions[i]) {                   //We don't: clone.
155
-					tlm::tlm_extension_base *ext = other.get_extension(i)->clone();
156
-					if (ext)     //extension may not be clonable.
157
-					{
158
-						set_extension(i, ext);
159
-					}
160
-				} else {                   //We already have such extension. Copy original over it.
161
-					m_extensions[i]->copy_from(*other.get_extension(i));
162
-				}
163
-			}
164
-		}
165
-	}
166
-
167
-	// To update the state of the original generic payload from a deep copy
168
-	// Assumes that "other" was created from the original by calling deep_copy_from
169
-	// Argument use_byte_enable_on_read determines whether to use or ignores byte enables
170
-	// when copying back the data array on a read command
171
-
172
-	void update_original_from(const tlm::tlm_generic_payload & other, bool use_byte_enable_on_read = true) {
173
-		// Copy back extensions that are present on the original
174
-		// update_extensions_from(other);
175
-
176
-		// Copy back the response status and DMI hint attributes
177
-		response_status = other.get_response_status();
178
-		dmi = other.is_dmi_allowed();
179
-
180
-		// Copy back the data array for a read command only
181
-		// deep_copy_from allowed null pointers, and so will we
182
-		// We assume the arrays are the same size
183
-		// We test for equal pointers in case the original and the copy share the same array
184
-
185
-		if (is_read() && data && other.get_data_ptr() && data != other.get_data_ptr()) {
186
-			if (byte_enable && use_byte_enable_on_read) {
187
-				if (byte_enable_length == 8 && data_length % 8 == 0) {
188
-					// Optimized implementation copies 64-bit words by masking
189
-					for (unsigned int i = 0; i < data_length; i += 8) {
190
-						typedef sc_dt::uint64* u;
191
-						*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
192
-						*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
193
-										& *reinterpret_cast<u>(byte_enable);
194
-					}
195
-				} else if (byte_enable_length == 4 && data_length % 4 == 0) {
196
-					// Optimized implementation copies 32-bit words by masking
197
-					for (unsigned int i = 0; i < data_length; i += 4) {
198
-						typedef unsigned int* u;
199
-						*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
200
-						*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
201
-										& *reinterpret_cast<u>(byte_enable);
202
-					}
203
-				} else
204
-					// Unoptimized implementation
205
-					for (unsigned int i = 0; i < data_length; i++)
206
-						if (byte_enable[i % byte_enable_length])
207
-							data[i] = other.get_data_ptr()[i];
208
-			} else
209
-				memcpy(data, other.get_data_ptr(), data_length);
210
-		}
211
-	}
212
-
213
-	/*
214
-	void update_extensions_from(const tlm::tlm_generic_payload & other) {
215
-		// deep copy extensions that are already present
216
-		for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {
217
-			if (other.get_extension(i)) {                       //original has extension i
218
-				if (m_extensions[i]) {                   //We have it too. copy.
219
-					m_extensions[i]->copy_from(*other.get_extension(i));
220
-				}
221
-			}
222
-		}
223
-	}
224
-	 */
225
-
226
-	// Free all extensions. Useful when reusing a cloned transaction that doesn't have memory manager.
227
-	// normal and sticky extensions are freed and extension array cleared.
228
-	void free_all_extensions() {
229
-		m_extensions.free_entire_cache();
230
-		for (unsigned int i = 0; i < m_extensions.size(); i++) {
231
-			if (m_extensions[i]) {
232
-				m_extensions[i]->free();
233
-				m_extensions[i] = 0;
234
-			}
235
-		}
236
-	}
237
-	//--------------
238
-	// Destructor
239
-	//--------------
240
-	virtual ~tlm_gp_data() {
241
-		for(unsigned int i=0; i<m_extensions.size(); i++)
242
-			if(m_extensions[i]) m_extensions[i]->free();
243
-	}
244
-
245
-	//----------------
246
-	// API (including setters & getters)
247
-	//---------------
248
-
249
-	// Command related method
250
-	bool is_read() const {
251
-		return (command == tlm::TLM_READ_COMMAND);
252
-	}
253
-	void set_read() {
254
-		command = tlm::TLM_READ_COMMAND;
255
-	}
256
-	bool is_write() const {
257
-		return (command == tlm::TLM_WRITE_COMMAND);
258
-	}
259
-	void set_write() {
260
-		command = tlm::TLM_WRITE_COMMAND;
261
-	}
262
-	tlm::tlm_command get_command() const {
263
-		return command;
264
-	}
265
-	void set_command(const tlm::tlm_command command) {
266
-		this->command = command;
267
-	}
268
-
269
-	// Address related methods
270
-	sc_dt::uint64 get_address() const {
271
-		return address;
272
-	}
273
-	void set_address(const sc_dt::uint64 address) {
274
-		this->address = address;
275
-	}
276
-
277
-	// Data related methods
278
-	unsigned char* get_data_ptr() const {
279
-		return data;
280
-	}
281
-	void set_data_ptr(unsigned char* data) {
282
-		this->data = data;
283
-	}
284
-
285
-	// Transaction length (in bytes) related methods
286
-	unsigned int get_data_length() const {
287
-		return data_length;
288
-	}
289
-	void set_data_length(const unsigned int length) {
290
-		data_length = length;
291
-	}
292
-
293
-	// Response status related methods
294
-	bool is_response_ok() const {
295
-		return (response_status > 0);
296
-	}
297
-	bool is_response_error() const {
298
-		return (response_status <= 0);
299
-	}
300
-	tlm::tlm_response_status get_response_status() const {
301
-		return response_status;
302
-	}
303
-	void set_response_status(const tlm::tlm_response_status response_status) {
304
-		this->response_status = response_status;
305
-	}
306
-	std::string get_response_string() const {
307
-		switch (response_status) {
308
-		case tlm::TLM_OK_RESPONSE:
309
-			return "TLM_OK_RESPONSE";
310
-		case tlm::TLM_INCOMPLETE_RESPONSE:
311
-			return "TLM_INCOMPLETE_RESPONSE";
312
-		case tlm::TLM_GENERIC_ERROR_RESPONSE:
313
-			return "TLM_GENERIC_ERROR_RESPONSE";
314
-		case tlm::TLM_ADDRESS_ERROR_RESPONSE:
315
-			return "TLM_ADDRESS_ERROR_RESPONSE";
316
-		case tlm::TLM_COMMAND_ERROR_RESPONSE:
317
-			return "TLM_COMMAND_ERROR_RESPONSE";
318
-		case tlm::TLM_BURST_ERROR_RESPONSE:
319
-			return "TLM_BURST_ERROR_RESPONSE";
320
-		case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE:
321
-			return "TLM_BYTE_ENABLE_ERROR_RESPONSE";
322
-		}
323
-		return "TLM_UNKNOWN_RESPONSE";
324
-	}
325
-
326
-	// Streaming related methods
327
-	unsigned int get_streaming_width() const {
328
-		return streaming_width;
329
-	}
330
-	void set_streaming_width(const unsigned int streaming_width) {
331
-		this->streaming_width = streaming_width;
332
-	}
333
-
334
-	// Byte enable related methods
335
-	unsigned char* get_byte_enable_ptr() const {
336
-		return byte_enable;
337
-	}
338
-	void set_byte_enable_ptr(unsigned char* byte_enable) {
339
-		this->byte_enable = byte_enable;
340
-	}
341
-	unsigned int get_byte_enable_length() const {
342
-		return byte_enable_length;
343
-	}
344
-	void set_byte_enable_length(const unsigned int byte_enable_length) {
345
-		this->byte_enable_length = byte_enable_length;
346
-	}
347
-
348
-	// This is the "DMI-hint" a slave can set this to true if it
349
-	// wants to indicate that a DMI request would be supported:
350
-	void set_dmi_allowed(bool dmi_allowed) {
351
-		dmi = dmi_allowed;
352
-	}
353
-	bool is_dmi_allowed() const {
354
-		return dmi;
355
-	}
356
-
357
-	// Use full set of attributes in DMI/debug?
358
-	tlm::tlm_gp_option get_gp_option() const {
359
-		return gp_option;
360
-	}
361
-	void set_gp_option(const tlm::tlm_gp_option gp_opt) {
362
-		gp_option = gp_opt;
363
-	}
58
+    // disabled copy ctor and assignment operator.
59
+    // Copy constructor
60
+    tlm_gp_data(const tlm_gp_data &x)
61
+        : address(x.get_address()), command(x.get_command()), data(x.get_data_ptr()), data_length(x.get_data_length()),
62
+          response_status(x.get_response_status()), dmi(x.is_dmi_allowed()), byte_enable(x.get_byte_enable_ptr()),
63
+          byte_enable_length(x.get_byte_enable_length()), streaming_width(x.get_streaming_width()),
64
+          gp_option(x.gp_option), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {}
364 65
 
365 66
 public:
366
-
367
-	/* --------------------------------------------------------------------- */
368
-	/* Generic Payload attributes:                                           */
369
-	/* --------------------------------------------------------------------- */
370
-	/* - m_command         : Type of transaction. Three values supported:    */
371
-	/*                       - TLM_WRITE_COMMAND                             */
372
-	/*                       - TLM_READ_COMMAND                              */
373
-	/*                       - TLM_IGNORE_COMMAND                            */
374
-	/* - m_address         : Transaction base address (byte-addressing).     */
375
-	/* - m_data            : When m_command = TLM_WRITE_COMMAND contains a   */
376
-	/*                       pointer to the data to be written in the target.*/
377
-	/*                       When m_command = TLM_READ_COMMAND contains a    */
378
-	/*                       pointer where to copy the data read from the    */
379
-	/*                       target.                                         */
380
-	/* - m_length          : Total number of bytes of the transaction.       */
381
-	/* - m_response_status : This attribute indicates whether an error has   */
382
-	/*                       occurred during the transaction.                */
383
-	/*                       Values supported are:                           */
384
-	/*                       - TLM_OK_RESP                                   */
385
-	/*                       - TLM_INCOMPLETE_RESP                           */
386
-	/*                       - TLM_GENERIC_ERROR_RESP                        */
387
-	/*                       - TLM_ADDRESS_ERROR_RESP                        */
388
-	/*                       - TLM_COMMAND_ERROR_RESP                        */
389
-	/*                       - TLM_BURST_ERROR_RESP                          */
390
-	/*                       - TLM_BYTE_ENABLE_ERROR_RESP                    */
391
-	/*                                                                       */
392
-	/* - m_byte_enable     : It can be used to create burst transfers where  */
393
-	/*                    the address increment between each beat is greater */
394
-	/*                    than the word length of each beat, or to place     */
395
-	/*                    words in selected byte lanes of a bus.             */
396
-	/* - m_byte_enable_length : For a read or a write command, the target    */
397
-	/*                    interpret the byte enable length attribute as the  */
398
-	/*                    number of elements in the bytes enable array.      */
399
-	/* - m_streaming_width  :                                                */
400
-	/* --------------------------------------------------------------------- */
401
-
402
-	sc_dt::uint64 address;
403
-	tlm::tlm_command command;
404
-	unsigned char* data;
405
-	unsigned int data_length;
406
-	tlm::tlm_response_status response_status;
407
-	bool dmi;
408
-	unsigned char* byte_enable;
409
-	unsigned int byte_enable_length;
410
-	unsigned int streaming_width;
411
-	tlm::tlm_gp_option gp_option;
67
+    // Assignment operator needed for SCV introspection
68
+    tlm_gp_data &operator=(const tlm_gp_data &x) {
69
+        command = x.get_command();
70
+        address = x.get_address();
71
+        data = x.get_data_ptr();
72
+        data_length = x.get_data_length();
73
+        response_status = x.get_response_status();
74
+        byte_enable = x.get_byte_enable_ptr();
75
+        byte_enable_length = x.get_byte_enable_length();
76
+        streaming_width = x.get_streaming_width();
77
+        gp_option = x.get_gp_option();
78
+        dmi = x.is_dmi_allowed();
79
+
80
+        // extension copy: all extension arrays must be of equal size by
81
+        // construction (i.e. it must either be constructed after C++
82
+        // static construction time, or the resize_extensions() method must
83
+        // have been called prior to using the object)
84
+        for (unsigned int i = 0; i < m_extensions.size(); i++) {
85
+            m_extensions[i] = x.get_extension(i);
86
+        }
87
+        return (*this);
88
+    }
89
+
90
+    // non-virtual deep-copying of the object
91
+    void deep_copy_from(const scv4tlm::tlm_gp_data &other) {
92
+        command = other.get_command();
93
+        address = other.get_address();
94
+        data_length = other.get_data_length();
95
+        response_status = other.get_response_status();
96
+        byte_enable_length = other.get_byte_enable_length();
97
+        streaming_width = other.get_streaming_width();
98
+        gp_option = other.get_gp_option();
99
+        dmi = other.is_dmi_allowed();
100
+
101
+        // deep copy data
102
+        // there must be enough space in the target transaction!
103
+        if (data && other.get_data_ptr()) {
104
+            memcpy(data, other.get_data_ptr(), data_length);
105
+        }
106
+        // deep copy byte enables
107
+        // there must be enough space in the target transaction!
108
+        if (byte_enable && other.get_byte_enable_ptr()) {
109
+            memcpy(byte_enable, other.get_byte_enable_ptr(), byte_enable_length);
110
+        }
111
+        // deep copy extensions (sticky and non-sticky)
112
+        for (unsigned int i = 0; i < other.m_extensions.size(); i++) {
113
+            if (other.get_extension(i)) { // original has extension i
114
+                if (!m_extensions[i]) {   // We don't: clone.
115
+                    tlm::tlm_extension_base *ext = other.get_extension(i)->clone();
116
+                    if (ext) // extension may not be clonable.
117
+                    {
118
+                        set_extension(i, ext);
119
+                    }
120
+                } else { // We already have such extension. Copy original over it.
121
+                    m_extensions[i]->copy_from(*other.get_extension(i));
122
+                }
123
+            }
124
+        }
125
+    }
126
+
127
+    // To update the state of the original generic payload from a deep copy
128
+    // Assumes that "other" was created from the original by calling
129
+    // deep_copy_from
130
+    // Argument use_byte_enable_on_read determines whether to use or ignores byte
131
+    // enables
132
+    // when copying back the data array on a read command
133
+
134
+    void update_original_from(const tlm::tlm_generic_payload &other, bool use_byte_enable_on_read = true) {
135
+        // Copy back extensions that are present on the original
136
+        // update_extensions_from(other);
137
+
138
+        // Copy back the response status and DMI hint attributes
139
+        response_status = other.get_response_status();
140
+        dmi = other.is_dmi_allowed();
141
+
142
+        // Copy back the data array for a read command only
143
+        // deep_copy_from allowed null pointers, and so will we
144
+        // We assume the arrays are the same size
145
+        // We test for equal pointers in case the original and the copy share the
146
+        // same array
147
+
148
+        if (is_read() && data && other.get_data_ptr() && data != other.get_data_ptr()) {
149
+            if (byte_enable && use_byte_enable_on_read) {
150
+                if (byte_enable_length == 8 && data_length % 8 == 0) {
151
+                    // Optimized implementation copies 64-bit words by masking
152
+                    for (unsigned int i = 0; i < data_length; i += 8) {
153
+                        typedef sc_dt::uint64 *u;
154
+                        *reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
155
+                        *reinterpret_cast<u>(&data[i]) |=
156
+                            *reinterpret_cast<u>(&other.get_data_ptr()[i]) & *reinterpret_cast<u>(byte_enable);
157
+                    }
158
+                } else if (byte_enable_length == 4 && data_length % 4 == 0) {
159
+                    // Optimized implementation copies 32-bit words by masking
160
+                    for (unsigned int i = 0; i < data_length; i += 4) {
161
+                        typedef unsigned int *u;
162
+                        *reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
163
+                        *reinterpret_cast<u>(&data[i]) |=
164
+                            *reinterpret_cast<u>(&other.get_data_ptr()[i]) & *reinterpret_cast<u>(byte_enable);
165
+                    }
166
+                } else
167
+                    // Unoptimized implementation
168
+                    for (unsigned int i = 0; i < data_length; i++)
169
+                        if (byte_enable[i % byte_enable_length]) data[i] = other.get_data_ptr()[i];
170
+            } else
171
+                memcpy(data, other.get_data_ptr(), data_length);
172
+        }
173
+    }
174
+
175
+    /*
176
+    void update_extensions_from(const tlm::tlm_generic_payload & other) {
177
+            // deep copy extensions that are already present
178
+            for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {
179
+                    if (other.get_extension(i)) {                       //original
180
+    has extension i
181
+                            if (m_extensions[i]) {                   //We have it
182
+    too. copy.
183
+                                    m_extensions[i]->copy_from(*other.get_extension(i));
184
+                            }
185
+                    }
186
+            }
187
+    }
188
+     */
189
+
190
+    // Free all extensions. Useful when reusing a cloned transaction that doesn't
191
+    // have memory manager.
192
+    // normal and sticky extensions are freed and extension array cleared.
193
+    void free_all_extensions() {
194
+        m_extensions.free_entire_cache();
195
+        for (unsigned int i = 0; i < m_extensions.size(); i++) {
196
+            if (m_extensions[i]) {
197
+                m_extensions[i]->free();
198
+                m_extensions[i] = 0;
199
+            }
200
+        }
201
+    }
202
+    //--------------
203
+    // Destructor
204
+    //--------------
205
+    virtual ~tlm_gp_data() {
206
+        for (unsigned int i = 0; i < m_extensions.size(); i++)
207
+            if (m_extensions[i]) m_extensions[i]->free();
208
+    }
209
+
210
+    //----------------
211
+    // API (including setters & getters)
212
+    //---------------
213
+
214
+    // Command related method
215
+    bool is_read() const { return (command == tlm::TLM_READ_COMMAND); }
216
+    void set_read() { command = tlm::TLM_READ_COMMAND; }
217
+    bool is_write() const { return (command == tlm::TLM_WRITE_COMMAND); }
218
+    void set_write() { command = tlm::TLM_WRITE_COMMAND; }
219
+    tlm::tlm_command get_command() const { return command; }
220
+    void set_command(const tlm::tlm_command command) { this->command = command; }
221
+
222
+    // Address related methods
223
+    sc_dt::uint64 get_address() const { return address; }
224
+    void set_address(const sc_dt::uint64 address) { this->address = address; }
225
+
226
+    // Data related methods
227
+    unsigned char *get_data_ptr() const { return data; }
228
+    void set_data_ptr(unsigned char *data) { this->data = data; }
229
+
230
+    // Transaction length (in bytes) related methods
231
+    unsigned int get_data_length() const { return data_length; }
232
+    void set_data_length(const unsigned int length) { data_length = length; }
233
+
234
+    // Response status related methods
235
+    bool is_response_ok() const { return (response_status > 0); }
236
+    bool is_response_error() const { return (response_status <= 0); }
237
+    tlm::tlm_response_status get_response_status() const { return response_status; }
238
+    void set_response_status(const tlm::tlm_response_status response_status) {
239
+        this->response_status = response_status;
240
+    }
241
+    std::string get_response_string() const {
242
+        switch (response_status) {
243
+        case tlm::TLM_OK_RESPONSE:
244
+            return "TLM_OK_RESPONSE";
245
+        case tlm::TLM_INCOMPLETE_RESPONSE:
246
+            return "TLM_INCOMPLETE_RESPONSE";
247
+        case tlm::TLM_GENERIC_ERROR_RESPONSE:
248
+            return "TLM_GENERIC_ERROR_RESPONSE";
249
+        case tlm::TLM_ADDRESS_ERROR_RESPONSE:
250
+            return "TLM_ADDRESS_ERROR_RESPONSE";
251
+        case tlm::TLM_COMMAND_ERROR_RESPONSE:
252
+            return "TLM_COMMAND_ERROR_RESPONSE";
253
+        case tlm::TLM_BURST_ERROR_RESPONSE:
254
+            return "TLM_BURST_ERROR_RESPONSE";
255
+        case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE:
256
+            return "TLM_BYTE_ENABLE_ERROR_RESPONSE";
257
+        }
258
+        return "TLM_UNKNOWN_RESPONSE";
259
+    }
260
+
261
+    // Streaming related methods
262
+    unsigned int get_streaming_width() const { return streaming_width; }
263
+    void set_streaming_width(const unsigned int streaming_width) { this->streaming_width = streaming_width; }
264
+
265
+    // Byte enable related methods
266
+    unsigned char *get_byte_enable_ptr() const { return byte_enable; }
267
+    void set_byte_enable_ptr(unsigned char *byte_enable) { this->byte_enable = byte_enable; }
268
+    unsigned int get_byte_enable_length() const { return byte_enable_length; }
269
+    void set_byte_enable_length(const unsigned int byte_enable_length) {
270
+        this->byte_enable_length = byte_enable_length;
271
+    }
272
+
273
+    // This is the "DMI-hint" a slave can set this to true if it
274
+    // wants to indicate that a DMI request would be supported:
275
+    void set_dmi_allowed(bool dmi_allowed) { dmi = dmi_allowed; }
276
+    bool is_dmi_allowed() const { return dmi; }
277
+
278
+    // Use full set of attributes in DMI/debug?
279
+    tlm::tlm_gp_option get_gp_option() const { return gp_option; }
280
+    void set_gp_option(const tlm::tlm_gp_option gp_opt) { gp_option = gp_opt; }
412 281
 
413 282
 public:
283
+    /* --------------------------------------------------------------------- */
284
+    /* Generic Payload attributes:                                           */
285
+    /* --------------------------------------------------------------------- */
286
+    /* - m_command         : Type of transaction. Three values supported:    */
287
+    /*                       - TLM_WRITE_COMMAND                             */
288
+    /*                       - TLM_READ_COMMAND                              */
289
+    /*                       - TLM_IGNORE_COMMAND                            */
290
+    /* - m_address         : Transaction base address (byte-addressing).     */
291
+    /* - m_data            : When m_command = TLM_WRITE_COMMAND contains a   */
292
+    /*                       pointer to the data to be written in the target.*/
293
+    /*                       When m_command = TLM_READ_COMMAND contains a    */
294
+    /*                       pointer where to copy the data read from the    */
295
+    /*                       target.                                         */
296
+    /* - m_length          : Total number of bytes of the transaction.       */
297
+    /* - m_response_status : This attribute indicates whether an error has   */
298
+    /*                       occurred during the transaction.                */
299
+    /*                       Values supported are:                           */
300
+    /*                       - TLM_OK_RESP                                   */
301
+    /*                       - TLM_INCOMPLETE_RESP                           */
302
+    /*                       - TLM_GENERIC_ERROR_RESP                        */
303
+    /*                       - TLM_ADDRESS_ERROR_RESP                        */
304
+    /*                       - TLM_COMMAND_ERROR_RESP                        */
305
+    /*                       - TLM_BURST_ERROR_RESP                          */
306
+    /*                       - TLM_BYTE_ENABLE_ERROR_RESP                    */
307
+    /*                                                                       */
308
+    /* - m_byte_enable     : It can be used to create burst transfers where  */
309
+    /*                    the address increment between each beat is greater */
310
+    /*                    than the word length of each beat, or to place     */
311
+    /*                    words in selected byte lanes of a bus.             */
312
+    /* - m_byte_enable_length : For a read or a write command, the target    */
313
+    /*                    interpret the byte enable length attribute as the  */
314
+    /*                    number of elements in the bytes enable array.      */
315
+    /* - m_streaming_width  :                                                */
316
+    /* --------------------------------------------------------------------- */
317
+
318
+    sc_dt::uint64 address;
319
+    tlm::tlm_command command;
320
+    unsigned char *data;
321
+    unsigned int data_length;
322
+    tlm::tlm_response_status response_status;
323
+    bool dmi;
324
+    unsigned char *byte_enable;
325
+    unsigned int byte_enable_length;
326
+    unsigned int streaming_width;
327
+    tlm::tlm_gp_option gp_option;
414 328
 
415
-	/* --------------------------------------------------------------------- */
416
-	/* Dynamic extension mechanism:                                          */
417
-	/* --------------------------------------------------------------------- */
418
-	/* The extension mechanism is intended to enable initiator modules to    */
419
-	/* optionally and transparently add data fields to the                   */
420
-	/* tlm_generic_payload. Target modules are free to check for extensions  */
421
-	/* and may or may not react to the data in the extension fields. The     */
422
-	/* definition of the extensions' semantics is solely in the              */
423
-	/* responsibility of the user.                                           */
424
-	/*                                                                       */
425
-	/* The following rules apply:                                            */
426
-	/*                                                                       */
427
-	/* - Every extension class must be derived from tlm_extension, e.g.:     */
428
-	/*     class my_extension : public tlm_extension<my_extension> { ... }   */
429
-	/*                                                                       */
430
-	/* - A tlm_generic_payload object should be constructed after C++        */
431
-	/*   static initialization time. This way it is guaranteed that the      */
432
-	/*   extension array is of sufficient size to hold all possible          */
433
-	/*   extensions. Alternatively, the initiator module can enforce a valid */
434
-	/*   extension array size by calling the resize_extensions() method      */
435
-	/*   once before the first transaction with the payload object is        */
436
-	/*   initiated.                                                          */
437
-	/*                                                                       */
438
-	/* - Initiators should use the the set_extension(e) or clear_extension(e)*/
439
-	/*   methods for manipulating the extension array. The type of the       */
440
-	/*   argument must be a pointer to the specific registered extension     */
441
-	/*   type (my_extension in the above example) and is used to             */
442
-	/*   automatically locate the appropriate index in the array.            */
443
-	/*                                                                       */
444
-	/* - Targets can check for a specific extension by calling               */
445
-	/*   get_extension(e). e will point to zero if the extension is not      */
446
-	/*   present.                                                            */
447
-	/*                                                                       */
448
-	/* --------------------------------------------------------------------- */
449
-
450
-	// Stick the pointer to an extension into the vector, return the
451
-	// previous value:
452
-	template<typename T> T* set_extension(T* ext) {
453
-		return static_cast<T*>(set_extension(T::ID, ext));
454
-	}
455
-
456
-	// non-templatized version with manual index:
457
-	tlm::tlm_extension_base* set_extension(unsigned int index, tlm::tlm_extension_base* ext) {
458
-		tlm::tlm_extension_base* tmp = m_extensions[index];
459
-		m_extensions[index] = ext;
460
-		return tmp;
461
-	}
462
-
463
-	// Check for an extension, ext will point to 0 if not present
464
-	template<typename T> void get_extension(T*& ext) const {
465
-		ext = get_extension<T>();
466
-	}
467
-	template<typename T> T* get_extension() const {
468
-		return static_cast<T*>(get_extension(T::ID));
469
-	}
470
-	// Non-templatized version with manual index:
471
-	tlm::tlm_extension_base* get_extension(unsigned int index) const {
472
-		return m_extensions[index];
473
-	}
474
-
475
-	//this call just removes the extension from the txn but does not
476
-	// call free() or tells the MM to do so
477
-	// it return false if there was active MM so you are now in an unsafe situation
478
-	// recommended use: when 100% sure there is no MM
479
-	template<typename T> void clear_extension(const T* ext) {
480
-		clear_extension<T>();
481
-	}
482
-
483
-	//this call just removes the extension from the txn but does not
484
-	// call free() or tells the MM to do so
485
-	// it return false if there was active MM so you are now in an unsafe situation
486
-	// recommended use: when 100% sure there is no MM
487
-	template<typename T> void clear_extension() {
488
-		clear_extension(T::ID);
489
-	}
490
-
491
-	//this call removes the extension from the txn and does
492
-	// call free() or tells the MM to do so when the txn is finally done
493
-	// recommended use: when not sure there is no MM
494
-	template<typename T> void release_extension(T* ext) {
495
-		release_extension<T>();
496
-	}
497
-
498
-	//this call removes the extension from the txn and does
499
-	// call free() or tells the MM to do so when the txn is finally done
500
-	// recommended use: when not sure there is no MM
501
-	template<typename T> void release_extension() {
502
-		release_extension(T::ID);
503
-	}
329
+public:
330
+    /* --------------------------------------------------------------------- */
331
+    /* Dynamic extension mechanism:                                          */
332
+    /* --------------------------------------------------------------------- */
333
+    /* The extension mechanism is intended to enable initiator modules to    */
334
+    /* optionally and transparently add data fields to the                   */
335
+    /* tlm_generic_payload. Target modules are free to check for extensions  */
336
+    /* and may or may not react to the data in the extension fields. The     */
337
+    /* definition of the extensions' semantics is solely in the              */
338
+    /* responsibility of the user.                                           */
339
+    /*                                                                       */
340
+    /* The following rules apply:                                            */
341
+    /*                                                                       */
342
+    /* - Every extension class must be derived from tlm_extension, e.g.:     */
343
+    /*     class my_extension : public tlm_extension<my_extension> { ... }   */
344
+    /*                                                                       */
345
+    /* - A tlm_generic_payload object should be constructed after C++        */
346
+    /*   static initialization time. This way it is guaranteed that the      */
347
+    /*   extension array is of sufficient size to hold all possible          */
348
+    /*   extensions. Alternatively, the initiator module can enforce a valid */
349
+    /*   extension array size by calling the resize_extensions() method      */
350
+    /*   once before the first transaction with the payload object is        */
351
+    /*   initiated.                                                          */
352
+    /*                                                                       */
353
+    /* - Initiators should use the the set_extension(e) or clear_extension(e)*/
354
+    /*   methods for manipulating the extension array. The type of the       */
355
+    /*   argument must be a pointer to the specific registered extension     */
356
+    /*   type (my_extension in the above example) and is used to             */
357
+    /*   automatically locate the appropriate index in the array.            */
358
+    /*                                                                       */
359
+    /* - Targets can check for a specific extension by calling               */
360
+    /*   get_extension(e). e will point to zero if the extension is not      */
361
+    /*   present.                                                            */
362
+    /*                                                                       */
363
+    /* --------------------------------------------------------------------- */
364
+
365
+    // Stick the pointer to an extension into the vector, return the
366
+    // previous value:
367
+    template <typename T> T *set_extension(T *ext) { return static_cast<T *>(set_extension(T::ID, ext)); }
368
+
369
+    // non-templatized version with manual index:
370
+    tlm::tlm_extension_base *set_extension(unsigned int index, tlm::tlm_extension_base *ext) {
371
+        tlm::tlm_extension_base *tmp = m_extensions[index];
372
+        m_extensions[index] = ext;
373
+        return tmp;
374
+    }
375
+
376
+    // Check for an extension, ext will point to 0 if not present
377
+    template <typename T> void get_extension(T *&ext) const { ext = get_extension<T>(); }
378
+    template <typename T> T *get_extension() const { return static_cast<T *>(get_extension(T::ID)); }
379
+    // Non-templatized version with manual index:
380
+    tlm::tlm_extension_base *get_extension(unsigned int index) const { return m_extensions[index]; }
381
+
382
+    // this call just removes the extension from the txn but does not
383
+    // call free() or tells the MM to do so
384
+    // it return false if there was active MM so you are now in an unsafe
385
+    // situation
386
+    // recommended use: when 100% sure there is no MM
387
+    template <typename T> void clear_extension(const T *ext) { clear_extension<T>(); }
388
+
389
+    // this call just removes the extension from the txn but does not
390
+    // call free() or tells the MM to do so
391
+    // it return false if there was active MM so you are now in an unsafe
392
+    // situation
393
+    // recommended use: when 100% sure there is no MM
394
+    template <typename T> void clear_extension() { clear_extension(T::ID); }
395
+
396
+    // this call removes the extension from the txn and does
397
+    // call free() or tells the MM to do so when the txn is finally done
398
+    // recommended use: when not sure there is no MM
399
+    template <typename T> void release_extension(T *ext) { release_extension<T>(); }
400
+
401
+    // this call removes the extension from the txn and does
402
+    // call free() or tells the MM to do so when the txn is finally done
403
+    // recommended use: when not sure there is no MM
404
+    template <typename T> void release_extension() { release_extension(T::ID); }
504 405
 
505 406
 private:
506
-	// Non-templatized version with manual index
507
-	void clear_extension(unsigned int index) {
508
-		m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
509
-	}
510
-	// Non-templatized version with manual index
511
-	void release_extension(unsigned int index) {
512
-		m_extensions[index]->free();
513
-		m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
514
-	}
407
+    // Non-templatized version with manual index
408
+    void clear_extension(unsigned int index) { m_extensions[index] = static_cast<tlm::tlm_extension_base *>(0); }
409
+    // Non-templatized version with manual index
410
+    void release_extension(unsigned int index) {
411
+        m_extensions[index]->free();
412
+        m_extensions[index] = static_cast<tlm::tlm_extension_base *>(0);
413
+    }
515 414
 
516 415
 public:
517
-	// Make sure the extension array is large enough. Can be called once by
518
-	// an initiator module (before issuing the first transaction) to make
519
-	// sure that the extension array is of correct size. This is only needed
520
-	// if the initiator cannot guarantee that the generic payload object is
521
-	// allocated after C++ static construction time.
522
-	void resize_extensions() {
523
-		m_extensions.expand(tlm::max_num_extensions());
524
-	}
416
+    // Make sure the extension array is large enough. Can be called once by
417
+    // an initiator module (before issuing the first transaction) to make
418
+    // sure that the extension array is of correct size. This is only needed
419
+    // if the initiator cannot guarantee that the generic payload object is
420
+    // allocated after C++ static construction time.
421
+    void resize_extensions() { m_extensions.expand(tlm::max_num_extensions()); }
525 422
 
526 423
 private:
527
-	tlm::tlm_array<tlm::tlm_extension_base*> m_extensions;
528
-	unsigned int m_ref_count;
424
+    tlm::tlm_array<tlm::tlm_extension_base *> m_extensions;
425
+    unsigned int m_ref_count;
529 426
 };
530 427
 
531
-
532 428
 struct tlm_dmi_data {
533
-	tlm_dmi_data()
534
-	:dmi_ptr(0)
535
-	,dmi_start_address(0)
536
-	,dmi_end_address(0)
537
-	,dmi_access(tlm::tlm_dmi::DMI_ACCESS_NONE)
538
-	,dmi_read_latency(0)
539
-	,dmi_write_latency(0)
540
-	{}
541
-
542
-	tlm_dmi_data(tlm::tlm_dmi& dmi_data)
543
-	:dmi_ptr(dmi_data.get_dmi_ptr())
544
-	,dmi_start_address(dmi_data.get_start_address())
545
-	,dmi_end_address(dmi_data.get_end_address())
546
-	,dmi_access(dmi_data.get_granted_access())
547
-	,dmi_read_latency(dmi_data.get_read_latency().value())
548
-	,dmi_write_latency(dmi_data.get_write_latency().value())
549
-	{}
550
-	//--------------
551
-	// Destructor
552
-	//--------------
553
-	virtual ~tlm_dmi_data() {}
554
-
555
-	unsigned char*   dmi_ptr;
556
-	sc_dt::uint64    dmi_start_address;
557
-	sc_dt::uint64    dmi_end_address;
558
-	tlm::tlm_dmi::dmi_access_e     dmi_access;
559
-	sc_dt::uint64 dmi_read_latency;
560
-	sc_dt::uint64 dmi_write_latency;
561
-
429
+    tlm_dmi_data()
430
+        : dmi_ptr(0), dmi_start_address(0), dmi_end_address(0), dmi_access(tlm::tlm_dmi::DMI_ACCESS_NONE),
431
+          dmi_read_latency(0), dmi_write_latency(0) {}
432
+
433
+    tlm_dmi_data(tlm::tlm_dmi &dmi_data)
434
+        : dmi_ptr(dmi_data.get_dmi_ptr()), dmi_start_address(dmi_data.get_start_address()),
435
+          dmi_end_address(dmi_data.get_end_address()), dmi_access(dmi_data.get_granted_access()),
436
+          dmi_read_latency(dmi_data.get_read_latency().value()),
437
+          dmi_write_latency(dmi_data.get_write_latency().value()) {}
438
+    //--------------
439
+    // Destructor
440
+    //--------------
441
+    virtual ~tlm_dmi_data() {}
442
+
443
+    unsigned char *dmi_ptr;
444
+    sc_dt::uint64 dmi_start_address;
445
+    sc_dt::uint64 dmi_end_address;
446
+    tlm::tlm_dmi::dmi_access_e dmi_access;
447
+    sc_dt::uint64 dmi_read_latency;
448
+    sc_dt::uint64 dmi_write_latency;
562 449
 };
563
-
564
-
565 450
 }
566 451
 #endif /* TLM_GP_DATA_H_ */

+ 83
- 92
incl/scv4tlm/tlm_gp_data_ext.h View File

@@ -20,121 +20,112 @@
20 20
 #include "tlm_gp_data.h"
21 21
 #include <scv.h>
22 22
 
23
-template<>
24
-class scv_extensions<tlm::tlm_command> : public scv_enum_base<tlm::tlm_command> {
23
+template <> class scv_extensions<tlm::tlm_command> : public scv_enum_base<tlm::tlm_command> {
25 24
 public:
26
-	SCV_ENUM_CTOR(tlm::tlm_command) {
27
-		SCV_ENUM(tlm::TLM_READ_COMMAND);
28
-		SCV_ENUM(tlm::TLM_WRITE_COMMAND);
29
-		SCV_ENUM(tlm::TLM_IGNORE_COMMAND);
30
-	}
25
+    SCV_ENUM_CTOR(tlm::tlm_command) {
26
+        SCV_ENUM(tlm::TLM_READ_COMMAND);
27
+        SCV_ENUM(tlm::TLM_WRITE_COMMAND);
28
+        SCV_ENUM(tlm::TLM_IGNORE_COMMAND);
29
+    }
31 30
 };
32 31
 
33
-template<>
34
-class scv_extensions<tlm::tlm_response_status> : public scv_enum_base<tlm::tlm_response_status> {
32
+template <> class scv_extensions<tlm::tlm_response_status> : public scv_enum_base<tlm::tlm_response_status> {
35 33
 public:
36
-	SCV_ENUM_CTOR(tlm::tlm_response_status) {
37
-		SCV_ENUM(tlm::TLM_OK_RESPONSE);
38
-		SCV_ENUM(tlm::TLM_INCOMPLETE_RESPONSE);
39
-		SCV_ENUM(tlm::TLM_GENERIC_ERROR_RESPONSE);
40
-		SCV_ENUM(tlm::TLM_ADDRESS_ERROR_RESPONSE);
41
-		SCV_ENUM(tlm::TLM_COMMAND_ERROR_RESPONSE);
42
-		SCV_ENUM(tlm::TLM_BURST_ERROR_RESPONSE);
43
-		SCV_ENUM(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
44
-	}
34
+    SCV_ENUM_CTOR(tlm::tlm_response_status) {
35
+        SCV_ENUM(tlm::TLM_OK_RESPONSE);
36
+        SCV_ENUM(tlm::TLM_INCOMPLETE_RESPONSE);
37
+        SCV_ENUM(tlm::TLM_GENERIC_ERROR_RESPONSE);
38
+        SCV_ENUM(tlm::TLM_ADDRESS_ERROR_RESPONSE);
39
+        SCV_ENUM(tlm::TLM_COMMAND_ERROR_RESPONSE);
40
+        SCV_ENUM(tlm::TLM_BURST_ERROR_RESPONSE);
41
+        SCV_ENUM(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
42
+    }
45 43
 };
46 44
 
47
-template<>
48
-class scv_extensions<tlm::tlm_gp_option> : public scv_enum_base<tlm::tlm_gp_option> {
45
+template <> class scv_extensions<tlm::tlm_gp_option> : public scv_enum_base<tlm::tlm_gp_option> {
49 46
 public:
50
-	SCV_ENUM_CTOR(tlm::tlm_gp_option) {
51
-		SCV_ENUM(tlm::TLM_MIN_PAYLOAD);
52
-		SCV_ENUM(tlm::TLM_FULL_PAYLOAD);
53
-		SCV_ENUM(tlm::TLM_FULL_PAYLOAD_ACCEPTED);
54
-	}
47
+    SCV_ENUM_CTOR(tlm::tlm_gp_option) {
48
+        SCV_ENUM(tlm::TLM_MIN_PAYLOAD);
49
+        SCV_ENUM(tlm::TLM_FULL_PAYLOAD);
50
+        SCV_ENUM(tlm::TLM_FULL_PAYLOAD_ACCEPTED);
51
+    }
55 52
 };
56 53
 
57
-template<>
58
-class scv_extensions<tlm::tlm_phase_enum> : public scv_enum_base<tlm::tlm_phase_enum> {
54
+template <> class scv_extensions<tlm::tlm_phase_enum> : public scv_enum_base<tlm::tlm_phase_enum> {
59 55
 public:
60
-	SCV_ENUM_CTOR(tlm::tlm_phase_enum) {
61
-		SCV_ENUM(tlm::UNINITIALIZED_PHASE);
62
-		SCV_ENUM(tlm::BEGIN_REQ);
63
-		SCV_ENUM(tlm::END_REQ);
64
-		SCV_ENUM(tlm::BEGIN_RESP);
65
-		SCV_ENUM(tlm::END_RESP);
66
-	}
56
+    SCV_ENUM_CTOR(tlm::tlm_phase_enum) {
57
+        SCV_ENUM(tlm::UNINITIALIZED_PHASE);
58
+        SCV_ENUM(tlm::BEGIN_REQ);
59
+        SCV_ENUM(tlm::END_REQ);
60
+        SCV_ENUM(tlm::BEGIN_RESP);
61
+        SCV_ENUM(tlm::END_RESP);
62
+    }
67 63
 };
68 64
 
69
-template<>
70
-class scv_extensions<tlm::tlm_sync_enum> : public scv_enum_base<tlm::tlm_sync_enum> {
65
+template <> class scv_extensions<tlm::tlm_sync_enum> : public scv_enum_base<tlm::tlm_sync_enum> {
71 66
 public:
72
-	SCV_ENUM_CTOR(tlm::tlm_sync_enum) {
73
-		SCV_ENUM(tlm::TLM_ACCEPTED);
74
-		SCV_ENUM(tlm::TLM_UPDATED);
75
-		SCV_ENUM(tlm::TLM_COMPLETED);
76
-	}
67
+    SCV_ENUM_CTOR(tlm::tlm_sync_enum) {
68
+        SCV_ENUM(tlm::TLM_ACCEPTED);
69
+        SCV_ENUM(tlm::TLM_UPDATED);
70
+        SCV_ENUM(tlm::TLM_COMPLETED);
71
+    }
77 72
 };
78 73
 
79
-template<>
80
-class scv_extensions<scv4tlm::tlm_gp_data> : public scv_extensions_base<scv4tlm::tlm_gp_data> {
74
+template <> class scv_extensions<scv4tlm::tlm_gp_data> : public scv_extensions_base<scv4tlm::tlm_gp_data> {
81 75
 public:
82
-	scv_extensions<sc_dt::uint64>            address;
83
-	scv_extensions<tlm::tlm_command>         command;
84
-	scv_extensions<unsigned char*>           data;
85
-	scv_extensions<unsigned int>             data_length;
86
-	scv_extensions<tlm::tlm_response_status> response_status;
87
-	scv_extensions<bool>                     dmi;
88
-	scv_extensions<unsigned char*>           byte_enable;
89
-	scv_extensions<unsigned int>             byte_enable_length;
90
-	scv_extensions<unsigned int>             streaming_width;
91
-	scv_extensions<tlm::tlm_gp_option>       gp_option;
76
+    scv_extensions<sc_dt::uint64> address;
77
+    scv_extensions<tlm::tlm_command> command;
78
+    scv_extensions<unsigned char *> data;
79
+    scv_extensions<unsigned int> data_length;
80
+    scv_extensions<tlm::tlm_response_status> response_status;
81
+    scv_extensions<bool> dmi;
82
+    scv_extensions<unsigned char *> byte_enable;
83
+    scv_extensions<unsigned int> byte_enable_length;
84
+    scv_extensions<unsigned int> streaming_width;
85
+    scv_extensions<tlm::tlm_gp_option> gp_option;
92 86
 
93
-	SCV_EXTENSIONS_CTOR(scv4tlm::tlm_gp_data) {
94
-		//must be in order
95
-		SCV_FIELD(address);
96
-		SCV_FIELD(command);
97
-		SCV_FIELD(data);
98
-		SCV_FIELD(data_length);
99
-		SCV_FIELD(response_status);
100
-		SCV_FIELD(dmi);
101
-		SCV_FIELD(byte_enable);
102
-		SCV_FIELD(byte_enable_length);
103
-		SCV_FIELD(streaming_width);
104
-		SCV_FIELD(gp_option);
105
-	}
87
+    SCV_EXTENSIONS_CTOR(scv4tlm::tlm_gp_data) {
88
+        // must be in order
89
+        SCV_FIELD(address);
90
+        SCV_FIELD(command);
91
+        SCV_FIELD(data);
92
+        SCV_FIELD(data_length);
93
+        SCV_FIELD(response_status);
94
+        SCV_FIELD(dmi);
95
+        SCV_FIELD(byte_enable);
96
+        SCV_FIELD(byte_enable_length);
97
+        SCV_FIELD(streaming_width);
98
+        SCV_FIELD(gp_option);
99
+    }
106 100
 };
107 101
 
108
-template<>
109
-class scv_extensions<tlm::tlm_dmi::dmi_access_e> : public scv_enum_base<tlm::tlm_dmi::dmi_access_e> {
102
+template <> class scv_extensions<tlm::tlm_dmi::dmi_access_e> : public scv_enum_base<tlm::tlm_dmi::dmi_access_e> {
110 103
 public:
111
-	SCV_ENUM_CTOR(tlm::tlm_dmi::dmi_access_e) {
112
-		SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_NONE);
113
-		SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ);
114
-		SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_WRITE);
115
-		SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ_WRITE);
116
-	}
104
+    SCV_ENUM_CTOR(tlm::tlm_dmi::dmi_access_e) {
105
+        SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_NONE);
106
+        SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ);
107
+        SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_WRITE);
108
+        SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ_WRITE);
109
+    }
117 110
 };
118 111
 
119
-template<>
120
-class scv_extensions<scv4tlm::tlm_dmi_data> : public scv_extensions_base<scv4tlm::tlm_dmi_data> {
112
+template <> class scv_extensions<scv4tlm::tlm_dmi_data> : public scv_extensions_base<scv4tlm::tlm_dmi_data> {
121 113
 public:
122
-	scv_extensions<unsigned char*>   dmi_ptr;
123
-	scv_extensions<sc_dt::uint64>    dmi_start_address;
124
-	scv_extensions<sc_dt::uint64>    dmi_end_address;
125
-	scv_extensions<tlm::tlm_dmi::dmi_access_e> dmi_access;
126
-	scv_extensions<sc_dt::uint64> dmi_read_latency;
127
-	scv_extensions<sc_dt::uint64> dmi_write_latency;
128
-	SCV_EXTENSIONS_CTOR(scv4tlm::tlm_dmi_data) {
129
-		//must be in order
130
-		SCV_FIELD(dmi_ptr);
131
-		SCV_FIELD(dmi_start_address);
132
-		SCV_FIELD(dmi_end_address);
133
-		SCV_FIELD(dmi_access);
134
-		SCV_FIELD(dmi_read_latency);
135
-		SCV_FIELD(dmi_write_latency);
136
-	}
114
+    scv_extensions<unsigned char *> dmi_ptr;
115
+    scv_extensions<sc_dt::uint64> dmi_start_address;
116
+    scv_extensions<sc_dt::uint64> dmi_end_address;
117
+    scv_extensions<tlm::tlm_dmi::dmi_access_e> dmi_access;
118
+    scv_extensions<sc_dt::uint64> dmi_read_latency;
119
+    scv_extensions<sc_dt::uint64> dmi_write_latency;
120
+    SCV_EXTENSIONS_CTOR(scv4tlm::tlm_dmi_data) {
121
+        // must be in order
122
+        SCV_FIELD(dmi_ptr);
123
+        SCV_FIELD(dmi_start_address);
124
+        SCV_FIELD(dmi_end_address);
125
+        SCV_FIELD(dmi_access);
126
+        SCV_FIELD(dmi_read_latency);
127
+        SCV_FIELD(dmi_write_latency);
128
+    }
137 129
 };
138 130
 
139
-
140 131
 #endif /* TLM_GP_DATA_EXT_H_ */

+ 80
- 88
incl/scv4tlm/tlm_rec_initiator_socket.h View File

@@ -23,117 +23,109 @@
23 23
 #include <tlm.h>
24 24
 
25 25
 namespace scv4tlm {
26
-template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
26
+template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
27 27
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
28
-		, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
28
+          ,
29
+          sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
29 30
 #endif
30
-		>
31
+          >
31 32
 #ifndef WITH_SCV
32
-using tlm_rec_initiator_socket  = tlm::tlm_initiator_socket<BUSWIDTH,TYPES,N
33
+using tlm_rec_initiator_socket = tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
33 34
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
34
-, POL
35
+                                                           ,
36
+                                                           POL
35 37
 #endif
36
-		>;
38
+                                                           >;
37 39
 #else
38
-class tlm_rec_initiator_socket: public tlm::tlm_initiator_socket<BUSWIDTH
39
-, TYPES
40
-, N
40
+class tlm_rec_initiator_socket : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
41 41
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
42
-, POL
42
+                                                                  ,
43
+                                                                  POL
43 44
 #endif
44
-> {
45
-	static std::string gen_name(const char* first, const char* second){
46
-		std::stringstream ss;
47
-		ss<<first<<"_"<<second;
48
-		return ss.str();
49
-	}
45
+                                                                  > {
46
+    static std::string gen_name(const char *first, const char *second) {
47
+        std::stringstream ss;
48
+        ss << first << "_" << second;
49
+        return ss.str();
50
+    }
51
+
50 52
 public:
51
-	typedef tlm::tlm_fw_transport_if<TYPES>  fw_interface_type;
52
-	typedef tlm::tlm_bw_transport_if<TYPES>  bw_interface_type;
53
-	typedef sc_core::sc_port<fw_interface_type, N
53
+    typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
54
+    typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
55
+    typedef sc_core::sc_port<fw_interface_type, N
54 56
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
55
-			, POL
57
+                             ,
58
+                             POL
56 59
 #endif
57
-			>   port_type;
58
-	typedef sc_core::sc_export<bw_interface_type> export_type;
59
-	typedef tlm::tlm_base_target_socket_b<BUSWIDTH,
60
-			fw_interface_type,
61
-			bw_interface_type> base_target_socket_type;
62
-	typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH,
63
-			fw_interface_type,
64
-			bw_interface_type> base_type;
60
+                             >
61
+        port_type;
62
+    typedef sc_core::sc_export<bw_interface_type> export_type;
63
+    typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_target_socket_type;
64
+    typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;
65 65
 
66
-	tlm_rec_initiator_socket() :
67
-		tlm::tlm_initiator_socket<BUSWIDTH
68
-		, TYPES
69
-		, N
66
+    tlm_rec_initiator_socket()
67
+        : tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
70 68
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
71
-, POL
69
+                                    ,
70
+                                    POL
72 71
 #endif
73
->()
74
-,recorder()
75
-{
76
-}
72
+                                    >(),
73
+          recorder() {
74
+    }
77 75
 
78
-	explicit tlm_rec_initiator_socket(const char* name) :
79
-						tlm::tlm_initiator_socket<BUSWIDTH
80
-						, TYPES
81
-						, N
76
+    explicit tlm_rec_initiator_socket(const char *name)
77
+        : tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
82 78
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
83
-						, POL
79
+                                    ,
80
+                                    POL
84 81
 #endif
85
-						>(name)
86
-						,recorder(gen_name(name, "rec").c_str())
87
-						{
88
-						}
82
+                                    >(name),
83
+          recorder(gen_name(name, "rec").c_str()) {
84
+    }
89 85
 
90
-	virtual ~tlm_rec_initiator_socket(){}
86
+    virtual ~tlm_rec_initiator_socket() {}
91 87
 
92
-	virtual const char* kind() const {
93
-		return "tlm_rec_target_socket";
94
-	}
95
-	//
96
-	// Bind initiator socket to target socket
97
-	// - Binds the port of the initiator socket to the export of the target
98
-	//   socket
99
-	// - Binds the port of the target socket to the export of the initiator
100
-	//   socket
101
-	//
102
-	virtual void bind(base_target_socket_type& s) {
103
-		// initiator.port -> target.export
104
-		(this->get_base_port())(recorder);
105
-		recorder.fw_port(s.get_base_interface());
106
-		// target.port -> initiator.export
107
-		(s.get_base_port())(recorder);
108
-		recorder.bw_port(this->get_base_interface());
109
-	}
110
-	//
111
-	// Bind initiator socket to initiator socket (hierarchical bind)
112
-	// - Binds both the export and the port
113
-	//
114
-	virtual void bind(base_type& s){
115
-		// port
116
-		(this->get_base_port())(recorder);
117
-		recorder.fw_port(s.get_base_port());
118
-		// export
119
-		(s.get_base_export())(recorder);
120
-		recorder.bw_port(this->get_base_export());
121
-	}
88
+    virtual const char *kind() const { return "tlm_rec_target_socket"; }
89
+    //
90
+    // Bind initiator socket to target socket
91
+    // - Binds the port of the initiator socket to the export of the target
92
+    //   socket
93
+    // - Binds the port of the target socket to the export of the initiator
94
+    //   socket
95
+    //
96
+    virtual void bind(base_target_socket_type &s) {
97
+        // initiator.port -> target.export
98
+        (this->get_base_port())(recorder);
99
+        recorder.fw_port(s.get_base_interface());
100
+        // target.port -> initiator.export
101
+        (s.get_base_port())(recorder);
102
+        recorder.bw_port(this->get_base_interface());
103
+    }
104
+    //
105
+    // Bind initiator socket to initiator socket (hierarchical bind)
106
+    // - Binds both the export and the port
107
+    //
108
+    virtual void bind(base_type &s) {
109
+        // port
110
+        (this->get_base_port())(recorder);
111
+        recorder.fw_port(s.get_base_port());
112
+        // export
113
+        (s.get_base_export())(recorder);
114
+        recorder.bw_port(this->get_base_export());
115
+    }
122 116
 
123
-	//
124
-	// Bind interface to socket
125
-	// - Binds the interface to the export of this socket
126
-	//
127
-	virtual void bind(bw_interface_type& ifs) {
128
-		(this->get_base_export())(ifs);
129
-	}
117
+    //
118
+    // Bind interface to socket
119
+    // - Binds the interface to the export of this socket
120
+    //
121
+    virtual void bind(bw_interface_type &ifs) { (this->get_base_export())(ifs); }
130 122
 
131
-	void setExtensionRecording(tlm2_extensions_recording_if<TYPES>* extensionRecording){
132
-		recorder.setExtensionRecording(extensionRecording);
133
-	}
123
+    void setExtensionRecording(tlm2_extensions_recording_if<TYPES> *extensionRecording) {
124
+        recorder.setExtensionRecording(extensionRecording);
125
+    }
134 126
 
135 127
 protected:
136
-	scv4tlm::tlm2_recorder<TYPES> recorder;
128
+    scv4tlm::tlm2_recorder<TYPES> recorder;
137 129
 };
138 130
 #endif
139 131
 }

+ 75
- 81
incl/scv4tlm/tlm_rec_target_socket.h View File

@@ -23,111 +23,105 @@
23 23
 #include <tlm.h>
24 24
 
25 25
 namespace scv4tlm {
26
-template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
26
+template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
27 27
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
28
-		, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
28
+          ,
29
+          sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
29 30
 #endif
30
-		>
31
+          >
31 32
 #ifndef WITH_SCV
32
-using tlm_rec_target_socket  = tlm::tlm_target_socket<BUSWIDTH,TYPES,N
33
+using tlm_rec_target_socket = tlm::tlm_target_socket<BUSWIDTH, TYPES, N
33 34
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
34
-, POL
35
+                                                     ,
36
+                                                     POL
35 37
 #endif
36
-		>;
38
+                                                     >;
37 39
 #else
38
-class tlm_rec_target_socket: public tlm::tlm_target_socket<BUSWIDTH
39
-, TYPES
40
-, N
40
+class tlm_rec_target_socket : public tlm::tlm_target_socket<BUSWIDTH, TYPES, N
41 41
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
42
-, POL
42
+                                                            ,
43
+                                                            POL
43 44
 #endif
44
-> {
45
-	static std::string gen_name(const char* first, const char* second){
46
-		std::stringstream ss;
47
-		ss<<first<<"_"<<second;
48
-		return ss.str();
49
-	}
45
+                                                            > {
46
+    static std::string gen_name(const char *first, const char *second) {
47
+        std::stringstream ss;
48
+        ss << first << "_" << second;
49
+        return ss.str();
50
+    }
51
+
50 52
 public:
51
-	typedef tlm::tlm_fw_transport_if<TYPES>  fw_interface_type;
52
-	typedef tlm::tlm_bw_transport_if<TYPES>  bw_interface_type;
53
-	typedef sc_core::sc_port<bw_interface_type, N
53
+    typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
54
+    typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
55
+    typedef sc_core::sc_port<bw_interface_type, N
54 56
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
55
-			, POL
57
+                             ,
58
+                             POL
56 59
 #endif
57
-			>   port_type;
60
+                             >
61
+        port_type;
58 62
 
59
-	typedef sc_core::sc_export<fw_interface_type> export_type;
60
-	typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>  base_initiator_socket_type;
63
+    typedef sc_core::sc_export<fw_interface_type> export_type;
64
+    typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_initiator_socket_type;
61 65
 
62
-	typedef tlm::tlm_base_target_socket_b<BUSWIDTH,	fw_interface_type, bw_interface_type> base_type;
66
+    typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;
63 67
 
64
-	tlm_rec_target_socket() :
65
-		tlm::tlm_target_socket<BUSWIDTH
66
-		, TYPES
67
-		, N
68
+    tlm_rec_target_socket()
69
+        : tlm::tlm_target_socket<BUSWIDTH, TYPES, N
68 70
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
69
-		, POL
71
+                                 ,
72
+                                 POL
70 73
 #endif
71
-		>()
72
-		,recorder()
73
-	{
74
-	}
74
+                                 >(),
75
+          recorder() {
76
+    }
75 77
 
76
-	explicit tlm_rec_target_socket(const char* name) :
77
-		tlm::tlm_target_socket<BUSWIDTH
78
-		, TYPES
79
-		, N
78
+    explicit tlm_rec_target_socket(const char *name)
79
+        : tlm::tlm_target_socket<BUSWIDTH, TYPES, N
80 80
 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
81
-		, POL
81
+                                 ,
82
+                                 POL
82 83
 #endif
83
-		>(name)
84
-		,recorder(gen_name(name, "rec").c_str())
85
-	{
86
-	}
87
-
88
-	virtual ~tlm_rec_target_socket(){}
84
+                                 >(name),
85
+          recorder(gen_name(name, "rec").c_str()) {
86
+    }
89 87
 
90
-	virtual const char* kind() const {
91
-		return "tlm_rec_target_socket";
92
-	}
93
-	//
94
-	// Bind target socket to target socket (hierarchical bind)
95
-	// - Binds both the export and the port
96
-	//
97
-	virtual void bind(base_type& s) {
98
-		// export
99
-		(this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
100
-		// port
101
-		(s.get_base_port())(recorder); // bind the recording interface to the port, recording will use the m_port
102
-	}
103
-	//
104
-	// Bind interface to socket
105
-	// - Binds the interface to the export
106
-	//
107
-	virtual void bind(fw_interface_type& ifs){
108
-		export_type* exp = &this->get_base_export();
109
-		if( this == exp ) {
110
-			export_type::bind(recorder); // non-virtual function call
111
-			recorder.fw_port(ifs);
112
-			recorder.bw_port(this->get_base_port());
113
-		} else {
114
-			exp->bind( ifs );
115
-		}
88
+    virtual ~tlm_rec_target_socket() {}
116 89
 
117
-	}
118
-	//
119
-	// Forward to 'operator->()' of port class
120
-	//
121
-	bw_interface_type* operator->() {
122
-		return &recorder;
123
-	}
90
+    virtual const char *kind() const { return "tlm_rec_target_socket"; }
91
+    //
92
+    // Bind target socket to target socket (hierarchical bind)
93
+    // - Binds both the export and the port
94
+    //
95
+    virtual void bind(base_type &s) {
96
+        // export
97
+        (this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
98
+        // port
99
+        (s.get_base_port())(recorder); // bind the recording interface to the port,
100
+                                       // recording will use the m_port
101
+    }
102
+    //
103
+    // Bind interface to socket
104
+    // - Binds the interface to the export
105
+    //
106
+    virtual void bind(fw_interface_type &ifs) {
107
+        export_type *exp = &this->get_base_export();
108
+        if (this == exp) {
109
+            export_type::bind(recorder); // non-virtual function call
110
+            recorder.fw_port(ifs);
111
+            recorder.bw_port(this->get_base_port());
112
+        } else {
113
+            exp->bind(ifs);
114
+        }
115
+    }
116
+    //
117
+    // Forward to 'operator->()' of port class
118
+    //
119
+    bw_interface_type *operator->() { return &recorder; }
124 120
 
125
-	scv4tlm::tlm2_recorder<TYPES>& get_recorder(){
126
-		return recorder;
127
-	}
121
+    scv4tlm::tlm2_recorder<TYPES> &get_recorder() { return recorder; }
128 122
 
129 123
 protected:
130
-	scv4tlm::tlm2_recorder<TYPES> recorder;
124
+    scv4tlm::tlm2_recorder<TYPES> recorder;
131 125
 };
132 126
 #endif
133 127
 }

+ 45
- 46
incl/scv4tlm/tlm_recording_extension.h View File

@@ -23,64 +23,63 @@ namespace scv4tlm {
23 23
 
24 24
 //! transaction relationships
25 25
 enum tx_rel {
26
-	PARENT_CHILD = 0, /*!< indicates parent child relationship */
27
-	PREDECESSOR_SUCCESSOR /*!< indicates predecessor successor relationship */
26
+    PARENT_CHILD = 0,     /*!< indicates parent child relationship */
27
+    PREDECESSOR_SUCCESSOR /*!< indicates predecessor successor relationship */
28 28
 };
29 29
 //! the string representation of the tx_rel
30
-static char const* tx_rel_str[] = { "PARENT/CHILD", "PRED/SUCC" };
30
+static char const *tx_rel_str[] = {"PARENT/CHILD", "PRED/SUCC"};
31 31
 /*! \brief cast the tx_rel enum to a string
32 32
  *
33 33
  * \param tc_rel is the relationship enum
34 34
  */
35
-inline const char* rel_str(tx_rel rel) {
36
-	return (tx_rel_str[rel]);
37
-}
35
+inline const char *rel_str(tx_rel rel) { return (tx_rel_str[rel]); }
38 36
 
39
-/*! \brief generic payload extension class holding the handle of the last recorded SCV transaction
37
+/*! \brief generic payload extension class holding the handle of the last
38
+ * recorded SCV transaction
40 39
  *
41
- * This extension is been used in the \ref scv_tlm2_recorder. The recorder stores the handle to the generated SCV transaction and
42
- * forwrds it along with the generic payload. If the recorder finds an extension containing a valid handle it links the generated
40
+ * This extension is been used in the \ref scv_tlm2_recorder. The recorder
41
+ * stores the handle to the generated SCV transaction and
42
+ * forwrds it along with the generic payload. If the recorder finds an extension
43
+ * containing a valid handle it links the generated
43 44
  * SCV transdaction to the found one using the \ref PREDECESSOR releationship
44 45
  */
45
-struct tlm_recording_extension: public tlm::tlm_extension<tlm_recording_extension> {
46
-	/*! \brief clone the given extension and duplicate the SCV transaction handle.
47
-	 *
48
-	 */
49
-	virtual tlm_extension_base* clone() const {
50
-		tlm_recording_extension* t = new tlm_recording_extension(this->txHandle, this->creator);
51
-		return t;
52
-	}
53
-	/*! \brief copy data between extensions.
54
-	 *
55
-	 * \param from is the source extension.
56
-	 */
57
-	virtual void copy_from(tlm_extension_base const& from) {
58
-		txHandle = static_cast<tlm_recording_extension const &>(from).txHandle;
59
-		creator = static_cast<tlm_recording_extension const &>(from).creator;
60
-	}
61
-	/*! \brief constructor storing the handle of the transaction and the owner of this extension
62
-	 *
63
-	 * \param handle is the handle of the created SCV transaction.
64
-	 * \param creator_ is the pointer to the owner of this extension (usually an instance of scv_tlm2_recorder).
65
-	 */
66
-	tlm_recording_extension(scv_tr_handle handle, void* creator_) :
67
-			txHandle(handle), creator(creator_) {
68
-	}
69
-	/*! \brief accessor to the owner, the property is read only.
70
-	 *
71
-	 */
72
-	void* get_creator() {
73
-		return creator;
74
-	}
75
-	/*! \brief accessor to the SCV transaction handle.
76
-	 *
77
-	 */
78
-	scv_tr_handle txHandle;
46
+struct tlm_recording_extension : public tlm::tlm_extension<tlm_recording_extension> {
47
+    /*! \brief clone the given extension and duplicate the SCV transaction handle.
48
+     *
49
+     */
50
+    virtual tlm_extension_base *clone() const {
51
+        tlm_recording_extension *t = new tlm_recording_extension(this->txHandle, this->creator);
52
+        return t;
53
+    }
54
+    /*! \brief copy data between extensions.
55
+     *
56
+     * \param from is the source extension.
57
+     */
58
+    virtual void copy_from(tlm_extension_base const &from) {
59
+        txHandle = static_cast<tlm_recording_extension const &>(from).txHandle;
60
+        creator = static_cast<tlm_recording_extension const &>(from).creator;
61
+    }
62
+    /*! \brief constructor storing the handle of the transaction and the owner of
63
+     * this extension
64
+     *
65
+     * \param handle is the handle of the created SCV transaction.
66
+     * \param creator_ is the pointer to the owner of this extension (usually an
67
+     * instance of scv_tlm2_recorder).
68
+     */
69
+    tlm_recording_extension(scv_tr_handle handle, void *creator_) : txHandle(handle), creator(creator_) {}
70
+    /*! \brief accessor to the owner, the property is read only.
71
+     *
72
+     */
73
+    void *get_creator() { return creator; }
74
+    /*! \brief accessor to the SCV transaction handle.
75
+     *
76
+     */
77
+    scv_tr_handle txHandle;
78
+
79 79
 private:
80
-	//! the owner of this transaction
81
-	void* creator;
80
+    //! the owner of this transaction
81
+    void *creator;
82 82
 };
83
-
84 83
 }
85 84
 
86 85
 #endif /* TLM_RECORDING_EXTENSION_H_ */

+ 118
- 166
incl/sysc/core/sc_logic_7.h View File

@@ -24,10 +24,10 @@
24 24
 #define INCL_SYSC_CORE_SC_LOGIC_7_H_
25 25
 #include <cstdio>
26 26
 
27
-#include "sysc/utils/sc_iostream.h"
27
+#include "sysc/datatypes/bit/sc_bit.h"
28 28
 #include "sysc/kernel/sc_macros.h"
29
+#include "sysc/utils/sc_iostream.h"
29 30
 #include "sysc/utils/sc_mempool.h"
30
-#include "sysc/datatypes/bit/sc_bit.h"
31 31
 
32 32
 namespace sysc {
33 33
 namespace sc_dt {
@@ -35,23 +35,13 @@ namespace sc_dt {
35 35
 // classes defined in this module
36 36
 class sc_logic_7;
37 37
 
38
-
39 38
 // ----------------------------------------------------------------------------
40 39
 //  ENUM : sc_logic_7_value_t
41 40
 //
42 41
 //  Enumeration of values for sc_logic_7.
43 42
 // ----------------------------------------------------------------------------
44 43
 
45
-enum sc_logic_7_value_t
46
-{
47
-    Log_0 = 0,
48
-    Log_1,
49
-    Log_L,
50
-    Log_H,
51
-    Log_Z,
52
-    Log_X,
53
-    Log_U
54
-};
44
+enum sc_logic_7_value_t { Log_0 = 0, Log_1, Log_L, Log_H, Log_Z, Log_X, Log_U };
55 45
 
56 46
 // ----------------------------------------------------------------------------
57 47
 //  CLASS : sc_logic_7
@@ -59,59 +49,48 @@ enum sc_logic_7_value_t
59 49
 //  Four-valued logic type.
60 50
 // ----------------------------------------------------------------------------
61 51
 
62
-class sc_logic_7
63
-{
52
+class sc_logic_7 {
64 53
 private:
65
-
66 54
     // support methods
67 55
 
68
-    static void invalid_value( sc_logic_7_value_t );
69
-    static void invalid_value( char );
70
-    static void invalid_value( int );
56
+    static void invalid_value(sc_logic_7_value_t);
57
+    static void invalid_value(char);
58
+    static void invalid_value(int);
71 59
 
72
-    static sc_logic_7_value_t to_value( sc_logic_7_value_t v )
73
-    {
74
-        if( v < Log_0 || v > Log_X ) {
75
-        invalid_value( v );
60
+    static sc_logic_7_value_t to_value(sc_logic_7_value_t v) {
61
+        if (v < Log_0 || v > Log_X) {
62
+            invalid_value(v);
76 63
         }
77 64
         return v;
78 65
     }
79 66
 
80
-    static sc_logic_7_value_t to_value( bool b )
81
-    { return ( b ? Log_1 : Log_0 ); }
67
+    static sc_logic_7_value_t to_value(bool b) { return (b ? Log_1 : Log_0); }
82 68
 
83
-    static sc_logic_7_value_t to_value( char c )
84
-    {
69
+    static sc_logic_7_value_t to_value(char c) {
85 70
         sc_logic_7_value_t v;
86 71
         unsigned int index = (int)c;
87
-        if ( index > 127 )
88
-        {
72
+        if (index > 127) {
89 73
             invalid_value(c);
90
-        v = Log_X;
91
-        }
92
-        else
93
-        {
94
-        v = char_to_logic[index];
95
-        if( v < Log_0 || v > Log_X ) {
96
-            invalid_value( c );
97
-        }
74
+            v = Log_X;
75
+        } else {
76
+            v = char_to_logic[index];
77
+            if (v < Log_0 || v > Log_X) {
78
+                invalid_value(c);
79
+            }
98 80
         }
99 81
         return v;
100 82
     }
101 83
 
102
-    static sc_logic_7_value_t to_value( int i )
103
-    {
104
-        if( i < 0 || i > 3 ) {
105
-        invalid_value( i );
84
+    static sc_logic_7_value_t to_value(int i) {
85
+        if (i < 0 || i > 3) {
86
+            invalid_value(i);
106 87
         }
107
-        return sc_logic_7_value_t( i );
88
+        return sc_logic_7_value_t(i);
108 89
     }
109 90
 
110
-
111 91
     void invalid_01() const;
112 92
 
113 93
 public:
114
-
115 94
     // conversion tables
116 95
 
117 96
     static const sc_logic_7_value_t char_to_logic[128];
@@ -121,68 +100,60 @@ public:
121 100
     static const sc_logic_7_value_t xor_table[7][7];
122 101
     static const sc_logic_7_value_t not_table[7];
123 102
 
124
-
125 103
     // constructors
126 104
 
127
-    sc_logic_7()
128
-    : m_val( Log_U )
129
-    {}
130
-
131
-    sc_logic_7( const sc_logic_7& a )
132
-    : m_val( a.m_val )
133
-    {}
105
+    sc_logic_7() : m_val(Log_U) {}
134 106
 
135
-    sc_logic_7( sc_logic_7_value_t v )
136
-    : m_val( to_value( v ) )
137
-    {}
107
+    sc_logic_7(const sc_logic_7 &a) : m_val(a.m_val) {}
138 108
 
139
-    explicit sc_logic_7( bool a )
140
-    : m_val( to_value( a ) )
141
-    {}
109
+    sc_logic_7(sc_logic_7_value_t v) : m_val(to_value(v)) {}
142 110
 
143
-    explicit sc_logic_7( char a )
144
-    : m_val( to_value( a ) )
145
-    {}
111
+    explicit sc_logic_7(bool a) : m_val(to_value(a)) {}
146 112
 
147
-    explicit sc_logic_7( int a )
148
-    : m_val( to_value( a ) )
149
-    {}
113
+    explicit sc_logic_7(char a) : m_val(to_value(a)) {}
150 114
 
151
-    explicit sc_logic_7( const ::sc_dt::sc_bit& a )
152
-    : m_val( to_value( a.to_bool() ) )
153
-    {}
115
+    explicit sc_logic_7(int a) : m_val(to_value(a)) {}
154 116
 
117
+    explicit sc_logic_7(const ::sc_dt::sc_bit &a) : m_val(to_value(a.to_bool())) {}
155 118
 
156 119
     // destructor
157 120
 
158
-    ~sc_logic_7()
159
-    {}
121
+    ~sc_logic_7() {}
160 122
 
123
+// (bitwise) assignment operators
161 124
 
162
-    // (bitwise) assignment operators
163
-
164
-#define DEFN_ASN_OP_T(op,tp)                       \
165
-    sc_logic_7& operator op ( tp v )                 \
166
-        { *this op sc_logic_7( v ); return *this; }
125
+#define DEFN_ASN_OP_T(op, tp)                                                                                          \
126
+    sc_logic_7 &operator op(tp v) {                                                                                    \
127
+        *this op sc_logic_7(v);                                                                                        \
128
+        return *this;                                                                                                  \
129
+    }
167 130
 
168
-#define DEFN_ASN_OP(op)                            \
169
-    DEFN_ASN_OP_T(op, sc_logic_7_value_t)            \
170
-    DEFN_ASN_OP_T(op, bool)                        \
171
-    DEFN_ASN_OP_T(op, char)                        \
172
-    DEFN_ASN_OP_T(op, int )                        \
173
-    DEFN_ASN_OP_T(op, const ::sc_dt::sc_bit& )
131
+#define DEFN_ASN_OP(op)                                                                                                \
132
+    DEFN_ASN_OP_T(op, sc_logic_7_value_t)                                                                              \
133
+    DEFN_ASN_OP_T(op, bool)                                                                                            \
134
+    DEFN_ASN_OP_T(op, char)                                                                                            \
135
+    DEFN_ASN_OP_T(op, int)                                                                                             \
136
+    DEFN_ASN_OP_T(op, const ::sc_dt::sc_bit &)
174 137
 
175
-    sc_logic_7& operator = ( const sc_logic_7& a )
176
-        { m_val = a.m_val; return *this; }
138
+    sc_logic_7 &operator=(const sc_logic_7 &a) {
139
+        m_val = a.m_val;
140
+        return *this;
141
+    }
177 142
 
178
-    sc_logic_7& operator &= ( const sc_logic_7& b )
179
-        { m_val = and_table[m_val][b.m_val]; return *this; }
143
+    sc_logic_7 &operator&=(const sc_logic_7 &b) {
144
+        m_val = and_table[m_val][b.m_val];
145
+        return *this;
146
+    }
180 147
 
181
-    sc_logic_7& operator |= ( const sc_logic_7& b )
182
-        { m_val = or_table[m_val][b.m_val]; return *this; }
148
+    sc_logic_7 &operator|=(const sc_logic_7 &b) {
149
+        m_val = or_table[m_val][b.m_val];
150
+        return *this;
151
+    }
183 152
 
184
-    sc_logic_7& operator ^= ( const sc_logic_7& b )
185
-        { m_val = xor_table[m_val][b.m_val]; return *this; }
153
+    sc_logic_7 &operator^=(const sc_logic_7 &b) {
154
+        m_val = xor_table[m_val][b.m_val];
155
+        return *this;
156
+    }
186 157
 
187 158
     DEFN_ASN_OP(=)
188 159
     DEFN_ASN_OP(&=)
@@ -192,142 +163,125 @@ public:
192 163
 #undef DEFN_ASN_OP_T
193 164
 #undef DEFN_ASN_OP
194 165
 
195
-
196 166
     // bitwise operators and functions
197 167
 
198
-
199
-    friend const sc_logic_7 operator & ( const sc_logic_7&, const sc_logic_7& );
200
-    friend const sc_logic_7 operator | ( const sc_logic_7&, const sc_logic_7& );
201
-    friend const sc_logic_7 operator ^ ( const sc_logic_7&, const sc_logic_7& );
168
+    friend const sc_logic_7 operator&(const sc_logic_7 &, const sc_logic_7 &);
169
+    friend const sc_logic_7 operator|(const sc_logic_7 &, const sc_logic_7 &);
170
+    friend const sc_logic_7 operator^(const sc_logic_7 &, const sc_logic_7 &);
202 171
 
203 172
     // relational operators
204 173
 
205
-    friend bool operator == ( const sc_logic_7&, const sc_logic_7& );
206
-    friend bool operator != ( const sc_logic_7&, const sc_logic_7& );
174
+    friend bool operator==(const sc_logic_7 &, const sc_logic_7 &);
175
+    friend bool operator!=(const sc_logic_7 &, const sc_logic_7 &);
207 176
 
208 177
     // bitwise complement
209 178
 
210
-    const sc_logic_7 operator ~ () const
211
-    { return sc_logic_7( not_table[m_val] ); }
212
-
213
-    sc_logic_7& b_not()
214
-    { m_val = not_table[m_val]; return *this; }
179
+    const sc_logic_7 operator~() const { return sc_logic_7(not_table[m_val]); }
215 180
 
181
+    sc_logic_7 &b_not() {
182
+        m_val = not_table[m_val];
183
+        return *this;
184
+    }
216 185
 
217 186
     // explicit conversions
218 187
 
219
-    sc_logic_7_value_t value() const
220
-    { return m_val; }
188
+    sc_logic_7_value_t value() const { return m_val; }
221 189
 
190
+    bool is_01() const { return ((int)m_val == Log_0 || (int)m_val == Log_1); }
222 191
 
223
-    bool is_01() const
224
-    { return ( (int) m_val == Log_0 || (int) m_val == Log_1 ); }
225
-
226
-    bool to_bool() const
227
-    { if( ! is_01() ) { invalid_01(); } return ( (int) m_val != Log_0 ); }
228
-
229
-    char to_char() const
230
-    { return logic_to_char[m_val]; }
192
+    bool to_bool() const {
193
+        if (!is_01()) {
194
+            invalid_01();
195
+        }
196
+        return ((int)m_val != Log_0);
197
+    }
231 198
 
199
+    char to_char() const { return logic_to_char[m_val]; }
232 200
 
233 201
     // other methods
234 202
 
235
-    void print( ::std::ostream& os = ::std::cout ) const
236
-    { os << to_char(); }
237
-
238
-    void scan( ::std::istream& is = ::std::cin );
203
+    void print(::std::ostream &os = ::std::cout) const { os << to_char(); }
239 204
 
205
+    void scan(::std::istream &is = ::std::cin);
240 206
 
241 207
     // memory (de)allocation
242 208
 
243
-    static void* operator new( std::size_t, void* p ) // placement new
244
-    { return p; }
209
+    static void *operator new(std::size_t, void *p) // placement new
210
+    {
211
+        return p;
212
+    }
245 213
 
246
-    static void* operator new( std::size_t sz )
247
-    { return sc_core::sc_mempool::allocate( sz ); }
214
+    static void *operator new(std::size_t sz) { return sc_core::sc_mempool::allocate(sz); }
248 215
 
249
-    static void operator delete( void* p, std::size_t sz )
250
-    { sc_core::sc_mempool::release( p, sz ); }
216
+    static void operator delete(void *p, std::size_t sz) { sc_core::sc_mempool::release(p, sz); }
251 217
 
252
-    static void* operator new [] ( std::size_t sz )
253
-    { return sc_core::sc_mempool::allocate( sz ); }
218
+    static void *operator new[](std::size_t sz) { return sc_core::sc_mempool::allocate(sz); }
254 219
 
255
-    static void operator delete [] ( void* p, std::size_t sz )
256
-    { sc_core::sc_mempool::release( p, sz ); }
220
+    static void operator delete[](void *p, std::size_t sz) { sc_core::sc_mempool::release(p, sz); }
257 221
 
258 222
 private:
259
-
260 223
     sc_logic_7_value_t m_val;
261 224
 
262 225
 private:
263
-
264 226
     // disabled
265
-    explicit sc_logic_7( const char* );
266
-    sc_logic_7& operator = ( const char* );
227
+    explicit sc_logic_7(const char *);
228
+    sc_logic_7 &operator=(const char *);
267 229
 };
268 230
 
269 231
 // ----------------------------------------------------------------------------
270 232
 
271 233
 // bitwise operators
272 234
 
273
-inline const sc_logic_7 operator & ( const sc_logic_7& a, const sc_logic_7& b )
274
-       { return sc_logic_7( sc_logic_7::and_table[a.m_val][b.m_val] ); }
235
+inline const sc_logic_7 operator&(const sc_logic_7 &a, const sc_logic_7 &b) {
236
+    return sc_logic_7(sc_logic_7::and_table[a.m_val][b.m_val]);
237
+}
275 238
 
276
-inline const sc_logic_7 operator | ( const sc_logic_7& a, const sc_logic_7& b )
277
-       { return sc_logic_7( sc_logic_7::or_table[a.m_val][b.m_val] ); }
239
+inline const sc_logic_7 operator|(const sc_logic_7 &a, const sc_logic_7 &b) {
240
+    return sc_logic_7(sc_logic_7::or_table[a.m_val][b.m_val]);
241
+}
278 242
 
279
-inline const sc_logic_7 operator ^ ( const sc_logic_7& a, const sc_logic_7& b )
280
-       { return sc_logic_7( sc_logic_7::xor_table[a.m_val][b.m_val] ); }
243
+inline const sc_logic_7 operator^(const sc_logic_7 &a, const sc_logic_7 &b) {
244
+    return sc_logic_7(sc_logic_7::xor_table[a.m_val][b.m_val]);
245
+}
281 246
 
282
-#define DEFN_BIN_OP_T(ret,op,tp)                       \
283
-    inline ret operator op ( const sc_logic_7& a, tp b ) \
284
-        { return ( a op sc_logic_7( b ) ); }             \
285
-    inline ret operator op ( tp a, const sc_logic_7& b ) \
286
-        { return ( sc_logic_7( a ) op b ); }
247
+#define DEFN_BIN_OP_T(ret, op, tp)                                                                                     \
248
+    inline ret operator op(const sc_logic_7 &a, tp b) { return (a op sc_logic_7(b)); }                                 \
249
+    inline ret operator op(tp a, const sc_logic_7 &b) { return (sc_logic_7(a) op b); }
287 250
 
288
-#define DEFN_BIN_OP(ret,op)                            \
289
-    DEFN_BIN_OP_T(ret,op,sc_logic_7_value_t)             \
290
-    DEFN_BIN_OP_T(ret,op,bool)                         \
291
-    DEFN_BIN_OP_T(ret,op,char)                         \
292
-    DEFN_BIN_OP_T(ret,op,int)
251
+#define DEFN_BIN_OP(ret, op)                                                                                           \
252
+    DEFN_BIN_OP_T(ret, op, sc_logic_7_value_t)                                                                         \
253
+    DEFN_BIN_OP_T(ret, op, bool)                                                                                       \
254
+    DEFN_BIN_OP_T(ret, op, char)                                                                                       \
255
+    DEFN_BIN_OP_T(ret, op, int)
293 256
 
294
-DEFN_BIN_OP(const sc_logic_7,&)
295
-DEFN_BIN_OP(const sc_logic_7,|)
296
-DEFN_BIN_OP(const sc_logic_7,^)
257
+DEFN_BIN_OP(const sc_logic_7, &)
258
+DEFN_BIN_OP(const sc_logic_7, |)
259
+DEFN_BIN_OP(const sc_logic_7, ^)
297 260
 
298 261
 // relational operators and functions
299 262
 
300
-inline bool operator == ( const sc_logic_7& a, const sc_logic_7& b )
301
-       { return ( (int) a.m_val == b.m_val ); }
263
+inline bool operator==(const sc_logic_7 &a, const sc_logic_7 &b) { return ((int)a.m_val == b.m_val); }
302 264
 
303
-inline bool operator != ( const sc_logic_7& a, const sc_logic_7& b )
304
-       { return ( (int) a.m_val != b.m_val ); }
265
+inline bool operator!=(const sc_logic_7 &a, const sc_logic_7 &b) { return ((int)a.m_val != b.m_val); }
305 266
 
306
-DEFN_BIN_OP(bool,==)
307
-DEFN_BIN_OP(bool,!=)
267
+DEFN_BIN_OP(bool, ==)
268
+DEFN_BIN_OP(bool, !=)
308 269
 
309 270
 #undef DEFN_BIN_OP_T
310 271
 #undef DEFN_BIN_OP
311 272
 
312 273
 // ----------------------------------------------------------------------------
313 274
 
314
-inline
315
-::std::ostream&
316
-operator << ( ::std::ostream& os, const sc_logic_7& a )
317
-{
318
-    a.print( os );
275
+inline ::std::ostream &operator<<(::std::ostream &os, const sc_logic_7 &a) {
276
+    a.print(os);
319 277
     return os;
320 278
 }
321 279
 
322
-inline
323
-::std::istream&
324
-operator >> ( ::std::istream& is, sc_logic_7& a )
325
-{
326
-    a.scan( is );
280
+inline ::std::istream &operator>>(::std::istream &is, sc_logic_7 &a) {
281
+    a.scan(is);
327 282
     return is;
328 283
 }
329 284
 
330
-
331 285
 extern const sc_logic_7 SC_LOGIC7_0;
332 286
 extern const sc_logic_7 SC_LOGIC7_1;
333 287
 extern const sc_logic_7 SC_LOGIC7_Z;
@@ -336,6 +290,4 @@ extern const sc_logic_7 SC_LOGIC7_X;
336 290
 } // namespace sc_dt
337 291
 } // namespace sysc
338 292
 
339
-
340
-
341 293
 #endif /* INCL_SYSC_CORE_SC_LOGIC_7_H_ */

+ 13
- 21
incl/sysc/initiator_mixin.h View File

@@ -18,14 +18,13 @@
18 18
 #define _SYSC_INITIATOR_MIXIN_H__
19 19
 
20 20
 #include "utilities.h"
21
-#include <tlm>
22 21
 #include <functional>
23 22
 #include <sstream>
23
+#include <tlm>
24 24
 
25 25
 namespace sysc {
26 26
 
27
-template<typename BASE_TYPE, typename TYPES = tlm::tlm_base_protocol_types>
28
-class initiator_mixin: public BASE_TYPE {
27
+template <typename BASE_TYPE, typename TYPES = tlm::tlm_base_protocol_types> class initiator_mixin : public BASE_TYPE {
29 28
 public:
30 29
     typedef typename TYPES::tlm_payload_type transaction_type;
31 30
     typedef typename TYPES::tlm_phase_type phase_type;
@@ -34,20 +33,17 @@ public:
34 33
     typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
35 34
 
36 35
 public:
37
-    initiator_mixin()
38
-            : BASE_TYPE(sc_core::sc_gen_unique_name("initiator_mixin_socket")), bw_if(this->name()) {
36
+    initiator_mixin() : BASE_TYPE(sc_core::sc_gen_unique_name("initiator_mixin_socket")), bw_if(this->name()) {
39 37
         this->m_export.bind(bw_if);
40 38
     }
41 39
 
42
-    explicit initiator_mixin(const char* n)
43
-            : BASE_TYPE(n), bw_if(this->name()) {
44
-        this->m_export.bind(bw_if);
45
-    }
40
+    explicit initiator_mixin(const char *n) : BASE_TYPE(n), bw_if(this->name()) { this->m_export.bind(bw_if); }
46 41
     /**
47 42
      *
48 43
      * @param cb the callback function
49 44
      */
50
-    void register_nb_transport_bw(std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)> cb) {
45
+    void
46
+    register_nb_transport_bw(std::function<sync_enum_type(transaction_type &, phase_type &, sc_core::sc_time &)> cb) {
51 47
         bw_if.set_transport_function(cb);
52 48
     }
53 49
     /**
@@ -59,14 +55,12 @@ public:
59 55
     }
60 56
 
61 57
 private:
62
-    class bw_transport_if: public tlm::tlm_bw_transport_if<TYPES> {
58
+    class bw_transport_if : public tlm::tlm_bw_transport_if<TYPES> {
63 59
     public:
64
-        typedef std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)> transport_fct;
65
-        typedef std::function<void (sc_dt::uint64, sc_dt::uint64)> invalidate_dmi_fct;
60
+        typedef std::function<sync_enum_type(transaction_type &, phase_type &, sc_core::sc_time &)> transport_fct;
61
+        typedef std::function<void(sc_dt::uint64, sc_dt::uint64)> invalidate_dmi_fct;
66 62
 
67
-        bw_transport_if(const std::string& name)
68
-                : m_name(name), m_transport_ptr(0), m_invalidate_direct_mem_ptr(0) {
69
-        }
63
+        bw_transport_if(const std::string &name) : m_name(name), m_transport_ptr(0), m_invalidate_direct_mem_ptr(0) {}
70 64
 
71 65
         void set_transport_function(transport_fct p) {
72 66
             if (m_transport_ptr) {
@@ -88,13 +82,12 @@ private:
88 82
             }
89 83
         }
90 84
 
91
-        sync_enum_type nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) {
92
-            if (m_transport_ptr)
93
-                return m_transport_ptr(trans, phase, t);
85
+        sync_enum_type nb_transport_bw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t) {
86
+            if (m_transport_ptr) return m_transport_ptr(trans, phase, t);
94 87
             std::stringstream s;
95 88
             s << m_name << ": no transport callback registered";
96 89
             SC_REPORT_ERROR("/OSCI_TLM-2/initiator_mixin", s.str().c_str());
97
-            return tlm::TLM_ACCEPTED;   ///< unreachable code
90
+            return tlm::TLM_ACCEPTED; ///< unreachable code
98 91
         }
99 92
 
100 93
         void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) {
@@ -111,7 +104,6 @@ private:
111 104
 private:
112 105
     bw_transport_if bw_if;
113 106
 };
114
-
115 107
 }
116 108
 
117 109
 #endif //_SYSC_INITIATOR_MIXIN_H__

+ 28
- 27
incl/sysc/memory.h View File

@@ -35,26 +35,25 @@ namespace sysc {
35 35
 
36 36
 // simple memory model
37 37
 
38
-template<unsigned SIZE, unsigned BUSWIDTH=32, bool LOG_ACCESS=false>
39
-struct memory: sc_core::sc_module {
38
+template <unsigned SIZE, unsigned BUSWIDTH = 32, bool LOG_ACCESS = false> struct memory : sc_core::sc_module {
40 39
 
41 40
     tlm_utils::simple_target_socket<memory, BUSWIDTH> socket;
42 41
 
43
-    memory(const sc_core::sc_module_name& nm);
42
+    memory(const sc_core::sc_module_name &nm);
44 43
 
45
-    void b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& delay);
44
+    void b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &delay);
46 45
 
47
-    unsigned transport_dbg(tlm::tlm_generic_payload& trans);
46
+    unsigned transport_dbg(tlm::tlm_generic_payload &trans);
48 47
 
49 48
 protected:
50 49
     uint8_t mem[SIZE];
51 50
 
52 51
 private:
53
-    int handle_operation(tlm::tlm_generic_payload& trans);
52
+    int handle_operation(tlm::tlm_generic_payload &trans);
54 53
 };
55 54
 
56
-template<unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
57
-memory<SIZE,BUSWIDTH,LOG_ACCESS>::memory(const sc_core::sc_module_name& nm):sc_module(nm),NAMED(socket) {
55
+template <unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
56
+memory<SIZE, BUSWIDTH, LOG_ACCESS>::memory(const sc_core::sc_module_name &nm) : sc_module(nm), NAMED(socket) {
58 57
     // Register callback for incoming b_transport interface method call
59 58
     socket.register_b_transport(this, &memory::b_transport);
60 59
     socket.register_transport_dbg(this, &memory::transport_dbg);
@@ -62,43 +61,45 @@ memory<SIZE,BUSWIDTH,LOG_ACCESS>::memory(const sc_core::sc_module_name& nm):sc_m
62 61
     for (size_t i = 0; i < SIZE; i++) mem[i] = rand() % 256;
63 62
 }
64 63
 
65
-template<unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
66
-void memory<SIZE,BUSWIDTH,LOG_ACCESS>::b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& delay) {
64
+template <unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
65
+void memory<SIZE, BUSWIDTH, LOG_ACCESS>::b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &delay) {
67 66
     handle_operation(trans);
68 67
 }
69 68
 
70
-template<unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
71
-unsigned memory<SIZE,BUSWIDTH,LOG_ACCESS>::transport_dbg(tlm::tlm_generic_payload& trans) {
69
+template <unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
70
+unsigned memory<SIZE, BUSWIDTH, LOG_ACCESS>::transport_dbg(tlm::tlm_generic_payload &trans) {
72 71
     return handle_operation(trans);
73 72
 }
74 73
 
75
-template<unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
76
-int memory<SIZE,BUSWIDTH,LOG_ACCESS>::handle_operation(tlm::tlm_generic_payload& trans) {
74
+template <unsigned SIZE, unsigned BUSWIDTH, bool LOG_ACCESS>
75
+int memory<SIZE, BUSWIDTH, LOG_ACCESS>::handle_operation(tlm::tlm_generic_payload &trans) {
77 76
     sc_dt::uint64 adr = trans.get_address();
78
-    unsigned char* ptr = trans.get_data_ptr();
79
-    unsigned       len = trans.get_data_length();
80
-    unsigned char* byt = trans.get_byte_enable_ptr();
81
-    unsigned       wid = trans.get_streaming_width();
77
+    unsigned char *ptr = trans.get_data_ptr();
78
+    unsigned len = trans.get_data_length();
79
+    unsigned char *byt = trans.get_byte_enable_ptr();
80
+    unsigned wid = trans.get_streaming_width();
82 81
     // check address range and check for unsupported features,
83 82
     //   i.e. byte enables, streaming, and bursts
84 83
     // Can ignore DMI hint and extensions
85
-    if (adr+len > sc_dt::uint64(SIZE)){
86
-        SC_REPORT_ERROR("TLM-2","generic payload transaction exceeeds memory size");
84
+    if (adr + len > sc_dt::uint64(SIZE)) {
85
+        SC_REPORT_ERROR("TLM-2", "generic payload transaction exceeeds memory size");
87 86
         trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
88 87
         return 0;
89 88
     }
90
-    if (adr+len > sc_dt::uint64(SIZE) || byt != 0 || wid < len){
91
-        SC_REPORT_ERROR("TLM-2","generic payload transaction not supported");
89
+    if (adr + len > sc_dt::uint64(SIZE) || byt != 0 || wid < len) {
90
+        SC_REPORT_ERROR("TLM-2", "generic payload transaction not supported");
92 91
         trans.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);
93 92
         return 0;
94 93
     }
95 94
 
96 95
     tlm::tlm_command cmd = trans.get_command();
97
-    if(LOG_ACCESS){
98
-        if(adr>=0x20 && adr<0x60)
99
-            LOG(WARNING)<<(cmd==tlm::TLM_READ_COMMAND?"read":"write")<<" access to addr 0x"<<std::hex<<adr-0x20<<"(0x"<<(adr)<<")"<<std::dec;
96
+    if (LOG_ACCESS) {
97
+        if (adr >= 0x20 && adr < 0x60)
98
+            LOG(WARNING) << (cmd == tlm::TLM_READ_COMMAND ? "read" : "write") << " access to addr 0x" << std::hex
99
+                         << adr - 0x20 << "(0x" << (adr) << ")" << std::dec;
100 100
         else
101
-            LOG(WARNING)<<(cmd==tlm::TLM_READ_COMMAND?"read":"write")<<" access to addr 0x"<<std::hex<<adr<<std::dec;
101
+            LOG(WARNING) << (cmd == tlm::TLM_READ_COMMAND ? "read" : "write") << " access to addr 0x" << std::hex << adr
102
+                         << std::dec;
102 103
     }
103 104
     if (cmd == tlm::TLM_READ_COMMAND)
104 105
         memcpy(ptr, mem + adr, len);
@@ -108,6 +109,6 @@ int memory<SIZE,BUSWIDTH,LOG_ACCESS>::handle_operation(tlm::tlm_generic_payload&
108 109
     return len;
109 110
 }
110 111
 
111
-}  // namespace sysc
112
+} // namespace sysc
112 113
 
113 114
 #endif /* _SYSC_MEMORY_H_ */

+ 127
- 163
incl/sysc/register.h View File

@@ -23,125 +23,109 @@
23 23
 #ifndef _SYSC_REGISTER_H_
24 24
 #define _SYSC_REGISTER_H_
25 25
 
26
-#include "utilities.h"
27 26
 #include "resetable.h"
28 27
 #include "resource_access_if.h"
28
+#include "utilities.h"
29 29
 
30 30
 #include <functional>
31 31
 #include <limits>
32 32
 
33 33
 namespace sysc {
34 34
 
35
-namespace impl{
35
+namespace impl {
36 36
 
37
-template<typename T, bool = std::is_integral<T>::value>
38
-struct helper {
39
-};
37
+template <typename T, bool = std::is_integral<T>::value> struct helper {};
40 38
 
41
-template<typename T>
42
-struct helper<T, true> {
39
+template <typename T> struct helper<T, true> {
43 40
     using Type = T;
44
-    template<typename Type>
45
-    constexpr Type get_max_uval(){
46
-        return std::numeric_limits<Type>::is_signed?-1:std::numeric_limits<Type>::max();
41
+    template <typename Type> constexpr Type get_max_uval() {
42
+        return std::numeric_limits<Type>::is_signed ? -1 : std::numeric_limits<Type>::max();
47 43
     }
48 44
 };
49 45
 
50
-template<typename T>
51
-struct helper<T, false> {
46
+template <typename T> struct helper<T, false> {
52 47
     using Type = typename T::StorageType;
53
-    template<typename Type>
54
-    constexpr Type get_max_uval(){
55
-        return std::numeric_limits<Type>::is_signed?-1:std::numeric_limits<Type>::max();
48
+    template <typename Type> constexpr Type get_max_uval() {
49
+        return std::numeric_limits<Type>::is_signed ? -1 : std::numeric_limits<Type>::max();
56 50
     }
57 51
 };
58 52
 
59
-template<typename Type>
60
-constexpr Type get_max_uval(){
61
-    return std::numeric_limits<Type>::is_signed?-1:std::numeric_limits<Type>::max();
53
+template <typename Type> constexpr Type get_max_uval() {
54
+    return std::numeric_limits<Type>::is_signed ? -1 : std::numeric_limits<Type>::max();
62 55
 }
63 56
 
64
-template<typename DATATYPE>
65
-struct sc_register:
66
-        public sc_core::sc_object,
67
-        public resource_access_if,
68
-        public traceable
69
-        {
57
+template <typename DATATYPE>
58
+struct sc_register : public sc_core::sc_object, public resource_access_if, public traceable {
70 59
 
71 60
     using this_t