From 275d2779656fd2dd72762b2eb16a738d1b3b2b18 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 8 Dec 2018 02:05:34 -0800 Subject: systemc: Fix style issues in the TLM header files. Change-Id: Id12ffb9b56b3887afcf30120f81ce5eb75a5987b Reviewed-on: https://gem5-review.googlesource.com/c/15057 Reviewed-by: Anthony Gutierrez Maintainer: Anthony Gutierrez --- .../ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h | 16 +- .../tlm_1/tlm_analysis/tlm_analysis_fifo.h | 46 ++- .../tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h | 19 +- .../tlm_1/tlm_analysis/tlm_analysis_port.h | 88 +++--- .../tlm_1/tlm_analysis/tlm_analysis_triple.h | 60 ++-- .../ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h | 24 +- .../tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h | 169 +++++----- .../tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h | 75 +++-- .../tlm_1_interfaces/tlm_master_slave_ifs.h | 75 ++--- .../tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h | 16 +- .../tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h | 131 ++++---- .../tlm_channels/tlm_fifo/circular_buffer.h | 343 ++++++++++----------- .../tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h | 274 ++++++++-------- .../tlm_channels/tlm_fifo/tlm_fifo_peek.h | 110 +++---- .../tlm_channels/tlm_fifo/tlm_fifo_put_get.h | 136 ++++---- .../tlm_channels/tlm_fifo/tlm_fifo_resize.h | 106 +++---- .../tlm_req_rsp_channels/tlm_put_get_imp.h | 159 +++++----- .../tlm_req_rsp_channels/tlm_req_rsp_channels.h | 223 +++++++------- .../tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h | 67 ++-- .../tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h | 104 +++---- .../ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h | 12 +- 21 files changed, 1059 insertions(+), 1194 deletions(-) (limited to 'src/systemc/ext/tlm_core/tlm_1') diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h index 777f7141a..661399c60 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis.h @@ -17,17 +17,13 @@ *****************************************************************************/ -#ifndef __TLM_ANALYSIS_H__ -#define __TLM_ANALYSIS_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ - -#include "tlm_core/tlm_1/tlm_analysis/tlm_write_if.h" +#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h" #include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" - -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h" #include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h" -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h" - -#endif - +#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h" +#include "tlm_core/tlm_1/tlm_analysis/tlm_write_if.h" +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h index 1f01b2a8e..84807031f 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_fifo.h @@ -17,38 +17,30 @@ *****************************************************************************/ -#ifndef __TLM_ANALYSIS_FIFO_H__ -#define __TLM_ANALYSIS_FIFO_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ -#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h" #include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" #include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h" +#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h" -namespace tlm { - -template< typename T > -class tlm_analysis_fifo : - public tlm_fifo< T > , - public virtual tlm_analysis_if< T > , - public virtual tlm_analysis_if< tlm_analysis_triple< T > > { - - public: - - // analysis fifo is an unbounded tlm_fifo - - tlm_analysis_fifo( const char *nm ) : tlm_fifo( nm , -16 ) {} - tlm_analysis_fifo() : tlm_fifo( -16 ) {} - - void write( const tlm_analysis_triple &t ) { - nb_put( t ); - } - - void write( const T &t ) { - nb_put( t ); - } - +namespace tlm +{ + +template +class tlm_analysis_fifo : public tlm_fifo, + public virtual tlm_analysis_if, + public virtual tlm_analysis_if> +{ + public: + // analysis fifo is an unbounded tlm_fifo + tlm_analysis_fifo(const char *nm) : tlm_fifo(nm, -16) {} + tlm_analysis_fifo() : tlm_fifo(-16) {} + + void write(const tlm_analysis_triple &t) { nb_put(t); } + void write(const T &t) { nb_put(t); } }; } // namespace tlm -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_FIFO_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h index bc24fee54..d1b91effc 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h @@ -17,23 +17,22 @@ *****************************************************************************/ -#ifndef __TLM_ANALYSIS_IF_H__ -#define __TLM_ANALYSIS_IF_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ #include "tlm_core/tlm_1/tlm_analysis/tlm_write_if.h" -namespace tlm { +namespace tlm +{ -template < typename T > +template class tlm_analysis_if : public virtual tlm_write_if -{ -}; +{}; -template < typename T > +template class tlm_delayed_analysis_if : public virtual tlm_delayed_write_if -{ -}; +{}; } // namespace tlm -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h index 999092538..5195417a8 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_port.h @@ -17,68 +17,62 @@ *****************************************************************************/ -#ifndef __TLM_ANALYSIS_PORT_H__ -#define __TLM_ANALYSIS_PORT_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ -#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" -#include #include +#include -namespace tlm { - +#include "tlm_core/tlm_1/tlm_analysis/tlm_analysis_if.h" -template < typename T> -class tlm_analysis_port : - public sc_core::sc_object , - public virtual tlm_analysis_if< T > +namespace tlm { - public: - tlm_analysis_port() : sc_core::sc_object() {} - tlm_analysis_port( const char *nm ) : sc_core::sc_object( nm ) {} - // bind and () work for both interfaces and analysis ports, since - // analysis ports implement the analysis interface - - virtual void bind( tlm_analysis_if &_if ) { - m_interfaces.push_back( &_if ); - } - - void operator() ( tlm_analysis_if &_if ) { bind( _if ); } - - virtual bool unbind( tlm_analysis_if &_if ) { +template +class tlm_analysis_port : public sc_core::sc_object, + public virtual tlm_analysis_if +{ + public: + tlm_analysis_port() : sc_core::sc_object() {} + tlm_analysis_port(const char *nm) : sc_core::sc_object(nm) {} - typename std::deque< tlm_analysis_if * >::iterator i - = std::remove( m_interfaces.begin(), m_interfaces.end(), &_if ); + // bind and () work for both interfaces and analysis ports, since + // analysis ports implement the analysis interface. - if( i != m_interfaces.end() ) { - m_interfaces.erase(i, m_interfaces.end() ); - return 1; + virtual void + bind(tlm_analysis_if &_if) + { + m_interfaces.push_back(&_if); } - return 0; - - } - - void write( const T &t ) { - typename std::deque< tlm_analysis_if * >::iterator i; - - for( i = m_interfaces.begin(); - i != m_interfaces.end(); - i++ ) { - - (*i)->write( t ); - + void operator() (tlm_analysis_if &_if) { bind(_if); } + virtual bool + unbind(tlm_analysis_if &_if) + { + typename std::deque *>::iterator i = + std::remove(m_interfaces.begin(), m_interfaces.end(), &_if); + + if (i != m_interfaces.end()) { + m_interfaces.erase(i, m_interfaces.end()); + return 1; + } + return 0; } - } + void + write(const T &t) + { + typename std::deque *>::iterator i; - private: - std::deque< tlm_analysis_if * > m_interfaces; + for (i = m_interfaces.begin(); i != m_interfaces.end(); i++) { + (*i)->write(t); + } + } + private: + std::deque *> m_interfaces; }; } // namespace tlm -#endif - - +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_PORT_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h index f65a25a2e..9727f23e5 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_analysis_triple.h @@ -17,37 +17,37 @@ *****************************************************************************/ -#ifndef __TLM_ANALYSIS_TRIPLE_H__ -#define __TLM_ANALYSIS_TRIPLE_H__ - -//#include - -namespace tlm { - -template< typename T> -struct tlm_analysis_triple { - - sc_core::sc_time start_time; - T transaction; - sc_core::sc_time end_time; - - tlm_analysis_triple() {} - - tlm_analysis_triple( const tlm_analysis_triple &triple ) { - start_time = triple.start_time; - transaction = triple.transaction; - end_time = triple.end_time; - } - - tlm_analysis_triple( const T &t ) { - transaction = t; - } - - operator T() { return transaction; } - operator const T &() const { return transaction; } - +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ + +namespace tlm +{ + +template +struct tlm_analysis_triple +{ + sc_core::sc_time start_time; + T transaction; + sc_core::sc_time end_time; + + tlm_analysis_triple() {} + + tlm_analysis_triple(const tlm_analysis_triple &triple) + { + start_time = triple.start_time; + transaction = triple.transaction; + end_time = triple.end_time; + } + + tlm_analysis_triple(const T &t) + { + transaction = t; + } + + operator T() { return transaction; } + operator const T &() const { return transaction; } }; } // namespace tlm -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_ANALYSIS_TRIPLE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h index b66a591bc..3d77f880d 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_analysis/tlm_write_if.h @@ -17,26 +17,28 @@ *****************************************************************************/ -#ifndef __TLM_WRITE_IF_H__ -#define __TLM_WRITE_IF_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ #include -namespace tlm { +namespace tlm +{ template -class tlm_write_if : public virtual sc_core::sc_interface { -public: - virtual void write(const T& t) = 0; +class tlm_write_if : public virtual sc_core::sc_interface +{ + public: + virtual void write(const T &t) = 0; }; template -class tlm_delayed_write_if : public virtual sc_core::sc_interface { -public: - virtual void write(const T& t, const sc_core::sc_time& time) = 0; +class tlm_delayed_write_if : public virtual sc_core::sc_interface +{ + public: + virtual void write(const T &t, const sc_core::sc_time &time) = 0; }; } // namespace tlm - -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_ANALYSIS_TLM_WRITE_IF_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h index 4c1340338..2cd919bd2 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h @@ -17,133 +17,122 @@ *****************************************************************************/ -// -// Note to the LRM writer : This is the core of the TLM standard -// - - -#ifndef __TLM_CORE_IFS_H__ -#define __TLM_CORE_IFS_H__ - -//#include +#ifndef \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ +#define \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h" -namespace tlm { - -// bidirectional blocking interfaces +namespace tlm +{ -template < typename REQ , typename RSP > +// Bidirectional blocking interfaces. +template class tlm_transport_if : public virtual sc_core::sc_interface { -public: - virtual RSP transport( const REQ & ) = 0; - - virtual void transport( const REQ &req , RSP &rsp ) { - rsp = transport( req ); - } - + public: + virtual RSP transport(const REQ &) = 0; + + virtual void + transport(const REQ &req, RSP &rsp) + { + rsp = transport(req); + } }; - -// uni-directional blocking interfaces - -template < typename T > +// Uni-directional blocking interfaces. +template class tlm_blocking_get_if : public virtual sc_core::sc_interface { -public: - virtual T get( tlm_tag *t = 0 ) = 0; - virtual void get( T &t ) { t = get(); } - + public: + virtual T get(tlm_tag *t=nullptr) = 0; + virtual void get(T &t) { t = get(); } }; -template < typename T > +template class tlm_blocking_put_if : public virtual sc_core::sc_interface { -public: - virtual void put( const T &t ) = 0; + public: + virtual void put(const T &t) = 0; }; -// uni-directional non blocking interfaces +// Uni-directional non blocking interfaces. -template < typename T > +template class tlm_nonblocking_get_if : public virtual sc_core::sc_interface { -public: - virtual bool nb_get( T &t ) = 0; - virtual bool nb_can_get( tlm_tag *t = 0 ) const = 0; - virtual const sc_core::sc_event &ok_to_get( tlm_tag *t = 0 ) const = 0; + public: + virtual bool nb_get(T &t) = 0; + virtual bool nb_can_get(tlm_tag *t=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_get(tlm_tag *t=nullptr) const = 0; }; -template < typename T > +template class tlm_nonblocking_put_if : public virtual sc_core::sc_interface { -public: - virtual bool nb_put( const T &t ) = 0; - virtual bool nb_can_put( tlm_tag *t = 0 ) const = 0; - virtual const sc_core::sc_event &ok_to_put( tlm_tag *t = 0 ) const = 0; + public: + virtual bool nb_put(const T &t) = 0; + virtual bool nb_can_put(tlm_tag *t=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_put(tlm_tag *t=nullptr) const = 0; }; +// Combined uni-directional blocking and non blocking. +template +class tlm_get_if : public virtual tlm_blocking_get_if, + public virtual tlm_nonblocking_get_if +{}; -// combined uni-directional blocking and non blocking +template +class tlm_put_if : public virtual tlm_blocking_put_if, + public virtual tlm_nonblocking_put_if +{}; -template < typename T > -class tlm_get_if : - public virtual tlm_blocking_get_if< T > , - public virtual tlm_nonblocking_get_if< T > {}; - -template < typename T > -class tlm_put_if : - public virtual tlm_blocking_put_if< T > , - public virtual tlm_nonblocking_put_if< T > {}; - - -// peek interfaces - -template < typename T > +// Peek interfaces. +template class tlm_blocking_peek_if : public virtual sc_core::sc_interface { -public: - virtual T peek( tlm_tag *t = 0 ) const = 0; - virtual void peek( T &t ) const { t = peek(); } - + public: + virtual T peek(tlm_tag *t=nullptr) const = 0; + virtual void peek(T &t) const { t = peek(); } }; -template < typename T > +template class tlm_nonblocking_peek_if : public virtual sc_core::sc_interface { -public: - virtual bool nb_peek( T &t ) const = 0; - virtual bool nb_can_peek( tlm_tag *t = 0 ) const = 0; - virtual const sc_core::sc_event &ok_to_peek( tlm_tag *t = 0 ) const = 0; + public: + virtual bool nb_peek(T &t) const = 0; + virtual bool nb_can_peek(tlm_tag *t=nullptr) const = 0; + virtual const sc_core::sc_event & + ok_to_peek(tlm_tag *t=nullptr) const = 0; }; -template < typename T > +template class tlm_peek_if : - public virtual tlm_blocking_peek_if< T > , - public virtual tlm_nonblocking_peek_if< T > {}; - -// get_peek interfaces - -template < typename T > -class tlm_blocking_get_peek_if : - public virtual tlm_blocking_get_if , - public virtual tlm_blocking_peek_if {}; - -template < typename T > -class tlm_nonblocking_get_peek_if : - public virtual tlm_nonblocking_get_if , - public virtual tlm_nonblocking_peek_if {}; - - -template < typename T > -class tlm_get_peek_if : - public virtual tlm_get_if , - public virtual tlm_peek_if , - public virtual tlm_blocking_get_peek_if , - public virtual tlm_nonblocking_get_peek_if - {}; + public virtual tlm_blocking_peek_if, + public virtual tlm_nonblocking_peek_if +{}; + +// Get_peek interfaces. +template +class tlm_blocking_get_peek_if : public virtual tlm_blocking_get_if, + public virtual tlm_blocking_peek_if +{}; + +template +class tlm_nonblocking_get_peek_if : public virtual tlm_nonblocking_get_if, + public virtual tlm_nonblocking_peek_if +{}; + +template +class tlm_get_peek_if : public virtual tlm_get_if, + public virtual tlm_peek_if, public virtual tlm_blocking_get_peek_if, + public virtual tlm_nonblocking_get_peek_if +{}; } // namespace tlm #endif +/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM1_INTERFACES_TLM_CORE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h index d9b2b985b..57418ae92 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h @@ -17,17 +17,15 @@ *****************************************************************************/ -// -// Note to the LRM writer : These interfaces are channel specific interfaces -// useful in the context of tlm_fifo. -// - -#ifndef __TLM_FIFO_IFS_H__ -#define __TLM_FIFO_IFS_H__ +#ifndef \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_FIFO_IFS_H__ +#define \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_FIFO_IFS_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h" -namespace tlm { +namespace tlm +{ // // Fifo specific interfaces @@ -35,51 +33,50 @@ namespace tlm { // Fifo Debug Interface -template< typename T > +template class tlm_fifo_debug_if : public virtual sc_core::sc_interface { -public: - virtual int used() const = 0; - virtual int size() const = 0; - virtual void debug() const = 0; - - // - // non blocking peek and poke - no notification - // - // n is index of data : - // 0 <= n < size(), where 0 is most recently written, and size() - 1 - // is oldest ie the one about to be read. - // - - virtual bool nb_peek( T & , int n ) const = 0; - virtual bool nb_poke( const T & , int n = 0 ) = 0; - + public: + virtual int used() const = 0; + virtual int size() const = 0; + virtual void debug() const = 0; + + // + // non blocking peek and poke - no notification + // + // n is index of data : + // 0 <= n < size(), where 0 is most recently written, and size() - 1 + // is oldest ie the one about to be read. + // + + virtual bool nb_peek(T &, int n) const = 0; + virtual bool nb_poke(const T&, int n=0) = 0; }; // fifo interfaces = extended + debug -template < typename T > -class tlm_fifo_put_if : - public virtual tlm_put_if , - public virtual tlm_fifo_debug_if {}; +template +class tlm_fifo_put_if : public virtual tlm_put_if, + public virtual tlm_fifo_debug_if +{}; -template < typename T > +template class tlm_fifo_get_if : - public virtual tlm_get_peek_if , - public virtual tlm_fifo_debug_if {}; + public virtual tlm_get_peek_if, + public virtual tlm_fifo_debug_if +{}; class tlm_fifo_config_size_if : public virtual sc_core::sc_interface { -public: - virtual void nb_expand( unsigned int n = 1 ) = 0; - virtual void nb_unbound( unsigned int n = 16 ) = 0; - - virtual bool nb_reduce( unsigned int n = 1 ) = 0; - virtual bool nb_bound( unsigned int n ) = 0; + public: + virtual void nb_expand(unsigned int n=1) = 0; + virtual void nb_unbound(unsigned int n=16) = 0; + virtual bool nb_reduce(unsigned int n=1) = 0; + virtual bool nb_bound(unsigned int n) = 0; }; } // namespace tlm #endif - +/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_FIFO_IFS_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h index 5bac3c877..29a89de47 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h @@ -17,57 +17,62 @@ *****************************************************************************/ -#ifndef __TLM_MASTER_SLAVE_IFS_H__ -#define __TLM_MASTER_SLAVE_IFS_H__ +#ifndef \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_MASTER_SLAVE_IFS_H__ +#define \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_MASTER_SLAVE_IFS_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h" -namespace tlm { +namespace tlm +{ // // req/rsp combined interfaces // -// blocking - -template < typename REQ , typename RSP> +// Blocking. +template class tlm_blocking_master_if : - public virtual tlm_blocking_put_if< REQ > , - public virtual tlm_blocking_get_peek_if< RSP > {}; + public virtual tlm_blocking_put_if, + public virtual tlm_blocking_get_peek_if +{}; -template < typename REQ , typename RSP> +template class tlm_blocking_slave_if : - public virtual tlm_blocking_put_if< RSP > , - public virtual tlm_blocking_get_peek_if< REQ > {}; - -// nonblocking + public virtual tlm_blocking_put_if, + public virtual tlm_blocking_get_peek_if +{}; -template < typename REQ , typename RSP > +// Nonblocking. +template class tlm_nonblocking_master_if : - public virtual tlm_nonblocking_put_if< REQ > , - public virtual tlm_nonblocking_get_peek_if< RSP > {}; + public virtual tlm_nonblocking_put_if, + public virtual tlm_nonblocking_get_peek_if +{}; -template < typename REQ , typename RSP > +template class tlm_nonblocking_slave_if : - public virtual tlm_nonblocking_put_if< RSP > , - public virtual tlm_nonblocking_get_peek_if< REQ > {}; - -// combined - -template < typename REQ , typename RSP > -class tlm_master_if : - public virtual tlm_put_if< REQ > , - public virtual tlm_get_peek_if< RSP > , - public virtual tlm_blocking_master_if< REQ , RSP > , - public virtual tlm_nonblocking_master_if< REQ , RSP > {}; - -template < typename REQ , typename RSP > -class tlm_slave_if : - public virtual tlm_put_if< RSP > , - public virtual tlm_get_peek_if< REQ > , - public virtual tlm_blocking_slave_if< REQ , RSP > , - public virtual tlm_nonblocking_slave_if< REQ , RSP > {}; + public virtual tlm_nonblocking_put_if, + public virtual tlm_nonblocking_get_peek_if +{}; + +// Combined. +template +class tlm_master_if : public virtual tlm_put_if, + public virtual tlm_get_peek_if , + public virtual tlm_blocking_master_if, + public virtual tlm_nonblocking_master_if +{}; + +template +class tlm_slave_if : public virtual tlm_put_if, + public virtual tlm_get_peek_if, + public virtual tlm_blocking_slave_if, + public virtual tlm_nonblocking_slave_if +{}; } // namespace tlm #endif +/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_MASTER_SLAVE_IFS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h index 230b77d17..b19c904fb 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h @@ -17,15 +17,17 @@ *****************************************************************************/ -// -// Note to the LRM writer : This is part of the core TLM standard -// +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ -#ifndef __TLM_TAG_H__ -#define __TLM_TAG_H__ +namespace tlm +{ + +template +class tlm_tag +{}; -namespace tlm { -template class tlm_tag {}; } #endif +/* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_1_INTERFACES_TLM_TAG_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h index 13207187a..c81df4b15 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h @@ -17,89 +17,84 @@ *****************************************************************************/ -#ifndef __TLM_ADAPTERS_H__ -#define __TLM_ADAPTERS_H__ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h" -namespace tlm { - -template< typename REQ , typename RSP > -class tlm_transport_to_master : - public sc_core::sc_module , - public virtual tlm_transport_if< REQ , RSP > +namespace tlm { -public: - sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export; - sc_core::sc_port< tlm_master_if< REQ , RSP > > master_port; - - tlm_transport_to_master( sc_core::sc_module_name nm ) : - sc_core::sc_module( nm ) { - - target_export( *this ); - - } - - tlm_transport_to_master() : - sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name( "transport_to_master" ) ) ){ - - target_export( *this ); - - } - RSP transport( const REQ &req ) { - - mutex.lock(); - - master_port->put( req ); - rsp = master_port->get(); +template +class tlm_transport_to_master : public sc_core::sc_module, + public virtual tlm_transport_if +{ + public: + sc_core::sc_export> target_export; + sc_core::sc_port> master_port; + + tlm_transport_to_master(sc_core::sc_module_name nm) : + sc_core::sc_module(nm) + { + target_export( *this ); + } - mutex.unlock(); - return rsp; + tlm_transport_to_master() : + sc_core::sc_module(sc_core::sc_module_name( + sc_core::sc_gen_unique_name("transport_to_master"))) + { + target_export( *this ); + } - } + RSP + transport(const REQ &req) + { + mutex.lock(); + master_port->put(req); + rsp = master_port->get(); -private: - sc_core::sc_mutex mutex; - RSP rsp; + mutex.unlock(); + return rsp; + } + private: + sc_core::sc_mutex mutex; + RSP rsp; }; -template< typename REQ , typename RSP > +template class tlm_slave_to_transport : public sc_core::sc_module { -public: - - SC_HAS_PROCESS( tlm_slave_to_transport ); - - sc_core::sc_port< tlm_slave_if< REQ , RSP > > slave_port; - sc_core::sc_port< tlm_transport_if< REQ , RSP > > initiator_port; - - tlm_slave_to_transport( sc_core::sc_module_name nm ) : sc_core::sc_module( nm ) - {} - - tlm_slave_to_transport() : - sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("slave_to_transport") ) ) - {} - -private: - void run() { - - REQ req; - RSP rsp; - - while( true ) { - - slave_port->get( req ); - rsp = initiator_port->transport( req ); - slave_port->put( rsp ); - + public: + SC_HAS_PROCESS(tlm_slave_to_transport); + + sc_core::sc_port> slave_port; + sc_core::sc_port> initiator_port; + + tlm_slave_to_transport(sc_core::sc_module_name nm) : + sc_core::sc_module(nm) + {} + + tlm_slave_to_transport() : + sc_core::sc_module(sc_core::sc_module_name( + sc_core::sc_gen_unique_name("slave_to_transport"))) + {} + + private: + void + run() + { + REQ req; + RSP rsp; + + while (true) { + slave_port->get(req); + rsp = initiator_port->transport(req); + slave_port->put(rsp); + } } - - } - }; } // namespace tlm -#endif +#endif /* __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_ADAPTERS_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h index 50309e31b..c00fe4881 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h @@ -17,252 +17,239 @@ *****************************************************************************/ -// -// To the LRM writer : this class is purely an artifact of the implementation. -// - -#ifndef __CIRCULAR_BUFFER_H__ -#define __CIRCULAR_BUFFER_H__ +#ifndef \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ +#define \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ #include -namespace tlm { +namespace tlm +{ -template < typename T > +template class circular_buffer { -public: - - explicit - circular_buffer( int size = 0 ); - ~circular_buffer(); - - void resize( int size ); - void clear(); - - T read(); - void write( const T & ); - - bool is_empty() const { return used() == 0; } - bool is_full() const { return free() == 0; } - - int size() const { return m_size; } - int used() const { return m_used; } - int free() const { return m_free; } - - const T& read_data() const - { return buf_read( m_buf, m_ri ); } - - const T& peek_data( int i ) const - { return buf_read( m_buf, (m_ri + i) % size() ); } - - T & poke_data( int i ) - { return buf_read( m_buf , (m_wi + i) % size() ); } - - void debug() const; - -private: - void increment_write_pos( int i = 1 ); - void increment_read_pos( int i = 1 ); - - void init(); - - circular_buffer( const circular_buffer &b ); // disabled - circular_buffer &operator=( const circular_buffer & ); // disabled - - void* buf_alloc( int size ); - void buf_free( void*& buf ); - void buf_write( void* buf, int n, const T & t ); - T& buf_read( void* buf, int n ) const; - void buf_clear( void* buf, int n ); - -private: - int m_size; // size of the buffer - void* m_buf; // the buffer - int m_free; // number of free spaces - int m_used; // number of used spaces - int m_ri; // index of next read - int m_wi; // index of next write - + public: + explicit circular_buffer(int size=0); + ~circular_buffer(); + + void resize(int size); + void clear(); + + T read(); + void write(const T &); + + bool is_empty() const { return used() == 0; } + bool is_full() const { return free() == 0; } + + int size() const { return m_size; } + int used() const { return m_used; } + int free() const { return m_free; } + + const T &read_data() const { return buf_read(m_buf, m_ri); } + const T & + peek_data(int i) const + { + return buf_read(m_buf, (m_ri + i) % size()); + } + + T & + poke_data(int i) + { + return buf_read(m_buf, (m_wi + i) % size()); + } + + void debug() const; + + private: + void increment_write_pos(int i=1); + void increment_read_pos(int i=1); + + void init(); + + // Disabled. + circular_buffer(const circular_buffer &b); + circular_buffer &operator = (const circular_buffer &); + + void *buf_alloc(int size); + void buf_free(void *&buf); + void buf_write(void *buf, int n, const T &t); + T &buf_read(void *buf, int n) const; + void buf_clear(void *buf, int n); + + private: + int m_size; // size of the buffer + void *m_buf; // the buffer + int m_free; // number of free spaces + int m_used; // number of used spaces + int m_ri; // index of next read + int m_wi; // index of next write }; -template< typename T > +template void circular_buffer::debug() const { - - std::cout << "Buffer debug" << std::endl; - std::cout << "Size : " << size() << std::endl; - std::cout << "Free/Used " << free() << "/" << used() << std::endl; - std::cout << "Indices : r/w = " << m_ri << "/" << m_wi << std::endl; - - if( is_empty() ) { - - std::cout << "empty" << std::endl; - - } - - if( is_full() ) { - - std::cout << "full" << std::endl; - - } - - std::cout << "Data : " << std::endl; - for( int i = 0; i < used(); i++ ) { - - std::cout << peek_data( i ) << std::endl; - - } - - + std::cout << "Buffer debug" << std::endl; + std::cout << "Size : " << size() << std::endl; + std::cout << "Free/Used " << free() << "/" << used() << std::endl; + std::cout << "Indices : r/w = " << m_ri << "/" << m_wi << std::endl; + + if (is_empty()) { + std::cout << "empty" << std::endl; + } + + if (is_full()) { + std::cout << "full" << std::endl; + } + + std::cout << "Data : " << std::endl; + for (int i = 0; i < used(); i++) { + std::cout << peek_data( i ) << std::endl; + } } -template < typename T > -circular_buffer::circular_buffer( int size ) - : m_size(size) - , m_buf(0) +template +circular_buffer::circular_buffer(int size) : m_size(size), m_buf(0) { - init(); - + init(); } -template < typename T > +template void circular_buffer::clear() { - for( int i=0; i < used(); i++ ) { - buf_clear( m_buf, (m_ri + i) % m_size ); - } - m_free = m_size; - m_used = m_ri = m_wi = 0; + for (int i = 0; i < used(); i++) { + buf_clear(m_buf, (m_ri + i) % m_size); + } + m_free = m_size; + m_used = m_ri = m_wi = 0; } -template < typename T > +template circular_buffer::~circular_buffer() { - clear(); - buf_free( m_buf ); + clear(); + buf_free(m_buf); } -template < typename T > +template void -circular_buffer::resize( int size ) +circular_buffer::resize(int size) { + int i; + void *new_buf = buf_alloc(size); - int i; - void * new_buf = buf_alloc(size); - - for( i = 0; i < size && i < used(); i++ ) { + for (i = 0; i < size && i < used(); i++) { + buf_write(new_buf, i, peek_data(i)); + buf_clear(m_buf, (m_ri + i) % m_size); + } - buf_write( new_buf, i, peek_data( i ) ); - buf_clear( m_buf, (m_ri + i) % m_size ); + buf_free(m_buf); - } + m_size = size; + m_ri = 0; + m_wi = i % m_size; + m_used = i; + m_free = m_size - m_used; - buf_free( m_buf ); - - m_size = size; - m_ri = 0; - m_wi = i % m_size; - m_used = i; - m_free = m_size - m_used; - - m_buf = new_buf; + m_buf = new_buf; } -template < typename T > +template void -circular_buffer::init() { - - if( m_size > 0 ) { - m_buf = buf_alloc( m_size ); - } - - m_free = m_size; - m_used = 0; - m_ri = 0; - m_wi = 0; - +circular_buffer::init() +{ + if (m_size > 0) { + m_buf = buf_alloc(m_size); + } + + m_free = m_size; + m_used = 0; + m_ri = 0; + m_wi = 0; } -template < typename T > +template T circular_buffer::read() { - T t = read_data(); + T t = read_data(); - buf_clear( m_buf, m_ri ); - increment_read_pos(); + buf_clear(m_buf, m_ri); + increment_read_pos(); - return t; + return t; } -template < typename T > +template void -circular_buffer::write( const T &t ) +circular_buffer::write(const T &t) { - buf_write( m_buf, m_wi, t ); - increment_write_pos(); + buf_write(m_buf, m_wi, t); + increment_write_pos(); } - -template < typename T > +template void -circular_buffer::increment_write_pos( int i ) { - - m_wi = ( m_wi + i ) % m_size; - m_used += i; - m_free -= i; - +circular_buffer::increment_write_pos(int i) +{ + m_wi = (m_wi + i) % m_size; + m_used += i; + m_free -= i; } -template < typename T > +template void -circular_buffer::increment_read_pos( int i ) { - - m_ri = ( m_ri + i ) % m_size; - m_used -= i; - m_free += i; - +circular_buffer::increment_read_pos(int i) +{ + m_ri = (m_ri + i) % m_size; + m_used -= i; + m_free += i; } -template < typename T > -inline void* -circular_buffer::buf_alloc( int size ) - { return new unsigned char[ size * sizeof(T) ]; } +template +inline void * +circular_buffer::buf_alloc(int size) +{ + return new unsigned char [size * sizeof(T)]; +} -template < typename T > +template inline void -circular_buffer::buf_free( void* & buf ) - { delete [] static_cast(buf); buf = 0; } +circular_buffer::buf_free(void *&buf) +{ + delete [] static_cast(buf); + buf = nullptr; +} -template < typename T > +template inline void -circular_buffer::buf_write( void* buf, int n, const T & t ) +circular_buffer::buf_write(void *buf, int n, const T &t) { - T* p = static_cast(buf) + n; - new (p) T(t); + T *p = static_cast(buf) + n; + new (p)T(t); } -template < typename T > -inline T& -circular_buffer::buf_read( void* buf, int n ) const +template +inline T & +circular_buffer::buf_read(void *buf, int n) const { - T* p = static_cast(buf) + n; - return *p; + T *p = static_cast(buf) + n; + return *p; } -template < typename T > +template inline void -circular_buffer::buf_clear( void* buf, int n ) +circular_buffer::buf_clear(void *buf, int n) { - T* p = static_cast(buf) + n; - p->~T(); + T *p = static_cast(buf) + n; + p->~T(); } } // namespace tlm #endif - +/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_CIRCULAR_BUFFER_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h index 7b44a32ee..25a183459 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h @@ -17,8 +17,10 @@ *****************************************************************************/ -#ifndef __TLM_FIFO_H__ -#define __TLM_FIFO_H__ +#ifndef \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_H__ +#define \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_H__ // // This implements put, get and peek @@ -34,171 +36,147 @@ // actual physical buffer. // -//#include - #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_fifo_ifs.h" #include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/circular_buffer.h" -namespace tlm { +namespace tlm +{ template -class tlm_fifo : - public virtual tlm_fifo_get_if, - public virtual tlm_fifo_put_if, - public sc_core::sc_prim_channel +class tlm_fifo : public virtual tlm_fifo_get_if, + public virtual tlm_fifo_put_if, public sc_core::sc_prim_channel { -public: - - // constructors - - explicit tlm_fifo( int size_ = 1 ) - : sc_core::sc_prim_channel( sc_core::sc_gen_unique_name( "fifo" ) ) { - - init( size_ ); - + public: + // Constructors. + explicit tlm_fifo(int size_=1) : + sc_core::sc_prim_channel(sc_core::sc_gen_unique_name("fifo")) + { + init(size_); } - explicit tlm_fifo( const char* name_, int size_ = 1 ) - : sc_core::sc_prim_channel( name_ ) { - - init( size_ ); - + explicit tlm_fifo(const char *name_, int size_=1) : + sc_core::sc_prim_channel(name_) + { + init(size_); } - // destructor - + // Destructor.. virtual ~tlm_fifo() {} - // tlm get interface - - T get( tlm_tag * = 0 ); + // Tlm get interface. + T get(tlm_tag * =nullptr); - bool nb_get( T& ); - bool nb_can_get( tlm_tag * = 0 ) const; - const sc_core::sc_event &ok_to_get( tlm_tag * = 0 ) const { - return m_data_written_event; + bool nb_get(T &); + bool nb_can_get(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_get(tlm_tag * =nullptr) const + { + return m_data_written_event; } - // tlm peek interface + // Tlm peek interface. + T peek(tlm_tag * =nullptr) const; - T peek( tlm_tag * = 0 ) const; - - bool nb_peek( T& ) const; - bool nb_can_peek( tlm_tag * = 0 ) const; - const sc_core::sc_event &ok_to_peek( tlm_tag * = 0 ) const { - return m_data_written_event; + bool nb_peek(T &) const; + bool nb_can_peek(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_peek(tlm_tag * =nullptr) const + { + return m_data_written_event; } - // tlm put interface - - void put( const T& ); - - bool nb_put( const T& ); - bool nb_can_put( tlm_tag * = 0 ) const; + // Tlm put interface. + void put(const T &); - const sc_core::sc_event& ok_to_put( tlm_tag * = 0 ) const { - return m_data_read_event; + bool nb_put(const T &); + bool nb_can_put(tlm_tag * =nullptr) const; + const sc_core::sc_event & + ok_to_put(tlm_tag * =nullptr) const + { + return m_data_read_event; } - // resize if - - void nb_expand( unsigned int n = 1 ); - void nb_unbound( unsigned int n = 16 ); - - bool nb_reduce( unsigned int n = 1 ); - bool nb_bound( unsigned int n ); - - // debug interface - - bool nb_peek( T & , int n ) const; - bool nb_poke( const T & , int n = 0 ); - - int used() const { - return m_num_readable - m_num_read; - } - - int size() const { - return m_size; + // Resize if. + void nb_expand(unsigned int n=1); + void nb_unbound(unsigned int n=16); + + bool nb_reduce(unsigned int n=1); + bool nb_bound(unsigned int n); + + // Debug interface. + bool nb_peek(T &, int n) const; + bool nb_poke(const T &, int n=0); + + int used() const { return m_num_readable - m_num_read; } + int size() const { return m_size; } + + void + debug() const + { + if (is_empty()) + std::cout << "empty" << std::endl; + if (is_full()) + std::cout << "full" << std::endl; + + std::cout << "size " << size() << " - " << used() << " used " + << std::endl; + std::cout << "readable " << m_num_readable << std::endl; + std::cout << "written/read " << m_num_written << "/" << m_num_read + << std::endl; } - void debug() const { - - if( is_empty() ) std::cout << "empty" << std::endl; - if( is_full() ) std::cout << "full" << std::endl; - - std::cout << "size " << size() << " - " << used() << " used " - << std::endl; - std::cout << "readable " << m_num_readable - << std::endl; - std::cout << "written/read " << m_num_written << "/" << m_num_read - << std::endl; + // Support functions. + static const char * const kind_string; + const char *kind() const { return kind_string; } + protected: + sc_core::sc_event & + read_event(tlm_tag * =nullptr) + { + return m_data_read_event; } - // support functions - - static const char* const kind_string; - - const char* kind() const - { return kind_string; } - - -protected: - sc_core::sc_event &read_event( tlm_tag * = 0 ) { - return m_data_read_event; - } - -protected: - void update(); - - // support methods - - void init( int ); - -protected: + void init(int); circular_buffer buffer; - int m_size; // logical size of fifo + int m_size; // logical size of fifo - int m_num_readable; // #samples readable - int m_num_read; // #samples read during this delta cycle - int m_num_written; // #samples written during this delta cycle - bool m_expand; // has an expand occurred during this delta cycle ? - int m_num_read_no_notify; // #samples read without notify during this delta cycle + int m_num_readable; // #samples readable + int m_num_read; // #samples read during this delta cycle + int m_num_written; // #samples written during this delta cycle + bool m_expand; // has an expand occurred during this delta cycle ? + // #samples read without notify during this delta cycle + int m_num_read_no_notify; sc_core::sc_event m_data_read_event; sc_core::sc_event m_data_written_event; -private: - + private: // disabled - tlm_fifo( const tlm_fifo& ); - tlm_fifo& operator = ( const tlm_fifo& ); + tlm_fifo(const tlm_fifo &); + tlm_fifo &operator = (const tlm_fifo &); // // use nb_can_get() and nb_can_put() rather than the following two // private functions // - bool is_empty() const { - return used() == 0; - } + bool is_empty() const { return used() == 0; } - bool is_full() const { - //return size() == m_num_readable + m_num_written; // Old buggy code - if( size() < 0 ) - return false; - else - return size() <= m_num_readable + m_num_written; + bool + is_full() const + { + if (size() < 0) + return false; + else + return size() <= m_num_readable + m_num_written; } - }; template -const char* const tlm_fifo::kind_string = "tlm_fifo"; - +const char *const tlm_fifo::kind_string = "tlm_fifo"; /****************************************************************** // @@ -206,43 +184,36 @@ const char* const tlm_fifo::kind_string = "tlm_fifo"; // ******************************************************************/ -template< typename T > -inline -void -tlm_fifo::init( int size_ ) { - - if( size_ > 0 ) { - buffer.resize( size_ ); - } - - else if( size_ < 0 ) { - buffer.resize( -size_ ); - } - - else { - buffer.resize( 16 ); - } - - m_size = size_; - m_num_readable = 0; - m_num_read = 0; - m_num_written = 0; - m_expand = false; - m_num_read_no_notify = false; +template +inline void +tlm_fifo::init(int size_) +{ + if (size_ > 0) { + buffer.resize( size_ ); + } else if (size_ < 0) { + buffer.resize(-size_); + } else { + buffer.resize(16); + } + m_size = size_; + m_num_readable = 0; + m_num_read = 0; + m_num_written = 0; + m_expand = false; + m_num_read_no_notify = false; } -template < typename T> -inline -void +template +inline void tlm_fifo::update() { - if( m_num_read > m_num_read_no_notify || m_expand ) { - m_data_read_event.notify( sc_core::SC_ZERO_TIME ); + if (m_num_read > m_num_read_no_notify || m_expand) { + m_data_read_event.notify(sc_core::SC_ZERO_TIME); } - if( m_num_written > 0 ) { - m_data_written_event.notify( sc_core::SC_ZERO_TIME ); + if (m_num_written > 0) { + m_data_written_event.notify(sc_core::SC_ZERO_TIME); } m_expand = false; @@ -250,7 +221,6 @@ tlm_fifo::update() m_num_written = 0; m_num_readable = buffer.used(); m_num_read_no_notify = 0; - } } // namespace tlm @@ -260,4 +230,4 @@ tlm_fifo::update() #include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h" #endif - +/*__SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h index e856c5657..540f72de6 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h @@ -17,82 +17,74 @@ *****************************************************************************/ -#ifndef __TLM_FIFO_PEEK_H__ -#define __TLM_FIFO_PEEK_H__ +#ifndef \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ +#define \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ -namespace tlm { - -template < typename T> -inline -T -tlm_fifo::peek( tlm_tag * ) const { - - while( is_empty() ) { - - // call free-standing sc_core::wait(), - // since sc_prim_channel::wait(.) is not const - - sc_core::wait( m_data_written_event ); - } - - return buffer.read_data(); +namespace tlm +{ +template +inline T +tlm_fifo::peek(tlm_tag *) const +{ + while (is_empty()) { + // call free-standing sc_core::wait(), + // since sc_prim_channel::wait(.) is not const + sc_core::wait(m_data_written_event); + } + return buffer.read_data(); } -template < typename T> -inline -bool -tlm_fifo::nb_peek( T &t ) const { - - if( used() < 1 ) { - return false; - } - - t = buffer.peek_data( 0 ); - return true; +template +inline bool +tlm_fifo::nb_peek(T &t) const +{ + if (used() < 1) { + return false; + } + t = buffer.peek_data(0); + return true; } -template < typename T> -inline -bool -tlm_fifo::nb_peek( T &t , int n ) const { - - if( n >= used() || n < -1 ) { - return false; - } - - if( n == -1 ) { - n = used() - 1; - } +template +inline bool +tlm_fifo::nb_peek(T &t, int n) const +{ + if (n >= used() || n < -1) { + return false; + } - t = buffer.peek_data( n ); - return true; + if (n == -1) { + n = used() - 1; + } + t = buffer.peek_data(n); + return true; } -template< typename T > -inline -bool -tlm_fifo::nb_can_peek( tlm_tag * ) const +template +inline bool +tlm_fifo::nb_can_peek(tlm_tag *) const { - return !is_empty(); + return !is_empty(); } -template < typename T> -inline -bool -tlm_fifo::nb_poke( const T &t , int n ) { - - if( n >= used() || n < 0 ) { - return false; - } - - buffer.poke_data( n ) = t; - return true; +template +inline bool +tlm_fifo::nb_poke(const T &t, int n) +{ + if (n >= used() || n < 0) { + return false; + } + buffer.poke_data(n) = t; + return true; } } // namespace tlm #endif +/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PEEK_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h index 2728e0394..a9a8ee3f4 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_put_get.h @@ -17,124 +17,100 @@ *****************************************************************************/ -#ifndef __TLM_FIFO_PUT_GET_IF_H__ -#define __TLM_FIFO_PUT_GET_IF_H__ +#ifndef \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ +#define \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ -namespace tlm { - -/****************************************************************** -// -// get interface -// -******************************************************************/ +namespace tlm +{ +// Get interface. template -inline -T -tlm_fifo::get( tlm_tag * ) +inline T +tlm_fifo::get(tlm_tag *) { + while (is_empty()) { + wait(m_data_written_event); + } - while( is_empty() ) { - wait( m_data_written_event ); - } - - m_num_read ++; - request_update(); - - return buffer.read(); + m_num_read++; + request_update(); + return buffer.read(); } -// non-blocking read - +// Non-blocking read. template -inline -bool -tlm_fifo::nb_get( T& val_ ) +inline bool +tlm_fifo::nb_get(T &val_) { + if (is_empty()) { + return false; + } - if( is_empty() ) { - return false; - } - - m_num_read ++; - request_update(); - - val_ = buffer.read(); + m_num_read++; + request_update(); - return true; + val_ = buffer.read(); + return true; } template -inline -bool -tlm_fifo::nb_can_get( tlm_tag * ) const { - - return !is_empty(); - +inline bool +tlm_fifo::nb_can_get(tlm_tag *) const +{ + return !is_empty(); } -/****************************************************************** -// -// put interface -// -******************************************************************/ - +// Put interface. template -inline -void -tlm_fifo::put( const T& val_ ) +inline void +tlm_fifo::put(const T &val_) { - while( is_full() ) { - wait( m_data_read_event ); + while (is_full()) { + wait(m_data_read_event); } - if( buffer.is_full() ) { - - buffer.resize( buffer.size() * 2 ); - + if (buffer.is_full()) { + buffer.resize(buffer.size() * 2); } - m_num_written ++; - buffer.write( val_ ); + m_num_written++; + buffer.write(val_); request_update(); } template -inline -bool -tlm_fifo::nb_put( const T& val_ ) +inline bool +tlm_fifo::nb_put(const T &val_) { + if (is_full()) { + return false; + } - if( is_full() ) { - return false; - } - - if( buffer.is_full() ) { - - buffer.resize( buffer.size() * 2 ); - - } + if (buffer.is_full()) { + buffer.resize(buffer.size() * 2); + } - m_num_written ++; - buffer.write( val_ ); - request_update(); + m_num_written++; + buffer.write(val_); + request_update(); - return true; + return true; } -template < typename T > -inline -bool -tlm_fifo::nb_can_put( tlm_tag * ) const { - - return !is_full(); - +template +inline bool +tlm_fifo::nb_can_put(tlm_tag *) const +{ + return !is_full(); } } // namespace tlm #endif +/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_PUT_GET_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h index 39932fea1..79292fd78 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h @@ -17,77 +17,67 @@ *****************************************************************************/ -#ifndef __TLM_FIFO_RESIZE_H__ -#define __TLM_FIFO_RESIZE_H__ - -/****************************************************************** -// -// resize interface -// -******************************************************************/ - -namespace tlm { - -template < typename T> -inline -void -tlm_fifo::nb_expand( unsigned int n ) { - - if( m_size >= 0 ) { - m_expand = true; - m_size += n; - request_update(); - } +#ifndef \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ +#define \ + __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ + +// Resize interface. +namespace tlm +{ + +template +inline void +tlm_fifo::nb_expand(unsigned int n) +{ + if (m_size >= 0) { + m_expand = true; + m_size += n; + request_update(); + } } -template < typename T> -inline -void -tlm_fifo::nb_unbound( unsigned int n ) { - - m_expand = true; - m_size = -n; - - if( buffer.size() < static_cast( n ) ) { - buffer.resize( n ); - } +template +inline void +tlm_fifo::nb_unbound(unsigned int n) +{ + m_expand = true; + m_size = -n; - request_update(); + if (buffer.size() < static_cast(n)) { + buffer.resize(n); + } + request_update(); } -template < typename T> -inline -bool -tlm_fifo::nb_reduce( unsigned int n ) { - - if( m_size < 0 ) { - return false; - } - - return nb_bound( size() - n ); +template +inline bool +tlm_fifo::nb_reduce(unsigned int n) +{ + if (m_size < 0) { + return false; + } + return nb_bound(size() - n); } -template < typename T> -inline -bool -tlm_fifo::nb_bound( unsigned int new_size ) { - - bool ret = true; - - if( static_cast( new_size ) < used() ) { - - new_size = used(); - ret = false; - - } +template +inline bool +tlm_fifo::nb_bound(unsigned int new_size) +{ + bool ret = true; - m_size = new_size; - return ret; + if (static_cast(new_size) < used()) { + new_size = used(); + ret = false; + } + m_size = new_size; + return ret; } } // namespace tlm #endif +/* __TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_FIFO_TLM_FIFO_RESIZE_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h index 36dbd21d6..8335cc85c 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h @@ -17,98 +17,99 @@ *****************************************************************************/ -// -// To the LRM writer : these classes are purely artifacts of the implementation. -// - -#ifndef __TLM_PUT_GET_IMP_H__ -#define __TLM_PUT_GET_IMP_H__ +#ifndef \ + __TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ +#define \ + __TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h" -namespace tlm { - -template < typename PUT_DATA , typename GET_DATA> -class tlm_put_get_imp : - private virtual tlm_put_if< PUT_DATA > , - private virtual tlm_get_peek_if< GET_DATA > +namespace tlm { -public: - tlm_put_get_imp( tlm_put_if &p , - tlm_get_peek_if &g ) : - put_fifo( p ) , get_fifo( g ) {} - - // put interface - - void put( const PUT_DATA &t ) { put_fifo.put( t ); } - - bool nb_put( const PUT_DATA &t ) { return put_fifo.nb_put( t ); } - bool nb_can_put( tlm_tag *t = 0 ) const { - return put_fifo.nb_can_put( t ); - } - const sc_core::sc_event &ok_to_put( tlm_tag *t = 0 ) const { - return put_fifo.ok_to_put( t ); - } - - // get interface - - GET_DATA get( tlm_tag * = 0 ) { return get_fifo.get(); } - - bool nb_get( GET_DATA &t ) { return get_fifo.nb_get( t ); } - - bool nb_can_get( tlm_tag *t = 0 ) const { - return get_fifo.nb_can_get( t ); - } - - virtual const sc_core::sc_event &ok_to_get( tlm_tag *t = 0 ) const { - return get_fifo.ok_to_get( t ); - } - // peek interface - - GET_DATA peek( tlm_tag * = 0 ) const { return get_fifo.peek(); } - - bool nb_peek( GET_DATA &t ) const { return get_fifo.nb_peek( t ); } - - bool nb_can_peek( tlm_tag *t = 0 ) const { - return get_fifo.nb_can_peek( t ); - } - - virtual const sc_core::sc_event &ok_to_peek( tlm_tag *t = 0 ) const { - return get_fifo.ok_to_peek( t ); - } - -private: - tlm_put_if &put_fifo; - tlm_get_peek_if &get_fifo; +template +class tlm_put_get_imp : private virtual tlm_put_if, + private virtual tlm_get_peek_if +{ + public: + tlm_put_get_imp(tlm_put_if &p, tlm_get_peek_if &g) : + put_fifo(p), get_fifo(g) + {} + + // Put interface. + void put(const PUT_DATA &t) { put_fifo.put(t); } + bool nb_put(const PUT_DATA &t) { return put_fifo.nb_put(t); } + bool + nb_can_put(tlm_tag *t=nullptr) const + { + return put_fifo.nb_can_put(t); + } + const sc_core::sc_event & + ok_to_put(tlm_tag *t=nullptr) const + { + return put_fifo.ok_to_put(t); + } + + // Get interface. + GET_DATA get(tlm_tag * =nullptr) { return get_fifo.get(); } + bool nb_get(GET_DATA &t) { return get_fifo.nb_get(t); } + bool + nb_can_get(tlm_tag *t=nullptr) const + { + return get_fifo.nb_can_get(t); + } + + virtual const sc_core::sc_event & + ok_to_get(tlm_tag *t=nullptr) const + { + return get_fifo.ok_to_get(t); + } + + // Peek interface. + GET_DATA + peek(tlm_tag * =nullptr) const + { + return get_fifo.peek(); + } + bool nb_peek(GET_DATA &t) const { return get_fifo.nb_peek(t); } + bool + nb_can_peek(tlm_tag *t=nullptr) const + { + return get_fifo.nb_can_peek(t); + } + + virtual const sc_core::sc_event & + ok_to_peek(tlm_tag *t=nullptr) const + { + return get_fifo.ok_to_peek(t); + } + + private: + tlm_put_if &put_fifo; + tlm_get_peek_if &get_fifo; }; -template < typename REQ , typename RSP > -class tlm_master_imp : - private tlm_put_get_imp< REQ , RSP > , - public virtual tlm_master_if< REQ , RSP > +template +class tlm_master_imp : private tlm_put_get_imp, + public virtual tlm_master_if { -public: - - tlm_master_imp( tlm_put_if &req , - tlm_get_peek_if &rsp ) : - tlm_put_get_imp( req , rsp ) {} - + public: + tlm_master_imp(tlm_put_if &req, tlm_get_peek_if &rsp) : + tlm_put_get_imp(req, rsp) + {} }; -template < typename REQ , typename RSP > -class tlm_slave_imp : - private tlm_put_get_imp< RSP , REQ > , - public virtual tlm_slave_if< REQ , RSP > +template +class tlm_slave_imp : private tlm_put_get_imp, + public virtual tlm_slave_if { -public: - - tlm_slave_imp( tlm_get_peek_if &req , - tlm_put_if &rsp ) : - tlm_put_get_imp( rsp , req ) {} - + public: + tlm_slave_imp(tlm_get_peek_if &req, tlm_put_if &rsp) : + tlm_put_get_imp(rsp, req) + {} }; } // namespace tlm #endif +/* __TLM_1_TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_PUT_GET_IMP_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h index 7bd5652f7..1548e0852 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h @@ -17,139 +17,124 @@ *****************************************************************************/ -#ifndef __TLM_REQ_RSP_CHANNELS_H__ -#define __TLM_REQ_RSP_CHANNELS_H__ +#ifndef \ + __TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_REQ_RSP_CHANNELS_H__ +#define \ + __TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_REQ_RSP_CHANNELS_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h" #include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h" #include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h" -namespace tlm { - -template < typename REQ , typename RSP , - typename REQ_CHANNEL = tlm_fifo , - typename RSP_CHANNEL = tlm_fifo > +namespace tlm +{ +template , + typename RSP_CHANNEL=tlm_fifo> class tlm_req_rsp_channel : public sc_core::sc_module { -public: - // uni-directional slave interface - - sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export; - sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export; - - // uni-directional master interface - - sc_core::sc_export< tlm_fifo_put_if< REQ > > put_request_export; - sc_core::sc_export< tlm_fifo_get_if< RSP > > get_response_export; - - // master / slave interfaces - - sc_core::sc_export< tlm_master_if< REQ , RSP > > master_export; - sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export; - - - tlm_req_rsp_channel( int req_size = 1 , int rsp_size = 1 ) : - sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("tlm_req_rsp_channel") ) ) , - request_fifo( req_size ) , - response_fifo( rsp_size ) , - master( request_fifo , response_fifo ) , - slave( request_fifo , response_fifo ) - { - - bind_exports(); - - } - - tlm_req_rsp_channel( sc_core::sc_module_name module_name , - int req_size = 1 , int rsp_size = 1 ) : - sc_core::sc_module( module_name ) , - request_fifo( req_size ) , - response_fifo( rsp_size ) , - master( request_fifo , response_fifo ) , - slave( request_fifo , response_fifo ) - { - - bind_exports(); - - } - -private: - void bind_exports() { - - put_request_export( request_fifo ); - get_request_export( request_fifo ); - - put_response_export( response_fifo ); - get_response_export( response_fifo ); - - master_export( master ); - slave_export( slave ); - - } - -protected: - REQ_CHANNEL request_fifo; - RSP_CHANNEL response_fifo; - - tlm_master_imp< REQ , RSP > master; - tlm_slave_imp< REQ , RSP > slave; + public: + // Uni-directional slave interface. + sc_core::sc_export> get_request_export; + sc_core::sc_export> put_response_export; + + // Uni-directional master interface. + sc_core::sc_export> put_request_export; + sc_core::sc_export> get_response_export; + + // Master/slave interfaces. + sc_core::sc_export> master_export; + sc_core::sc_export> slave_export; + + tlm_req_rsp_channel(int req_size=1, int rsp_size=1) : + sc_core::sc_module(sc_core::sc_module_name( + sc_core::sc_gen_unique_name("tlm_req_rsp_channel"))), + request_fifo(req_size), response_fifo(rsp_size), + master(request_fifo, response_fifo), + slave(request_fifo, response_fifo) + { + bind_exports(); + } + + tlm_req_rsp_channel(sc_core::sc_module_name module_name, + int req_size=1, int rsp_size=1) : + sc_core::sc_module(module_name), + request_fifo(req_size), response_fifo(rsp_size), + master(request_fifo, response_fifo), + slave(request_fifo, response_fifo) + { + bind_exports(); + } + + private: + void + bind_exports() + { + put_request_export(request_fifo); + get_request_export(request_fifo); + + put_response_export(response_fifo); + get_response_export(response_fifo); + + master_export(master); + slave_export(slave); + } + + protected: + REQ_CHANNEL request_fifo; + RSP_CHANNEL response_fifo; + + tlm_master_imp master; + tlm_slave_imp slave; }; -template < typename REQ , typename RSP , - typename REQ_CHANNEL = tlm_fifo , - typename RSP_CHANNEL = tlm_fifo > +template , + typename RSP_CHANNEL=tlm_fifo> class tlm_transport_channel : public sc_core::sc_module { -public: - - // master transport interface - - sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export; - - // slave interfaces - - sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export; - sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export; - - sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export; - - tlm_transport_channel() : - sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("transport_channel" ) ) ) , - target_export("target_export") , - req_rsp( "req_rsp" , 1 , 1 ) , - t2m("ts2m") - { - do_binding(); - } - - tlm_transport_channel( sc_core::sc_module_name nm ) : - sc_core::sc_module( nm ) , - target_export("target_export") , - req_rsp( "req_rsp" , 1 , 1 ) , - t2m("tsm" ) - { - do_binding(); - } - -private: - void do_binding() { - - target_export( t2m.target_export ); - - t2m.master_port( req_rsp.master_export ); - - get_request_export( req_rsp.get_request_export ); - put_response_export( req_rsp.put_response_export ); - slave_export( req_rsp.slave_export ); - - } - - tlm_req_rsp_channel< REQ , RSP , REQ_CHANNEL , RSP_CHANNEL > req_rsp; - tlm_transport_to_master< REQ , RSP > t2m; - + public: + // Master transport interface. + sc_core::sc_export> target_export; + + // Slave interfaces. + sc_core::sc_export> get_request_export; + sc_core::sc_export> put_response_export; + + sc_core::sc_export> slave_export; + + tlm_transport_channel() : + sc_core::sc_module(sc_core::sc_module_name( + sc_core::sc_gen_unique_name("transport_channel"))), + target_export("target_export"), req_rsp("req_rsp", 1, 1), t2m("ts2m") + { + do_binding(); + } + + tlm_transport_channel(sc_core::sc_module_name nm) : + sc_core::sc_module(nm), target_export("target_export"), + req_rsp("req_rsp", 1, 1), t2m("tsm") + { + do_binding(); + } + + private: + void + do_binding() + { + target_export(t2m.target_export); + t2m.master_port(req_rsp.master_export); + + get_request_export(req_rsp.get_request_export); + put_response_export(req_rsp.put_response_export); + slave_export(req_rsp.slave_export); + } + + tlm_req_rsp_channel req_rsp; + tlm_transport_to_master t2m; }; } // namespace tlm #endif +/* __TLM_REQ_RSP_TLM_CHANNELS_TLM_REQ_RSP_CHANNELS_TLM_REQ_RSP_CHANNELS_H__ */ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h index 4ca042857..75d7ffdde 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h @@ -17,60 +17,53 @@ *****************************************************************************/ -#ifndef TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_ -#define TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ +#define __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h" -namespace tlm { - -template -class tlm_event_finder_t - : public sc_core::sc_event_finder +namespace tlm { -public: - - // constructor - - tlm_event_finder_t( const sc_core::sc_port_base& port_, - const sc_core::sc_event& (IF::*event_method_) ( tlm_tag * ) const ) - : sc_core::sc_event_finder( port_ ), m_event_method( event_method_ ) - {} - - // destructor (does nothing) - virtual ~tlm_event_finder_t() - {} - - virtual const sc_core::sc_event& find_event( sc_core::sc_interface* if_p = 0 ) const; +template +class tlm_event_finder_t : public sc_core::sc_event_finder +{ + public: + tlm_event_finder_t(const sc_core::sc_port_base &port_, + const sc_core::sc_event &(IF::*event_method_)( + tlm_tag *) const) : + sc_core::sc_event_finder(port_), m_event_method(event_method_) + {} -private: + virtual ~tlm_event_finder_t() {} - const sc_core::sc_event& (IF::*m_event_method) ( tlm_tag * ) const; + virtual const sc_core::sc_event & + find_event(sc_core::sc_interface *if_p=nullptr) const; -private: + private: + const sc_core::sc_event &(IF::*m_event_method)(tlm_tag *) const; + private: // disabled tlm_event_finder_t(); - tlm_event_finder_t( const tlm_event_finder_t& ); - tlm_event_finder_t& operator = ( const tlm_event_finder_t& ); + tlm_event_finder_t(const tlm_event_finder_t &); + tlm_event_finder_t &operator = (const tlm_event_finder_t &); }; - -template -inline -const sc_core::sc_event& -tlm_event_finder_t::find_event( sc_core::sc_interface* if_p ) const +template +inline const sc_core::sc_event & +tlm_event_finder_t::find_event(sc_core::sc_interface *if_p) const { - const IF* iface = ( if_p ) ? dynamic_cast( if_p ) : - dynamic_cast( port().get_interface() ); - if( iface == 0 ) { - report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" ); + const IF *iface = if_p ? dynamic_cast(if_p) : + dynamic_cast(port().get_interface()); + if (iface == nullptr) { + report_error(sc_core::SC_ID_FIND_EVENT_, "port is not bound"); return sc_core::sc_event::none; } - return (const_cast( iface )->*m_event_method) ( 0 ); + return (const_cast(iface)->*m_event_method)(nullptr); } } // namespace tlm -#endif // TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_ +// __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_EVENT_FINDER_H__ +#endif diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h index 0af1e3487..370b2cae0 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h @@ -17,75 +17,75 @@ *****************************************************************************/ -#ifndef __TLM_NONBLOCKING_PORT_H__ -#define __TLM_NONBLOCKING_PORT_H__ +#ifndef \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_NONBLOCKING_PORT_H__ +#define \ + __SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_NONBLOCKING_PORT_H__ #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h" #include "tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_event_finder.h" -namespace tlm { +namespace tlm +{ -template < typename T > +template class tlm_nonblocking_get_port : -public sc_core::sc_port< tlm_nonblocking_get_if< T > , 1 > + public sc_core::sc_port, 1> { -public: - typedef tlm_nonblocking_get_if get_if_type; - - tlm_nonblocking_get_port( const char *port_name ) : - sc_core::sc_port< tlm_nonblocking_get_if< T > , 1 >( port_name ) {} - - sc_core::sc_event_finder& ok_to_get() const { - - return *new tlm_event_finder_t< get_if_type , T >( - *this, - &get_if_type::ok_to_get ); - - } - + public: + typedef tlm_nonblocking_get_if get_if_type; + + tlm_nonblocking_get_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_get() const + { + return *new tlm_event_finder_t( + *this, &get_if_type::ok_to_get); + } }; -template < typename T > +template class tlm_nonblocking_peek_port : -public sc_core::sc_port< tlm_nonblocking_peek_if< T > , 1 > + public sc_core::sc_port, 1> { -public: - typedef tlm_nonblocking_peek_if peek_if_type; - - tlm_nonblocking_peek_port( const char *port_name ) : - sc_core::sc_port< tlm_nonblocking_peek_if< T > , 1 >( port_name ) {} - - sc_core::sc_event_finder& ok_to_peek() const { - - return *new tlm_event_finder_t< peek_if_type , T >( - *this, - &peek_if_type::ok_to_peek ); - - } - + public: + typedef tlm_nonblocking_peek_if peek_if_type; + + tlm_nonblocking_peek_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_peek() const + { + return *new tlm_event_finder_t( + *this, &peek_if_type::ok_to_peek); + } }; - -template < typename T > +template class tlm_nonblocking_put_port : -public sc_core::sc_port< tlm_nonblocking_put_if< T > , 1 > + public sc_core::sc_port, 1> { -public: - typedef tlm_nonblocking_put_if put_if_type; - - tlm_nonblocking_put_port( const char *port_name ) : - sc_core::sc_port< tlm_nonblocking_put_if< T > , 1 >( port_name ) {} - - sc_core::sc_event_finder& ok_to_put() const { - - return *new tlm_event_finder_t< put_if_type , T >( - *this, - &put_if_type::ok_to_put ); - - } - + public: + typedef tlm_nonblocking_put_if put_if_type; + + tlm_nonblocking_put_port(const char *port_name) : + sc_core::sc_port, 1>(port_name) + {} + + sc_core::sc_event_finder & + ok_to_put() const + { + return *new tlm_event_finder_t( + *this, &put_if_type::ok_to_put); + } }; } // namespace tlm #endif +/*__SYSTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_PORTS_TLM_NONBLOCKING_PORT_H__*/ diff --git a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h index 88f1d0e8c..0d4d0b966 100644 --- a/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h +++ b/src/systemc/ext/tlm_core/tlm_1/tlm_req_rsp/tlm_req_rsp.h @@ -17,21 +17,21 @@ *****************************************************************************/ -#ifndef __TLM_REQ_RSP_H__ -#define __TLM_REQ_RSP_H__ +#ifndef __SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_REQ_RSP_H__ +#define __SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_REQ_RSP_H__ -// The unannotated TLM interfaces +// The unannotated TLM interfaces. #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_core_ifs.h" #include "tlm_core/tlm_1/tlm_req_rsp/tlm_1_interfaces/tlm_master_slave_ifs.h" -// The channels : tlm_fifo, tlm_transport_channel and tlm_req_rsp_channel +// The channels : tlm_fifo, tlm_transport_channel and tlm_req_rsp_channel. #include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h" -// Some non blocking ports to provide static sensitivity +// Some non blocking ports to provide static sensitivity. #include "tlm_core/tlm_1/tlm_req_rsp/tlm_ports/tlm_nonblocking_port.h" -#endif /* __TLM_REQ_RSP_H__ */ +#endif /*__SYsTEMC_EXT_TLM_CORE_TLM_1_TLM_REQ_RSP_TLM_REQ_RSP_H__ */ -- cgit v1.2.3