📄 scx_signal_uint.h
字号:
/***************************************************************************** The following code is derived, directly or indirectly, from the SystemC source code Copyright (c) 1996-2006 by all Contributors. All Rights reserved. The contents of this file are subject to the restrictions and limitations set forth in the SystemC Open Source License Version 2.4 (the "License"); You may not use this file except in compliance with such restrictions and limitations. You may obtain instructions on how to receive a copy of the License at http://www.systemc.org/. Software distributed by Contributors under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. *****************************************************************************//***************************************************************************** sc_signal_uint.h -- The sc_signal<sc_uint<W> > definitions. Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22 *****************************************************************************//***************************************************************************** MODIFICATION LOG - modifiers, enter your name, affiliation, date and changes you are making here. Name, Affiliation, Date: Description of Modification: *****************************************************************************//* $Log: scx_signal_uint.h,v $Revision 1.1.1.1 2006/12/15 20:31:29 acgSystemC 2.2Revision 1.4 2006/04/05 23:47:02 acg Andy Goodrich: changed sc_get_current_process_base calls into sc_get_current_process_b calls.Revision 1.3 2006/03/21 01:31:48 acg Andy Goodrich: changed over to sc_get_current_process_b() from sc_get_current_process_base() since the function's name changed.Revision 1.2 2005/12/26 20:11:14 acgFixed up copyright.Revision 1.1.1.1 2005/12/19 23:16:42 acgFirst check in of SystemC 2.1 into its own archive.Revision 1.27 2005/09/15 23:01:52 acgAdded std:: prefix to appropriate methods and types to get aroundissues with the Edison Front End.Revision 1.26 2005/07/30 03:44:11 acgChanges from 2.1.Revision 1.25 2005/06/10 22:40:55 acgChanges from 2.1 for operator << and other iostream stuff.Revision 1.24 2005/05/09 17:17:12 acgChanges from 2.1.Revision 1.23 2005/05/08 19:04:06 acgFix bug in concat_set(int64,off). Other changes from 2.1 examples usage.Revision 1.22 2005/05/03 19:50:20 acgName space version.Revision 1.20 2005/03/21 22:31:32 acgChanges to sc_core namespace.Revision 1.18 2004/11/09 00:11:27 acgAdded support for sc_generic_base<T> in place of sc_concatref. sc_concatrefnow is derived from sc_generic_base<sc_concatref>.Revision 1.17 2004/09/27 21:01:59 acgAndy Goodrich - Forte Design Systems, Inc. - This is specialized signal support that allows better use of signals and ports whose target value is a SystemC native type.*/#if !defined(SC_SIGNAL_UINT_H)#define SC_SIGNAL_UINT_H#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )# define SC_TEMPLATE template<int W>#else# define SC_TEMPLATE template<> template<int W>#endif// FORWARD REFERENCES AND USINGS:namespace sc_core {class sc_uint_sigref;//==============================================================================// CLASS sc_uint_part_if//// This class provides generic access to part selections for signals whose// data type is sc_dt::sc_uint<W>. This class serves as the base class for the// sc_dt::sc_uint<W> specialization of the sc_signal_in_if<T> class. The methods// in this class may be over-ridden individually, those that are not overridden// will produce an error message when called. The methods are used by the // sc_uint_sigref class.//// Notes:// (1) Descriptions of the methods and operators in this class appear with// their implementations in sc_signal<sc_dt::sc_uint<W> >.//==============================================================================class sc_uint_part_if : virtual public sc_interface { protected: // constructor: sc_uint_part_if() {} public: // perform a part read. virtual sc_dt::sc_uint_base* part_read_target(); virtual sc_dt::uint64 read_part( int left, int right ) const; // perform a part write. virtual sc_uint_sigref& select_part( int left, int right ); virtual void write_part( sc_dt::uint64 v, int left, int right ); private: sc_uint_part_if( const sc_uint_part_if& ); sc_uint_part_if& operator = ( const sc_uint_part_if& );};//==============================================================================// CLASS sc_signal_in_if<sc_dt::sc_uint<W> >//// This is the class specializations for the sc_signal_in_if<T> class to// provide additional features for sc_signal instances whose template is// sc_dt::sc_uint<W>, including part access. //// Notes:// (1) Descriptions of the methods and operators in this class appear with// their implementations in sc_signal<sc_dt::sc_uint<W> >.//==============================================================================template< int W >class sc_signal_in_if<sc_dt::sc_uint<W> > : public sc_uint_part_if { friend class sc_uint_sigref; public: typedef sc_signal_in_if<sc_dt::sc_uint<W> > this_type; // get the value changed event virtual const sc_event& value_changed_event() const = 0; // read the current value virtual const sc_dt::sc_uint<W>& read() const = 0; // get a reference to the current value (for tracing) virtual const sc_dt::sc_uint<W>& get_data_ref() const = 0; // was there a value changed event? virtual bool event() const = 0; protected: // constructor sc_signal_in_if() {} private: // disabled sc_signal_in_if( const this_type& ); this_type& operator = ( const this_type& );};//=============================================================================// CLASS : sc_uint_sigref//// Proxy class for sc_signal_uint bit and part selection.//=============================================================================class sc_uint_sigref : public sc_dt::sc_uint_subref_r{ public: sc_uint_sigref() : sc_dt::sc_uint_subref_r() {} virtual ~sc_uint_sigref() {} virtual void concat_set(sc_dt::int64 src, int low_i); virtual void concat_set(const sc_dt::sc_signed& src, int low_i); virtual void concat_set(const sc_dt::sc_unsigned& src, int low_i); virtual void concat_set(const sc_dt::sc_lv_base& src, int low_i); virtual void concat_set(sc_dt::uint64 src, int low_i); public: inline void initialize( sc_uint_part_if* if_p, int left_, int right_ ); public: inline void operator = ( sc_dt::uint64 v ); inline void operator = ( const char* v ); inline void operator = ( unsigned long v ); inline void operator = ( long v ); inline void operator = ( unsigned int v ); inline void operator = ( int v ); inline void operator = ( sc_dt::int64 v ); inline void operator = ( double v ); inline void operator = ( const sc_uint_sigref& v ); template<typename T> inline void operator = ( const sc_dt::sc_generic_base<T>& v ); inline void operator = ( const sc_dt::sc_signed& v ); inline void operator = ( const sc_dt::sc_unsigned& v ); inline void operator = ( const sc_dt::sc_bv_base& v ); inline void operator = ( const sc_dt::sc_lv_base& v ); public: static sc_vpool<sc_uint_sigref> m_pool; // Pool of objects to use. protected: sc_uint_part_if* m_if_p; // Target for selection. private: // disabled sc_uint_sigref( const sc_uint_sigref& a );};//==============================================================================// CLASS sc_signal<sc_dt::sc_uint<W> > //// This class implements a signal whose value acts like an sc_dt::sc_uint<W> data// value. This class is a specialization of the generic sc_signal class to // implement tailored support for the sc_dt::sc_uint<W> class.//// Notes:// (1) Descriptions of the methods and operators in this class appear with// their implementations.//==============================================================================SC_TEMPLATEclass sc_signal<sc_dt::sc_uint<W> > : public sc_signal_inout_if<sc_dt::sc_uint<W> >, public sc_prim_channel, public sc_dt::sc_uint<W>{ public: // typedefs typedef sc_signal<sc_dt::sc_uint<W> > this_type; public: // constructors and destructor: inline sc_signal(); explicit inline sc_signal(const char* name_); virtual inline ~sc_signal(); public: // base methods: inline bool base_event() const; inline const sc_dt::sc_uint<W>& base_read() const; inline const sc_event& base_value_changed_event() const; inline void base_write( sc_dt::uint64 value ); public: // sc_prim_channel virtual methods: virtual inline const char* kind() const; virtual inline void update(); public: // sc_interface virtual methods: virtual inline const sc_event& default_event() const; virtual inline void register_port( sc_port_base& port_, const char* if_typename_ ); public: // sc_uint_channel virtual methods: virtual sc_dt::sc_uint_base* part_read_target(); virtual inline sc_dt::uint64 read_part(int left, int right) const; virtual inline sc_uint_sigref& select_part(int left, int right); virtual inline void write_part(sc_dt::uint64 v, int left, int right); public: // interface virtual methods: virtual inline bool event() const; virtual inline const sc_dt::sc_uint<W>& get_data_ref() const; // virtual inline sc_signal<sc_dt::sc_uint<W> >& get_signal() ; virtual inline const sc_dt::sc_uint<W>& read() const; virtual inline const sc_event& value_changed_event() const; virtual inline void write( const sc_in<sc_dt::sc_uint<W> >& value ); virtual inline void write( const sc_inout<sc_dt::sc_uint<W> >& value ); virtual inline void write( const sc_dt::sc_uint<W>& value ); public: // part selections: inline sc_uint_sigref& operator () ( int left, int right ); inline sc_uint_sigref& operator [] ( int bit ); public: // operators: inline void operator = ( const this_type& new_val ); inline void operator = ( const char* new_val ); inline void operator = ( sc_dt::uint64 new_val ); inline void operator = ( sc_dt::int64 new_val ); inline void operator = ( int new_val ); inline void operator = ( long new_val ) ; inline void operator = ( short new_val ) ; inline void operator = ( unsigned int new_val ) ; inline void operator = ( unsigned long new_val ); inline void operator = ( unsigned short new_val ); template<typename T> inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ); inline void operator = ( const sc_dt::sc_signed& new_val ); inline void operator = ( const sc_dt::sc_unsigned& new_val ); inline void operator = ( const sc_dt::sc_bv_base& new_val ); inline void operator = ( const sc_dt::sc_lv_base& new_val ); public: // concatenation methods (we inherit length and gets from sc_dt::sc_uint<W>): virtual inline void concat_set(sc_dt::int64 src, int low_i); virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i); virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i); virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i); virtual inline void concat_set(sc_dt::uint64 src, int low_i); protected: // debugging methods: // #### void check_port(); void check_writer(); private: // Disabled operations that sc_dt::sc_uint<W> supports: sc_signal<sc_dt::sc_uint<W> >& operator ++ (); // prefix const sc_signal<sc_dt::sc_uint<W> >& operator ++ (int); // postfix sc_signal<sc_dt::sc_uint<W> >& operator -- (); // prefix const sc_signal<sc_dt::sc_uint<W> >& operator -- (int); // postfix sc_signal<sc_dt::sc_uint<W> >& operator += (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator -= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator *= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator /= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator %= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator &= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator |= (sc_dt::uint_type); sc_signal<sc_dt::sc_uint<W> >& operator ^= (sc_dt::uint_type); protected: mutable sc_event* m_changed_event_p; // Value changed event this object. sc_dt::uint64 m_event_delta; // Delta cycle of last event. sc_dt::uint64 m_new_val; // New value for this object instance. sc_port_base* m_output_p; // Single write port verify field. sc_process_b* m_writer_p; // Single writer verify field.};SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.inline bool sc_signal<sc_dt::sc_uint<W> >::base_event() const{ return simcontext()->delta_count() == m_event_delta + 1;}SC_TEMPLATE // Return this object's sc_dt::sc_uint<W> object instance.inline const sc_dt::sc_uint<W>& sc_signal<sc_dt::sc_uint<W> >::base_read() const{ return *this;}SC_TEMPLATE // Return the value changed event, allocating it if necessary.inline const sc_event& sc_signal<sc_dt::sc_uint<W> >::base_value_changed_event() const{ if ( !m_changed_event_p ) m_changed_event_p = new sc_event; return *m_changed_event_p;}SC_TEMPLATE // Write an sc_dt::uint64 value to this object instance.inline void sc_signal<sc_dt::sc_uint<W> >::base_write( sc_dt::uint64 value ){# if defined(DEBUG_SYSTEMC) check_writer();# endif m_new_val = value; request_update();}//------------------------------------------------------------------------------//"sc_signal<sc_dt::sc_uint<W> >::check_writer"//// This method checks to see if there is more than one writer for this // object instance by keeping track of the process performing the write.//------------------------------------------------------------------------------SC_TEMPLATE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -