Browse Source

applied clang-format

pull/6/head
Eyck Jentzsch 2 years ago
parent
commit
a5c9101b71
36 changed files with 3930 additions and 4251 deletions
  1. +97
    -0
      .clang-format
  2. +20
    -0
      cmake/clang-format.cmake
  3. +642
    -648
      incl/scv4tlm/tlm2_recorder.h
  4. +35
    -34
      incl/scv4tlm/tlm2_recorder_module.h
  5. +409
    -524
      incl/scv4tlm/tlm_gp_data.h
  6. +83
    -92
      incl/scv4tlm/tlm_gp_data_ext.h
  7. +80
    -88
      incl/scv4tlm/tlm_rec_initiator_socket.h
  8. +75
    -81
      incl/scv4tlm/tlm_rec_target_socket.h
  9. +45
    -46
      incl/scv4tlm/tlm_recording_extension.h
  10. +118
    -166
      incl/sysc/core/sc_logic_7.h
  11. +13
    -21
      incl/sysc/initiator_mixin.h
  12. +28
    -27
      incl/sysc/memory.h
  13. +127
    -163
      incl/sysc/register.h
  14. +21
    -22
      incl/sysc/report.h
  15. +11
    -12
      incl/sysc/resetable.h
  16. +14
    -14
      incl/sysc/resource_access_if.h
  17. +58
    -66
      incl/sysc/router.h
  18. +89
    -106
      incl/sysc/target_mixin.h
  19. +49
    -64
      incl/sysc/tlm_target.h
  20. +2
    -2
      incl/sysc/traceable.h
  21. +11
    -10
      incl/sysc/tracer.h
  22. +24
    -21
      incl/sysc/utilities.h
  23. +16
    -13
      incl/util/assert.h
  24. +52
    -77
      incl/util/bit_field.h
  25. +21
    -24
      incl/util/ities.h
  26. +127
    -125
      incl/util/logging.h
  27. +54
    -62
      incl/util/range_lut.h
  28. +28
    -33
      incl/util/sparse_array.h
  29. +70
    -71
      incl/util/thread_syncronizer.h
  30. +59
    -43
      src/report.cpp
  31. +60
    -91
      src/sc_logic_7.cpp
  32. +104
    -115
      src/scv_tr_compressed.cpp
  33. +132
    -127
      src/scv_tr_sqlite/scv_tr_sqlite.cpp
  34. +1046
    -1161
      src/scv_tr_sqlite/sqlite3.h
  35. +102
    -86
      src/tracer.cpp
  36. +8
    -16
      src/utilities.cpp

+ 97
- 0
.clang-format View File

@@ -0,0 +1,97 @@
---
Language: Cpp
# BasedOnStyle: LLVM
# should be in line with IndentWidth
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...


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

@@ -0,0 +1,20 @@
# additional target to perform clang-format run, requires clang-format

# get all project files
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
foreach(PROJECT_TRDPARTY_DIR ${PROJECT_3PARTY_DIRS})
string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_EXTERNAL_DIR_FOUND)
if (NOT ${PROJECT_EXTERNAL_DIR_FOUND} EQUAL -1)
#message( STATUS "Skipping ${SOURCE_FILE} for clang-format." )
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach()
endforeach ()

add_custom_target(
clangformat
COMMAND clang-format
-i
${ALL_SOURCE_FILES}
)

+ 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 @@
namespace scv4tlm {
/*! \brief The TLM2 transaction recorder
*
* This module records all TLM transaction to a SCV transaction stream for further viewing and analysis.
* The handle of the created transaction is storee in an tlm_extension so that another instance of the scv_tlm2_recorder
* This module records all TLM transaction to a SCV transaction stream for
* further viewing and analysis.
* The handle of the created transaction is storee in an tlm_extension so that
* another instance of the scv_tlm2_recorder
* e.g. further down the opath can link to it.
* The transaction recorder is simply bound between an existing pair of initiator and target sockets
* The transaction recorder is simply bound between an existing pair of
* initiator and target sockets
*/
template<unsigned int BUSWIDTH = 32, typename TYPES=tlm::tlm_base_protocol_types>
class tlm2_recorder_module: public sc_core::sc_module, public tlm2_recorder<TYPES> {
template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types>
class tlm2_recorder_module : public sc_core::sc_module, public tlm2_recorder<TYPES> {
public:
SC_HAS_PROCESS(tlm2_recorder_module);
//! The target socket of the recorder to be bound to the initiator
tlm::tlm_target_socket<BUSWIDTH, TYPES, 1> target;
//! The initiator to be bound to the target socket
tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1> initiator;
SC_HAS_PROCESS(tlm2_recorder_module);
//! The target socket of the recorder to be bound to the initiator
tlm::tlm_target_socket<BUSWIDTH, TYPES, 1> target;
//! The initiator to be bound to the target socket
tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1> initiator;

/*! \brief The constructor of the component
*
* \param name is the SystemC module name of the recorder
* \param tr_db is a pointer to a transaction recording database. If none is
* provided the default one is retrieved.
* If this database is not initialized (e.g. by not calling
* scv_tr_db::set_default_db() ) recording is disabled.
*/
tlm2_recorder_module(sc_core::sc_module_name name, bool recording_enabled = true,
scv_tr_db *tr_db = scv_tr_db::get_default_db())
: sc_module(name), tlm2_recorder<TYPES>(recording_enabled, tr_db) {
// bind the sockets to the module
target.bind(*this);
initiator.bind(*this);
}

/*! \brief The constructor of the component
*
* \param name is the SystemC module name of the recorder
* \param tr_db is a pointer to a transaction recording database. If none is provided the default one is retrieved.
* If this database is not initialized (e.g. by not calling scv_tr_db::set_default_db() ) recording is disabled.
*/
tlm2_recorder_module(sc_core::sc_module_name name, bool recording_enabled = true, scv_tr_db* tr_db = scv_tr_db::get_default_db())
: sc_module(name)
, tlm2_recorder<TYPES>(recording_enabled, tr_db)
{
// bind the sockets to the module
target.bind(*this);
initiator.bind(*this);
}

virtual ~tlm2_recorder_module(){}

virtual tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>* get_fw_if() {
return initiator.get_base_port().operator->();
}
virtual tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types>* get_bw_if() {
return target.get_base_port().operator->();
}
virtual ~tlm2_recorder_module() {}

virtual tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types> *get_fw_if() {
return initiator.get_base_port().operator->();
}
virtual tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types> *get_bw_if() {
return target.get_base_port().operator->();
}
};
} // namespace


#endif /* TLM2_RECORDER_MODULE_H_ */

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

@@ -17,550 +17,435 @@
#ifndef TLM_GP_DATA_H_
#define TLM_GP_DATA_H_

#include <tlm>
#include <assert.h>
#include <tlm>

namespace scv4tlm {

struct tlm_gp_data {
//---------------
// Constructors
//---------------

// Default constructor
tlm_gp_data()
: address(0)
, command(tlm::TLM_IGNORE_COMMAND)
, data(0)
, data_length(0)
, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
, dmi(false)
, byte_enable(0)
, byte_enable_length(0)
, streaming_width(0)
, gp_option(tlm::TLM_MIN_PAYLOAD)
, m_extensions(tlm::max_num_extensions())
, m_ref_count(0)
{
}

explicit tlm_gp_data(tlm::tlm_mm_interface* mm)
: address(0)
, command(tlm::TLM_IGNORE_COMMAND)
, data(0)
, data_length(0)
, response_status(tlm::TLM_INCOMPLETE_RESPONSE)
, dmi(false)
, byte_enable(0)
, byte_enable_length(0)
, streaming_width(0)
, gp_option(tlm::TLM_MIN_PAYLOAD)
, m_extensions(tlm::max_num_extensions())
, m_ref_count(0) {
}

int get_ref_count() const {
return m_ref_count;
}

void reset() {
//should the other members be reset too?
gp_option = tlm::TLM_MIN_PAYLOAD;
m_extensions.free_entire_cache();
}
;

tlm_gp_data(const tlm::tlm_generic_payload& x)
: address(x.get_address())
, command(x.get_command())
, data(x.get_data_ptr())
, data_length(x.get_data_length())
, response_status(x.get_response_status())
, dmi(x.is_dmi_allowed())
, byte_enable(x.get_byte_enable_ptr())
, byte_enable_length(x.get_byte_enable_length())
, streaming_width(x.get_streaming_width())
, gp_option(x.get_gp_option())
, m_extensions(tlm::max_num_extensions())
, m_ref_count(0)
{
}
//---------------
// Constructors
//---------------

// Default constructor
tlm_gp_data()
: address(0), command(tlm::TLM_IGNORE_COMMAND), data(0), data_length(0),
response_status(tlm::TLM_INCOMPLETE_RESPONSE), dmi(false), byte_enable(0), byte_enable_length(0),
streaming_width(0), gp_option(tlm::TLM_MIN_PAYLOAD), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {
}

explicit tlm_gp_data(tlm::tlm_mm_interface *mm)
: address(0), command(tlm::TLM_IGNORE_COMMAND), data(0), data_length(0),
response_status(tlm::TLM_INCOMPLETE_RESPONSE), dmi(false), byte_enable(0), byte_enable_length(0),
streaming_width(0), gp_option(tlm::TLM_MIN_PAYLOAD), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {
}

int get_ref_count() const { return m_ref_count; }

void reset() {
// should the other members be reset too?
gp_option = tlm::TLM_MIN_PAYLOAD;
m_extensions.free_entire_cache();
};

tlm_gp_data(const tlm::tlm_generic_payload &x)
: address(x.get_address()), command(x.get_command()), data(x.get_data_ptr()), data_length(x.get_data_length()),
response_status(x.get_response_status()), dmi(x.is_dmi_allowed()), byte_enable(x.get_byte_enable_ptr()),
byte_enable_length(x.get_byte_enable_length()), streaming_width(x.get_streaming_width()),
gp_option(x.get_gp_option()), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {}

private:
//disabled copy ctor and assignment operator.
// Copy constructor
tlm_gp_data(const tlm_gp_data& x)
: address(x.get_address())
, command(x.get_command())
, data(x.get_data_ptr())
, data_length(x.get_data_length())
, response_status(x.get_response_status())
, dmi(x.is_dmi_allowed())
, byte_enable(x.get_byte_enable_ptr())
, byte_enable_length(x.get_byte_enable_length())
, streaming_width(x.get_streaming_width())
, gp_option(x.gp_option)
, m_extensions(tlm::max_num_extensions())
, m_ref_count(0)
{
}
public:
// Assignment operator needed for SCV introspection
tlm_gp_data& operator=(const tlm_gp_data& x) {
command = x.get_command();
address = x.get_address();
data = x.get_data_ptr();
data_length = x.get_data_length();
response_status = x.get_response_status();
byte_enable = x.get_byte_enable_ptr();
byte_enable_length = x.get_byte_enable_length();
streaming_width = x.get_streaming_width();
gp_option = x.get_gp_option();
dmi = x.is_dmi_allowed();

// extension copy: all extension arrays must be of equal size by
// construction (i.e. it must either be constructed after C++
// static construction time, or the resize_extensions() method must
// have been called prior to using the object)
for (unsigned int i = 0; i < m_extensions.size(); i++) {
m_extensions[i] = x.get_extension(i);
}
return (*this);
}

// non-virtual deep-copying of the object
void deep_copy_from(const scv4tlm::tlm_gp_data & other) {
command = other.get_command();
address = other.get_address();
data_length = other.get_data_length();
response_status = other.get_response_status();
byte_enable_length = other.get_byte_enable_length();
streaming_width = other.get_streaming_width();
gp_option = other.get_gp_option();
dmi = other.is_dmi_allowed();

// deep copy data
// there must be enough space in the target transaction!
if (data && other.get_data_ptr()) {
memcpy(data, other.get_data_ptr(), data_length);
}
// deep copy byte enables
// there must be enough space in the target transaction!
if (byte_enable && other.get_byte_enable_ptr()) {
memcpy(byte_enable, other.get_byte_enable_ptr(), byte_enable_length);
}
// deep copy extensions (sticky and non-sticky)
for (unsigned int i = 0; i < other.m_extensions.size(); i++) {
if (other.get_extension(i)) { //original has extension i
if (!m_extensions[i]) { //We don't: clone.
tlm::tlm_extension_base *ext = other.get_extension(i)->clone();
if (ext) //extension may not be clonable.
{
set_extension(i, ext);
}
} else { //We already have such extension. Copy original over it.
m_extensions[i]->copy_from(*other.get_extension(i));
}
}
}
}

// To update the state of the original generic payload from a deep copy
// Assumes that "other" was created from the original by calling deep_copy_from
// Argument use_byte_enable_on_read determines whether to use or ignores byte enables
// when copying back the data array on a read command

void update_original_from(const tlm::tlm_generic_payload & other, bool use_byte_enable_on_read = true) {
// Copy back extensions that are present on the original
// update_extensions_from(other);

// Copy back the response status and DMI hint attributes
response_status = other.get_response_status();
dmi = other.is_dmi_allowed();

// Copy back the data array for a read command only
// deep_copy_from allowed null pointers, and so will we
// We assume the arrays are the same size
// We test for equal pointers in case the original and the copy share the same array

if (is_read() && data && other.get_data_ptr() && data != other.get_data_ptr()) {
if (byte_enable && use_byte_enable_on_read) {
if (byte_enable_length == 8 && data_length % 8 == 0) {
// Optimized implementation copies 64-bit words by masking
for (unsigned int i = 0; i < data_length; i += 8) {
typedef sc_dt::uint64* u;
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
& *reinterpret_cast<u>(byte_enable);
}
} else if (byte_enable_length == 4 && data_length % 4 == 0) {
// Optimized implementation copies 32-bit words by masking
for (unsigned int i = 0; i < data_length; i += 4) {
typedef unsigned int* u;
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
*reinterpret_cast<u>(&data[i]) |= *reinterpret_cast<u>(&other.get_data_ptr()[i])
& *reinterpret_cast<u>(byte_enable);
}
} else
// Unoptimized implementation
for (unsigned int i = 0; i < data_length; i++)
if (byte_enable[i % byte_enable_length])
data[i] = other.get_data_ptr()[i];
} else
memcpy(data, other.get_data_ptr(), data_length);
}
}

/*
void update_extensions_from(const tlm::tlm_generic_payload & other) {
// deep copy extensions that are already present
for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {
if (other.get_extension(i)) { //original has extension i
if (m_extensions[i]) { //We have it too. copy.
m_extensions[i]->copy_from(*other.get_extension(i));
}
}
}
}
*/

// Free all extensions. Useful when reusing a cloned transaction that doesn't have memory manager.
// normal and sticky extensions are freed and extension array cleared.
void free_all_extensions() {
m_extensions.free_entire_cache();
for (unsigned int i = 0; i < m_extensions.size(); i++) {
if (m_extensions[i]) {
m_extensions[i]->free();
m_extensions[i] = 0;
}
}
}
//--------------
// Destructor
//--------------
virtual ~tlm_gp_data() {
for(unsigned int i=0; i<m_extensions.size(); i++)
if(m_extensions[i]) m_extensions[i]->free();
}

//----------------
// API (including setters & getters)
//---------------

// Command related method
bool is_read() const {
return (command == tlm::TLM_READ_COMMAND);
}
void set_read() {
command = tlm::TLM_READ_COMMAND;
}
bool is_write() const {
return (command == tlm::TLM_WRITE_COMMAND);
}
void set_write() {
command = tlm::TLM_WRITE_COMMAND;
}
tlm::tlm_command get_command() const {
return command;
}
void set_command(const tlm::tlm_command command) {
this->command = command;
}

// Address related methods
sc_dt::uint64 get_address() const {
return address;
}
void set_address(const sc_dt::uint64 address) {
this->address = address;
}

// Data related methods
unsigned char* get_data_ptr() const {
return data;
}
void set_data_ptr(unsigned char* data) {
this->data = data;
}

// Transaction length (in bytes) related methods
unsigned int get_data_length() const {
return data_length;
}
void set_data_length(const unsigned int length) {
data_length = length;
}

// Response status related methods
bool is_response_ok() const {
return (response_status > 0);
}
bool is_response_error() const {
return (response_status <= 0);
}
tlm::tlm_response_status get_response_status() const {
return response_status;
}
void set_response_status(const tlm::tlm_response_status response_status) {
this->response_status = response_status;
}
std::string get_response_string() const {
switch (response_status) {
case tlm::TLM_OK_RESPONSE:
return "TLM_OK_RESPONSE";
case tlm::TLM_INCOMPLETE_RESPONSE:
return "TLM_INCOMPLETE_RESPONSE";
case tlm::TLM_GENERIC_ERROR_RESPONSE:
return "TLM_GENERIC_ERROR_RESPONSE";
case tlm::TLM_ADDRESS_ERROR_RESPONSE:
return "TLM_ADDRESS_ERROR_RESPONSE";
case tlm::TLM_COMMAND_ERROR_RESPONSE:
return "TLM_COMMAND_ERROR_RESPONSE";
case tlm::TLM_BURST_ERROR_RESPONSE:
return "TLM_BURST_ERROR_RESPONSE";
case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE:
return "TLM_BYTE_ENABLE_ERROR_RESPONSE";
}
return "TLM_UNKNOWN_RESPONSE";
}

// Streaming related methods
unsigned int get_streaming_width() const {
return streaming_width;
}
void set_streaming_width(const unsigned int streaming_width) {
this->streaming_width = streaming_width;
}

// Byte enable related methods
unsigned char* get_byte_enable_ptr() const {
return byte_enable;
}
void set_byte_enable_ptr(unsigned char* byte_enable) {
this->byte_enable = byte_enable;
}
unsigned int get_byte_enable_length() const {
return byte_enable_length;
}
void set_byte_enable_length(const unsigned int byte_enable_length) {
this->byte_enable_length = byte_enable_length;
}

// This is the "DMI-hint" a slave can set this to true if it
// wants to indicate that a DMI request would be supported:
void set_dmi_allowed(bool dmi_allowed) {
dmi = dmi_allowed;
}
bool is_dmi_allowed() const {
return dmi;
}

// Use full set of attributes in DMI/debug?
tlm::tlm_gp_option get_gp_option() const {
return gp_option;
}
void set_gp_option(const tlm::tlm_gp_option gp_opt) {
gp_option = gp_opt;
}
// disabled copy ctor and assignment operator.
// Copy constructor
tlm_gp_data(const tlm_gp_data &x)
: address(x.get_address()), command(x.get_command()), data(x.get_data_ptr()), data_length(x.get_data_length()),
response_status(x.get_response_status()), dmi(x.is_dmi_allowed()), byte_enable(x.get_byte_enable_ptr()),
byte_enable_length(x.get_byte_enable_length()), streaming_width(x.get_streaming_width()),
gp_option(x.gp_option), m_extensions(tlm::max_num_extensions()), m_ref_count(0) {}

public:

/* --------------------------------------------------------------------- */
/* Generic Payload attributes: */
/* --------------------------------------------------------------------- */
/* - m_command : Type of transaction. Three values supported: */
/* - TLM_WRITE_COMMAND */
/* - TLM_READ_COMMAND */
/* - TLM_IGNORE_COMMAND */
/* - m_address : Transaction base address (byte-addressing). */
/* - m_data : When m_command = TLM_WRITE_COMMAND contains a */
/* pointer to the data to be written in the target.*/
/* When m_command = TLM_READ_COMMAND contains a */
/* pointer where to copy the data read from the */
/* target. */
/* - m_length : Total number of bytes of the transaction. */
/* - m_response_status : This attribute indicates whether an error has */
/* occurred during the transaction. */
/* Values supported are: */
/* - TLM_OK_RESP */
/* - TLM_INCOMPLETE_RESP */
/* - TLM_GENERIC_ERROR_RESP */
/* - TLM_ADDRESS_ERROR_RESP */
/* - TLM_COMMAND_ERROR_RESP */
/* - TLM_BURST_ERROR_RESP */
/* - TLM_BYTE_ENABLE_ERROR_RESP */
/* */
/* - m_byte_enable : It can be used to create burst transfers where */
/* the address increment between each beat is greater */
/* than the word length of each beat, or to place */
/* words in selected byte lanes of a bus. */
/* - m_byte_enable_length : For a read or a write command, the target */
/* interpret the byte enable length attribute as the */
/* number of elements in the bytes enable array. */
/* - m_streaming_width : */
/* --------------------------------------------------------------------- */

sc_dt::uint64 address;
tlm::tlm_command command;
unsigned char* data;
unsigned int data_length;
tlm::tlm_response_status response_status;
bool dmi;
unsigned char* byte_enable;
unsigned int byte_enable_length;
unsigned int streaming_width;
tlm::tlm_gp_option gp_option;
// Assignment operator needed for SCV introspection
tlm_gp_data &operator=(const tlm_gp_data &x) {
command = x.get_command();
address = x.get_address();
data = x.get_data_ptr();
data_length = x.get_data_length();
response_status = x.get_response_status();
byte_enable = x.get_byte_enable_ptr();
byte_enable_length = x.get_byte_enable_length();
streaming_width = x.get_streaming_width();
gp_option = x.get_gp_option();
dmi = x.is_dmi_allowed();

// extension copy: all extension arrays must be of equal size by
// construction (i.e. it must either be constructed after C++
// static construction time, or the resize_extensions() method must
// have been called prior to using the object)
for (unsigned int i = 0; i < m_extensions.size(); i++) {
m_extensions[i] = x.get_extension(i);
}
return (*this);
}

// non-virtual deep-copying of the object
void deep_copy_from(const scv4tlm::tlm_gp_data &other) {
command = other.get_command();
address = other.get_address();
data_length = other.get_data_length();
response_status = other.get_response_status();
byte_enable_length = other.get_byte_enable_length();
streaming_width = other.get_streaming_width();
gp_option = other.get_gp_option();
dmi = other.is_dmi_allowed();

// deep copy data
// there must be enough space in the target transaction!
if (data && other.get_data_ptr()) {
memcpy(data, other.get_data_ptr(), data_length);
}
// deep copy byte enables
// there must be enough space in the target transaction!
if (byte_enable && other.get_byte_enable_ptr()) {
memcpy(byte_enable, other.get_byte_enable_ptr(), byte_enable_length);
}
// deep copy extensions (sticky and non-sticky)
for (unsigned int i = 0; i < other.m_extensions.size(); i++) {
if (other.get_extension(i)) { // original has extension i
if (!m_extensions[i]) { // We don't: clone.
tlm::tlm_extension_base *ext = other.get_extension(i)->clone();
if (ext) // extension may not be clonable.
{
set_extension(i, ext);
}
} else { // We already have such extension. Copy original over it.
m_extensions[i]->copy_from(*other.get_extension(i));
}
}
}
}

// To update the state of the original generic payload from a deep copy
// Assumes that "other" was created from the original by calling
// deep_copy_from
// Argument use_byte_enable_on_read determines whether to use or ignores byte
// enables
// when copying back the data array on a read command

void update_original_from(const tlm::tlm_generic_payload &other, bool use_byte_enable_on_read = true) {
// Copy back extensions that are present on the original
// update_extensions_from(other);

// Copy back the response status and DMI hint attributes
response_status = other.get_response_status();
dmi = other.is_dmi_allowed();

// Copy back the data array for a read command only
// deep_copy_from allowed null pointers, and so will we
// We assume the arrays are the same size
// We test for equal pointers in case the original and the copy share the
// same array

if (is_read() && data && other.get_data_ptr() && data != other.get_data_ptr()) {
if (byte_enable && use_byte_enable_on_read) {
if (byte_enable_length == 8 && data_length % 8 == 0) {
// Optimized implementation copies 64-bit words by masking
for (unsigned int i = 0; i < data_length; i += 8) {
typedef sc_dt::uint64 *u;
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
*reinterpret_cast<u>(&data[i]) |=
*reinterpret_cast<u>(&other.get_data_ptr()[i]) & *reinterpret_cast<u>(byte_enable);
}
} else if (byte_enable_length == 4 && data_length % 4 == 0) {
// Optimized implementation copies 32-bit words by masking
for (unsigned int i = 0; i < data_length; i += 4) {
typedef unsigned int *u;
*reinterpret_cast<u>(&data[i]) &= ~*reinterpret_cast<u>(byte_enable);
*reinterpret_cast<u>(&data[i]) |=
*reinterpret_cast<u>(&other.get_data_ptr()[i]) & *reinterpret_cast<u>(byte_enable);
}
} else
// Unoptimized implementation
for (unsigned int i = 0; i < data_length; i++)
if (byte_enable[i % byte_enable_length]) data[i] = other.get_data_ptr()[i];
} else
memcpy(data, other.get_data_ptr(), data_length);
}
}

/*
void update_extensions_from(const tlm::tlm_generic_payload & other) {
// deep copy extensions that are already present
for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {
if (other.get_extension(i)) { //original
has extension i
if (m_extensions[i]) { //We have it
too. copy.
m_extensions[i]->copy_from(*other.get_extension(i));
}
}
}
}
*/

// Free all extensions. Useful when reusing a cloned transaction that doesn't
// have memory manager.
// normal and sticky extensions are freed and extension array cleared.
void free_all_extensions() {
m_extensions.free_entire_cache();
for (unsigned int i = 0; i < m_extensions.size(); i++) {
if (m_extensions[i]) {
m_extensions[i]->free();
m_extensions[i] = 0;
}
}
}
//--------------
// Destructor
//--------------
virtual ~tlm_gp_data() {
for (unsigned int i = 0; i < m_extensions.size(); i++)
if (m_extensions[i]) m_extensions[i]->free();
}

//----------------
// API (including setters & getters)
//---------------

// Command related method
bool is_read() const { return (command == tlm::TLM_READ_COMMAND); }
void set_read() { command = tlm::TLM_READ_COMMAND; }
bool is_write() const { return (command == tlm::TLM_WRITE_COMMAND); }
void set_write() { command = tlm::TLM_WRITE_COMMAND; }
tlm::tlm_command get_command() const { return command; }
void set_command(const tlm::tlm_command command) { this->command = command; }

// Address related methods
sc_dt::uint64 get_address() const { return address; }
void set_address(const sc_dt::uint64 address) { this->address = address; }

// Data related methods
unsigned char *get_data_ptr() const { return data; }
void set_data_ptr(unsigned char *data) { this->data = data; }

// Transaction length (in bytes) related methods
unsigned int get_data_length() const { return data_length; }
void set_data_length(const unsigned int length) { data_length = length; }

// Response status related methods
bool is_response_ok() const { return (response_status > 0); }
bool is_response_error() const { return (response_status <= 0); }
tlm::tlm_response_status get_response_status() const { return response_status; }
void set_response_status(const tlm::tlm_response_status response_status) {
this->response_status = response_status;
}
std::string get_response_string() const {
switch (response_status) {
case tlm::TLM_OK_RESPONSE:
return "TLM_OK_RESPONSE";
case tlm::TLM_INCOMPLETE_RESPONSE:
return "TLM_INCOMPLETE_RESPONSE";
case tlm::TLM_GENERIC_ERROR_RESPONSE:
return "TLM_GENERIC_ERROR_RESPONSE";
case tlm::TLM_ADDRESS_ERROR_RESPONSE:
return "TLM_ADDRESS_ERROR_RESPONSE";
case tlm::TLM_COMMAND_ERROR_RESPONSE:
return "TLM_COMMAND_ERROR_RESPONSE";
case tlm::TLM_BURST_ERROR_RESPONSE:
return "TLM_BURST_ERROR_RESPONSE";
case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE:
return "TLM_BYTE_ENABLE_ERROR_RESPONSE";
}
return "TLM_UNKNOWN_RESPONSE";
}

// Streaming related methods
unsigned int get_streaming_width() const { return streaming_width; }
void set_streaming_width(const unsigned int streaming_width) { this->streaming_width = streaming_width; }

// Byte enable related methods
unsigned char *get_byte_enable_ptr() const { return byte_enable; }
void set_byte_enable_ptr(unsigned char *byte_enable) { this->byte_enable = byte_enable; }
unsigned int get_byte_enable_length() const { return byte_enable_length; }
void set_byte_enable_length(const unsigned int byte_enable_length) {
this->byte_enable_length = byte_enable_length;
}

// This is the "DMI-hint" a slave can set this to true if it
// wants to indicate that a DMI request would be supported:
void set_dmi_allowed(bool dmi_allowed) { dmi = dmi_allowed; }
bool is_dmi_allowed() const { return dmi; }

// Use full set of attributes in DMI/debug?
tlm::tlm_gp_option get_gp_option() const { return gp_option; }
void set_gp_option(const tlm::tlm_gp_option gp_opt) { gp_option = gp_opt; }

public:
/* --------------------------------------------------------------------- */
/* Generic Payload attributes: */
/* --------------------------------------------------------------------- */
/* - m_command : Type of transaction. Three values supported: */
/* - TLM_WRITE_COMMAND */
/* - TLM_READ_COMMAND */
/* - TLM_IGNORE_COMMAND */
/* - m_address : Transaction base address (byte-addressing). */
/* - m_data : When m_command = TLM_WRITE_COMMAND contains a */
/* pointer to the data to be written in the target.*/
/* When m_command = TLM_READ_COMMAND contains a */
/* pointer where to copy the data read from the */
/* target. */
/* - m_length : Total number of bytes of the transaction. */
/* - m_response_status : This attribute indicates whether an error has */
/* occurred during the transaction. */
/* Values supported are: */
/* - TLM_OK_RESP */
/* - TLM_INCOMPLETE_RESP */
/* - TLM_GENERIC_ERROR_RESP */
/* - TLM_ADDRESS_ERROR_RESP */
/* - TLM_COMMAND_ERROR_RESP */
/* - TLM_BURST_ERROR_RESP */
/* - TLM_BYTE_ENABLE_ERROR_RESP */
/* */
/* - m_byte_enable : It can be used to create burst transfers where */
/* the address increment between each beat is greater */
/* than the word length of each beat, or to place */
/* words in selected byte lanes of a bus. */
/* - m_byte_enable_length : For a read or a write command, the target */
/* interpret the byte enable length attribute as the */
/* number of elements in the bytes enable array. */
/* - m_streaming_width : */
/* --------------------------------------------------------------------- */

sc_dt::uint64 address;
tlm::tlm_command command;
unsigned char *data;
unsigned int data_length;
tlm::tlm_response_status response_status;
bool dmi;
unsigned char *byte_enable;
unsigned int byte_enable_length;
unsigned int streaming_width;
tlm::tlm_gp_option gp_option;

/* --------------------------------------------------------------------- */
/* Dynamic extension mechanism: */
/* --------------------------------------------------------------------- */
/* The extension mechanism is intended to enable initiator modules to */
/* optionally and transparently add data fields to the */
/* tlm_generic_payload. Target modules are free to check for extensions */
/* and may or may not react to the data in the extension fields. The */
/* definition of the extensions' semantics is solely in the */
/* responsibility of the user. */
/* */
/* The following rules apply: */
/* */
/* - Every extension class must be derived from tlm_extension, e.g.: */
/* class my_extension : public tlm_extension<my_extension> { ... } */
/* */
/* - A tlm_generic_payload object should be constructed after C++ */
/* static initialization time. This way it is guaranteed that the */
/* extension array is of sufficient size to hold all possible */
/* extensions. Alternatively, the initiator module can enforce a valid */
/* extension array size by calling the resize_extensions() method */
/* once before the first transaction with the payload object is */
/* initiated. */
/* */
/* - Initiators should use the the set_extension(e) or clear_extension(e)*/
/* methods for manipulating the extension array. The type of the */
/* argument must be a pointer to the specific registered extension */
/* type (my_extension in the above example) and is used to */
/* automatically locate the appropriate index in the array. */
/* */
/* - Targets can check for a specific extension by calling */
/* get_extension(e). e will point to zero if the extension is not */
/* present. */
/* */
/* --------------------------------------------------------------------- */

// Stick the pointer to an extension into the vector, return the
// previous value:
template<typename T> T* set_extension(T* ext) {
return static_cast<T*>(set_extension(T::ID, ext));
}

// non-templatized version with manual index:
tlm::tlm_extension_base* set_extension(unsigned int index, tlm::tlm_extension_base* ext) {
tlm::tlm_extension_base* tmp = m_extensions[index];
m_extensions[index] = ext;
return tmp;
}

// Check for an extension, ext will point to 0 if not present
template<typename T> void get_extension(T*& ext) const {
ext = get_extension<T>();
}
template<typename T> T* get_extension() const {
return static_cast<T*>(get_extension(T::ID));
}
// Non-templatized version with manual index:
tlm::tlm_extension_base* get_extension(unsigned int index) const {
return m_extensions[index];
}

//this call just removes the extension from the txn but does not
// call free() or tells the MM to do so
// it return false if there was active MM so you are now in an unsafe situation
// recommended use: when 100% sure there is no MM
template<typename T> void clear_extension(const T* ext) {
clear_extension<T>();
}

//this call just removes the extension from the txn but does not
// call free() or tells the MM to do so
// it return false if there was active MM so you are now in an unsafe situation
// recommended use: when 100% sure there is no MM
template<typename T> void clear_extension() {
clear_extension(T::ID);
}

//this call removes the extension from the txn and does
// call free() or tells the MM to do so when the txn is finally done
// recommended use: when not sure there is no MM
template<typename T> void release_extension(T* ext) {
release_extension<T>();
}

//this call removes the extension from the txn and does
// call free() or tells the MM to do so when the txn is finally done
// recommended use: when not sure there is no MM
template<typename T> void release_extension() {
release_extension(T::ID);
}
public:
/* --------------------------------------------------------------------- */
/* Dynamic extension mechanism: */
/* --------------------------------------------------------------------- */
/* The extension mechanism is intended to enable initiator modules to */
/* optionally and transparently add data fields to the */
/* tlm_generic_payload. Target modules are free to check for extensions */
/* and may or may not react to the data in the extension fields. The */
/* definition of the extensions' semantics is solely in the */
/* responsibility of the user. */
/* */
/* The following rules apply: */
/* */
/* - Every extension class must be derived from tlm_extension, e.g.: */
/* class my_extension : public tlm_extension<my_extension> { ... } */
/* */
/* - A tlm_generic_payload object should be constructed after C++ */
/* static initialization time. This way it is guaranteed that the */
/* extension array is of sufficient size to hold all possible */
/* extensions. Alternatively, the initiator module can enforce a valid */
/* extension array size by calling the resize_extensions() method */
/* once before the first transaction with the payload object is */
/* initiated. */
/* */
/* - Initiators should use the the set_extension(e) or clear_extension(e)*/
/* methods for manipulating the extension array. The type of the */
/* argument must be a pointer to the specific registered extension */
/* type (my_extension in the above example) and is used to */
/* automatically locate the appropriate index in the array. */
/* */
/* - Targets can check for a specific extension by calling */
/* get_extension(e). e will point to zero if the extension is not */
/* present. */
/* */
/* --------------------------------------------------------------------- */

// Stick the pointer to an extension into the vector, return the
// previous value:
template <typename T> T *set_extension(T *ext) { return static_cast<T *>(set_extension(T::ID, ext)); }

// non-templatized version with manual index:
tlm::tlm_extension_base *set_extension(unsigned int index, tlm::tlm_extension_base *ext) {
tlm::tlm_extension_base *tmp = m_extensions[index];
m_extensions[index] = ext;
return tmp;
}

// Check for an extension, ext will point to 0 if not present
template <typename T> void get_extension(T *&ext) const { ext = get_extension<T>(); }
template <typename T> T *get_extension() const { return static_cast<T *>(get_extension(T::ID)); }
// Non-templatized version with manual index:
tlm::tlm_extension_base *get_extension(unsigned int index) const { return m_extensions[index]; }

// this call just removes the extension from the txn but does not
// call free() or tells the MM to do so
// it return false if there was active MM so you are now in an unsafe
// situation
// recommended use: when 100% sure there is no MM
template <typename T> void clear_extension(const T *ext) { clear_extension<T>(); }

// this call just removes the extension from the txn but does not
// call free() or tells the MM to do so
// it return false if there was active MM so you are now in an unsafe
// situation
// recommended use: when 100% sure there is no MM
template <typename T> void clear_extension() { clear_extension(T::ID); }

// this call removes the extension from the txn and does
// call free() or tells the MM to do so when the txn is finally done
// recommended use: when not sure there is no MM
template <typename T> void release_extension(T *ext) { release_extension<T>(); }

// this call removes the extension from the txn and does
// call free() or tells the MM to do so when the txn is finally done
// recommended use: when not sure there is no MM
template <typename T> void release_extension() { release_extension(T::ID); }

private:
// Non-templatized version with manual index
void clear_extension(unsigned int index) {
m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
}
// Non-templatized version with manual index
void release_extension(unsigned int index) {
m_extensions[index]->free();
m_extensions[index] = static_cast<tlm::tlm_extension_base*>(0);
}
// Non-templatized version with manual index
void clear_extension(unsigned int index) { m_extensions[index] = static_cast<tlm::tlm_extension_base *>(0); }
// Non-templatized version with manual index
void release_extension(unsigned int index) {
m_extensions[index]->free();
m_extensions[index] = static_cast<tlm::tlm_extension_base *>(0);
}

public:
// Make sure the extension array is large enough. Can be called once by
// an initiator module (before issuing the first transaction) to make
// sure that the extension array is of correct size. This is only needed
// if the initiator cannot guarantee that the generic payload object is
// allocated after C++ static construction time.
void resize_extensions() {
m_extensions.expand(tlm::max_num_extensions());
}
// Make sure the extension array is large enough. Can be called once by
// an initiator module (before issuing the first transaction) to make
// sure that the extension array is of correct size. This is only needed
// if the initiator cannot guarantee that the generic payload object is
// allocated after C++ static construction time.
void resize_extensions() { m_extensions.expand(tlm::max_num_extensions()); }

private:
tlm::tlm_array<tlm::tlm_extension_base*> m_extensions;
unsigned int m_ref_count;
tlm::tlm_array<tlm::tlm_extension_base *> m_extensions;
unsigned int m_ref_count;
};


struct tlm_dmi_data {
tlm_dmi_data()
:dmi_ptr(0)
,dmi_start_address(0)
,dmi_end_address(0)
,dmi_access(tlm::tlm_dmi::DMI_ACCESS_NONE)
,dmi_read_latency(0)
,dmi_write_latency(0)
{}

tlm_dmi_data(tlm::tlm_dmi& dmi_data)
:dmi_ptr(dmi_data.get_dmi_ptr())
,dmi_start_address(dmi_data.get_start_address())
,dmi_end_address(dmi_data.get_end_address())
,dmi_access(dmi_data.get_granted_access())
,dmi_read_latency(dmi_data.get_read_latency().value())
,dmi_write_latency(dmi_data.get_write_latency().value())
{}
//--------------
// Destructor
//--------------
virtual ~tlm_dmi_data() {}

unsigned char* dmi_ptr;
sc_dt::uint64 dmi_start_address;
sc_dt::uint64 dmi_end_address;
tlm::tlm_dmi::dmi_access_e dmi_access;
sc_dt::uint64 dmi_read_latency;
sc_dt::uint64 dmi_write_latency;

tlm_dmi_data()
: dmi_ptr(0), dmi_start_address(0), dmi_end_address(0), dmi_access(tlm::tlm_dmi::DMI_ACCESS_NONE),
dmi_read_latency(0), dmi_write_latency(0) {}

tlm_dmi_data(tlm::tlm_dmi &dmi_data)
: dmi_ptr(dmi_data.get_dmi_ptr()), dmi_start_address(dmi_data.get_start_address()),
dmi_end_address(dmi_data.get_end_address()), dmi_access(dmi_data.get_granted_access()),
dmi_read_latency(dmi_data.get_read_latency().value()),
dmi_write_latency(dmi_data.get_write_latency().value()) {}
//--------------
// Destructor
//--------------
virtual ~tlm_dmi_data() {}

unsigned char *dmi_ptr;
sc_dt::uint64 dmi_start_address;
sc_dt::uint64 dmi_end_address;
tlm::tlm_dmi::dmi_access_e dmi_access;
sc_dt::uint64 dmi_read_latency;
sc_dt::uint64 dmi_write_latency;
};


}
#endif /* TLM_GP_DATA_H_ */

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

@@ -20,121 +20,112 @@
#include "tlm_gp_data.h"
#include <scv.h>

template<>
class scv_extensions<tlm::tlm_command> : public scv_enum_base<tlm::tlm_command> {
template <> class scv_extensions<tlm::tlm_command> : public scv_enum_base<tlm::tlm_command> {
public:
SCV_ENUM_CTOR(tlm::tlm_command) {
SCV_ENUM(tlm::TLM_READ_COMMAND);
SCV_ENUM(tlm::TLM_WRITE_COMMAND);
SCV_ENUM(tlm::TLM_IGNORE_COMMAND);
}
SCV_ENUM_CTOR(tlm::tlm_command) {
SCV_ENUM(tlm::TLM_READ_COMMAND);
SCV_ENUM(tlm::TLM_WRITE_COMMAND);
SCV_ENUM(tlm::TLM_IGNORE_COMMAND);
}
};

template<>
class scv_extensions<tlm::tlm_response_status> : public scv_enum_base<tlm::tlm_response_status> {
template <> class scv_extensions<tlm::tlm_response_status> : public scv_enum_base<tlm::tlm_response_status> {
public:
SCV_ENUM_CTOR(tlm::tlm_response_status) {
SCV_ENUM(tlm::TLM_OK_RESPONSE);
SCV_ENUM(tlm::TLM_INCOMPLETE_RESPONSE);
SCV_ENUM(tlm::TLM_GENERIC_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_ADDRESS_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_COMMAND_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_BURST_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
}
SCV_ENUM_CTOR(tlm::tlm_response_status) {
SCV_ENUM(tlm::TLM_OK_RESPONSE);
SCV_ENUM(tlm::TLM_INCOMPLETE_RESPONSE);
SCV_ENUM(tlm::TLM_GENERIC_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_ADDRESS_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_COMMAND_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_BURST_ERROR_RESPONSE);
SCV_ENUM(tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE);
}
};

template<>
class scv_extensions<tlm::tlm_gp_option> : public scv_enum_base<tlm::tlm_gp_option> {
template <> class scv_extensions<tlm::tlm_gp_option> : public scv_enum_base<tlm::tlm_gp_option> {
public:
SCV_ENUM_CTOR(tlm::tlm_gp_option) {
SCV_ENUM(tlm::TLM_MIN_PAYLOAD);
SCV_ENUM(tlm::TLM_FULL_PAYLOAD);
SCV_ENUM(tlm::TLM_FULL_PAYLOAD_ACCEPTED);
}
SCV_ENUM_CTOR(tlm::tlm_gp_option) {
SCV_ENUM(tlm::TLM_MIN_PAYLOAD);
SCV_ENUM(tlm::TLM_FULL_PAYLOAD);
SCV_ENUM(tlm::TLM_FULL_PAYLOAD_ACCEPTED);
}
};

template<>
class scv_extensions<tlm::tlm_phase_enum> : public scv_enum_base<tlm::tlm_phase_enum> {
template <> class scv_extensions<tlm::tlm_phase_enum> : public scv_enum_base<tlm::tlm_phase_enum> {
public:
SCV_ENUM_CTOR(tlm::tlm_phase_enum) {
SCV_ENUM(tlm::UNINITIALIZED_PHASE);
SCV_ENUM(tlm::BEGIN_REQ);
SCV_ENUM(tlm::END_REQ);
SCV_ENUM(tlm::BEGIN_RESP);
SCV_ENUM(tlm::END_RESP);
}
SCV_ENUM_CTOR(tlm::tlm_phase_enum) {
SCV_ENUM(tlm::UNINITIALIZED_PHASE);
SCV_ENUM(tlm::BEGIN_REQ);
SCV_ENUM(tlm::END_REQ);
SCV_ENUM(tlm::BEGIN_RESP);
SCV_ENUM(tlm::END_RESP);
}
};

template<>
class scv_extensions<tlm::tlm_sync_enum> : public scv_enum_base<tlm::tlm_sync_enum> {
template <> class scv_extensions<tlm::tlm_sync_enum> : public scv_enum_base<tlm::tlm_sync_enum> {
public:
SCV_ENUM_CTOR(tlm::tlm_sync_enum) {
SCV_ENUM(tlm::TLM_ACCEPTED);
SCV_ENUM(tlm::TLM_UPDATED);
SCV_ENUM(tlm::TLM_COMPLETED);
}
SCV_ENUM_CTOR(tlm::tlm_sync_enum) {
SCV_ENUM(tlm::TLM_ACCEPTED);
SCV_ENUM(tlm::TLM_UPDATED);
SCV_ENUM(tlm::TLM_COMPLETED);
}
};

template<>
class scv_extensions<scv4tlm::tlm_gp_data> : public scv_extensions_base<scv4tlm::tlm_gp_data> {
template <> class scv_extensions<scv4tlm::tlm_gp_data> : public scv_extensions_base<scv4tlm::tlm_gp_data> {
public:
scv_extensions<sc_dt::uint64> address;
scv_extensions<tlm::tlm_command> command;
scv_extensions<unsigned char*> data;
scv_extensions<unsigned int> data_length;
scv_extensions<tlm::tlm_response_status> response_status;
scv_extensions<bool> dmi;
scv_extensions<unsigned char*> byte_enable;
scv_extensions<unsigned int> byte_enable_length;
scv_extensions<unsigned int> streaming_width;
scv_extensions<tlm::tlm_gp_option> gp_option;
scv_extensions<sc_dt::uint64> address;
scv_extensions<tlm::tlm_command> command;
scv_extensions<unsigned char *> data;
scv_extensions<unsigned int> data_length;
scv_extensions<tlm::tlm_response_status> response_status;
scv_extensions<bool> dmi;
scv_extensions<unsigned char *> byte_enable;
scv_extensions<unsigned int> byte_enable_length;
scv_extensions<unsigned int> streaming_width;
scv_extensions<tlm::tlm_gp_option> gp_option;

SCV_EXTENSIONS_CTOR(scv4tlm::tlm_gp_data) {
//must be in order
SCV_FIELD(address);
SCV_FIELD(command);
SCV_FIELD(data);
SCV_FIELD(data_length);
SCV_FIELD(response_status);
SCV_FIELD(dmi);
SCV_FIELD(byte_enable);
SCV_FIELD(byte_enable_length);
SCV_FIELD(streaming_width);
SCV_FIELD(gp_option);
}
SCV_EXTENSIONS_CTOR(scv4tlm::tlm_gp_data) {
// must be in order
SCV_FIELD(address);
SCV_FIELD(command);
SCV_FIELD(data);
SCV_FIELD(data_length);
SCV_FIELD(response_status);
SCV_FIELD(dmi);
SCV_FIELD(byte_enable);
SCV_FIELD(byte_enable_length);
SCV_FIELD(streaming_width);
SCV_FIELD(gp_option);
}
};

template<>
class scv_extensions<tlm::tlm_dmi::dmi_access_e> : public scv_enum_base<tlm::tlm_dmi::dmi_access_e> {
template <> class scv_extensions<tlm::tlm_dmi::dmi_access_e> : public scv_enum_base<tlm::tlm_dmi::dmi_access_e> {
public:
SCV_ENUM_CTOR(tlm::tlm_dmi::dmi_access_e) {
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_NONE);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_WRITE);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ_WRITE);
}
SCV_ENUM_CTOR(tlm::tlm_dmi::dmi_access_e) {
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_NONE);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_WRITE);
SCV_ENUM(tlm::tlm_dmi::DMI_ACCESS_READ_WRITE);
}
};

template<>
class scv_extensions<scv4tlm::tlm_dmi_data> : public scv_extensions_base<scv4tlm::tlm_dmi_data> {
template <> class scv_extensions<scv4tlm::tlm_dmi_data> : public scv_extensions_base<scv4tlm::tlm_dmi_data> {
public:
scv_extensions<unsigned char*> dmi_ptr;
scv_extensions<sc_dt::uint64> dmi_start_address;
scv_extensions<sc_dt::uint64> dmi_end_address;
scv_extensions<tlm::tlm_dmi::dmi_access_e> dmi_access;
scv_extensions<sc_dt::uint64> dmi_read_latency;
scv_extensions<sc_dt::uint64> dmi_write_latency;
SCV_EXTENSIONS_CTOR(scv4tlm::tlm_dmi_data) {
//must be in order
SCV_FIELD(dmi_ptr);
SCV_FIELD(dmi_start_address);
SCV_FIELD(dmi_end_address);
SCV_FIELD(dmi_access);
SCV_FIELD(dmi_read_latency);
SCV_FIELD(dmi_write_latency);
}
scv_extensions<unsigned char *> dmi_ptr;
scv_extensions<sc_dt::uint64> dmi_start_address;
scv_extensions<sc_dt::uint64> dmi_end_address;
scv_extensions<tlm::tlm_dmi::dmi_access_e> dmi_access;
scv_extensions<sc_dt::uint64> dmi_read_latency;
scv_extensions<sc_dt::uint64> dmi_write_latency;
SCV_EXTENSIONS_CTOR(scv4tlm::tlm_dmi_data) {
// must be in order
SCV_FIELD(dmi_ptr);
SCV_FIELD(dmi_start_address);
SCV_FIELD(dmi_end_address);
SCV_FIELD(dmi_access);
SCV_FIELD(dmi_read_latency);
SCV_FIELD(dmi_write_latency);
}
};


#endif /* TLM_GP_DATA_EXT_H_ */

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

@@ -23,117 +23,109 @@
#include <tlm.h>

namespace scv4tlm {
template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
,
sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
#endif
>
>
#ifndef WITH_SCV
using tlm_rec_initiator_socket = tlm::tlm_initiator_socket<BUSWIDTH,TYPES,N
using tlm_rec_initiator_socket = tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>;
>;
#else
class tlm_rec_initiator_socket: public tlm::tlm_initiator_socket<BUSWIDTH
, TYPES
, N
class tlm_rec_initiator_socket : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
> {
static std::string gen_name(const char* first, const char* second){
std::stringstream ss;
ss<<first<<"_"<<second;
return ss.str();
}
> {
static std::string gen_name(const char *first, const char *second) {
std::stringstream ss;
ss << first << "_" << second;
return ss.str();
}

public:
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
typedef sc_core::sc_port<fw_interface_type, N
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
typedef sc_core::sc_port<fw_interface_type, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
> port_type;
typedef sc_core::sc_export<bw_interface_type> export_type;
typedef tlm::tlm_base_target_socket_b<BUSWIDTH,
fw_interface_type,
bw_interface_type> base_target_socket_type;
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH,
fw_interface_type,
bw_interface_type> base_type;
>
port_type;
typedef sc_core::sc_export<bw_interface_type> export_type;
typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_target_socket_type;
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;

tlm_rec_initiator_socket() :
tlm::tlm_initiator_socket<BUSWIDTH
, TYPES
, N
tlm_rec_initiator_socket()
: tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>()
,recorder()
{
}
>(),
recorder() {
}

explicit tlm_rec_initiator_socket(const char* name) :
tlm::tlm_initiator_socket<BUSWIDTH
, TYPES
, N
explicit tlm_rec_initiator_socket(const char *name)
: tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>(name)
,recorder(gen_name(name, "rec").c_str())
{
}
>(name),
recorder(gen_name(name, "rec").c_str()) {
}

virtual ~tlm_rec_initiator_socket(){}
virtual ~tlm_rec_initiator_socket() {}

virtual const char* kind() const {
return "tlm_rec_target_socket";
}
//
// Bind initiator socket to target socket
// - Binds the port of the initiator socket to the export of the target
// socket
// - Binds the port of the target socket to the export of the initiator
// socket
//
virtual void bind(base_target_socket_type& s) {
// initiator.port -> target.export
(this->get_base_port())(recorder);
recorder.fw_port(s.get_base_interface());
// target.port -> initiator.export
(s.get_base_port())(recorder);
recorder.bw_port(this->get_base_interface());
}
//
// Bind initiator socket to initiator socket (hierarchical bind)
// - Binds both the export and the port
//
virtual void bind(base_type& s){
// port
(this->get_base_port())(recorder);
recorder.fw_port(s.get_base_port());
// export
(s.get_base_export())(recorder);
recorder.bw_port(this->get_base_export());
}
virtual const char *kind() const { return "tlm_rec_target_socket"; }
//
// Bind initiator socket to target socket
// - Binds the port of the initiator socket to the export of the target
// socket
// - Binds the port of the target socket to the export of the initiator
// socket
//
virtual void bind(base_target_socket_type &s) {
// initiator.port -> target.export
(this->get_base_port())(recorder);
recorder.fw_port(s.get_base_interface());
// target.port -> initiator.export
(s.get_base_port())(recorder);
recorder.bw_port(this->get_base_interface());
}
//
// Bind initiator socket to initiator socket (hierarchical bind)
// - Binds both the export and the port
//
virtual void bind(base_type &s) {
// port
(this->get_base_port())(recorder);
recorder.fw_port(s.get_base_port());
// export
(s.get_base_export())(recorder);
recorder.bw_port(this->get_base_export());
}

//
// Bind interface to socket
// - Binds the interface to the export of this socket
//
virtual void bind(bw_interface_type& ifs) {
(this->get_base_export())(ifs);
}
//
// Bind interface to socket
// - Binds the interface to the export of this socket
//
virtual void bind(bw_interface_type &ifs) { (this->get_base_export())(ifs); }

void setExtensionRecording(tlm2_extensions_recording_if<TYPES>* extensionRecording){
recorder.setExtensionRecording(extensionRecording);
}
void setExtensionRecording(tlm2_extensions_recording_if<TYPES> *extensionRecording) {
recorder.setExtensionRecording(extensionRecording);
}

protected:
scv4tlm::tlm2_recorder<TYPES> recorder;
scv4tlm::tlm2_recorder<TYPES> recorder;
};
#endif
}


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

@@ -23,111 +23,105 @@
#include <tlm.h>

namespace scv4tlm {
template<unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
template <unsigned int BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
,
sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
#endif
>
>
#ifndef WITH_SCV
using tlm_rec_target_socket = tlm::tlm_target_socket<BUSWIDTH,TYPES,N
using tlm_rec_target_socket = tlm::tlm_target_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>;
>;
#else
class tlm_rec_target_socket: public tlm::tlm_target_socket<BUSWIDTH
, TYPES
, N
class tlm_rec_target_socket : public tlm::tlm_target_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
> {
static std::string gen_name(const char* first, const char* second){
std::stringstream ss;
ss<<first<<"_"<<second;
return ss.str();
}
> {
static std::string gen_name(const char *first, const char *second) {
std::stringstream ss;
ss << first << "_" << second;
return ss.str();
}

public:
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
typedef sc_core::sc_port<bw_interface_type, N
typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
typedef sc_core::sc_port<bw_interface_type, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
> port_type;
>
port_type;

typedef sc_core::sc_export<fw_interface_type> export_type;
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_initiator_socket_type;
typedef sc_core::sc_export<fw_interface_type> export_type;
typedef tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_initiator_socket_type;

typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;
typedef tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type> base_type;

tlm_rec_target_socket() :
tlm::tlm_target_socket<BUSWIDTH
, TYPES
, N
tlm_rec_target_socket()
: tlm::tlm_target_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>()
,recorder()
{
}
>(),
recorder() {
}

explicit tlm_rec_target_socket(const char* name) :
tlm::tlm_target_socket<BUSWIDTH
, TYPES
, N
explicit tlm_rec_target_socket(const char *name)
: tlm::tlm_target_socket<BUSWIDTH, TYPES, N
#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
, POL
,
POL
#endif
>(name)
,recorder(gen_name(name, "rec").c_str())
{
}

virtual ~tlm_rec_target_socket(){}
>(name),
recorder(gen_name(name, "rec").c_str()) {
}

virtual const char* kind() const {
return "tlm_rec_target_socket";
}
//
// Bind target socket to target socket (hierarchical bind)
// - Binds both the export and the port
//
virtual void bind(base_type& s) {
// export
(this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
// port
(s.get_base_port())(recorder); // bind the recording interface to the port, recording will use the m_port
}
//
// Bind interface to socket
// - Binds the interface to the export
//
virtual void bind(fw_interface_type& ifs){
export_type* exp = &this->get_base_export();
if( this == exp ) {
export_type::bind(recorder); // non-virtual function call
recorder.fw_port(ifs);
recorder.bw_port(this->get_base_port());
} else {
exp->bind( ifs );
}
virtual ~tlm_rec_target_socket() {}

}
//
// Forward to 'operator->()' of port class
//
bw_interface_type* operator->() {
return &recorder;
}
virtual const char *kind() const { return "tlm_rec_target_socket"; }
//
// Bind target socket to target socket (hierarchical bind)
// - Binds both the export and the port
//
virtual void bind(base_type &s) {
// export
(this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
// port
(s.get_base_port())(recorder); // bind the recording interface to the port,
// recording will use the m_port
}
//
// Bind interface to socket
// - Binds the interface to the export
//
virtual void bind(fw_interface_type &ifs) {
export_type *exp = &this->get_base_export();
if (this == exp) {
export_type::bind(recorder); // non-virtual function call
recorder.fw_port(ifs);
recorder.bw_port(this->get_base_port());
} else {
exp->bind(ifs);
}
}
//
// Forward to 'operator->()' of port class
//
bw_interface_type *operator->() { return &recorder; }

scv4tlm::tlm2_recorder<TYPES>& get_recorder(){
return recorder;
}
scv4tlm::tlm2_recorder<TYPES> &get_recorder() { return recorder; }

protected:
scv4tlm::tlm2_recorder<TYPES> recorder;
scv4tlm::tlm2_recorder<TYPES> recorder;
};
#endif
}


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

@@ -23,64 +23,63 @@ namespace scv4tlm {

//! transaction relationships
enum tx_rel {
PARENT_CHILD = 0, /*!< indicates parent child relationship */
PREDECESSOR_SUCCESSOR /*!< indicates predecessor successor relationship */
PARENT_CHILD = 0, /*!< indicates parent child relationship */
PREDECESSOR_SUCCESSOR /*!< indicates predecessor successor relationship */
};
//! the string representation of the tx_rel
static char const* tx_rel_str[] = { "PARENT/CHILD", "PRED/SUCC" };
static char const *tx_rel_str[] = {"PARENT/CHILD", "PRED/SUCC"};
/*! \brief cast the tx_rel enum to a string
*
* \param tc_rel is the relationship enum
*/
inline const char* rel_str(tx_rel rel) {
return (tx_rel_str[rel]);
}
inline const char *rel_str(tx_rel rel) { return (tx_rel_str[rel]); }

/*! \brief generic payload extension class holding the handle of the last recorded SCV transaction
/*! \brief generic payload extension class holding the handle of the last
* recorded SCV transaction
*
* This extension is been used in the \ref scv_tlm2_recorder. The recorder stores the handle to the generated SCV transaction and
* forwrds it along with the generic payload. If the recorder finds an extension containing a valid handle it links the generated
* This extension is been used in the \ref scv_tlm2_recorder. The recorder
* stores the handle to the generated SCV transaction and
* forwrds it along with the generic payload. If the recorder finds an extension
* containing a valid handle it links the generated
* SCV transdaction to the found one using the \ref PREDECESSOR releationship
*/
struct tlm_recording_extension: public tlm::tlm_extension<tlm_recording_extension> {
/*! \brief clone the given extension and duplicate the SCV transaction handle.
*
*/
virtual tlm_extension_base* clone() const {
tlm_recording_extension* t = new tlm_recording_extension(this->txHandle, this->creator);
return t;
}
/*! \brief copy data between extensions.
*
* \param from is the source extension.
*/
virtual void copy_from(tlm_extension_base const& from) {
txHandle = static_cast<tlm_recording_extension const &>(from).txHandle;
creator = static_cast<tlm_recording_extension const &>(from).creator;
}
/*! \brief constructor storing the handle of the transaction and the owner of this extension
*
* \param handle is the handle of the created SCV transaction.
* \param creator_ is the pointer to the owner of this extension (usually an instance of scv_tlm2_recorder).
*/
tlm_recording_extension(scv_tr_handle handle, void* creator_) :
txHandle(handle), creator(creator_) {
}
/*! \brief accessor to the owner, the property is read only.
*
*/
void* get_creator() {
return creator;
}
/*! \brief accessor to the SCV transaction handle.
*
*/
scv_tr_handle txHandle;
struct tlm_recording_extension : public tlm::tlm_extension<tlm_recording_extension> {
/*! \brief clone the given extension and duplicate the SCV transaction handle.
*
*/
virtual tlm_extension_base *clone() const {
tlm_recording_extension *t = new tlm_recording_extension(this->txHandle, this->creator);
return t;
}
/*! \brief copy data between extensions.
*
* \param from is the source extension.
*/
virtual void copy_from(tlm_extension_base const &from) {
txHandle = static_cast<tlm_recording_extension const &>(from).txHandle;
creator = static_cast<tlm_recording_extension const &>(from).creator;
}
/*! \brief constructor storing the handle of the transaction and the owner of
* this extension
*
* \param handle is the handle of the created SCV transaction.
* \param creator_ is the pointer to the owner of this extension (usually an
* instance of scv_tlm2_recorder).
*/
tlm_recording_extension(scv_tr_handle handle, void *creator_) : txHandle(handle), creator(creator_) {}
/*! \brief accessor to the owner, the property is read only.
*
*/
void *get_creator() { return creator; }
/*! \brief accessor to the SCV transaction handle.
*
*/
scv_tr_handle txHandle;

private:
//! the owner of this transaction
void* creator;
//! the owner of this transaction
void *creator;
};

}

#endif /* TLM_RECORDING_EXTENSION_H_ */

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

@@ -24,10 +24,10 @@
#define INCL_SYSC_CORE_SC_LOGIC_7_H_
#include <cstdio>

#include "sysc/utils/sc_iostream.h"
#include "sysc/datatypes/bit/sc_bit.h"
#include "sysc/kernel/sc_macros.h"
#include "sysc/utils/sc_iostream.h"
#include "sysc/utils/sc_mempool.h"
#include "sysc/datatypes/bit/sc_bit.h"

namespace sysc {
namespace sc_dt {
@@ -35,23 +35,13 @@ namespace sc_dt {
// classes defined in this module
class sc_logic_7;


// ----------------------------------------------------------------------------
// ENUM : sc_logic_7_value_t
//
// Enumeration of values for sc_logic_7.
// ----------------------------------------------------------------------------

enum sc_logic_7_value_t
{
Log_0 = 0,
Log_1,
Log_L,
Log_H,
Log_Z,
Log_X,
Log_U
};
enum sc_logic_7_value_t { Log_0 = 0, Log_1, Log_L, Log_H, Log_Z, Log_X, Log_U };

// ----------------------------------------------------------------------------
// CLASS : sc_logic_7
@@ -59,59 +49,48 @@ enum sc_logic_7_value_t
// Four-valued logic type.
// ----------------------------------------------------------------------------

class sc_logic_7
{
class sc_logic_7 {
private:

// support methods

static void invalid_value( sc_logic_7_value_t );
static void invalid_value( char );
static void invalid_value( int );
static void invalid_value(sc_logic_7_value_t);
static void invalid_value(char);
static void invalid_value(int);

static sc_logic_7_value_t to_value( sc_logic_7_value_t v )
{
if( v < Log_0 || v > Log_X ) {
invalid_value( v );
static sc_logic_7_value_t to_value(sc_logic_7_value_t v) {
if (v < Log_0 || v > Log_X) {
invalid_value(v);
}
return v;
}

static sc_logic_7_value_t to_value( bool b )
{ return ( b ? Log_1 : Log_0 ); }
static sc_logic_7_value_t to_value(bool b) { return (b ? Log_1 : Log_0); }

static sc_logic_7_value_t to_value( char c )
{
static sc_logic_7_value_t to_value(char c) {
sc_logic_7_value_t v;
unsigned int index = (int)c;
if ( index > 127 )
{
if (index > 127) {
invalid_value(c);
v = Log_X;
}
else
{
v = char_to_logic[index];
if( v < Log_0 || v > Log_X ) {
invalid_value( c );
}
v = Log_X;
} else {
v = char_to_logic[index];
if (v < Log_0 || v > Log_X) {
invalid_value(c);
}
}
return v;
}

static sc_logic_7_value_t to_value( int i )
{
if( i < 0 || i > 3 ) {
invalid_value( i );
static sc_logic_7_value_t to_value(int i) {
if (i < 0 || i > 3) {
invalid_value(i);
}
return sc_logic_7_value_t( i );
return sc_logic_7_value_t(i);
}


void invalid_01() const;

public:

// conversion tables

static const sc_logic_7_value_t char_to_logic[128];
@@ -121,68 +100,60 @@ public:
static const sc_logic_7_value_t xor_table[7][7];
static const sc_logic_7_value_t not_table[7];


// constructors

sc_logic_7()
: m_val( Log_U )
{}

sc_logic_7( const sc_logic_7& a )
: m_val( a.m_val )
{}
sc_logic_7() : m_val(Log_U) {}

sc_logic_7( sc_logic_7_value_t v )
: m_val( to_value( v ) )
{}
sc_logic_7(const sc_logic_7 &a) : m_val(a.m_val) {}

explicit sc_logic_7( bool a )
: m_val( to_value( a ) )
{}
sc_logic_7(sc_logic_7_value_t v) : m_val(to_value(v)) {}

explicit sc_logic_7( char a )
: m_val( to_value( a ) )
{}
explicit sc_logic_7(bool a) : m_val(to_value(a)) {}

explicit sc_logic_7( int a )
: m_val( to_value( a ) )
{}
explicit sc_logic_7(char a) : m_val(to_value(a)) {}

explicit sc_logic_7( const ::sc_dt::sc_bit& a )
: m_val( to_value( a.to_bool() ) )
{}
explicit sc_logic_7(int a) : m_val(to_value(a)) {}

explicit sc_logic_7(const ::sc_dt::sc_bit &a) : m_val(to_value(a.to_bool())) {}

// destructor

~sc_logic_7()
{}
~sc_logic_7() {}

// (bitwise) assignment operators

// (bitwise) assignment operators
#define DEFN_ASN_OP_T(op,tp) \
sc_logic_7& operator op ( tp v ) \
{ *this op sc_logic_7( v ); return *this; }
#define DEFN_ASN_OP_T(op, tp) \
sc_logic_7 &operator op(tp v) { \
*this op sc_logic_7(v); \
return *this; \
}

#define DEFN_ASN_OP(op) \
DEFN_ASN_OP_T(op, sc_logic_7_value_t) \
</