📄 sc_signal_ports.h
字号:
// disabled sc_inout( const this_type& );#ifdef __GNUC__ // Needed to circumvent a problem in the g++-2.95.2 compiler: // This unused variable forces the compiler to instantiate // an object of T template so an implicit conversion from // read() to a C++ intrinsic data type will work. static data_type dummy;#endif};// ----------------------------------------------------------------------------// CLASS : sc_inout<sc_dt::sc_logic>//// Specialization of sc_inout<T> for type sc_dt::sc_logic.// ----------------------------------------------------------------------------template <>class sc_inout<sc_dt::sc_logic>: public sc_port<sc_signal_inout_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>{public: // typedefs typedef sc_dt::sc_logic data_type; typedef sc_signal_inout_if<data_type> if_type; typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND> base_type; typedef sc_inout<data_type> this_type; typedef sc_signal_in_if<data_type> in_if_type; typedef sc_port<in_if_type,1,SC_ONE_OR_MORE_BOUND> in_port_type; typedef if_type inout_if_type; typedef base_type inout_port_type;public: // constructors sc_inout() : base_type(), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} explicit sc_inout( const char* name_ ) : base_type( name_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} explicit sc_inout( inout_if_type& interface_ ) : base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} sc_inout( const char* name_, inout_if_type& interface_ ) : base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} explicit sc_inout( inout_port_type& parent_ ) : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} sc_inout( const char* name_, inout_port_type& parent_ ) : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} sc_inout( this_type& parent_ ) : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} sc_inout( const char* name_, this_type& parent_ ) : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ), m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0) {} // destructor virtual ~sc_inout(); // interface access shortcut methods // get the default event const sc_event& default_event() const { return (*this)->default_event(); } // get the value changed event const sc_event& value_changed_event() const { return (*this)->value_changed_event(); } // get the positive edge event const sc_event& posedge_event() const { return (*this)->posedge_event(); } // get the negative edge event const sc_event& negedge_event() const { return (*this)->negedge_event(); } // read the current value const data_type& read() const { return (*this)->read(); } operator const data_type& () const { return (*this)->read(); } // use for positive edge sensitivity sc_event_finder& pos() const { if ( !m_pos_finder_p ) { m_pos_finder_p = new sc_event_finder_t<in_if_type>( *this, &in_if_type::posedge_event ); } return *m_pos_finder_p; } // use for negative edge sensitivity sc_event_finder& neg() const { if ( !m_neg_finder_p ) { m_neg_finder_p = new sc_event_finder_t<in_if_type>( *this, &in_if_type::negedge_event ); } return *m_neg_finder_p; } // was there a value changed event? bool event() const { return (*this)->event(); } // was there a positive edge event? bool posedge() const { return (*this)->posedge(); } // was there a negative edge event? bool negedge() const { return (*this)->negedge(); } // write the new value void write( const data_type& value_ ) { (*this)->write( value_ ); } this_type& operator = ( const data_type& value_ ) { (*this)->write( value_ ); return *this; } this_type& operator = ( const in_if_type& interface_ ) { (*this)->write( interface_.read() ); return *this; } this_type& operator = ( const in_port_type& port_ ) { (*this)->write( port_->read() ); return *this; } this_type& operator = ( const inout_port_type& port_ ) { (*this)->write( port_->read() ); return *this; } this_type& operator = ( const this_type& port_ ) { (*this)->write( port_->read() ); return *this; } // set initial value (can also be called when port is not bound yet) void initialize( const data_type& value_ ); void initialize( const in_if_type& interface_ ) { initialize( interface_.read() ); } // called when elaboration is done /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */ /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */ virtual void end_of_elaboration(); // (other) event finder method(s) sc_event_finder& value_changed() const { if ( !m_change_finder_p ) { m_change_finder_p = new sc_event_finder_t<in_if_type>( *this, &in_if_type::value_changed_event ); } return *m_change_finder_p; } virtual const char* kind() const { return "sc_inout"; }protected: data_type* m_init_val;public: // called by sc_trace void add_trace_internal( sc_trace_file*, const std::string& ) const; void add_trace( sc_trace_file*, const std::string& ) const;protected: void remove_traces() const; mutable sc_trace_params_vec* m_traces;private: mutable sc_event_finder* m_change_finder_p; mutable sc_event_finder* m_neg_finder_p; mutable sc_event_finder* m_pos_finder_p;private: // disabled sc_inout( const this_type& );#ifdef __GNUC__ // Needed to circumvent a problem in the g++-2.95.2 compiler: // This unused variable forces the compiler to instantiate // an object of T template so an implicit conversion from // read() to a C++ intrinsic data type will work. static data_type dummy;#endif};// ----------------------------------------------------------------------------// CLASS : sc_out<T>//// The sc_signal<T> output port class.// ----------------------------------------------------------------------------// sc_out can also read from its port, hence no difference with sc_inout.// For debugging reasons, a class is provided instead of a define.template <class T>class sc_out: public sc_inout<T>{public: // typedefs typedef T data_type; typedef sc_out<data_type> this_type; typedef sc_inout<data_type> base_type; typedef typename base_type::in_if_type in_if_type; typedef typename base_type::in_port_type in_port_type; typedef typename base_type::inout_if_type inout_if_type; typedef typename base_type::inout_port_type inout_port_type;public: // constructors sc_out() : base_type() {} explicit sc_out( const char* name_ ) : base_type( name_ ) {} explicit sc_out( inout_if_type& interface_ ) : base_type( interface_ ) {} sc_out( const char* name_, inout_if_type& interface_ ) : base_type( name_, interface_ ) {} explicit sc_out( inout_port_type& parent_ ) : base_type( parent_ ) {} sc_out( const char* name_, inout_port_type& parent_ ) : base_type( name_, parent_ ) {} sc_out( this_type& parent_ ) : base_type( parent_ ) {} sc_out( const char* name_, this_type& parent_ ) : base_type( name_, parent_ ) {} // destructor (does nothing) virtual ~sc_out() {} // write the new value this_type& operator = ( const data_type& value_ ) { (*this)->write( value_ ); return *this; } this_type& operator = ( const in_if_type& interface_ ) { (*this)->write( interface_.read() ); return *this; } this_type& operator = ( const in_port_type& port_ ) { (*this)->write( port_->read() ); return *this; } this_type& operator = ( const inout_port_type& port_ ) { (*this)->write( port_->read() ); return *this; } this_type& operator = ( const this_type& port_ ) { (*this)->write( port_->read() ); return *this; } virtual const char* kind() const { return "sc_out"; }private: // disabled sc_out( const this_type& );};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// ----------------------------------------------------------------------------// FUNCTION : sc_trace// ----------------------------------------------------------------------------template <class T>inlinevoidsc_trace(sc_trace_file* tf, const sc_in<T>& port, const std::string& name){ const sc_signal_in_if<T>* iface = 0; if (sc_get_curr_simcontext()->elaboration_done() ) { iface = DCAST<const sc_signal_in_if<T>*>( port.get_interface() ); } if ( iface ) sc_trace( tf, iface->read(), name ); else port.add_trace_internal( tf, name );}template <class T>inlinevoidsc_trace( sc_trace_file* tf, const sc_inout<T>& port, const std::string& name ){ const sc_signal_in_if<T>* iface = 0; if (sc_get_curr_simcontext()->elaboration_done() ) { iface =DCAST<const sc_signal_in_if<T>*>( port.get_interface() ); } if ( iface ) sc_trace( tf, iface->read(), name ); else port.add_trace_internal( tf, name );}} // namespace sc_core/***************************************************************************** MODIFICATION LOG - modifiers, enter your name, affiliation, date and changes you are making here. Name, Affiliation, Date: Jason Elbaum, Motorola, Inc., 2001-11-12 Description of Modification: Added a static, private, otherwise unused data member to the sc_in and sc_inout classes to address a bug in the GNU compiler *only*. This works around a bug in g++ 2.95.2 regarding implicit casting from a templated class to a C++ intrinsic type. *****************************************************************************///$Log: sc_signal_ports.h,v $//Revision 1.1.1.1 2006/12/15 20:31:35 acg//SystemC 2.2////Revision 1.11 2006/04/18 23:36:50 acg// Andy Goodrich: made add_trace_internal public until I can figure out// how to do a friend specification for sc_trace in an environment where// there are partial template and full template specifications for its// arguments.////Revision 1.10 2006/04/18 18:01:26 acg// Andy Goodrich: added an add_trace_internal() method to the various port// classes so that sc_trace has something to call that won't emit an// IEEE 1666 deprecation message.////Revision 1.9 2006/03/13 20:19:44 acg// Andy Goodrich: changed sc_event instances into pointers to sc_event instances// that are allocated as needed. This saves considerable storage for large// numbers of signals, etc.////Revision 1.8 2006/02/02 23:42:37 acg// Andy Goodrich: implemented a much better fix to the sc_event_finder// proliferation problem. This new version allocates only a single event// finder for each port for each type of event, e.g., pos(), neg(), and// value_change(). The event finder persists as long as the port does,// which is what the LRM dictates. Because only a single instance is// allocated for each event type per port there is not a potential// explosion of storage as was true in the 2.0.1/2.1 versions.////Revision 1.7 2006/02/02 21:38:12 acg// Andy Goodrich: fix to the comment log.////Revision 1.4 2006/01/24 20:46:32 acg//Andy Goodrich: changes to eliminate use of deprecated features. For instance,//using notify(SC_ZERO_TIME) in place of notify_delayed().////Revision 1.3 2006/01/13 18:47:42 acg//Added $Log command so that CVS comments are reproduced in the source.////Revision 1.2 2006/01/03 23:18:26 acg//Changed copyright to include 2006.////Revision 1.1.1.1 2005/12/19 23:16:43 acg//First check in of SystemC 2.1 into its own archive.////Revision 1.18 2005/09/15 23:01:52 acg//Added std:: prefix to appropriate methods and types to get around//issues with the Edison Front End.////Revision 1.17 2005/06/10 22:43:55 acg//Added CVS change log annotation.//#endif// Taf!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -