⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scx_signal_int.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************  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_dt::sc_int<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_int.h,v $Revision 1.1.1.1  2006/12/15 20:31:29  acgSystemC 2.2Revision 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.21  2005/03/21 22:31:32  acgChanges to sc_core namespace.Revision 1.20  2005/01/10 17:51:58  acgImprovements.Revision 1.19  2004/11/09 00:11:26  acgAdded support for sc_generic_base<T> in place of sc_concatref. sc_concatrefnow is derived from sc_generic_base<sc_concatref>.Revision 1.18  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_INT_H)#define SC_SIGNAL_INT_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_int_sigref;//==============================================================================// CLASS sc_int_part_if//// This class provides generic access to part selections for signals whose// data type is sc_dt::sc_int<W>. This class serves as the base class for the// sc_dt::sc_int<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_int_sigref class.//// Notes://   (1) Descriptions of the methods and operators in this class appear with//       their implementations in sc_signal<sc_dt::sc_int<W> >.//==============================================================================class sc_int_part_if : virtual public sc_interface {  protected:	// constructor:  	sc_int_part_if() {}  public:    // perform a part read.	virtual sc_dt::sc_int_base* part_read_target();  	virtual sc_dt::uint64 read_part( int left, int right ) const;    // perform a part write.	virtual sc_int_sigref& select_part( int left, int right );  	virtual void write_part( sc_dt::uint64 v, int left, int right );  private:  	sc_int_part_if( const sc_int_part_if& );  	sc_int_part_if& operator = ( const sc_int_part_if& );};//==============================================================================// CLASS sc_signal_in_if<sc_dt::sc_int<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_int<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_int<W> >.//==============================================================================template< int W >class sc_signal_in_if<sc_dt::sc_int<W> > : public sc_int_part_if {	friend class sc_int_sigref;  public:    typedef sc_signal_in_if<sc_dt::sc_int<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_int<W>& read() const = 0;    // get a reference to the current value (for tracing)    virtual const sc_dt::sc_int<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_int_sigref////  Proxy class for sc_signal_int bit and part selection.//=============================================================================class sc_int_sigref : public sc_dt::sc_int_subref_r{  public:    sc_int_sigref() : sc_dt::sc_int_subref_r() {}    virtual ~sc_int_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_int_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_int_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_int_sigref> m_pool; // Pool of objects to use.  protected:    sc_int_part_if*                m_if_p; // Target for selection.  private:    // disabled    sc_int_sigref( const sc_int_sigref& a );};//==============================================================================// CLASS sc_signal<sc_dt::sc_int<W> > //// This class implements a signal whose value acts like an sc_dt::sc_int<W> data// value. This class is a specialization of the generic sc_signal class to // implement tailored support for the sc_dt::sc_int<W> class.//// Notes://   (1) Descriptions of the methods and operators in this class appear with//       their implementations.//==============================================================================SC_TEMPLATEclass sc_signal<sc_dt::sc_int<W> > :     public sc_signal_inout_if<sc_dt::sc_int<W> >,	public sc_prim_channel,    public sc_dt::sc_int<W>{  public: // typedefs    typedef sc_signal<sc_dt::sc_int<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_int<W>& base_read() const;    inline const sc_event& base_value_changed_event() const;    inline void base_write( sc_dt::int64 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_int_part_if virtual methods:    virtual inline sc_dt::sc_int_base* part_read_target();    virtual inline sc_dt::uint64 read_part(int left, int right) const;	virtual inline sc_int_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_int<W>& get_data_ref() const;    virtual inline sc_signal<sc_dt::sc_int<W> >& get_signal() ;    virtual inline const sc_dt::sc_int<W>& read() const;    virtual inline const sc_event& value_changed_event() const;    virtual inline void write( const sc_in<sc_dt::sc_int<W> >& value );    virtual inline void write( const sc_inout<sc_dt::sc_int<W> >& value );    virtual inline void write( const sc_dt::sc_int<W>& value );  public: // part selections:  	inline sc_int_sigref& operator () ( int left, int right );  	inline sc_int_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 );    // concatenation methods (we inherit length and gets from sc_dt::sc_int<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_int<W> supports:    sc_signal<sc_dt::sc_int<W> >& operator ++ ();          // prefix    const sc_signal<sc_dt::sc_int<W> >& operator ++ (int); // postfix    sc_signal<sc_dt::sc_int<W> >& operator -- ();          // prefix    const sc_signal<sc_dt::sc_int<W> >& operator -- (int); // postfix    sc_signal<sc_dt::sc_int<W> >& operator += (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator -= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator *= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator /= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator %= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator &= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator |= (sc_dt::int_type);    sc_signal<sc_dt::sc_int<W> >& operator ^= (sc_dt::int_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::int64             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_int<W> >::base_event() const{    return simcontext()->delta_count() == m_event_delta + 1;}SC_TEMPLATE // Return this object's sc_dt::sc_int<W> object instance.inline const sc_dt::sc_int<W>& sc_signal<sc_dt::sc_int<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_int<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 // Select a portion of a value. inline sc_int_sigref& sc_signal<sc_dt::sc_int<W> >::select_part(int left, int right){    sc_int_sigref* result_p = sc_int_sigref::m_pool.allocate();    result_p->initialize(this, left, right);    return *result_p;}SC_TEMPLATE // Write an sc_dt::uint64 value to this object instance.inline void sc_signal<sc_dt::sc_int<W> >::base_write( sc_dt::int64 value ){#   if defined(DEBUG_SYSTEMC)        check_writer();#   endif    m_new_val = value;    request_update();}//------------------------------------------------------------------------------//"sc_signal<sc_dt::sc_int<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 + -