diff options
Diffstat (limited to 'src/systemc/ext/tlm_core/tlm_2')
16 files changed, 1606 insertions, 1549 deletions
diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h index 8a0c543c8..386f7cb75 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_2_interfaces.h @@ -17,11 +17,10 @@ *****************************************************************************/ -#ifndef __TLM_2_INTERFACES_H__ -#define __TLM_2_INTERFACES_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ #include "tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h" #include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" -#endif - +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_INTERFACES_TLM_2_INTERFACES_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h index d7c3304eb..573744d28 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h @@ -17,98 +17,108 @@ *****************************************************************************/ -#ifndef __TLM_DMI_H__ -#define __TLM_DMI_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ #include <systemc> -namespace tlm { +namespace tlm +{ class tlm_dmi { public: - - // Enum for indicating the access granted to the initiator. - // The initiator uses gp.m_command to indicate it intention (read/write) - // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE - // requests to dmi_access_read_write. - - enum dmi_access_e - { DMI_ACCESS_NONE = 0x00 // no access - , DMI_ACCESS_READ = 0x01 // read access - , DMI_ACCESS_WRITE = 0x02 // write access - , DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE // read/write access - }; - - tlm_dmi (void) - { - init(); - } - - void init (void) - { - m_dmi_ptr = 0x0; - m_dmi_start_address = 0x0; - m_dmi_end_address = (sc_dt::uint64)(-1); - m_dmi_access = DMI_ACCESS_NONE; - m_dmi_read_latency = sc_core::SC_ZERO_TIME; - m_dmi_write_latency = sc_core::SC_ZERO_TIME; - } - - unsigned char* get_dmi_ptr (void) const {return m_dmi_ptr;} - sc_dt::uint64 get_start_address (void) const {return m_dmi_start_address;} - sc_dt::uint64 get_end_address (void) const {return m_dmi_end_address;} - sc_core::sc_time get_read_latency (void) const {return m_dmi_read_latency;} - sc_core::sc_time get_write_latency (void) const {return m_dmi_write_latency;} - dmi_access_e get_granted_access (void) const {return m_dmi_access;} - bool is_none_allowed (void) const {return m_dmi_access == DMI_ACCESS_NONE;} - bool is_read_allowed (void) const {return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ;} - bool is_write_allowed (void) const {return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE;} - bool is_read_write_allowed (void) const {return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE;} - - void set_dmi_ptr (unsigned char* p) {m_dmi_ptr = p;} - void set_start_address (sc_dt::uint64 addr) {m_dmi_start_address = addr;} - void set_end_address (sc_dt::uint64 addr) {m_dmi_end_address = addr;} - void set_read_latency (sc_core::sc_time t) {m_dmi_read_latency = t;} - void set_write_latency (sc_core::sc_time t) {m_dmi_write_latency = t;} - void set_granted_access (dmi_access_e a) {m_dmi_access = a;} - void allow_none (void) {m_dmi_access = DMI_ACCESS_NONE;} - void allow_read (void) {m_dmi_access = DMI_ACCESS_READ;} - void allow_write (void) {m_dmi_access = DMI_ACCESS_WRITE;} - void allow_read_write (void) {m_dmi_access = DMI_ACCESS_READ_WRITE;} + // Enum for indicating the access granted to the initiator. + // The initiator uses gp.m_command to indicate it intention (read/write) + // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE + // requests to dmi_access_read_write. + + enum dmi_access_e { + DMI_ACCESS_NONE = 0x00, // no access + DMI_ACCESS_READ = 0x01, // read access + DMI_ACCESS_WRITE = 0x02, // write access + DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE + // read/write access + }; + + tlm_dmi() { init(); } + + void + init() + { + m_dmi_ptr = nullptr; + m_dmi_start_address = 0x0; + m_dmi_end_address = (sc_dt::uint64)(-1); + m_dmi_access = DMI_ACCESS_NONE; + m_dmi_read_latency = sc_core::SC_ZERO_TIME; + m_dmi_write_latency = sc_core::SC_ZERO_TIME; + } + + unsigned char *get_dmi_ptr() const { return m_dmi_ptr; } + sc_dt::uint64 get_start_address() const { return m_dmi_start_address; } + sc_dt::uint64 get_end_address() const { return m_dmi_end_address; } + sc_core::sc_time get_read_latency() const { return m_dmi_read_latency; } + sc_core::sc_time get_write_latency() const { return m_dmi_write_latency; } + dmi_access_e get_granted_access() const { return m_dmi_access; } + bool is_none_allowed() const { return m_dmi_access == DMI_ACCESS_NONE; } + bool + is_read_allowed() const + { + return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ; + } + bool + is_write_allowed() const + { + return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE; + } + bool + is_read_write_allowed() const + { + return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE; + } + + void set_dmi_ptr(unsigned char *p) { m_dmi_ptr = p; } + void set_start_address(sc_dt::uint64 addr) { m_dmi_start_address = addr; } + void set_end_address(sc_dt::uint64 addr) { m_dmi_end_address = addr; } + void set_read_latency(sc_core::sc_time t) { m_dmi_read_latency = t; } + void set_write_latency(sc_core::sc_time t) { m_dmi_write_latency = t; } + void set_granted_access(dmi_access_e a) { m_dmi_access = a; } + void allow_none() { m_dmi_access = DMI_ACCESS_NONE; } + void allow_read() { m_dmi_access = DMI_ACCESS_READ; } + void allow_write() { m_dmi_access = DMI_ACCESS_WRITE; } + void allow_read_write() { m_dmi_access = DMI_ACCESS_READ_WRITE; } private: + // If the forward call is successful, the target returns the dmi_ptr, + // which must point to the data element corresponding to the + // dmi_start_address. The data is organized as a byte array with the + // endianness of the target (endianness member of the tlm_dmi struct). + + unsigned char *m_dmi_ptr; + + // The absolute start and end addresses of the DMI region. If the decoder + // logic in the interconnect changes the address field e.g. by masking, the + // interconnect is responsible to transform the relative address back to an + // absolute address again. + + sc_dt::uint64 m_dmi_start_address; + sc_dt::uint64 m_dmi_end_address; + + // Granted access + + dmi_access_e m_dmi_access; + + // These members define the latency of read/write transactions. The + // initiator must initialize these members to zero before requesting a + // dmi pointer, because both the interconnect as well as the target can + // add to the total transaction latency. + // Depending on the 'type' attribute only one, or both of these attributes + // will be valid. - // If the forward call is successful, the target returns the dmi_ptr, - // which must point to the data element corresponding to the - // dmi_start_address. The data is organized as a byte array with the - // endianness of the target (endianness member of the tlm_dmi struct). - - unsigned char* m_dmi_ptr; - - // The absolute start and end addresses of the DMI region. If the decoder - // logic in the interconnect changes the address field e.g. by masking, the - // interconnect is responsible to transform the relative address back to an - // absolute address again. - - sc_dt::uint64 m_dmi_start_address; - sc_dt::uint64 m_dmi_end_address; - - // Granted access - - dmi_access_e m_dmi_access; - - // These members define the latency of read/write transactions. The - // initiator must initialize these members to zero before requesting a - // dmi pointer, because both the interconnect as well as the target can - // add to the total transaction latency. - // Depending on the 'type' attribute only one, or both of these attributes - // will be valid. - - sc_core::sc_time m_dmi_read_latency; - sc_core::sc_time m_dmi_write_latency; + sc_core::sc_time m_dmi_read_latency; + sc_core::sc_time m_dmi_write_latency; }; } // namespace tlm -#endif /* TLM_DMI_HEADER */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_DMI_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h index 59e81c658..3c21ca01e 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h @@ -17,43 +17,43 @@ *****************************************************************************/ -#ifndef __TLM_FW_BW_IFS_H__ -#define __TLM_FW_BW_IFS_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ #include <systemc> -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h" + #include "tlm_core/tlm_2/tlm_2_interfaces/tlm_dmi.h" +#include "tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h" -namespace tlm { +namespace tlm +{ enum tlm_sync_enum { TLM_ACCEPTED, TLM_UPDATED, TLM_COMPLETED }; //////////////////////////////////////////////////////////////////////////// // Basic interfaces //////////////////////////////////////////////////////////////////////////// -template <typename TRANS = tlm_generic_payload, - typename PHASE = tlm_phase> -class tlm_fw_nonblocking_transport_if : public virtual sc_core::sc_interface { -public: - virtual tlm_sync_enum nb_transport_fw(TRANS& trans, - PHASE& phase, - sc_core::sc_time& t) = 0; +template <typename TRANS=tlm_generic_payload, typename PHASE=tlm_phase> +class tlm_fw_nonblocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual tlm_sync_enum nb_transport_fw(TRANS &trans, PHASE &phase, + sc_core::sc_time& t) = 0; }; -template <typename TRANS = tlm_generic_payload, - typename PHASE = tlm_phase> -class tlm_bw_nonblocking_transport_if : public virtual sc_core::sc_interface { -public: - virtual tlm_sync_enum nb_transport_bw(TRANS& trans, - PHASE& phase, - sc_core::sc_time& t) = 0; +template <typename TRANS=tlm_generic_payload, typename PHASE=tlm_phase> +class tlm_bw_nonblocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual tlm_sync_enum nb_transport_bw(TRANS &trans, PHASE &phase, + sc_core::sc_time &t) = 0; }; -template <typename TRANS = tlm_generic_payload> -class tlm_blocking_transport_if : public virtual sc_core::sc_interface { -public: - virtual void b_transport(TRANS& trans, - sc_core::sc_time& t) = 0; +template <typename TRANS=tlm_generic_payload> +class tlm_blocking_transport_if : public virtual sc_core::sc_interface +{ + public: + virtual void b_transport(TRANS &trans, sc_core::sc_time &t) = 0; }; ////////////////////////////////////////////////////////////////////////// @@ -115,12 +115,11 @@ public: // required to set the DMI hint to true if a DMI request on the given address // with the given transaction type (read or write) would have succeeded. -template <typename TRANS = tlm_generic_payload> +template <typename TRANS=tlm_generic_payload> class tlm_fw_direct_mem_if : public virtual sc_core::sc_interface { -public: - virtual bool get_direct_mem_ptr(TRANS& trans, - tlm_dmi& dmi_data) = 0; + public: + virtual bool get_direct_mem_ptr(TRANS &trans, tlm_dmi &dmi_data) = 0; }; // The semantics of the backwards call is as follows: @@ -152,9 +151,9 @@ public: // class tlm_bw_direct_mem_if : public virtual sc_core::sc_interface { -public: - virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, - sc_dt::uint64 end_range) = 0; + public: + virtual void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, + sc_dt::uint64 end_range) = 0; }; ///////////////////////////////////////////////////////////////////// @@ -181,13 +180,13 @@ public: // this number must be <= num_bytes. Thus, a target can safely return 0 if it // does not support debug transactions. // -template <typename TRANS = tlm_generic_payload> +template <typename TRANS=tlm_generic_payload> class tlm_transport_dbg_if : public virtual sc_core::sc_interface { -public: - // The return value of defines the number of bytes successfully - // transferred. - virtual unsigned int transport_dbg(TRANS& trans) = 0; + public: + // The return value of defines the number of bytes successfully + // transferred. + virtual unsigned int transport_dbg(TRANS &trans) = 0; }; //////////////////////////////////////////////////////////////////////////// @@ -196,28 +195,28 @@ public: struct tlm_base_protocol_types { - typedef tlm_generic_payload tlm_payload_type; - typedef tlm_phase tlm_phase_type; + typedef tlm_generic_payload tlm_payload_type; + typedef tlm_phase tlm_phase_type; }; // The forward interface: -template <typename TYPES = tlm_base_protocol_types> -class tlm_fw_transport_if - : public virtual tlm_fw_nonblocking_transport_if<typename TYPES::tlm_payload_type, - typename TYPES::tlm_phase_type> - , public virtual tlm_blocking_transport_if<typename TYPES::tlm_payload_type> - , public virtual tlm_fw_direct_mem_if<typename TYPES::tlm_payload_type> - , public virtual tlm_transport_dbg_if<typename TYPES::tlm_payload_type> +template <typename TYPES=tlm_base_protocol_types> +class tlm_fw_transport_if : + public virtual tlm_fw_nonblocking_transport_if< + typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, + public virtual tlm_blocking_transport_if<typename TYPES::tlm_payload_type>, + public virtual tlm_fw_direct_mem_if<typename TYPES::tlm_payload_type>, + public virtual tlm_transport_dbg_if<typename TYPES::tlm_payload_type> {}; // The backward interface: -template <typename TYPES = tlm_base_protocol_types> -class tlm_bw_transport_if - : public virtual tlm_bw_nonblocking_transport_if<typename TYPES::tlm_payload_type, - typename TYPES::tlm_phase_type> - , public virtual tlm_bw_direct_mem_if +template <typename TYPES=tlm_base_protocol_types> +class tlm_bw_transport_if : + public virtual tlm_bw_nonblocking_transport_if< + typename TYPES::tlm_payload_type, typename TYPES::tlm_phase_type>, + public virtual tlm_bw_direct_mem_if {}; } // namespace tlm -#endif /* __TLM_FW_BW_IFS_H__ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_2_INTERFACES_TLM_FW_BW_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h index 1a49b0895..9890a2a2c 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_array.h @@ -17,23 +17,13 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM2_TLM_ARRAY_H_INCLUDED_ -#define TLM_CORE_TLM2_TLM_ARRAY_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ #include <vector> -#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) -#pragma warning(push) -#pragma warning(disable: 4251) // DLL import for std::string,vector -#endif - -namespace tlm { - -// -// To the LRM writer: the below class is an artifact of the tlm_generic_payload -// implementation and not part of the core TLM standard -// - +namespace tlm +{ // This implements a lean and fast array class that supports array expansion on // request. The class is primarily used in the tlm_generic_payload class for @@ -48,79 +38,61 @@ namespace tlm { // may invalidate all direct pointers into the array. -//the tlm_array shall always be used with T=tlm_extension_base* +// The tlm_array shall always be used with T=tlm_extension_base*. template <typename T> -class tlm_array - : private std::vector<T> +class tlm_array : private std::vector<T> { - typedef std::vector<T> base_type; + private: + typedef std::vector<T> base_type; typedef typename base_type::size_type size_type; -public: - - // constructor: - tlm_array(size_type size = 0) - : base_type(size) - , m_entries() - { - //m_entries.reserve(size); // optional - } - // copy constructor: - // tlm_array(const tlm_array& orig) = default; + public: + tlm_array(size_type size=0) : base_type(size), m_entries() {} - // destructor: - // ~tlm_array() = default; + // Operators for dereferencing: + using base_type::operator []; - // operators for dereferencing: - using base_type::operator[]; - - // array size: + // Array size: using base_type::size; - // expand the array if needed: - void expand(size_type new_size) + // Expand the array if needed: + void + expand(size_type new_size) { if (new_size > size()) - { base_type::resize(new_size); - //m_entries.reserve(new_size); // optional - } } - static const char* const kind_string; - const char* kind() const { return kind_string; } + static const char *const kind_string; + const char *kind() const { return kind_string; } - //this function shall get a pointer to a array slot + // This function shall get a pointer to an array slot // it stores this slot in a cache of active slots - void insert_in_cache(T* p) - { - //sc_assert( (p-&(*this)[0]) < size() ); - m_entries.push_back( p-&(*this)[0] ); - } + void insert_in_cache(T *p) { m_entries.push_back(p - &(*this)[0]); } - //this functions clears all active slots of the array - void free_entire_cache() + // This functions clears all active slots of the array. + void + free_entire_cache() { - while(m_entries.size()) - { - if ((*this)[m_entries.back()]) //we make sure no one cleared the slot manually - (*this)[m_entries.back()]->free();//...and then we call free on the content of the slot - (*this)[m_entries.back()]=0; //afterwards we set the slot to NULL + while (m_entries.size()) { + // We make sure no one cleared the slot manually. + if ((*this)[m_entries.back()]) { + // ...and then we call free on the content of the slot + (*this)[m_entries.back()]->free(); + } + // Afterwards we set the slot to NULL + (*this)[m_entries.back()] = nullptr; m_entries.pop_back(); } } -protected: + protected: std::vector<size_type> m_entries; }; template <typename T> -const char* const tlm_array<T>::kind_string = "tlm_array"; - -#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) -#pragma warning(pop) -#endif +const char *const tlm_array<T>::kind_string = "tlm_array"; } // namespace tlm -#endif /* TLM_CORE_TLM2_TLM_ARRAY_H_INCLUDED_ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOADS_TLM_ARRAY_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h index cf17a1ffb..7eb86fa68 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h @@ -18,14 +18,15 @@ *****************************************************************************/ -#ifndef __TLM_ENDIAN_CONV_H__ -#define __TLM_ENDIAN_CONV_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ #include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h" #include <cstring> // std::memset -namespace tlm { +namespace tlm +{ /* Tranaction-Level Modelling @@ -140,20 +141,13 @@ needing to store context. tlm_from_hostendian(tlm_generic_payload *txn) */ - - -#ifndef uchar -#define uchar unsigned char -#else -#define TLM_END_CONV_DONT_UNDEF_UCHAR -#endif - - /////////////////////////////////////////////////////////////////////////////// // Generic Utilities class tlm_endian_context; -class tlm_endian_context_pool { + +class tlm_endian_context_pool +{ public: tlm_endian_context *first; inline tlm_endian_context_pool(); @@ -161,54 +155,68 @@ class tlm_endian_context_pool { inline tlm_endian_context *pop(); inline void push(tlm_endian_context *c); }; + static tlm_endian_context_pool global_tlm_endian_context_pool; // an extension to keep the information needed for reconversion of response -class tlm_endian_context : public tlm_extension<tlm_endian_context> { +class tlm_endian_context : public tlm_extension<tlm_endian_context> +{ public: tlm_endian_context() : dbuf_size(0), bebuf_size(0) {} + ~tlm_endian_context() { - if(dbuf_size > 0) delete [] new_dbuf; - if(bebuf_size > 0) delete [] new_bebuf; + if (dbuf_size > 0) + delete [] new_dbuf; + if (bebuf_size > 0) + delete [] new_bebuf; } - sc_dt::uint64 address; // used by generic, word - sc_dt::uint64 new_address; // used by generic - uchar *data_ptr; // used by generic, word, aligned - uchar *byte_enable; // used by word - int length; // used by generic, word - int stream_width; // used by generic + sc_dt::uint64 address; // Used by generic, word. + sc_dt::uint64 new_address; // Used by generic. + unsigned char *data_ptr; // Used by generic, word, aligned. + unsigned char *byte_enable; // Used by word. + int length; // Used by generic, word. + int stream_width; // Used by generic. - // used by common entry point on response + // Used by common entry point on response. void (*from_f)(tlm_generic_payload *txn, unsigned int sizeof_databus); int sizeof_databus; - // reordering buffers for data and byte-enables - uchar *new_dbuf, *new_bebuf; + // Reordering buffers for data and byte-enables. + unsigned char *new_dbuf, *new_bebuf; int dbuf_size, bebuf_size; - void establish_dbuf(int len) { - if(len <= dbuf_size) return; - if(dbuf_size > 0) delete [] new_dbuf; - new_dbuf = new uchar[len]; - dbuf_size = len; - } - void establish_bebuf(int len) { - if(len <= bebuf_size) return; - if(bebuf_size > 0) delete [] new_bebuf; - new_bebuf = new uchar[len]; - bebuf_size = len; + + void + establish_dbuf(int len) + { + if (len <= dbuf_size) + return; + if (dbuf_size > 0) + delete [] new_dbuf; + new_dbuf = new unsigned char[len]; + dbuf_size = len; } - // required for extension management - void free() { - global_tlm_endian_context_pool.push(this); + void + establish_bebuf(int len) + { + if (len <= bebuf_size) + return; + if (bebuf_size > 0) + delete [] new_bebuf; + new_bebuf = new unsigned char[len]; + bebuf_size = len; } - tlm_extension_base* clone() const {return 0;} - void copy_from(tlm_extension_base const &) {return;} - // for pooling + // Required for extension management. + void free() { global_tlm_endian_context_pool.push(this); } + tlm_extension_base *clone() const { return 0; } + void copy_from(tlm_extension_base const &) { return; } + + // For pooling. tlm_endian_context *next; }; + // Assumptions about transaction contexts: // 1) only the address attribute of a transaction // is mutable. all other attributes are unchanged from the request to @@ -224,568 +232,711 @@ class tlm_endian_context : public tlm_extension<tlm_endian_context> { // should not remove it unless it deletes the generic payload // object. -inline tlm_endian_context *establish_context(tlm_generic_payload *txn) { - tlm_endian_context *tc = txn->get_extension<tlm_endian_context>(); - if(tc == 0) { - tc = global_tlm_endian_context_pool.pop(); - txn->set_extension(tc); - } - return tc; +inline tlm_endian_context * +establish_context(tlm_generic_payload *txn) +{ + tlm_endian_context *tc = txn->get_extension<tlm_endian_context>(); + if (tc == 0) { + tc = global_tlm_endian_context_pool.pop(); + txn->set_extension(tc); + } + return tc; } inline tlm_endian_context_pool::tlm_endian_context_pool() : first(0) {} -inline tlm_endian_context_pool::~tlm_endian_context_pool() { - while(first != 0) { - tlm_endian_context *next = first->next; - delete first; - first = next; - } +inline tlm_endian_context_pool::~tlm_endian_context_pool() +{ + while (first != 0) { + tlm_endian_context *next = first->next; + delete first; + first = next; + } } -tlm_endian_context *tlm_endian_context_pool::pop() { - if(first == 0) return new tlm_endian_context; - tlm_endian_context *r = first; - first = first->next; - return r; +tlm_endian_context * +tlm_endian_context_pool::pop() +{ + if (first == 0) + return new tlm_endian_context; + tlm_endian_context *r = first; + first = first->next; + return r; } -void tlm_endian_context_pool::push(tlm_endian_context *c) { - c->next = first; - first = c; +void tlm_endian_context_pool::push(tlm_endian_context *c) +{ + c->next = first; + first = c; } -// a set of constants for efficient filling of byte enables -template<class D> class tlm_bool { +// A set of constants for efficient filling of byte enables. +template <class D> +class tlm_bool +{ public: static D TLM_TRUE; static D TLM_FALSE; - static D make_uchar_array(uchar c) { - D d; - uchar *tmp = (uchar *)(&d); - for(ptrdiff_t i=0; i!=sizeof(D); i++) tmp[i] = c; // 64BITFIX negligable risk but easy fix // - return d; + static D + make_uchar_array(unsigned char c) + { + D d; + unsigned char *tmp = (unsigned char *)(&d); + for (ptrdiff_t i = 0; i != sizeof(D); i++) + tmp[i] = c; // 64BITFIX negligable risk but easy fix. + return d; } - // also provides an syntax-efficient tester, using a - // copy constuctor and an implicit cast to boolean - tlm_bool(D &d) : b(*((uchar*)&d) != TLM_BYTE_DISABLED) {} - operator bool() const {return b;} + + // Also provides an syntax-efficient tester, using a + // copy constuctor and an implicit cast to boolean. + tlm_bool(D &d) : b(*((unsigned char *)&d) != TLM_BYTE_DISABLED) {} + operator bool() const { return b; } private: bool b; }; -template<class D> D tlm_bool<D>::TLM_TRUE - = tlm_bool<D>::make_uchar_array(TLM_BYTE_ENABLED); -template<class D> D tlm_bool<D>::TLM_FALSE - = tlm_bool<D>::make_uchar_array(TLM_BYTE_DISABLED); - - - -/////////////////////////////////////////////////////////////////////////////// -// function set (0): Utilities -inline void copy_db0(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *dest1 = *src1; - *dest2 = *src2; -} - -inline void copy_dbtrue0(uchar *src1, uchar * /* src2 */, uchar *dest1, uchar *dest2) { - *dest1 = *src1; - *dest2 = TLM_BYTE_ENABLED; -} - -inline void copy_btrue0(uchar * /* src1 */, uchar * /* src2 */, uchar * /* dest1 */, uchar *dest2) { - *dest2 = TLM_BYTE_ENABLED; -} - -inline void copy_b0(uchar * /* src1 */, uchar *src2, uchar * /* dest1 */, uchar *dest2) { - *dest2 = *src2; -} - -inline void copy_dbyb0(uchar *src1, uchar * /* src2 */, uchar *dest1, uchar *dest2) { - if(*dest2 == TLM_BYTE_ENABLED) *src1 = *dest1; -} - - -template<class D, - void COPY(uchar *he_d, uchar *he_b, uchar *ie_d, uchar *ie_b)> -inline void loop_generic0(int new_len, int new_stream_width, - int orig_stream_width, int sizeof_databus, - sc_dt::uint64 orig_start_address, sc_dt::uint64 new_start_address, int be_length, - uchar *ie_data, uchar *ie_be, uchar *he_data, uchar *he_be) { - - for(int orig_sword = 0, new_sword = 0; new_sword < new_len; - new_sword += new_stream_width, orig_sword += orig_stream_width) { - - sc_dt::uint64 ie_addr = orig_start_address; - for(int orig_dword = orig_sword; - orig_dword < orig_sword + orig_stream_width; orig_dword += sizeof(D)) { - - for(int curr_byte = orig_dword + sizeof(D) - 1; - curr_byte >= orig_dword; curr_byte--) { - - ptrdiff_t he_index = ((ie_addr++) ^ (sizeof_databus - 1)) - - new_start_address + new_sword; // 64BITFIX // - COPY(ie_data+curr_byte, - ie_be+(curr_byte % be_length), // 64BITRISK no risk of overflow, always positive // - he_data+he_index, he_be+he_index); - } +template<class D> +D tlm_bool<D>::TLM_TRUE = tlm_bool<D>::make_uchar_array(TLM_BYTE_ENABLED); +template<class D> +D tlm_bool<D>::TLM_FALSE = tlm_bool<D>::make_uchar_array(TLM_BYTE_DISABLED); + + + +inline void +copy_db0(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *dest1 = *src1; + *dest2 = *src2; +} + +inline void +copy_dbtrue0(unsigned char *src1, unsigned char * /* src2 */, + unsigned char *dest1, unsigned char *dest2) +{ + *dest1 = *src1; + *dest2 = TLM_BYTE_ENABLED; +} + +inline void +copy_btrue0(unsigned char * /* src1 */, unsigned char * /* src2 */, + unsigned char * /* dest1 */, unsigned char *dest2) +{ + *dest2 = TLM_BYTE_ENABLED; +} + +inline void +copy_b0(unsigned char * /* src1 */, unsigned char *src2, + unsigned char * /* dest1 */, unsigned char *dest2) +{ + *dest2 = *src2; +} + +inline void +copy_dbyb0(unsigned char *src1, unsigned char * /* src2 */, + unsigned char *dest1, unsigned char *dest2) +{ + if (*dest2 == TLM_BYTE_ENABLED) + *src1 = *dest1; +} + + +template <class D, + void COPY(unsigned char *he_d, unsigned char *he_b, + unsigned char *ie_d, unsigned char *ie_b)> +inline void +loop_generic0(int new_len, int new_stream_width, int orig_stream_width, + int sizeof_databus, sc_dt::uint64 orig_start_address, + sc_dt::uint64 new_start_address, int be_length, + unsigned char *ie_data, unsigned char *ie_be, + unsigned char *he_data, unsigned char *he_be) +{ + for (int orig_sword = 0, new_sword = 0; new_sword < new_len; + new_sword += new_stream_width, orig_sword += orig_stream_width) { + sc_dt::uint64 ie_addr = orig_start_address; + for (int orig_dword = orig_sword; + orig_dword < orig_sword + orig_stream_width; + orig_dword += sizeof(D)) { + for (int curr_byte = orig_dword + sizeof(D) - 1; + curr_byte >= orig_dword; curr_byte--) { + ptrdiff_t he_index = ((ie_addr++) ^ (sizeof_databus - 1)) - + new_start_address + new_sword; // 64BITFIX + COPY(ie_data + curr_byte, + // 64BITRISK no risk of overflow, always positive. + ie_be + (curr_byte % be_length), + he_data + he_index, he_be + he_index); + } + } } - } } /////////////////////////////////////////////////////////////////////////////// // function set (0): Response -template<class DATAWORD> inline void -tlm_from_hostendian_generic(tlm_generic_payload *txn, unsigned int sizeof_databus) { - if(txn->is_read()) { - tlm_endian_context *tc = txn->template get_extension<tlm_endian_context>(); - loop_generic0<DATAWORD, ©_dbyb0>(txn->get_data_length(), - txn->get_streaming_width(), tc->stream_width, sizeof_databus, tc->address, - tc->new_address, txn->get_data_length(), tc->data_ptr, 0, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); - } +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_from_hostendian_generic(tlm_generic_payload *txn, + unsigned int sizeof_databus) +{ + if (txn->is_read()) { + tlm_endian_context *tc = + txn->template get_extension<tlm_endian_context>(); + loop_generic0<DATAWORD, ©_dbyb0>(txn->get_data_length(), + txn->get_streaming_width(), tc->stream_width, sizeof_databus, + tc->address, tc->new_address, txn->get_data_length(), + tc->data_ptr, 0, txn->get_data_ptr(), + txn->get_byte_enable_ptr()); + } } /////////////////////////////////////////////////////////////////////////////// // function set (0): Request -template<class DATAWORD> inline void -tlm_to_hostendian_generic(tlm_generic_payload *txn, unsigned int sizeof_databus) { - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_generic<DATAWORD>); - tc->sizeof_databus = sizeof_databus; - - // calculate new size: nr stream words multiplied by big enough stream width - int s_width = txn->get_streaming_width(); - int length = txn->get_data_length(); - if(s_width >= length) s_width = length; - int nr_stream_words = length/s_width; - - // find out in which bus word the stream word starts and ends - sc_dt::uint64 new_address = (txn->get_address() & ~(sizeof_databus - 1)); - sc_dt::uint64 end_address = ((txn->get_address() + s_width - 1) - & ~(sizeof_databus - 1)); - - int new_stream_width = end_address - new_address + sizeof_databus; - int new_length = new_stream_width * nr_stream_words; - - // store context - tc->data_ptr = txn->get_data_ptr(); - tc->address = txn->get_address(); - tc->new_address = new_address; - tc->stream_width = s_width; - uchar *orig_be = txn->get_byte_enable_ptr(); - int orig_be_length = txn->get_byte_enable_length(); - - // create data and byte-enable buffers - txn->set_address(new_address); - tc->establish_dbuf(new_length); - txn->set_data_ptr(tc->new_dbuf); - tc->establish_bebuf(new_length); - txn->set_byte_enable_ptr(tc->new_bebuf); - std::memset(txn->get_byte_enable_ptr(), TLM_BYTE_DISABLED, new_length); - txn->set_streaming_width(new_stream_width); - txn->set_data_length(new_length); - txn->set_byte_enable_length(new_length); - - // copy data and/or byte enables - if(txn->is_write()) { - if(orig_be == 0) { - loop_generic0<DATAWORD, ©_dbtrue0>(new_length, - new_stream_width, s_width, sizeof_databus, tc->address, - new_address, new_length, tc->data_ptr, 0, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); - } else { - loop_generic0<DATAWORD, ©_db0>(new_length, - new_stream_width, s_width, sizeof_databus, tc->address, - new_address, orig_be_length, tc->data_ptr, orig_be, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); - } - } else { // read transaction - if(orig_be == 0) { - loop_generic0<DATAWORD, ©_btrue0>(new_length, - new_stream_width, s_width, sizeof_databus, tc->address, - new_address, new_length, tc->data_ptr, 0, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); +template <class DATAWORD> +inline void +tlm_to_hostendian_generic(tlm_generic_payload *txn, + unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_generic<DATAWORD>); + tc->sizeof_databus = sizeof_databus; + + // Calculate new size: nr stream words multiplied by big enough stream + // width. + int s_width = txn->get_streaming_width(); + int length = txn->get_data_length(); + if (s_width >= length) + s_width = length; + int nr_stream_words = length / s_width; + + // Find out in which bus word the stream word starts and ends. + sc_dt::uint64 new_address = (txn->get_address() & ~(sizeof_databus - 1)); + sc_dt::uint64 end_address = ((txn->get_address() + s_width - 1) & + ~(sizeof_databus - 1)); + + int new_stream_width = end_address - new_address + sizeof_databus; + int new_length = new_stream_width * nr_stream_words; + + // Store context. + tc->data_ptr = txn->get_data_ptr(); + tc->address = txn->get_address(); + tc->new_address = new_address; + tc->stream_width = s_width; + unsigned char *orig_be = txn->get_byte_enable_ptr(); + int orig_be_length = txn->get_byte_enable_length(); + + // Create data and byte-enable buffers. + txn->set_address(new_address); + tc->establish_dbuf(new_length); + txn->set_data_ptr(tc->new_dbuf); + tc->establish_bebuf(new_length); + txn->set_byte_enable_ptr(tc->new_bebuf); + std::memset(txn->get_byte_enable_ptr(), TLM_BYTE_DISABLED, new_length); + txn->set_streaming_width(new_stream_width); + txn->set_data_length(new_length); + txn->set_byte_enable_length(new_length); + + // Copy data and/or byte enables. + if (txn->is_write()) { + if (orig_be == 0) { + loop_generic0<DATAWORD, ©_dbtrue0>( + new_length, new_stream_width, s_width, sizeof_databus, + tc->address, new_address, new_length, tc->data_ptr, 0, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } else { + loop_generic0<DATAWORD, ©_db0>(new_length, new_stream_width, + s_width, sizeof_databus, tc->address, new_address, + orig_be_length, tc->data_ptr, orig_be, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } } else { - loop_generic0<DATAWORD, ©_b0>(new_length, - new_stream_width, s_width, sizeof_databus, tc->address, - new_address, orig_be_length, tc->data_ptr, orig_be, txn->get_data_ptr(), - txn->get_byte_enable_ptr()); + // Read transaction. + if (orig_be == 0) { + loop_generic0<DATAWORD, ©_btrue0>(new_length, + new_stream_width, s_width, sizeof_databus, tc->address, + new_address, new_length, tc->data_ptr, 0, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } else { + loop_generic0<DATAWORD, ©_b0>(new_length, new_stream_width, + s_width, sizeof_databus, tc->address, new_address, + orig_be_length, tc->data_ptr, orig_be, + txn->get_data_ptr(), txn->get_byte_enable_ptr()); + } } - } } - /////////////////////////////////////////////////////////////////////////////// // function set (1): Utilities -template<class D> -inline void copy_d1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *((D *)dest1) = *((D *)src1); - *((D *)dest2) = tlm_bool<D>::TLM_TRUE; -} +/////////////////////////////////////////////////////////////////////////////// -template<class D> -inline void copy_db1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *((D *)dest1) = *((D *)src1); - *((D *)dest2) = *((D *)src2); +template <class D> +inline void +copy_d1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest1) = *((D *)src1); + *((D *)dest2) = tlm_bool<D>::TLM_TRUE; } -template<class D> -inline void true_b1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *((D *)dest2) = tlm_bool<D>::TLM_TRUE; +template <class D> +inline void +copy_db1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest1) = *((D *)src1); + *((D *)dest2) = *((D *)src2); } -template<class D> -inline void copy_b1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *((D *)dest2) = *((D *)src2); +template <class D> +inline void +true_b1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest2) = tlm_bool<D>::TLM_TRUE; } -template<class D> -inline void copy_dbyb1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - if(*src2 != TLM_BYTE_DISABLED) *((D *)src1) = *((D *)dest1); +template <class D> +inline void +copy_b1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)dest2) = *((D *)src2); } -template<class D> -inline void copy_dbytrue1(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2) { - *((D *)src1) = *((D *)dest1); +template <class D> +inline void +copy_dbyb1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + if (*src2 != TLM_BYTE_DISABLED) + *((D *)src1) = *((D *)dest1); } -template<class D> inline void false_b1(uchar *dest1) { - *((D *)dest1) = tlm_bool<D>::TLM_FALSE; +template <class D> +inline void +copy_dbytrue1(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2) +{ + *((D *)src1) = *((D *)dest1); } -template<class D> inline void no_b1(uchar *dest1) { +template<class D> +inline void +false_b1(unsigned char *dest1) +{ + *((D *)dest1) = tlm_bool<D>::TLM_FALSE; } -template<class D, - void COPY(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2), - void COPYuchar(uchar *src1, uchar *src2, uchar *dest1, uchar *dest2), - void FILLFALSE(uchar *dest1), void FILLFALSEuchar(uchar *dest1)> -inline int loop_word1( - int bytes_left, int len0, int lenN, int sizeof_databus, - uchar *start, uchar *end, uchar *src, uchar *bsrc, uchar *dest, uchar *bdest) { - ptrdiff_t d2b_src = bsrc - src; // 64BITFIX was int // - ptrdiff_t d2b_dest = bdest - dest; // 64BITFIX was int // - uchar *original_dest = dest; - - while(true) { - // len0 bytes at start of a bus word - if((src >= start) && (src < end)) { - for(int i=0; i<len0; i++) { - COPYuchar(src, src+d2b_src, dest, dest+d2b_dest); - src++; - dest++; - } - bytes_left -= len0; - if(bytes_left <= 0) return int(dest - original_dest); - } else { - for(int i=0; i<len0; i++) { - FILLFALSEuchar(dest+d2b_dest); - src++; - dest++; - } - } - src -= 2 * sizeof(D); - - // sequence of full data word fragments - for(unsigned int i=1; i<sizeof_databus/sizeof(D); i++) { - if((src >= start) && (src < end)) { - COPY(src, src+d2b_src, dest, dest+d2b_dest); - bytes_left -= sizeof(D); - } else { - FILLFALSE(dest+d2b_dest); - } - dest += sizeof(D); - if(bytes_left <= 0) return int(dest - original_dest); - src -= sizeof(D); - } +template<class D> +inline void +no_b1(unsigned char *dest1) +{} - // lenN bytes at end of bus word - if((src >= start) && (src < end)) { - for(int i=0; i<lenN; i++) { - COPYuchar(src, src+d2b_src, dest, dest+d2b_dest); - src++; - dest++; - } - bytes_left -= lenN; - if(bytes_left <= 0) return int(dest - original_dest); - } else { - for(int i=0; i<lenN; i++) { - FILLFALSEuchar(dest+d2b_dest); - src++; - dest++; - } +template<class D, + void COPY(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2), + void COPYuchar(unsigned char *src1, unsigned char *src2, + unsigned char *dest1, unsigned char *dest2), + void FILLFALSE(unsigned char *dest1), + void FILLFALSEuchar(unsigned char *dest1)> +inline int +loop_word1(int bytes_left, int len0, int lenN, int sizeof_databus, + unsigned char *start, unsigned char *end, + unsigned char *src, unsigned char *bsrc, + unsigned char *dest, unsigned char *bdest) +{ + ptrdiff_t d2b_src = bsrc - src; // 64BITFIX was int + ptrdiff_t d2b_dest = bdest - dest; // 64BITFIX was int + unsigned char *original_dest = dest; + + while (true) { + // len0 bytes at start of a bus word. + if ((src >= start) && (src < end)) { + for (int i = 0; i < len0; i++) { + COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); + src++; + dest++; + } + bytes_left -= len0; + if (bytes_left <= 0) + return int(dest - original_dest); + } else { + for (int i = 0; i < len0; i++) { + FILLFALSEuchar(dest + d2b_dest); + src++; + dest++; + } + } + src -= 2 * sizeof(D); + + // Sequence of full data word fragments. + for (unsigned int i = 1; i < sizeof_databus / sizeof(D); i++) { + if ((src >= start) && (src < end)) { + COPY(src, src + d2b_src, dest, dest + d2b_dest); + bytes_left -= sizeof(D); + } else { + FILLFALSE(dest + d2b_dest); + } + dest += sizeof(D); + if (bytes_left <= 0) + return int(dest - original_dest); + src -= sizeof(D); + } + + // lenN bytes at end of bus word. + if ((src >= start) && (src < end)) { + for (int i = 0; i < lenN; i++) { + COPYuchar(src, src + d2b_src, dest, dest + d2b_dest); + src++; + dest++; + } + bytes_left -= lenN; + if (bytes_left <= 0) + return int(dest - original_dest); + } else { + for (int i = 0; i < lenN; i++) { + FILLFALSEuchar(dest + d2b_dest); + src++; + dest++; + } + } + src += 2 * sizeof_databus; } - src += 2 * sizeof_databus; - } } /////////////////////////////////////////////////////////////////////////////// // function set (1): Response -template<class DATAWORD> inline void -tlm_from_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) { - if(txn->is_read()) { - tlm_endian_context *tc = txn->template get_extension<tlm_endian_context>(); - sc_dt::uint64 b_mask = sizeof_databus - 1; - int d_mask = sizeof(DATAWORD) - 1; - int a_offset = static_cast<int>(tc->address & b_mask); - int len0 = (sizeof_databus - a_offset) & d_mask; - int lenN = sizeof(DATAWORD) - len0; - uchar *d_start = tc->data_ptr; - uchar *d_end = ptrdiff_t(tc->length) + d_start; // 64BITFIX probably redundant // - uchar *d = ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + d_start; // 64BITFIX probably redundant // - - // iterate over transaction copying data qualified by byte-enables - if(tc->byte_enable == 0) { - loop_word1<DATAWORD, ©_dbytrue1<DATAWORD>, - ©_dbytrue1<uchar>, &no_b1<DATAWORD>, &no_b1<uchar> >( - tc->length, len0, lenN, sizeof_databus, d_start, d_end, d, - 0, txn->get_data_ptr(), 0); - } else { - loop_word1<DATAWORD, ©_dbyb1<DATAWORD>, - ©_dbyb1<uchar>, &no_b1<DATAWORD>, &no_b1<uchar> >( - tc->length, len0, lenN, sizeof_databus, d_start, d_end, d, - tc->byte_enable - d_start + d, txn->get_data_ptr(), 0); +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_from_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + if (txn->is_read()) { + tlm_endian_context *tc = + txn->template get_extension<tlm_endian_context>(); + sc_dt::uint64 b_mask = sizeof_databus - 1; + int d_mask = sizeof(DATAWORD) - 1; + int a_offset = static_cast<int>(tc->address & b_mask); + int len0 = (sizeof_databus - a_offset) & d_mask; + int lenN = sizeof(DATAWORD) - len0; + unsigned char *d_start = tc->data_ptr; + unsigned char *d_end = + ptrdiff_t(tc->length) + d_start; // 64BITFIX probably redundant + unsigned char *d = + ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + + d_start; // 64BITFIX probably redundant + + // Iterate over transaction copying data qualified by byte-enables. + if (tc->byte_enable == 0) { + loop_word1<DATAWORD, ©_dbytrue1<DATAWORD>, + ©_dbytrue1<unsigned char>, &no_b1<DATAWORD>, + &no_b1<unsigned char>>( + tc->length, len0, lenN, sizeof_databus, + d_start, d_end, d, 0, txn->get_data_ptr(), 0); + } else { + loop_word1<DATAWORD, ©_dbyb1<DATAWORD>, + ©_dbyb1<unsigned char>, &no_b1<DATAWORD>, + &no_b1<unsigned char>>( + tc->length, len0, lenN, sizeof_databus, + d_start, d_end, d, + tc->byte_enable - d_start + d, + txn->get_data_ptr(), 0); + } } - } } /////////////////////////////////////////////////////////////////////////////// // function set (1): Request -template<class DATAWORD> inline void -tlm_to_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) { - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_word<DATAWORD>); - tc->sizeof_databus = sizeof_databus; - - sc_dt::uint64 b_mask = sizeof_databus - 1; - int d_mask = sizeof(DATAWORD) - 1; - sc_dt::uint64 a_aligned = txn->get_address() & ~b_mask; - int a_offset = static_cast<int>(txn->get_address() & b_mask); - int len0 = (sizeof_databus - a_offset) & d_mask; - int lenN = sizeof(DATAWORD) - len0; - uchar *d_start = txn->get_data_ptr(); - uchar *d_end = ptrdiff_t(txn->get_data_length()) + d_start; // 64BITFIX probably redundant // - uchar *d = ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + d_start; // 64BITFIX probably redundant // - - // create new data and byte enable buffers - int long_enough = txn->get_data_length() + 2 * sizeof_databus; - tc->establish_dbuf(long_enough); - uchar *new_data = tc->new_dbuf; - tc->establish_bebuf(long_enough); - uchar *new_be = tc->new_bebuf; - - if(txn->is_read()) { - tc->data_ptr = d_start; - tc->address = txn->get_address(); - tc->byte_enable = txn->get_byte_enable_ptr(); - tc->length = txn->get_data_length(); - if(txn->get_byte_enable_ptr() == 0) { - // iterate over transaction creating new byte enables from all-true - txn->set_data_length(loop_word1<DATAWORD, &true_b1<DATAWORD>, - &true_b1<uchar>, &false_b1<DATAWORD>, &false_b1<uchar> >( - txn->get_data_length(), len0, lenN, sizeof_databus, - d_start, d_end, d, 0, new_data, new_be)); - } else { - // iterate over transaction copying byte enables - txn->set_data_length(loop_word1<DATAWORD, ©_b1<DATAWORD>, - ©_b1<uchar>, &false_b1<DATAWORD>, &false_b1<uchar> >( - txn->get_data_length(), len0, lenN, sizeof_databus, d_start, d_end, - d, txn->get_byte_enable_ptr() - d_start + d, new_data, new_be)); - } - } else { - // WRITE - if(txn->get_byte_enable_ptr() == 0) { - // iterate over transaction copying data and creating new byte-enables - txn->set_data_length(loop_word1<DATAWORD, ©_d1<DATAWORD>, - ©_d1<uchar>, &false_b1<DATAWORD>, &false_b1<uchar> >( - txn->get_data_length(), len0, lenN, sizeof_databus, - d_start, d_end, d, 0, new_data, new_be)); +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_to_hostendian_word(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_word<DATAWORD>); + tc->sizeof_databus = sizeof_databus; + + sc_dt::uint64 b_mask = sizeof_databus - 1; + int d_mask = sizeof(DATAWORD) - 1; + sc_dt::uint64 a_aligned = txn->get_address() & ~b_mask; + int a_offset = static_cast<int>(txn->get_address() & b_mask); + int len0 = (sizeof_databus - a_offset) & d_mask; + int lenN = sizeof(DATAWORD) - len0; + unsigned char *d_start = txn->get_data_ptr(); + unsigned char *d_end = + ptrdiff_t(txn->get_data_length()) + d_start; + // 64BITFIX probably redundant. + unsigned char *d = + ptrdiff_t(((sizeof_databus - a_offset) & ~d_mask) + lenN) + d_start; + // 64BITFIX probably redundant. + + // Create new data and byte enable buffers. + int long_enough = txn->get_data_length() + 2 * sizeof_databus; + tc->establish_dbuf(long_enough); + unsigned char *new_data = tc->new_dbuf; + tc->establish_bebuf(long_enough); + unsigned char *new_be = tc->new_bebuf; + + if (txn->is_read()) { + tc->data_ptr = d_start; + tc->address = txn->get_address(); + tc->byte_enable = txn->get_byte_enable_ptr(); + tc->length = txn->get_data_length(); + if (txn->get_byte_enable_ptr() == 0) { + // Iterate over transaction creating new byte enables from all-true + txn->set_data_length( + loop_word1<DATAWORD, &true_b1<DATAWORD>, + &true_b1<unsigned char>, &false_b1<DATAWORD>, + &false_b1<unsigned char>>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, 0, + new_data, new_be)); + } else { + // iterate over transaction copying byte enables + txn->set_data_length( + loop_word1<DATAWORD, ©_b1<DATAWORD>, + ©_b1<unsigned char>, &false_b1<DATAWORD>, + &false_b1<unsigned char>>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, + txn->get_byte_enable_ptr() - d_start + d, + new_data, new_be)); + } } else { - // iterate over transaction copying data and byte-enables - txn->set_data_length(loop_word1<DATAWORD, ©_db1<DATAWORD>, - ©_db1<uchar>, &false_b1<DATAWORD>, &false_b1<uchar> >( - txn->get_data_length(), len0, lenN, sizeof_databus, d_start, d_end, - d, txn->get_byte_enable_ptr() - d_start + d, new_data, new_be)); + // WRITE + if (txn->get_byte_enable_ptr() == 0) { + // Iterate over transaction copying data and creating new + // byte-enables. + txn->set_data_length( + loop_word1<DATAWORD, ©_d1<DATAWORD>, + ©_d1<unsigned char>, &false_b1<DATAWORD>, + &false_b1<unsigned char>>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, 0, + new_data, new_be)); + } else { + // Iterate over transaction copying data and byte-enables. + txn->set_data_length( + loop_word1<DATAWORD, ©_db1<DATAWORD>, + ©_db1<unsigned char>, &false_b1<DATAWORD>, + &false_b1<unsigned char>>( + txn->get_data_length(), len0, lenN, + sizeof_databus, d_start, d_end, d, + txn->get_byte_enable_ptr() - d_start + d, + new_data, new_be)); + } } - } - txn->set_byte_enable_length(txn->get_data_length()); - txn->set_streaming_width(txn->get_data_length()); - txn->set_data_ptr(new_data); - txn->set_byte_enable_ptr(new_be); - txn->set_address(a_aligned); + txn->set_byte_enable_length(txn->get_data_length()); + txn->set_streaming_width(txn->get_data_length()); + txn->set_data_ptr(new_data); + txn->set_byte_enable_ptr(new_be); + txn->set_address(a_aligned); } /////////////////////////////////////////////////////////////////////////////// // function set (2): Utilities -template<class D> inline void copy_d2(D *src1, D *src2, D *dest1, D *dest2) { - *dest1 = *src1; -} - -template<class D> inline void copy_db2(D *src1, D *src2, D *dest1, D *dest2) { - *dest1 = *src1; - *dest2 = *src2; -} - -template<class D> -inline void copy_dbyb2(D *src1, D *src2, D *dest1, D *dest2) { - if(tlm_bool<D>(*src2)) *dest1 = *src1; -} +/////////////////////////////////////////////////////////////////////////////// -template<class D, void COPY(D *src1, D *src2, D *dest1, D *dest2)> -inline void loop_aligned2(D *src1, D *src2, D *dest1, D *dest2, - int words, int words_per_bus) { - ptrdiff_t src1to2 = (char *)src2 - (char *)src1; // 64BITFIX was int and operands were cast to int // - ptrdiff_t dest1to2 = (char *)dest2 - (char *)dest1; // 64BITFIX was int and operands were cast to int // - - D *done = src1 + ptrdiff_t(words); // 64BITFIX // - D *bus_start = src1; - src1 += ptrdiff_t(words_per_bus - 1); // 64BITFIX // - - while(true) { - COPY(src1, (D *)(src1to2+(char *)src1), dest1, (D *)(dest1to2+(char *)dest1)); // 64BITFIX // - dest1++; - if((--src1) < bus_start) { - bus_start += ptrdiff_t(words_per_bus); // 64BITFIX // - if(bus_start == done) break; - src1 = bus_start + ptrdiff_t(words_per_bus - 1); // 64BITFIX // +template <class D> +inline void copy_d2(D *src1, D *src2, D *dest1, D *dest2) { *dest1 = *src1; } + +template <class D> +inline void +copy_db2(D *src1, D *src2, D *dest1, D *dest2) +{ + *dest1 = *src1; + *dest2 = *src2; +} + +template <class D> +inline void +copy_dbyb2(D *src1, D *src2, D *dest1, D *dest2) +{ + if (tlm_bool<D>(*src2)) + *dest1 = *src1; +} + +template <class D, void COPY(D *src1, D *src2, D *dest1, D *dest2)> +inline void +loop_aligned2(D *src1, D *src2, D *dest1, D *dest2, int words, + int words_per_bus) +{ + // 64BITFIX was int and operands were cast to int. + ptrdiff_t src1to2 = (char *)src2 - (char *)src1; + // 64BITFIX was int and operands were cast to int. + ptrdiff_t dest1to2 = (char *)dest2 - (char *)dest1; + + D *done = src1 + ptrdiff_t(words); // 64BITFIX. + D *bus_start = src1; + src1 += ptrdiff_t(words_per_bus - 1); // 64BITFIX. + + while (true) { + COPY(src1, (D *)(src1to2 + (char *)src1), dest1, + (D *)(dest1to2 + (char *)dest1)); // 64BITFIX. + dest1++; + if ((--src1) < bus_start) { + bus_start += ptrdiff_t(words_per_bus); // 64BITFIX. + if (bus_start == done) + break; + src1 = bus_start + ptrdiff_t(words_per_bus - 1); // 64BITFIX. + } } - } } /////////////////////////////////////////////////////////////////////////////// // function set (2): Response -template<class DATAWORD> inline void -tlm_from_hostendian_aligned(tlm_generic_payload *txn, unsigned int sizeof_databus) { - int words_per_bus = sizeof_databus/sizeof(DATAWORD); - if(words_per_bus == 1) return; - int words = (txn->get_data_length())/sizeof(DATAWORD); - tlm_endian_context *tc = txn->template get_extension<tlm_endian_context>(); - - if(txn->get_byte_enable_ptr() == 0) { - // no byte enables - if(txn->is_read()) { - // RD without byte enables. Copy data to original buffer - loop_aligned2<DATAWORD, ©_d2<DATAWORD> >( - (DATAWORD *)(txn->get_data_ptr()), - 0, (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); - } - } else { - // byte enables present - if(txn->is_read()) { - // RD with byte enables. Copy data qualified by byte-enables - loop_aligned2<DATAWORD, ©_dbyb2<DATAWORD> >( - (DATAWORD *)(txn->get_data_ptr()), - (DATAWORD *)(txn->get_byte_enable_ptr()), - (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_from_hostendian_aligned( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + int words_per_bus = sizeof_databus / sizeof(DATAWORD); + if (words_per_bus == 1) + return; + int words = (txn->get_data_length()) / sizeof(DATAWORD); + tlm_endian_context *tc = txn->template get_extension<tlm_endian_context>(); + + if (txn->get_byte_enable_ptr() == 0) { + // no byte enables + if (txn->is_read()) { + // RD without byte enables. Copy data to original buffer. + loop_aligned2<DATAWORD, ©_d2<DATAWORD>>( + (DATAWORD *)(txn->get_data_ptr()), 0, + (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); + } + } else { + // byte enables present + if (txn->is_read()) { + // RD with byte enables. Copy data qualified by byte-enables. + loop_aligned2<DATAWORD, ©_dbyb2<DATAWORD>>( + (DATAWORD *)(txn->get_data_ptr()), + (DATAWORD *)(txn->get_byte_enable_ptr()), + (DATAWORD *)(tc->data_ptr), 0, words, words_per_bus); + } } - } } /////////////////////////////////////////////////////////////////////////////// // function set (2): Request -template<class DATAWORD> inline void -tlm_to_hostendian_aligned(tlm_generic_payload *txn, unsigned int sizeof_databus) { - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_aligned<DATAWORD>); - tc->sizeof_databus = sizeof_databus; - - int words_per_bus = sizeof_databus/sizeof(DATAWORD); - if(words_per_bus == 1) return; - int words = (txn->get_data_length())/sizeof(DATAWORD); - - DATAWORD *original_be = (DATAWORD *)(txn->get_byte_enable_ptr()); - DATAWORD *original_data = (DATAWORD *)(txn->get_data_ptr()); - - // always allocate a new data buffer - tc->establish_dbuf(txn->get_data_length()); - txn->set_data_ptr(tc->new_dbuf); - - if(original_be == 0) { - // no byte enables - if(txn->is_write()) { - // WR no byte enables. Copy data - loop_aligned2<DATAWORD, ©_d2<DATAWORD> >(original_data, 0, - (DATAWORD *)(txn->get_data_ptr()), 0, - words, words_per_bus); - } else { - // RD no byte enables. Save original data pointer - tc->data_ptr = (uchar *)original_data; - } - } else { - // byte enables present - // allocate a new buffer for them - tc->establish_bebuf(txn->get_data_length()); - txn->set_byte_enable_ptr(tc->new_bebuf); - txn->set_byte_enable_length(txn->get_data_length()); +/////////////////////////////////////////////////////////////////////////////// - if(txn->is_write()) { - // WR with byte enables. Copy data and BEs - loop_aligned2<DATAWORD, ©_db2<DATAWORD> >(original_data, original_be, - (DATAWORD *)(txn->get_data_ptr()), - (DATAWORD *)(txn->get_byte_enable_ptr()), words, words_per_bus); +template <class DATAWORD> +inline void +tlm_to_hostendian_aligned( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_aligned<DATAWORD>); + tc->sizeof_databus = sizeof_databus; + + int words_per_bus = sizeof_databus / sizeof(DATAWORD); + if (words_per_bus == 1) + return; + int words = (txn->get_data_length()) / sizeof(DATAWORD); + + DATAWORD *original_be = (DATAWORD *)(txn->get_byte_enable_ptr()); + DATAWORD *original_data = (DATAWORD *)(txn->get_data_ptr()); + + // Always allocate a new data buffer. + tc->establish_dbuf(txn->get_data_length()); + txn->set_data_ptr(tc->new_dbuf); + + if (original_be == 0) { + // No byte enables. + if (txn->is_write()) { + // WR no byte enables. Copy data. + loop_aligned2<DATAWORD, ©_d2<DATAWORD>>( + original_data, 0, (DATAWORD *)(txn->get_data_ptr()), 0, + words, words_per_bus); + } else { + // RD no byte enables. Save original data pointer. + tc->data_ptr = (unsigned char *)original_data; + } } else { - // RD with byte enables. Save original data pointer - tc->data_ptr = (uchar *)original_data; - // Copy byte enables to new buffer - loop_aligned2<DATAWORD, ©_d2<DATAWORD> >(original_be, 0, - (DATAWORD *)(txn->get_byte_enable_ptr()), 0, - words, words_per_bus); + // Byte enables present. + // Allocate a new buffer for them. + tc->establish_bebuf(txn->get_data_length()); + txn->set_byte_enable_ptr(tc->new_bebuf); + txn->set_byte_enable_length(txn->get_data_length()); + + if (txn->is_write()) { + // WR with byte enables. Copy data and BEs. + loop_aligned2<DATAWORD, ©_db2<DATAWORD>>( + original_data, original_be, + (DATAWORD *)(txn->get_data_ptr()), + (DATAWORD *)(txn->get_byte_enable_ptr()), + words, words_per_bus); + } else { + // RD with byte enables. Save original data pointer. + tc->data_ptr = (unsigned char *)original_data; + // Copy byte enables to new buffer. + loop_aligned2<DATAWORD, ©_d2<DATAWORD>>( + original_be, 0, (DATAWORD *)(txn->get_byte_enable_ptr()), + 0, words, words_per_bus); + } } - } } /////////////////////////////////////////////////////////////////////////////// // function set (3): Response -template<class DATAWORD> inline void -tlm_from_hostendian_single(tlm_generic_payload *txn, unsigned int sizeof_databus) { - // nothing needs to be done here -} +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_from_hostendian_single( + tlm_generic_payload *txn, unsigned int sizeof_databus) +{} /////////////////////////////////////////////////////////////////////////////// // function set (3): Request -template<class DATAWORD> inline void -tlm_to_hostendian_single(tlm_generic_payload *txn, unsigned int sizeof_databus) { - tlm_endian_context *tc = establish_context(txn); - tc->from_f = &(tlm_from_hostendian_single<DATAWORD>); - tc->sizeof_databus = sizeof_databus; - - // only need to change the address, always safe to work in-place - sc_dt::uint64 mask = sizeof_databus-1; - sc_dt::uint64 a = txn->get_address(); - txn->set_address((a & ~mask) | - (sizeof_databus - (a & mask) - sizeof(DATAWORD))); +/////////////////////////////////////////////////////////////////////////////// + +template <class DATAWORD> +inline void +tlm_to_hostendian_single(tlm_generic_payload *txn, unsigned int sizeof_databus) +{ + tlm_endian_context *tc = establish_context(txn); + tc->from_f = &(tlm_from_hostendian_single<DATAWORD>); + tc->sizeof_databus = sizeof_databus; + + // Only need to change the address, always safe to work in-place. + sc_dt::uint64 mask = sizeof_databus - 1; + sc_dt::uint64 a = txn->get_address(); + txn->set_address((a & ~mask) | + (sizeof_databus - (a & mask) - sizeof(DATAWORD))); } /////////////////////////////////////////////////////////////////////////////// // helper function which works for all responses -inline void tlm_from_hostendian(tlm_generic_payload *txn) { - tlm_endian_context *tc = txn->get_extension<tlm_endian_context>(); - (*(tc->from_f))(txn, tc->sizeof_databus); -} - +/////////////////////////////////////////////////////////////////////////////// -#ifndef TLM_END_CONV_DONT_UNDEF_UCHAR -#undef uchar -#endif +inline void +tlm_from_hostendian(tlm_generic_payload *txn) +{ + tlm_endian_context *tc = txn->get_extension<tlm_endian_context>(); + (*(tc->from_f))(txn, tc->sizeof_databus); +} } // namespace tlm - -#endif // multiple-inclusion protection - +#endif +/* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_ENDIAN_CONV_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h index 3e25e56f2..c3b6b6bb0 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_generic_payload.h @@ -17,13 +17,12 @@ *****************************************************************************/ -#ifndef __TLM_GENERIC_PAYLOAD_H__ -#define __TLM_GENERIC_PAYLOAD_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ +#include "tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h" +#include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h" #include "tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h" #include "tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h" -#include "tlm_core/tlm_2/tlm_generic_payload/tlm_endian_conv.h" - -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_TLM_GENERIC_PAYLOAD_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h index 99bb1e969..0204aed76 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h @@ -17,51 +17,43 @@ *****************************************************************************/ -// 12-Jan-2009 John Aynsley Bug fix. has_mm() and get_ref_count() should both be const -// 23-Mar-2009 John Aynsley Add method update_original_from() -// 20-Apr-2009 John Aynsley Bug fix for 64-bit machines: unsigned long int -> unsigned int -// 5-May-2011 JA and Philipp Hartmann Add tlm_gp_option, set_gp_option, get_gp_option -// 11-May-2011 John Aynsley Add run-time check to release() +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ - -#ifndef TLM_CORE_TLM2_TLM_GP_H_INCLUDED_ -#define TLM_CORE_TLM2_TLM_GP_H_INCLUDED_ - -#include "sysc/kernel/sc_cmnhdr.h" // SC_API -#include "sysc/utils/sc_report.h" // sc_assert -#include "sysc/datatypes/int/sc_nbdefs.h" // sc_dt::uint64 +#include <systemc> +#include <typeinfo> // std::type_info #include "tlm_core/tlm_2/tlm_generic_payload/tlm_array.h" -#include <typeinfo> // std::type_info - -namespace tlm { +namespace tlm +{ class tlm_generic_payload; -class tlm_mm_interface { -public: - virtual void free(tlm_generic_payload*) = 0; - virtual ~tlm_mm_interface() {} +class tlm_mm_interface +{ + public: + virtual void free(tlm_generic_payload *) = 0; + virtual ~tlm_mm_interface() {} }; //--------------------------------------------------------------------------- // Classes and helpers for the extension mechanism //--------------------------------------------------------------------------- // Helper function: -SC_API unsigned int max_num_extensions(); +unsigned int max_num_extensions(); // This class can be used for storing pointers to the extension classes, used // in tlm_generic_payload: -class SC_API tlm_extension_base +class tlm_extension_base { -public: - virtual tlm_extension_base* clone() const = 0; + public: + virtual tlm_extension_base *clone() const = 0; virtual void free() { delete this; } virtual void copy_from(tlm_extension_base const &) = 0; -protected: + protected: virtual ~tlm_extension_base() {} - static unsigned int register_extension(const std::type_info&); + static unsigned int register_extension(const std::type_info &); }; // Base class for all extension classes, derive your extension class in @@ -73,27 +65,29 @@ protected: template <typename T> class tlm_extension : public tlm_extension_base { -public: - virtual tlm_extension_base* clone() const = 0; + public: + virtual tlm_extension_base *clone() const = 0; virtual void copy_from(tlm_extension_base const &ext) = 0; virtual ~tlm_extension() {} const static unsigned int ID; }; template <typename T> -const unsigned int tlm_extension<T>::ID - = tlm_extension_base::register_extension(typeid(T)); +const unsigned int tlm_extension<T>::ID = + tlm_extension_base::register_extension(typeid(T)); //--------------------------------------------------------------------------- // enumeration types //--------------------------------------------------------------------------- -enum tlm_command { +enum tlm_command +{ TLM_READ_COMMAND, TLM_WRITE_COMMAND, TLM_IGNORE_COMMAND }; -enum tlm_response_status { +enum tlm_response_status +{ TLM_OK_RESPONSE = 1, TLM_INCOMPLETE_RESPONSE = 0, TLM_GENERIC_ERROR_RESPONSE = -1, @@ -103,7 +97,8 @@ enum tlm_response_status { TLM_BYTE_ENABLE_ERROR_RESPONSE = -5 }; -enum tlm_gp_option { +enum tlm_gp_option +{ TLM_MIN_PAYLOAD, TLM_FULL_PAYLOAD, TLM_FULL_PAYLOAD_ACCEPTED @@ -116,115 +111,146 @@ enum tlm_gp_option { // The generic payload class: //--------------------------------------------------------------------------- -SC_API_TEMPLATE_DECL_ tlm_array<tlm_extension_base*>; - -class SC_API tlm_generic_payload { - -public: - //--------------- - // Constructors - //--------------- +extern template class tlm_array<tlm_extension_base *>; - // Default constructor +class tlm_generic_payload +{ + public: tlm_generic_payload(); - explicit tlm_generic_payload(tlm_mm_interface* mm); + explicit tlm_generic_payload(tlm_mm_interface *mm); - void acquire() { sc_assert(m_mm != 0); m_ref_count++; } + void + acquire() + { + sc_assert(m_mm != 0); + m_ref_count++; + } - void release() { + void + release() + { sc_assert(m_mm != 0 && m_ref_count > 0); - if (--m_ref_count==0) + if (--m_ref_count == 0) m_mm->free(this); } int get_ref_count() const { return m_ref_count; } - void set_mm(tlm_mm_interface* mm) { m_mm = mm; } + void set_mm(tlm_mm_interface *mm) { m_mm = mm; } bool has_mm() const { return m_mm != 0; } void reset(); -private: - //disabled copy ctor and assignment operator. - tlm_generic_payload(const tlm_generic_payload& x) /* = delete */; - tlm_generic_payload& operator= (const tlm_generic_payload& x) /* = delete */; + private: + // Disabled copy ctor and assignment operator. + tlm_generic_payload(const tlm_generic_payload &x); + tlm_generic_payload &operator = (const tlm_generic_payload &x); -public: - // non-virtual deep-copying of the object - void deep_copy_from(const tlm_generic_payload & other); + public: + // Non-virtual deep-copying of the object. + void deep_copy_from(const tlm_generic_payload &other); - // 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 + // 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_generic_payload & other, - bool use_byte_enable_on_read = true); + void update_original_from(const tlm_generic_payload &other, + bool use_byte_enable_on_read=true); - void update_extensions_from(const tlm_generic_payload & other); + void update_extensions_from(const tlm_generic_payload &other); - // 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. + // 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(); - //-------------- - // Destructor - //-------------- virtual ~tlm_generic_payload(); //---------------- - // API (including setters & getters) + // API (including setters & getters). //--------------- - // Command related method - bool is_read() const {return (m_command == TLM_READ_COMMAND);} - void set_read() {m_command = TLM_READ_COMMAND;} - bool is_write() const {return (m_command == TLM_WRITE_COMMAND);} - void set_write() {m_command = TLM_WRITE_COMMAND;} - tlm_command get_command() const {return m_command;} - void set_command(const tlm_command command) {m_command = command;} - - // Address related methods - sc_dt::uint64 get_address() const {return m_address;} - void set_address(const sc_dt::uint64 address) {m_address = address;} - - // Data related methods - unsigned char* get_data_ptr() const {return m_data;} - void set_data_ptr(unsigned char* data) {m_data = data;} - - // Transaction length (in bytes) related methods - unsigned int get_data_length() const {return m_length;} - void set_data_length(const unsigned int length) {m_length = length;} - - // Response status related methods - bool is_response_ok() const {return (m_response_status > 0);} - bool is_response_error() const {return (m_response_status <= 0);} - tlm_response_status get_response_status() const {return m_response_status;} - void set_response_status(const tlm_response_status response_status) - {m_response_status = response_status;} - std::string get_response_string() const; - - // Streaming related methods - unsigned int get_streaming_width() const {return m_streaming_width;} - void set_streaming_width(const unsigned int streaming_width) {m_streaming_width = streaming_width; } - - // Byte enable related methods - unsigned char* get_byte_enable_ptr() const {return m_byte_enable;} - void set_byte_enable_ptr(unsigned char* byte_enable){m_byte_enable = byte_enable;} - unsigned int get_byte_enable_length() const {return m_byte_enable_length;} - void set_byte_enable_length(const unsigned int byte_enable_length){m_byte_enable_length = byte_enable_length;} + // Command related method. + bool is_read() const { return (m_command == TLM_READ_COMMAND); } + void set_read() { m_command = TLM_READ_COMMAND; } + bool is_write() const { return (m_command == TLM_WRITE_COMMAND); } + void set_write() { m_command = TLM_WRITE_COMMAND; } + tlm_command get_command() const { return m_command; } + void set_command(const tlm_command command) { m_command = command; } + + // Address related methods. + sc_dt::uint64 get_address() const { return m_address; } + void set_address(const sc_dt::uint64 address) { m_address = address; } + + // Data related methods. + unsigned char *get_data_ptr() const { return m_data; } + void set_data_ptr(unsigned char *data) { m_data = data; } + + // Transaction length (in bytes) related methods. + unsigned int get_data_length() const { return m_length; } + void set_data_length(const unsigned int length) { m_length = length; } + + // Response status related methods. + bool is_response_ok() const { return (m_response_status > 0); } + bool is_response_error() const { return (m_response_status <= 0); } + tlm_response_status + get_response_status() const + { + return m_response_status; + } + void + set_response_status(const tlm_response_status response_status) + { + m_response_status = response_status; + } + std::string get_response_string() const; + + // Streaming related methods. + unsigned int get_streaming_width() const { return m_streaming_width; } + void + set_streaming_width(const unsigned int streaming_width) + { + m_streaming_width = streaming_width; + } + + // Byte enable related methods. + unsigned char *get_byte_enable_ptr() const { return m_byte_enable; } + void + set_byte_enable_ptr(unsigned char *byte_enable) + { + m_byte_enable = byte_enable; + } + unsigned int + get_byte_enable_length() const + { + return m_byte_enable_length; + } + void + set_byte_enable_length(const unsigned int byte_enable_length) + { + m_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) { m_dmi = dmi_allowed; } - bool is_dmi_allowed() const { return m_dmi; } + void + set_dmi_allowed(bool dmi_allowed) + { + m_dmi = dmi_allowed; + } + bool + is_dmi_allowed() const + { + return m_dmi; + } // Use full set of attributes in DMI/debug? tlm_gp_option get_gp_option() const { return m_gp_option; } - void set_gp_option( const tlm_gp_option gp_opt ) { m_gp_option = gp_opt; } - -private: + void set_gp_option(const tlm_gp_option gp_opt) { m_gp_option = gp_opt; } + private: /* --------------------------------------------------------------------- */ /* Generic Payload attributes: */ /* --------------------------------------------------------------------- */ @@ -260,19 +286,18 @@ private: /* - m_streaming_width : */ /* --------------------------------------------------------------------- */ - sc_dt::uint64 m_address; - tlm_command m_command; - unsigned char* m_data; - unsigned int m_length; - tlm_response_status m_response_status; - bool m_dmi; - unsigned char* m_byte_enable; - unsigned int m_byte_enable_length; - unsigned int m_streaming_width; - tlm_gp_option m_gp_option; - -public: - + sc_dt::uint64 m_address; + tlm_command m_command; + unsigned char *m_data; + unsigned int m_length; + tlm_response_status m_response_status; + bool m_dmi; + unsigned char *m_byte_enable; + unsigned int m_byte_enable_length; + unsigned int m_streaming_width; + tlm_gp_option m_gp_option; + + public: /* --------------------------------------------------------------------- */ /* Dynamic extension mechanism: */ /* --------------------------------------------------------------------- */ @@ -310,79 +335,81 @@ public: // Stick the pointer to an extension into the vector, return the // previous value: - template <typename T> T* set_extension(T* ext) + template <typename T> + T * + set_extension(T *ext) { - return static_cast<T*>(set_extension(T::ID, ext)); + return static_cast<T *>(set_extension(T::ID, ext)); } - // non-templatized version with manual index: - tlm_extension_base* set_extension(unsigned int index, - tlm_extension_base* ext); + // Non-templatized version with manual index: + tlm_extension_base *set_extension( + unsigned int index, tlm_extension_base *ext); // Stick the pointer to an extension into the vector, return the - // previous value and schedule its release - template <typename T> T* set_auto_extension(T* ext) + // previous value and schedule its release. + template <typename T> + T * + set_auto_extension(T *ext) { - return static_cast<T*>(set_auto_extension(T::ID, ext)); + return static_cast<T *>(set_auto_extension(T::ID, ext)); } - // non-templatized version with manual index: - tlm_extension_base* set_auto_extension(unsigned int index, - tlm_extension_base* ext); - - // 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 + // Non-templatized version with manual index: + tlm_extension_base *set_auto_extension( + unsigned int index, tlm_extension_base *ext); + + // 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_extension_base* get_extension(unsigned int index) const; - - //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) + tlm_extension_base *get_extension(unsigned int index) const; + + // 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() + // 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: + private: // Non-templatized version with manual index void clear_extension(unsigned int index); // Non-templatized version with manual index void release_extension(unsigned int index); -public: + 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 @@ -390,13 +417,12 @@ public: // allocated after C++ static construction time. void resize_extensions(); -private: - tlm_array<tlm_extension_base*> m_extensions; - tlm_mm_interface* m_mm; - unsigned int m_ref_count; + private: + tlm_array<tlm_extension_base *> m_extensions; + tlm_mm_interface *m_mm; + unsigned int m_ref_count; }; } // namespace tlm - -#endif /* TLM_CORE_TLM2_TLM_GP_H_INCLUDED_ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_GP_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h index da3abb4f9..74c6d935f 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_helpers.h @@ -17,64 +17,54 @@ *****************************************************************************/ -/* --------------------------------------------------------------------------------------- - @file tlm_helpers.h - - @brief - - Original Authors: - Charles Wilson, ESLX - ---------------------------------------------------------------------------------------- */ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ -#ifndef __TLM_HELPERS_H__ -#define __TLM_HELPERS_H__ - -//#include <sys/param.h> -//#include <cstring> - -namespace tlm { +namespace tlm +{ enum tlm_endianness { TLM_UNKNOWN_ENDIAN, TLM_LITTLE_ENDIAN, TLM_BIG_ENDIAN }; -inline tlm_endianness get_host_endianness(void) +inline tlm_endianness +get_host_endianness() { - static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; - - if (host_endianness == TLM_UNKNOWN_ENDIAN) { - unsigned int number = 1; - unsigned char *p_msb_or_lsb = (unsigned char*)&number; - - host_endianness = (p_msb_or_lsb[0] == 0) ? TLM_BIG_ENDIAN : TLM_LITTLE_ENDIAN; - } - return host_endianness; + static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; + + if (host_endianness == TLM_UNKNOWN_ENDIAN) { + unsigned int number = 1; + unsigned char *p_msb_or_lsb = (unsigned char *)&number; + host_endianness = (p_msb_or_lsb[0] == 0) ? + TLM_BIG_ENDIAN : TLM_LITTLE_ENDIAN; + } + return host_endianness; } -inline bool host_has_little_endianness(void) +inline bool +host_has_little_endianness() { - static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; - static bool host_little_endian = false; - - if (host_endianness == TLM_UNKNOWN_ENDIAN) { - unsigned int number = 1; - unsigned char *p_msb_or_lsb = (unsigned char*)&number; + static tlm_endianness host_endianness = TLM_UNKNOWN_ENDIAN; + static bool host_little_endian = false; - host_little_endian = (p_msb_or_lsb[0] == 0) ? false : true; - } + if (host_endianness == TLM_UNKNOWN_ENDIAN) { + unsigned int number = 1; + unsigned char *p_msb_or_lsb = (unsigned char *)&number; - return host_little_endian; + host_little_endian = (p_msb_or_lsb[0] == 0) ? false : true; + } + + return host_little_endian; } -inline bool has_host_endianness(tlm_endianness endianness) +inline bool +has_host_endianness(tlm_endianness endianness) { - if (host_has_little_endianness()) { - return endianness == TLM_LITTLE_ENDIAN; - - } else { - return endianness == TLM_BIG_ENDIAN; - } -} + if (host_has_little_endianness()) { + return endianness == TLM_LITTLE_ENDIAN; + } else { + return endianness == TLM_BIG_ENDIAN; + } +} } // namespace tlm -#endif /* __TLM_HELPERS_H__ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_HELPERS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h index a06ccc443..767cb886c 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h @@ -17,92 +17,101 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM2_TLM_PHASE_H_INCLUDED_ -#define TLM_CORE_TLM2_TLM_PHASE_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ -#include <string> #include <iostream> #include <typeinfo> #include <vector> -#include "sysc/kernel/sc_cmnhdr.h" // SC_API -#include "sysc/kernel/sc_macros.h" // SC_CONCAT_HELPER_, SC_STRINGIFY_HELPER_ +#define SC_CONCAT_HELPER_(a, b) SC_CONCAT_HELPER_DEFERRED_(a, b) +#define SC_CONCAT_HELPER_DEFERRED_(a, b) SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) +#define SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) a ## b -namespace tlm { +#define SC_STRINGIFY_HELPER_(a) SC_STRINGIFY_HELPER_DEFERRED_(a) +#define SC_STRINGIFY_HELPER_DEFERRED_(a) SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) +#define SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) #a -enum SC_API tlm_phase_enum +namespace tlm { - UNINITIALIZED_PHASE=0, - BEGIN_REQ=1, - END_REQ, - BEGIN_RESP, - END_RESP + +enum tlm_phase_enum +{ + UNINITIALIZED_PHASE = 0, + BEGIN_REQ = 1, + END_REQ, + BEGIN_RESP, + END_RESP }; -class SC_API tlm_phase +class tlm_phase { -public: - tlm_phase(); - tlm_phase(unsigned int id); // TODO: should be dropped + public: + tlm_phase(); + tlm_phase(unsigned int id); - tlm_phase(tlm_phase_enum standard); - tlm_phase& operator=(tlm_phase_enum standard); + tlm_phase(tlm_phase_enum standard); + tlm_phase &operator = (tlm_phase_enum standard); - operator unsigned int() const { return m_id; } - const char* get_name() const; + operator unsigned int() const { return m_id; } + const char *get_name() const; -protected: - // register extended phase - tlm_phase( const std::type_info & type, const char* name ); + protected: + // Register extended phase. + tlm_phase(const std::type_info &type, const char *name); -private: - unsigned int m_id; + private: + unsigned int m_id; }; -inline -tlm_phase::tlm_phase() - : m_id( UNINITIALIZED_PHASE ) -{} +inline tlm_phase::tlm_phase() : m_id(UNINITIALIZED_PHASE) {} -inline -tlm_phase::tlm_phase( tlm_phase_enum standard ) - : m_id( standard ) -{} +inline tlm_phase::tlm_phase(tlm_phase_enum standard) : m_id(standard) {} -inline -tlm_phase& tlm_phase::operator=( tlm_phase_enum standard ) +inline tlm_phase & +tlm_phase::operator = (tlm_phase_enum standard) { - m_id = standard; - return *this; + m_id = standard; + return *this; } -inline -std::ostream& operator<<(std::ostream& s, const tlm_phase& p) +inline std::ostream & +operator << (std::ostream &s, const tlm_phase &p) { - s << p.get_name(); - return s; + s << p.get_name(); + return s; } #define TLM_DECLARE_EXTENDED_PHASE(name_arg) \ - static class SC_CONCAT_HELPER_(tlm_phase_, name_arg) \ - : public ::tlm::tlm_phase \ - { \ +static class SC_CONCAT_HELPER_(tlm_phase_, name_arg) : \ + public ::tlm::tlm_phase \ +{ \ typedef SC_CONCAT_HELPER_(tlm_phase_, name_arg) this_type; \ public: \ - SC_CONCAT_HELPER_(tlm_phase_, name_arg)() /* register extended phase */ \ - : ::tlm::tlm_phase( typeid(*this), SC_STRINGIFY_HELPER_(name_arg) ) \ + SC_CONCAT_HELPER_(tlm_phase_, name_arg)() : \ + /* register extended phase */ \ + ::tlm::tlm_phase(typeid(*this), SC_STRINGIFY_HELPER_(name_arg)) \ {} \ \ - static const this_type& get_phase() /* needed only for IEEE 1666-2011 */ \ - { static this_type this_; return this_; } \ - } \ - const name_arg + static const this_type &get_phase() \ + /* needed only for IEEE 1666-2011 */ \ + { \ + static this_type this_; \ + return this_; \ + } \ +} const name_arg // for backwards-compatibility -#define DECLARE_EXTENDED_PHASE( NameArg ) \ - TLM_DECLARE_EXTENDED_PHASE( NameArg ) +#define DECLARE_EXTENDED_PHASE(NameArg) TLM_DECLARE_EXTENDED_PHASE(NameArg) } // namespace tlm -#endif /* TLM_CORE_TLM2_TLM_PHASE_H_INCLUDED_ */ -// Taf! +#undef SC_CONCAT_HELPER_ +#undef SC_CONCAT_HELPER_DEFERRED_ +#undef SC_CONCAT_HELPER_MORE_DEFERRED_ + +#undef SC_STRINGIFY_HELPER_ +#undef SC_STRINGIFY_HELPER_DEFERRED_ +#undef SC_STRINGIFY_HELPER_MORE_DEFERRED_ + +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_GENERIC_PAYLOAD_TLM_PHASE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h index 5c08acf28..74ae57aa5 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h @@ -17,12 +17,13 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM2_TLM_GLOBAL_QUANTUM_H_INCLUDED_ -#define TLM_CORE_TLM2_TLM_GLOBAL_QUANTUM_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ -#include "sysc/kernel/sc_time.h" +#include <systemc> -namespace tlm { +namespace tlm +{ // // tlm_global_quantum class @@ -38,45 +39,38 @@ namespace tlm { // the global quantum is set. // -class SC_API tlm_global_quantum +class tlm_global_quantum { -public: - // - // Returns a reference to the tlm_global_quantum singleton - // - static tlm_global_quantum& instance(); - -public: - - // - // Setter/getter for the global quantum - // - void set(const sc_core::sc_time& t) - { - m_global_quantum = t; - } - - const sc_core::sc_time& get() const - { - return m_global_quantum; - } - - // - // This function will calculate the maximum value for the next local - // quantum for an initiator. All initiators should synchronize on - // integer multiples of the global quantum value. The value for the - // local quantum of an initiator can be smaller, but should never be - // greater than the value returned by this method. - // - sc_core::sc_time compute_local_quantum(); - -protected: - tlm_global_quantum(); - -protected: - sc_core::sc_time m_global_quantum; + public: + // + // Returns a reference to the tlm_global_quantum singleton + // + static tlm_global_quantum &instance(); + + public: + + // + // Setter/getter for the global quantum + // + void set(const sc_core::sc_time &t) { m_global_quantum = t; } + const sc_core::sc_time &get() const { return m_global_quantum; } + + // + // This function will calculate the maximum value for the next local + // quantum for an initiator. All initiators should synchronize on + // integer multiples of the global quantum value. The value for the + // local quantum of an initiator can be smaller, but should never be + // greater than the value returned by this method. + // + sc_core::sc_time compute_local_quantum(); + + protected: + tlm_global_quantum(); + + protected: + sc_core::sc_time m_global_quantum; }; } // namespace tlm -#endif // TLM_CORE_TLM2_TLM_GLOBAL_QUANTUM_H_INCLUDED_ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_GLOBAL_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h index f06a4633a..dc7fdc296 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_quantum/tlm_quantum.h @@ -17,9 +17,9 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM2_TLM_QUANTUM_H_INCLUDED_ -#define TLM_CORE_TLM2_TLM_QUANTUM_H_INCLUDED_ +#ifndef ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ +#define ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ #include "tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h" -#endif // TLM_CORE_TLM2_TLM_QUANTUM_H_INCLUDED_ +#endif /* ____SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_QUANTUM_TLM_QUANTUM_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h index c847835d7..5dcd40129 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h @@ -17,12 +17,13 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM_BASE_SOCKET_IF_H_INCLUDED_ -#define TLM_CORE_TLM_BASE_SOCKET_IF_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ -#include "sysc/utils/sc_typeindex.h" +#include <systemc> -namespace tlm { +namespace tlm +{ enum tlm_socket_category { @@ -38,19 +39,19 @@ enum tlm_socket_category class tlm_base_socket_if { -public: - virtual sc_core::sc_port_base & get_port_base() = 0; - virtual sc_core::sc_port_base const & get_port_base() const = 0; - virtual sc_core::sc_export_base & get_export_base() = 0; - virtual sc_core::sc_export_base const & get_export_base() const = 0; - virtual unsigned int get_bus_width() const = 0; - virtual sc_core::sc_type_index get_protocol_types() const = 0; - virtual tlm_socket_category get_socket_category() const = 0; - -protected: - virtual ~tlm_base_socket_if() {} + public: + virtual sc_core::sc_port_base &get_port_base() = 0; + virtual sc_core::sc_port_base const &get_port_base() const = 0; + virtual sc_core::sc_export_base &get_export_base() = 0; + virtual sc_core::sc_export_base const &get_export_base() const = 0; + virtual unsigned int get_bus_width() const = 0; + virtual sc_core::sc_type_index get_protocol_types() const = 0; + virtual tlm_socket_category get_socket_category() const = 0; + + protected: + virtual ~tlm_base_socket_if() {} }; } // namespace tlm -#endif // TLM_CORE_TLM_BASE_SOCKET_IF_H_INCLUDED_ +#endif // __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_BASE_SOCKET_IF_H__ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h index b703ec210..93ed2fddb 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h @@ -17,224 +17,188 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM_INITIATOR_SOCKET_H_INCLUDED_ -#define TLM_CORE_TLM_INITIATOR_SOCKET_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ #include "tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h" #include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" -#if defined(__clang__) || \ - (defined(__GNUC__) && ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4006)) -// ignore warning about deliberately hidden "bind()" overloads -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverloaded-virtual" -#endif - -namespace tlm { +namespace tlm +{ -template <unsigned int BUSWIDTH = 32, - typename FW_IF = tlm_fw_transport_if<>, - typename BW_IF = tlm_bw_transport_if<> > +template <unsigned int BUSWIDTH=32, + typename FW_IF=tlm_fw_transport_if<>, + typename BW_IF=tlm_bw_transport_if<>> class tlm_base_initiator_socket_b { -public: - virtual ~tlm_base_initiator_socket_b() {} - - virtual sc_core::sc_port_b<FW_IF> & get_base_port() = 0; - virtual sc_core::sc_port_b<FW_IF> const & get_base_port() const = 0; - virtual BW_IF & get_base_interface() = 0; - virtual BW_IF const & get_base_interface() const = 0; - virtual sc_core::sc_export<BW_IF> & get_base_export() = 0; - virtual sc_core::sc_export<BW_IF> const & get_base_export() const = 0; + public: + virtual ~tlm_base_initiator_socket_b() {} + + virtual sc_core::sc_port_b<FW_IF> &get_base_port() = 0; + virtual sc_core::sc_port_b<FW_IF> const &get_base_port() const = 0; + virtual BW_IF &get_base_interface() = 0; + virtual BW_IF const &get_base_interface() const = 0; + virtual sc_core::sc_export<BW_IF> &get_base_export() = 0; + virtual sc_core::sc_export<BW_IF> const &get_base_export() const = 0; }; +template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF> +class tlm_base_target_socket_b; -template <unsigned int BUSWIDTH, - typename FW_IF, - typename BW_IF> class tlm_base_target_socket_b; - -template <unsigned int BUSWIDTH, - typename FW_IF, - typename BW_IF, - int N, - sc_core::sc_port_policy POL> class tlm_base_target_socket; - -template <unsigned int BUSWIDTH = 32, - typename FW_IF = tlm_fw_transport_if<>, - typename BW_IF = tlm_bw_transport_if<>, - int N = 1, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_initiator_socket : public tlm_base_socket_if, - public tlm_base_initiator_socket_b<BUSWIDTH, FW_IF, BW_IF>, - public sc_core::sc_port<FW_IF, N, POL> +template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N, + sc_core::sc_port_policy POL> +class tlm_base_target_socket; + +template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>, + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_initiator_socket : + public tlm_base_socket_if, + public tlm_base_initiator_socket_b<BUSWIDTH, FW_IF, BW_IF>, + public sc_core::sc_port<FW_IF, N, POL> { -public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port<fw_interface_type,N,POL> port_type; - - typedef sc_core::sc_export<bw_interface_type> export_type; - - typedef tlm_base_target_socket_b<BUSWIDTH, - fw_interface_type, - bw_interface_type> base_target_socket_type; - typedef tlm_base_initiator_socket_b<BUSWIDTH, - fw_interface_type, - bw_interface_type> base_type; - - template <unsigned int, typename, typename, int, sc_core::sc_port_policy> - friend class tlm_base_target_socket; - -public: - tlm_base_initiator_socket() - : port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")) - , m_export(sc_core::sc_gen_unique_name("tlm_base_initiator_socket_export")) - { - } - - explicit tlm_base_initiator_socket(const char* name) - : port_type(name) - , m_export(sc_core::sc_gen_unique_name((std::string(name) + "_export").c_str())) - { - } - - virtual const char* kind() const - { - return "tlm_base_initiator_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 - (get_base_port())(s.get_base_interface()); - // target.port -> initiator.export - (s.get_base_port())(get_base_interface()); - } - - void operator() (base_target_socket_type& s) - { - bind(s); - } - - // - // Bind initiator socket to initiator socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void bind(base_type& s) - { - // port - (get_base_port())(s.get_base_port()); - // export - (s.get_base_export())(get_base_export()); - } - - void operator() (base_type& s) - { - bind(s); - } - - // - // Bind interface to socket - // - Binds the interface to the export of this socket - // - virtual void bind(bw_interface_type& ifs) - { - (get_base_export())(ifs); - } - - void operator() (bw_interface_type& s) - { - bind(s); - } - - // Implementation of tlm_base_socket_if functions - virtual sc_core::sc_port_base & get_port_base() - { return *this; } - virtual sc_core::sc_port_base const & get_port_base() const - { return *this; } - virtual sc_core::sc_export_base & get_export_base() - { return m_export; } - virtual sc_core::sc_export_base const & get_export_base() const - { return m_export; } - virtual unsigned int get_bus_width() const - { return BUSWIDTH; } - virtual tlm_socket_category get_socket_category() const - { return TLM_INITIATOR_SOCKET; } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b<FW_IF> & get_base_port() - { return *this; } - virtual sc_core::sc_port_b<FW_IF> const & get_base_port() const - { return *this; } - - virtual BW_IF & get_base_interface() - { return m_export; } - virtual BW_IF const & get_base_interface() const - { return m_export; } - - virtual sc_core::sc_export<BW_IF> & get_base_export() - { return m_export; } - virtual sc_core::sc_export<BW_IF> const & get_base_export() const - { return m_export; } - -protected: - export_type m_export; + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port<fw_interface_type, N, POL> port_type; + + typedef sc_core::sc_export<bw_interface_type> export_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_target_socket_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template <unsigned int, typename, typename, int, sc_core::sc_port_policy> + friend class tlm_base_target_socket; + + public: + tlm_base_initiator_socket() : + port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")), + m_export(sc_core::sc_gen_unique_name( + "tlm_base_initiator_socket_export")) + {} + + explicit tlm_base_initiator_socket(const char *name) : port_type(name), + m_export(sc_core::sc_gen_unique_name( + (std::string(name) + "_export").c_str())) + {} + + virtual const char* kind() const { return "tlm_base_initiator_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 + (get_base_port())(s.get_base_interface()); + // target.port -> initiator.export + (s.get_base_port())(get_base_interface()); + } + + void operator () (base_target_socket_type &s) { bind(s); } + + // + // Bind initiator socket to initiator socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // port + (get_base_port())(s.get_base_port()); + // export + (s.get_base_export())(get_base_export()); + } + + void operator() (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export of this socket + // + virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } + void operator() (bw_interface_type &s) { bind(s); } + + // Implementation of tlm_base_socket_if functions + virtual sc_core::sc_port_base &get_port_base() { return *this; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return *this; + } + virtual sc_core::sc_export_base &get_export_base() { return m_export; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return m_export; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_INITIATOR_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b<FW_IF> &get_base_port() { return *this; } + virtual sc_core::sc_port_b<FW_IF> const & + get_base_port() const + { + return *this; + } + + virtual BW_IF &get_base_interface() { return m_export; } + virtual BW_IF const &get_base_interface() const { return m_export; } + + virtual sc_core::sc_export<BW_IF> &get_base_export() { return m_export; } + virtual sc_core::sc_export<BW_IF> const & + get_base_export() const + { + return m_export; + } + + protected: + export_type m_export; }; // // Convenience socket classes // -template <unsigned int BUSWIDTH = 32, - typename TYPES = tlm_base_protocol_types, - int N = 1, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_initiator_socket : - public tlm_base_initiator_socket<BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL> +template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types, + int N=1, sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_initiator_socket : public tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL> { -public: - tlm_initiator_socket() : - tlm_base_initiator_socket<BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL>() - { - } - - explicit tlm_initiator_socket(const char* name) : - tlm_base_initiator_socket<BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL>(name) - { - } - - virtual const char* kind() const - { - return "tlm_initiator_socket"; - } - - virtual sc_core::sc_type_index get_protocol_types() const - { - return typeid(TYPES); - } + public: + tlm_initiator_socket() : tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL>() + {} + + explicit tlm_initiator_socket(const char *name) : + tlm_base_initiator_socket<BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL>(name) + {} + + virtual const char *kind() const { return "tlm_initiator_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } }; } // namespace tlm -#if defined(__clang__) || \ - (defined(__GNUC__) && ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4006)) -#pragma GCC diagnostic pop -#endif - -#endif // TLM_CORE_TLM_INITIATOR_SOCKET_H_INCLUDED_ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_INITIATOR_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h index 013e29286..75697292b 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_sockets.h @@ -17,10 +17,10 @@ *****************************************************************************/ -#ifndef __TLM_SOCKETS_H__ -#define __TLM_SOCKETS_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ #include "tlm_core/tlm_2/tlm_sockets/tlm_initiator_socket.h" #include "tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h" -#endif /* __TLM_SOCKETS_H__ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_SOCKETS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h index 030643294..ba0fcc207 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h @@ -17,239 +17,207 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM_TARGET_SOCKET_H_INCLUDED_ -#define TLM_CORE_TLM_TARGET_SOCKET_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ #include "tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h" #include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h" +namespace tlm +{ -namespace tlm { - -template <unsigned int BUSWIDTH = 32, - typename FW_IF = tlm_fw_transport_if<>, - typename BW_IF = tlm_bw_transport_if<> > +template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>, + typename BW_IF=tlm_bw_transport_if<>> class tlm_base_target_socket_b { -public: - virtual ~tlm_base_target_socket_b() {} + public: + virtual ~tlm_base_target_socket_b() {} - virtual sc_core::sc_port_b<BW_IF> & get_base_port() = 0; - virtual sc_core::sc_export<FW_IF> & get_base_export() = 0; - virtual FW_IF & get_base_interface() = 0; + virtual sc_core::sc_port_b<BW_IF> &get_base_port() = 0; + virtual sc_core::sc_export<FW_IF> &get_base_export() = 0; + virtual FW_IF &get_base_interface() = 0; }; -template <unsigned int BUSWIDTH, - typename FW_IF, - typename BW_IF> class tlm_base_initiator_socket_b; - -template <unsigned int BUSWIDTH, - typename FW_IF, - typename BW_IF, - int N, - sc_core::sc_port_policy POL> class tlm_base_initiator_socket; - -template <unsigned int BUSWIDTH = 32, - typename FW_IF = tlm_fw_transport_if<>, - typename BW_IF = tlm_bw_transport_if<>, - int N = 1, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_target_socket : public tlm_base_socket_if, - public tlm_base_target_socket_b<BUSWIDTH, FW_IF, BW_IF>, - public sc_core::sc_export<FW_IF> +template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF> +class tlm_base_initiator_socket_b; + +template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N, + sc_core::sc_port_policy POL> +class tlm_base_initiator_socket; + +template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>, + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_target_socket : + public tlm_base_socket_if, + public tlm_base_target_socket_b<BUSWIDTH, FW_IF, BW_IF>, + public sc_core::sc_export<FW_IF> { -public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port<bw_interface_type, N , POL> port_type; - - typedef sc_core::sc_export<fw_interface_type> export_type; - typedef tlm_base_initiator_socket_b<BUSWIDTH, - fw_interface_type, - bw_interface_type> base_initiator_socket_type; - - typedef tlm_base_target_socket_b<BUSWIDTH, - fw_interface_type, - bw_interface_type> base_type; - - template <unsigned int, typename, typename, int, sc_core::sc_port_policy> - friend class tlm_base_initiator_socket; - -public: - tlm_base_target_socket() - : export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")) - , m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) - { - } - - explicit tlm_base_target_socket(const char* name) - : export_type(name) - , m_port(sc_core::sc_gen_unique_name((std::string(name) + "_port").c_str())) - { - } - - virtual const char* kind() const - { - return "tlm_base_target_socket"; - } - - // - // Bind target socket to initiator 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_initiator_socket_type& s) - { - // initiator.port -> target.export - (s.get_base_port())(get_base_interface()); - // target.port -> initiator.export - get_base_port()(s.get_base_interface()); - } - - void operator() (base_initiator_socket_type& s) - { - bind(s); - } - - // - // Bind target socket to target socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void bind(base_type& s) - { - // export - (get_base_export())(s.get_base_export()); - // port - (s.get_base_port())(get_base_port()); - } - - void operator() (base_type& s) - { - bind(s); - } - - // - // Bind interface to socket - // - Binds the interface to the export - // - virtual void bind(fw_interface_type& ifs) - { - export_type* exp = &get_base_export(); - if( this == exp ) { - export_type::bind( ifs ); // non-virtual function call - } else { - exp->bind( ifs ); + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port<bw_interface_type, N, POL> port_type; + + typedef sc_core::sc_export<fw_interface_type> export_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_initiator_socket_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template <unsigned int, typename, typename, int, sc_core::sc_port_policy> + friend class tlm_base_initiator_socket; + + public: + tlm_base_target_socket() : + export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")), + m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) + {} + + explicit tlm_base_target_socket(const char *name) : + export_type(name), m_port(sc_core::sc_gen_unique_name( + (std::string(name) + "_port").c_str())) + {} + + virtual const char *kind() const { return "tlm_base_target_socket"; } + + // + // Bind target socket to initiator 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_initiator_socket_type &s) + { + // initiator.port -> target.export + (s.get_base_port())(get_base_interface()); + // target.port -> initiator.export + get_base_port()(s.get_base_interface()); } - } - - void operator() (fw_interface_type& s) - { - bind(s); - } - - // - // Forward to 'size()' of port class - // - int size() const - { - return m_port.size(); - } - - // - // Forward to 'operator->()' of port class - // - bw_interface_type* operator->() - { - return m_port.operator->(); - } - - // - // Forward to 'operator[]()' of port class - // - bw_interface_type* operator[](int i) - { - return m_port.operator[](i); - } - - // Implementation of tlm_base_socket_if functions - virtual sc_core::sc_port_base & get_port_base() - { return m_port; } - virtual sc_core::sc_port_base const & get_port_base() const - { return m_port; } - virtual sc_core::sc_export_base & get_export_base() - { return *this; } - virtual sc_core::sc_export_base const & get_export_base() const - { return *this; } - virtual unsigned int get_bus_width() const - { return BUSWIDTH; } - virtual tlm_socket_category get_socket_category() const - { return TLM_TARGET_SOCKET; } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b<BW_IF> & get_base_port() - { return m_port; } - virtual sc_core::sc_port_b<BW_IF> const & get_base_port() const - { return m_port; } - - virtual FW_IF & get_base_interface() - { return *this; } - virtual FW_IF const & get_base_interface() const - { return *this; } - - virtual sc_core::sc_export<FW_IF> & get_base_export() - { return *this; } - virtual sc_core::sc_export<FW_IF> const & get_base_export() const - { return *this; } - -protected: - port_type m_port; -}; + void operator () (base_initiator_socket_type &s) { bind(s); } + + // + // Bind target socket to target socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // export + (get_base_export())(s.get_base_export()); + // port + (s.get_base_port())(get_base_port()); + } -// -// Convenience blocking and non-blocking socket classes -// + void operator () (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export + // + virtual void + bind(fw_interface_type &ifs) + { + export_type *exp = &get_base_export(); + if (this == exp) { + export_type::bind(ifs); + } else { + exp->bind( ifs ); + } + } -template <unsigned int BUSWIDTH = 32, - typename TYPES = tlm_base_protocol_types, - int N = 1, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> + void operator () (fw_interface_type &s) { bind(s); } + + // + // Forward to 'size()' of port class. + // + int size() const { return m_port.size(); } + + // + // Forward to 'operator->()' of port class. + // + bw_interface_type *operator->() { return m_port.operator->(); } + + // + // Forward to 'operator[]()' of port class. + // + bw_interface_type *operator[](int i) { return m_port.operator[](i); } + + // Implementation of tlm_base_socket_if functions. + virtual sc_core::sc_port_base &get_port_base() { return m_port; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return m_port; + } + virtual sc_core::sc_export_base &get_export_base() { return *this; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return *this; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_TARGET_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b<BW_IF> &get_base_port() { return m_port; } + virtual sc_core::sc_port_b<BW_IF> const & + get_base_port() const + { + return m_port; + } + + virtual FW_IF &get_base_interface() { return *this; } + virtual FW_IF const &get_base_interface() const { return *this; } + + virtual sc_core::sc_export<FW_IF> &get_base_export() { return *this; } + virtual sc_core::sc_export<FW_IF> const & + get_base_export() const + { + return *this; + } + + protected: + port_type m_port; +}; + +template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types, + int N=1, sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> class tlm_target_socket : - public tlm_base_target_socket <BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL> + public tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL> { -public: - tlm_target_socket() : - tlm_base_target_socket<BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL>() - { - } - - explicit tlm_target_socket(const char* name) : - tlm_base_target_socket<BUSWIDTH, - tlm_fw_transport_if<TYPES>, - tlm_bw_transport_if<TYPES>, - N, POL>(name) - { - } - - virtual const char* kind() const - { - return "tlm_target_socket"; - } - - virtual sc_core::sc_type_index get_protocol_types() const - { - return typeid(TYPES); - } + public: + tlm_target_socket() : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL>() + {} + + explicit tlm_target_socket(const char *name) : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if<TYPES>, + tlm_bw_transport_if<TYPES>, N, POL>(name) + {} + + virtual const char* kind() const { return "tlm_target_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } }; } // namespace tlm -#endif // TLM_CORE_TLM_TARGET_SOCKET_H_INCLUDED_ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_SOCKETS_TLM_TARGET_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_2/tlm_version.h b/src/systemc/ext/tlm_core/tlm_2/tlm_version.h index 3cf230077..36c36debe 100644 --- a/src/systemc/ext/tlm_core/tlm_2/tlm_version.h +++ b/src/systemc/ext/tlm_core/tlm_2/tlm_version.h @@ -17,20 +17,16 @@ *****************************************************************************/ -/* --------------------------------------------------------------------------------------- - @file tlm_version.h - - @brief TLM version header - +/* --------------------------------------------------------------------------- Original Author: Charles Wilson, XtremeEDA Corporation @description - This header contains preprocessor and compiler symbols to allow for the determination - of the TLM version information. This conforms to IEEE 1666-2005 section 8.5.5 - 8.5.7 - . + This header contains preprocessor and compiler symbols to allow for the + determination of the TLM version information. This conforms to + IEEE 1666-2005 section 8.5.5 - 8.5.7 The following are provided: - . + preprocessor: TLM_VERSION_MAJOR numeric TLM_VERSION_MINOR numeric TLM_VERSION_PATCH numeric @@ -40,7 +36,7 @@ TLM_IS_PRERELEASE bool (1,0) TLM_VERSION string {2.0.0_DR3-TLMWG} TLM_COPYRIGHT string - . + compiler: tlm_version_major const unsigned int tlm_version_minor const unsigned int tlm_version_patch const unsigned int @@ -50,131 +46,110 @@ tlm_is_prerelease const bool tlm_version const string tlm_copyright const string - . + accessors: inline const char* tlm_release (void) inline const char* tlm_version (void) inline const char* tlm_copyright (void) +--------------------------------------------------------------------------- */ ---------------------------------------------------------------------------------------- */ - -#ifndef __TLM_VERSION_H__ -#define __TLM_VERSION_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ namespace tlm { -#define TLM_VERSION_MAJOR 2 ///< version major level ( numeric ) -#define TLM_VERSION_MINOR 0 ///< version minor level ( numeric ) -#define TLM_VERSION_PATCH 4 ///< version patch level ( numeric ) -#define TLM_VERSION_ORIGINATOR "Accellera" ///< TLM creator string -#define TLM_VERSION_SEPARATOR "." ///< version string separator +#define TLM_VERSION_MAJOR 2 ///< version major level ( numeric ) +#define TLM_VERSION_MINOR 0 ///< version minor level ( numeric ) +#define TLM_VERSION_PATCH 4 ///< version patch level ( numeric ) +#define TLM_VERSION_ORIGINATOR "Accellera" ///< TLM creator string +#define TLM_VERSION_SEPARATOR "." ///< version string separator -#define TLM_IS_PRERELEASE 0 ///< pre-release flag ( 1 / 0 ) +#define TLM_IS_PRERELEASE 0 ///< pre-release flag (1/0) #if TLM_IS_PRERELEASE -# define TLM_VERSION_PRERELEASE "pub_rev" ///< pre-release version string +# define TLM_VERSION_PRERELEASE "pub_rev" ///< pre-release version string #else -# define TLM_VERSION_PRERELEASE "" ///< pre-release version string +# define TLM_VERSION_PRERELEASE "" ///< pre-release version string #endif -#define TLM_VERSION_RELEASE_YEAR "2017" ///< release year ( YYYY ) -#define TLM_VERSION_RELEASE_MONTH "10" ///< release month ( MM ) -#define TLM_VERSION_RELEASE_DAY "12" ///< release day ( DD ) +#define TLM_VERSION_RELEASE_YEAR "2017" ///< release year ( YYYY ) +#define TLM_VERSION_RELEASE_MONTH "10" ///< release month ( MM ) +#define TLM_VERSION_RELEASE_DAY "12" ///< release day ( DD ) #define TLM_COPYRIGHT \ "Copyright (c) 1996-" TLM_VERSION_RELEASE_YEAR " by all Contributors\n" \ "ALL RIGHTS RESERVED" -/************************** do not modify below this line *******************************/ +/******************** do not modify below this line *************************/ -/******************************* preprocessor symbols ***********************************/ +/************************* preprocessor symbols *****************************/ -#define TLM_VERSION_RELEASE_DATE TLM_VERSION_RELEASE_YEAR \ - TLM_VERSION_RELEASE_MONTH \ - TLM_VERSION_RELEASE_DAY +#define TLM_VERSION_RELEASE_DATE TLM_VERSION_RELEASE_YEAR \ + TLM_VERSION_RELEASE_MONTH \ + TLM_VERSION_RELEASE_DAY -#define TLM_VERSION_STR(x) TLM_VERSION_STR_HELPER(x) -#define TLM_VERSION_STR_HELPER(x) #x +#define TLM_VERSION_STR(x) TLM_VERSION_STR_HELPER(x) +#define TLM_VERSION_STR_HELPER(x) #x -#define TLM_VERSION_STRING_MAJOR TLM_VERSION_STR(TLM_VERSION_MAJOR) -#define TLM_VERSION_STRING_MINOR TLM_VERSION_STR(TLM_VERSION_MINOR) -#define TLM_VERSION_STRING_PATCH TLM_VERSION_STR(TLM_VERSION_PATCH) +#define TLM_VERSION_STRING_MAJOR TLM_VERSION_STR(TLM_VERSION_MAJOR) +#define TLM_VERSION_STRING_MINOR TLM_VERSION_STR(TLM_VERSION_MINOR) +#define TLM_VERSION_STRING_PATCH TLM_VERSION_STR(TLM_VERSION_PATCH) -#define TLM_VERSION_STRING_MMP TLM_VERSION_STRING_MAJOR TLM_VERSION_SEPARATOR \ - TLM_VERSION_STRING_MINOR TLM_VERSION_SEPARATOR \ - TLM_VERSION_STRING_PATCH +#define TLM_VERSION_STRING_MMP TLM_VERSION_STRING_MAJOR TLM_VERSION_SEPARATOR \ + TLM_VERSION_STRING_MINOR TLM_VERSION_SEPARATOR \ + TLM_VERSION_STRING_PATCH -#define TLM_VERSION_STRING_PRE_START "_" -#define TLM_VERSION_STRING_PRE_END "-" +#define TLM_VERSION_STRING_PRE_START "_" +#define TLM_VERSION_STRING_PRE_END "-" -#if ( TLM_IS_PRERELEASE == 1 ) +#if (TLM_IS_PRERELEASE == 1) -#define TLM_VERSION_STRING_PRERELEASE TLM_VERSION_PRERELEASE -#define TLM_VERSION_STRING_RELEASE_DATE "" +# define TLM_VERSION_STRING_PRERELEASE TLM_VERSION_PRERELEASE +# define TLM_VERSION_STRING_RELEASE_DATE "" -#else /* TLM_IS_PRERELEASE == 1 */ +#else /* TLM_IS_PRERELEASE == 1 */ -#define TLM_VERSION_STRING_PRERELEASE "" -#define TLM_VERSION_STRING_RELEASE_DATE TLM_VERSION_RELEASE_DATE +# define TLM_VERSION_STRING_PRERELEASE "" +# define TLM_VERSION_STRING_RELEASE_DATE TLM_VERSION_RELEASE_DATE -#endif /* TLM_IS_PRERELEASE == 1 */ +#endif /* TLM_IS_PRERELEASE == 1 */ -#define TLM_VERSION_STRING TLM_VERSION_STRING_MMP \ - TLM_VERSION_STRING_PRE_START \ - TLM_VERSION_STRING_PRERELEASE \ - TLM_VERSION_STRING_PRE_END \ - TLM_VERSION_ORIGINATOR +#define TLM_VERSION_STRING TLM_VERSION_STRING_MMP \ + TLM_VERSION_STRING_PRE_START \ + TLM_VERSION_STRING_PRERELEASE \ + TLM_VERSION_STRING_PRE_END \ + TLM_VERSION_ORIGINATOR -#define TLM_VERSION_STRING_2 "TLM " \ - TLM_VERSION_STRING_MMP \ - " --- " \ - TLM_VERSION_RELEASE_YEAR \ - "-" \ - TLM_VERSION_RELEASE_MONTH \ - "-" \ - TLM_VERSION_RELEASE_DAY +#define TLM_VERSION_STRING_2 "TLM " \ + TLM_VERSION_STRING_MMP \ + " --- " \ + TLM_VERSION_RELEASE_YEAR \ + "-" \ + TLM_VERSION_RELEASE_MONTH \ + "-" \ + TLM_VERSION_RELEASE_DAY -#define TLM_VERSION TLM_VERSION_STRING +#define TLM_VERSION TLM_VERSION_STRING -/********************************* compiler symbols **************************************/ +/*************************** compiler symbols ********************************/ -const unsigned int tlm_version_major ( TLM_VERSION_MAJOR ); -const unsigned int tlm_version_minor ( TLM_VERSION_MINOR ); -const unsigned int tlm_version_patch ( TLM_VERSION_PATCH ); +const unsigned int tlm_version_major(TLM_VERSION_MAJOR); +const unsigned int tlm_version_minor(TLM_VERSION_MINOR); +const unsigned int tlm_version_patch(TLM_VERSION_PATCH); -const bool tlm_is_prerelease ( TLM_IS_PRERELEASE ); +const bool tlm_is_prerelease(TLM_IS_PRERELEASE); -const std::string tlm_version_string ( TLM_VERSION_STRING ); -const std::string tlm_version_originator ( TLM_VERSION_ORIGINATOR ); -const std::string tlm_version_prerelease ( TLM_VERSION_PRERELEASE ); -const std::string tlm_version_release_date ( TLM_VERSION_STRING_RELEASE_DATE ); -const std::string tlm_copyright_string ( TLM_COPYRIGHT ); -const std::string tlm_version_string_2 ( TLM_VERSION_STRING_2 ); +const std::string tlm_version_string(TLM_VERSION_STRING); +const std::string tlm_version_originator(TLM_VERSION_ORIGINATOR); +const std::string tlm_version_prerelease(TLM_VERSION_PRERELEASE); +const std::string tlm_version_release_date(TLM_VERSION_STRING_RELEASE_DATE); +const std::string tlm_copyright_string(TLM_COPYRIGHT); +const std::string tlm_version_string_2(TLM_VERSION_STRING_2); -inline const char* -tlm_release -( void -) -{ - return tlm_version_string.c_str (); -} - -inline const char* -tlm_version -( void -) -{ - return tlm_version_string_2.c_str (); -} - -inline const char* -tlm_copyright -( void -) -{ - return tlm_copyright_string.c_str (); -} +inline const char *tlm_release() { return tlm_version_string.c_str(); } +inline const char *tlm_version() { return tlm_version_string_2.c_str(); } +inline const char *tlm_copyright() { return tlm_copyright_string.c_str(); } } // namespace tlm -#endif /* __TLM_VERSION_H__ */ +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_2_TLM_VERSION_H__ */ |