📄 scx_signal_signed.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_signed.h -- The sc_signal<sc_dt::sc_bigint<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_signed.h,v $Revision 1.1.1.1 2006/12/15 20:31:29 acgSystemC 2.2Revision 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.29 2005/09/15 23:01:52 acgAdded std:: prefix to appropriate methods and types to get aroundissues with the Edison Front End.Revision 1.28 2005/07/30 03:44:11 acgChanges from 2.1.Revision 1.27 2005/05/09 17:17:12 acgChanges from 2.1.Revision 1.26 2005/05/08 19:04:06 acgFix bug in concat_set(int64,off). Other changes from 2.1 examples usage.Revision 1.25 2005/05/03 20:05:16 acgPrefixed with sc_dt some sc_signed instances that were missed.Revision 1.24 2005/05/03 19:50:20 acgName space version.Revision 1.22 2005/03/21 22:31:32 acgChanges to sc_core namespace.Revision 1.21 2005/01/10 17:51:58 acgImprovements.Revision 1.20 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.19 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_SIGNED_H)#define SC_SIGNAL_SIGNED_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:using sc_dt::int64;namespace sc_core {class sc_signed_sigref;//==============================================================================// CLASS sc_signed_part_if//// This class provides generic access to part selections for signals whose// data type is sc_dt::sc_bigint<W>. This class serves as the base class for the// sc_dt::sc_bigint<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_bigint_sigref class.//// Notes:// (1) Descriptions of the methods and operators in this class appear with// their implementations in sc_signal<sc_dt::sc_bigint<W> >.//==============================================================================class sc_signed_part_if : virtual public sc_interface { protected: // constructor: sc_signed_part_if() {} public: // perform a part read. virtual sc_dt::sc_signed* part_read_target(); virtual sc_dt::sc_signed read_part( int left, int right ) const; // perform a part write. virtual sc_signed_sigref& select_part( int left, int right ); virtual void write_part( sc_dt::int64 v, int left, int right ); virtual void write_part( sc_dt::uint64 v, int left, int right ); virtual void write_part( const sc_dt::sc_signed& v, int left, int right ); virtual void write_part( const sc_dt::sc_unsigned& v, int left, int right ); private: sc_signed_part_if( const sc_signed_part_if& ); sc_signed_part_if& operator = ( const sc_signed_part_if& );};//==============================================================================// CLASS sc_signal_in_if<sc_dt::sc_bigint<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_bigint<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_bigint<W> >.//==============================================================================template< int W >class sc_signal_in_if<sc_dt::sc_bigint<W> > : public sc_signed_part_if { friend class sc_signed_sigref; public: typedef sc_signal_in_if<sc_dt::sc_bigint<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_bigint<W>& read() const = 0; // get a reference to the current value (for tracing) virtual const sc_dt::sc_bigint<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_signed_sigref//// Proxy class for sc_signal_uint bit and part selection.//=============================================================================class sc_signed_sigref : public sc_dt::sc_signed_subref_r{ public: sc_signed_sigref() : sc_dt::sc_signed_subref_r() {} virtual ~sc_signed_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_signed_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_signed_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_signed_sigref> m_pool; // Pool of objects to use. protected: sc_signed_part_if* m_if_p; // Target for selection. private: // disabled sc_signed_sigref( const sc_signed_sigref& a );};//==============================================================================// CLASS sc_signal<sc_dt::sc_bigint<W> > //// This class implements a signal whose value acts like an sc_dt::sc_bigint<W> data// value. This class is a specialization of the generic sc_signal class to // implement tailored support for the sc_dt::sc_bigint<W> class.//// Notes:// (1) Descriptions of the methods and operators in this class appear with// their implementations.//==============================================================================SC_TEMPLATEclass sc_signal<sc_dt::sc_bigint<W> > : public sc_dt::sc_bigint<W>, public sc_prim_channel, public sc_signal_inout_if<sc_dt::sc_bigint<W> >{ public: // typedefs typedef sc_signal<sc_dt::sc_bigint<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_bigint<W>& base_read() const; inline const sc_event& base_value_changed_event() const; inline void base_write( sc_dt::int64 value ); inline void base_write( sc_dt::uint64 value ); inline void base_write( const sc_dt::sc_signed& value ); inline void base_write( const sc_dt::sc_unsigned& 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_signed_part_if virtual methods: virtual inline sc_dt::sc_signed* part_read_target(); virtual inline sc_dt::sc_signed read_part(int left, int right) const; virtual sc_signed_sigref& select_part( int left, int right ); virtual inline void write_part( sc_dt::int64 v, int left, int right ); virtual inline void write_part( sc_dt::uint64 v, int left, int right ); virtual inline void write_part( const sc_dt::sc_signed& v, int left, int right ); virtual inline void write_part(const sc_dt::sc_unsigned& v, int left, int right); public: // interface virtual methods: virtual inline bool event() const; virtual inline const sc_dt::sc_bigint<W>& get_data_ref() const; virtual inline sc_signal<sc_dt::sc_bigint<W> >& get_signal(); virtual inline const sc_dt::sc_bigint<W>& read() const; virtual inline const sc_event& value_changed_event() const; virtual inline void write( const sc_in<sc_dt::sc_bigint<W> >& value ); virtual inline void write( const sc_inout<sc_dt::sc_bigint<W> >& value ); virtual inline void write( const sc_dt::sc_bigint<W>& value ); public: // part selections: inline sc_signed_sigref& operator () ( int left, int right ); // #### Need to add bit() and range() inline sc_signed_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_bigint<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_bigint<W> supports: sc_dt::sc_signed& operator ++ (); // prefix const sc_dt::sc_signed& operator ++ (int); // postfix sc_dt::sc_signed& operator -- (); // prefix const sc_dt::sc_signed& operator -- (int); // postfix sc_dt::sc_signed& operator += (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator += (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator += (sc_dt::int64 ); sc_dt::sc_signed& operator += (sc_dt::uint64 ); sc_dt::sc_signed& operator += (long ); sc_dt::sc_signed& operator += (unsigned long ); sc_dt::sc_signed& operator += (int ); sc_dt::sc_signed& operator += (unsigned int ); sc_dt::sc_signed& operator -= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator -= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator -= (sc_dt::int64 ); sc_dt::sc_signed& operator -= (sc_dt::uint64 ); sc_dt::sc_signed& operator -= (long ); sc_dt::sc_signed& operator -= (unsigned long ); sc_dt::sc_signed& operator -= (int ); sc_dt::sc_signed& operator -= (unsigned int ); sc_dt::sc_signed& operator *= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator *= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator *= (sc_dt::int64 ); sc_dt::sc_signed& operator *= (sc_dt::uint64 ); sc_dt::sc_signed& operator *= (long ); sc_dt::sc_signed& operator *= (unsigned long ); sc_dt::sc_signed& operator *= (int ); sc_dt::sc_signed& operator *= (unsigned int ); sc_dt::sc_signed& operator /= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator /= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator /= (sc_dt::int64 ); sc_dt::sc_signed& operator /= (sc_dt::uint64 ); sc_dt::sc_signed& operator /= (long ); sc_dt::sc_signed& operator /= (unsigned long ); sc_dt::sc_signed& operator /= (int ); sc_dt::sc_signed& operator /= (unsigned int ); sc_dt::sc_signed& operator %= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator %= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator %= (sc_dt::int64 ); sc_dt::sc_signed& operator %= (sc_dt::uint64 ); sc_dt::sc_signed& operator %= (long ); sc_dt::sc_signed& operator %= (unsigned long ); sc_dt::sc_signed& operator %= (int ); sc_dt::sc_signed& operator %= (unsigned int ); sc_dt::sc_signed& operator &= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator &= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator &= (sc_dt::int64 ); sc_dt::sc_signed& operator &= (sc_dt::uint64 ); sc_dt::sc_signed& operator &= (long ); sc_dt::sc_signed& operator &= (unsigned long ); sc_dt::sc_signed& operator &= (int ); sc_dt::sc_signed& operator &= (unsigned int ); sc_dt::sc_signed& operator |= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator |= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator |= (sc_dt::int64 ); sc_dt::sc_signed& operator |= (sc_dt::uint64 ); sc_dt::sc_signed& operator |= (long ); sc_dt::sc_signed& operator |= (unsigned long ); sc_dt::sc_signed& operator |= (int ); sc_dt::sc_signed& operator |= (unsigned int ); sc_dt::sc_signed& operator ^= (const sc_dt::sc_signed& ); sc_dt::sc_signed& operator ^= (const sc_dt::sc_unsigned& ); sc_dt::sc_signed& operator ^= (sc_dt::int64 ); sc_dt::sc_signed& operator ^= (sc_dt::uint64 ); sc_dt::sc_signed& operator ^= (long ); sc_dt::sc_signed& operator ^= (unsigned long ); sc_dt::sc_signed& operator ^= (int ); sc_dt::sc_signed& operator ^= (unsigned int ); 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::sc_signed 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.};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -