112922Sgabeblack@google.com/***************************************************************************** 212922Sgabeblack@google.com 312922Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412922Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512922Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612922Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712922Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812922Sgabeblack@google.com License. You may obtain a copy of the License at 912922Sgabeblack@google.com 1012922Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112922Sgabeblack@google.com 1212922Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312922Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412922Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512922Sgabeblack@google.com implied. See the License for the specific language governing 1612922Sgabeblack@google.com permissions and limitations under the License. 1712922Sgabeblack@google.com 1812922Sgabeblack@google.com *****************************************************************************/ 1912922Sgabeblack@google.com 2012922Sgabeblack@google.com/***************************************************************************** 2112922Sgabeblack@google.com 2212922Sgabeblack@google.com sc_signal_int.cpp -- The sc_signal<sc_dt::sc_int<W> > implementations. 2312922Sgabeblack@google.com 2412922Sgabeblack@google.com Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22 2512922Sgabeblack@google.com 2612922Sgabeblack@google.com *****************************************************************************/ 2712922Sgabeblack@google.com 2812922Sgabeblack@google.com/***************************************************************************** 2912922Sgabeblack@google.com 3012922Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112922Sgabeblack@google.com changes you are making here. 3212922Sgabeblack@google.com 3312922Sgabeblack@google.com Name, Affiliation, Date: 3412922Sgabeblack@google.com Description of Modification: 3512922Sgabeblack@google.com 3612922Sgabeblack@google.com *****************************************************************************/ 3712922Sgabeblack@google.com 3812922Sgabeblack@google.com/* 3912922Sgabeblack@google.com$Log: scx_signal_int.h,v $ 4012922Sgabeblack@google.comRevision 1.1 2011/08/15 17:31:11 acg 4112922Sgabeblack@google.com Andy Goodrich: moved specialized signals from examples to this tree. 4212922Sgabeblack@google.com 4312922Sgabeblack@google.comRevision 1.2 2011/08/15 16:43:24 acg 4412922Sgabeblack@google.com Torsten Maehne: changes to remove unused argument warnings. 4512922Sgabeblack@google.com 4612922Sgabeblack@google.comRevision 1.1.1.1 2006/12/15 20:20:03 acg 4712922Sgabeblack@google.comSystemC 2.3 4812922Sgabeblack@google.com 4912922Sgabeblack@google.comRevision 1.2 2005/12/26 20:11:14 acg 5012922Sgabeblack@google.comFixed up copyright. 5112922Sgabeblack@google.com 5212922Sgabeblack@google.comRevision 1.1.1.1 2005/12/19 23:16:42 acg 5312922Sgabeblack@google.comFirst check in of SystemC 2.1 into its own archive. 5412922Sgabeblack@google.com 5512922Sgabeblack@google.comRevision 1.11 2005/04/11 19:05:36 acg 5612922Sgabeblack@google.comChange to sc_clock for Microsoft VCC 6.0. Changes for namespaces 5712922Sgabeblack@google.com 5812922Sgabeblack@google.comRevision 1.10 2005/04/03 22:52:51 acg 5912922Sgabeblack@google.comNamespace changes. 6012922Sgabeblack@google.com 6112922Sgabeblack@google.comRevision 1.9 2005/03/21 22:31:32 acg 6212922Sgabeblack@google.comChanges to sc_core namespace. 6312922Sgabeblack@google.com 6412922Sgabeblack@google.comRevision 1.8 2004/09/27 21:01:59 acg 6512922Sgabeblack@google.comAndy Goodrich - Forte Design Systems, Inc. 6612922Sgabeblack@google.com - This is specialized signal support that allows better use of signals 6712922Sgabeblack@google.com and ports whose target value is a SystemC native type. 6812922Sgabeblack@google.com 6912922Sgabeblack@google.com*/ 7012922Sgabeblack@google.com 7112922Sgabeblack@google.com 7212922Sgabeblack@google.com 7312922Sgabeblack@google.com#include <systemc> 7412922Sgabeblack@google.com#include <typeinfo> 7512922Sgabeblack@google.com 7612922Sgabeblack@google.com/***************************************************************************** 7712922Sgabeblack@google.com 7812922Sgabeblack@google.com sc_signal_uint.h -- The sc_signal<sc_dt::sc_int<W> > definitions. 7912922Sgabeblack@google.com 8012922Sgabeblack@google.com Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22 8112922Sgabeblack@google.com 8212922Sgabeblack@google.com *****************************************************************************/ 8312922Sgabeblack@google.com 8412922Sgabeblack@google.com/***************************************************************************** 8512922Sgabeblack@google.com 8612922Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 8712922Sgabeblack@google.com changes you are making here. 8812922Sgabeblack@google.com 8912922Sgabeblack@google.com Name, Affiliation, Date: 9012922Sgabeblack@google.com Description of Modification: 9112922Sgabeblack@google.com 9212922Sgabeblack@google.com *****************************************************************************/ 9312922Sgabeblack@google.com 9412922Sgabeblack@google.com/* 9512922Sgabeblack@google.com$Log: scx_signal_int.h,v $ 9612922Sgabeblack@google.comRevision 1.1 2011/08/15 17:31:11 acg 9712922Sgabeblack@google.com Andy Goodrich: moved specialized signals from examples to this tree. 9812922Sgabeblack@google.com 9912922Sgabeblack@google.comRevision 1.3 2011/08/15 16:43:24 acg 10012922Sgabeblack@google.com Torsten Maehne: changes to remove unused argument warnings. 10112922Sgabeblack@google.com 10212922Sgabeblack@google.comRevision 1.2 2011/06/28 21:23:02 acg 10312922Sgabeblack@google.com Andy Goodrich: merging of SCV tree. 10412922Sgabeblack@google.com 10512922Sgabeblack@google.comRevision 1.1.1.1 2006/12/15 20:20:03 acg 10612922Sgabeblack@google.comSystemC 2.3 10712922Sgabeblack@google.com 10812922Sgabeblack@google.comRevision 1.2 2005/12/26 20:11:14 acg 10912922Sgabeblack@google.comFixed up copyright. 11012922Sgabeblack@google.com 11112922Sgabeblack@google.comRevision 1.1.1.1 2005/12/19 23:16:42 acg 11212922Sgabeblack@google.comFirst check in of SystemC 2.1 into its own archive. 11312922Sgabeblack@google.com 11412922Sgabeblack@google.comRevision 1.21 2005/03/21 22:31:32 acg 11512922Sgabeblack@google.comChanges to sc_core namespace. 11612922Sgabeblack@google.com 11712922Sgabeblack@google.comRevision 1.20 2005/01/10 17:51:58 acg 11812922Sgabeblack@google.comImprovements. 11912922Sgabeblack@google.com 12012922Sgabeblack@google.comRevision 1.19 2004/11/09 00:11:26 acg 12112922Sgabeblack@google.comAdded support for sc_generic_base<T> in place of sc_concatref. sc_concatref 12212922Sgabeblack@google.comnow is derived from sc_generic_base<sc_concatref>. 12312922Sgabeblack@google.com 12412922Sgabeblack@google.comRevision 1.18 2004/09/27 21:01:59 acg 12512922Sgabeblack@google.comAndy Goodrich - Forte Design Systems, Inc. 12612922Sgabeblack@google.com - This is specialized signal support that allows better use of signals 12712922Sgabeblack@google.com and ports whose target value is a SystemC native type. 12812922Sgabeblack@google.com 12912922Sgabeblack@google.com*/ 13012922Sgabeblack@google.com 13112922Sgabeblack@google.com 13212922Sgabeblack@google.com#if !defined(SC_SIGNAL_INT_H) 13312922Sgabeblack@google.com#define SC_SIGNAL_INT_H 13412922Sgabeblack@google.com 13512922Sgabeblack@google.com#if ( !defined(_MSC_VER) || _MSC_VER > 1200 ) 13612922Sgabeblack@google.com# define SC_TEMPLATE template<int W> 13712922Sgabeblack@google.com#else 13812922Sgabeblack@google.com# define SC_TEMPLATE template<> template<int W> 13912922Sgabeblack@google.com#endif 14012922Sgabeblack@google.com 14112922Sgabeblack@google.com 14212922Sgabeblack@google.com// FORWARD REFERENCES AND USINGS: 14312922Sgabeblack@google.com 14412922Sgabeblack@google.com 14512922Sgabeblack@google.comnamespace sc_core { 14612922Sgabeblack@google.com 14712922Sgabeblack@google.comclass sc_int_sigref; 14812922Sgabeblack@google.com 14912922Sgabeblack@google.com//============================================================================== 15012922Sgabeblack@google.com// CLASS sc_int_part_if 15112922Sgabeblack@google.com// 15212922Sgabeblack@google.com// This class provides generic access to part selections for signals whose 15312922Sgabeblack@google.com// data type is sc_dt::sc_int<W>. This class serves as the base class for the 15412922Sgabeblack@google.com// sc_dt::sc_int<W> specialization of the sc_signal_in_if<T> class. The methods 15512922Sgabeblack@google.com// in this class may be over-ridden individually, those that are not overridden 15612922Sgabeblack@google.com// will produce an error message when called. The methods are used by the 15712922Sgabeblack@google.com// sc_int_sigref class. 15812922Sgabeblack@google.com// 15912922Sgabeblack@google.com// Notes: 16012922Sgabeblack@google.com// (1) Descriptions of the methods and operators in this class appear with 16112922Sgabeblack@google.com// their implementations in sc_signal<sc_dt::sc_int<W> >. 16212922Sgabeblack@google.com//============================================================================== 16312922Sgabeblack@google.comclass sc_int_part_if : virtual public sc_interface { 16412922Sgabeblack@google.com protected: 16512922Sgabeblack@google.com // constructor: 16612922Sgabeblack@google.com sc_int_part_if() {} 16712922Sgabeblack@google.com 16812922Sgabeblack@google.com public: 16912922Sgabeblack@google.com // perform a part read. 17012922Sgabeblack@google.com virtual sc_dt::sc_int_base* part_read_target(); 17112922Sgabeblack@google.com virtual sc_dt::uint64 read_part( int left, int right ) const; 17212922Sgabeblack@google.com 17312922Sgabeblack@google.com // perform a part write. 17412922Sgabeblack@google.com virtual sc_int_sigref& select_part( int left, int right ); 17512922Sgabeblack@google.com virtual void write_part( sc_dt::uint64 v, int left, int right ); 17612922Sgabeblack@google.com 17712922Sgabeblack@google.com private: 17812922Sgabeblack@google.com sc_int_part_if( const sc_int_part_if& ); 17912922Sgabeblack@google.com sc_int_part_if& operator = ( const sc_int_part_if& ); 18012922Sgabeblack@google.com}; 18112922Sgabeblack@google.com 18212922Sgabeblack@google.com 18312922Sgabeblack@google.com//============================================================================== 18412922Sgabeblack@google.com// CLASS sc_signal_in_if<sc_dt::sc_int<W> > 18512922Sgabeblack@google.com// 18612922Sgabeblack@google.com// This is the class specializations for the sc_signal_in_if<T> class to 18712922Sgabeblack@google.com// provide additional features for sc_signal instances whose template is 18812922Sgabeblack@google.com// sc_dt::sc_int<W>, including part access. 18912922Sgabeblack@google.com// 19012922Sgabeblack@google.com// Notes: 19112922Sgabeblack@google.com// (1) Descriptions of the methods and operators in this class appear with 19212922Sgabeblack@google.com// their implementations in sc_signal<sc_dt::sc_int<W> >. 19312922Sgabeblack@google.com//============================================================================== 19412922Sgabeblack@google.comtemplate< int W > 19512922Sgabeblack@google.comclass sc_signal_in_if<sc_dt::sc_int<W> > : public sc_int_part_if { 19612922Sgabeblack@google.com friend class sc_int_sigref; 19712922Sgabeblack@google.com public: 19812922Sgabeblack@google.com typedef sc_signal_in_if<sc_dt::sc_int<W> > this_type; 19912922Sgabeblack@google.com 20012922Sgabeblack@google.com // get the value changed event 20112922Sgabeblack@google.com virtual const sc_event& value_changed_event() const = 0; 20212922Sgabeblack@google.com 20312922Sgabeblack@google.com 20412922Sgabeblack@google.com // read the current value 20512922Sgabeblack@google.com virtual const sc_dt::sc_int<W>& read() const = 0; 20612922Sgabeblack@google.com 20712922Sgabeblack@google.com // get a reference to the current value (for tracing) 20812922Sgabeblack@google.com virtual const sc_dt::sc_int<W>& get_data_ref() const = 0; 20912922Sgabeblack@google.com 21012922Sgabeblack@google.com 21112922Sgabeblack@google.com // was there a value changed event? 21212922Sgabeblack@google.com virtual bool event() const = 0; 21312922Sgabeblack@google.com 21412922Sgabeblack@google.com protected: 21512922Sgabeblack@google.com // constructor 21612922Sgabeblack@google.com sc_signal_in_if() 21712922Sgabeblack@google.com {} 21812922Sgabeblack@google.com 21912922Sgabeblack@google.com private: // disabled 22012922Sgabeblack@google.com sc_signal_in_if( const this_type& ); 22112922Sgabeblack@google.com this_type& operator = ( const this_type& ); 22212922Sgabeblack@google.com}; 22312922Sgabeblack@google.com 22412922Sgabeblack@google.com//============================================================================= 22512922Sgabeblack@google.com// CLASS : sc_int_sigref 22612922Sgabeblack@google.com// 22712922Sgabeblack@google.com// Proxy class for sc_signal_int bit and part selection. 22812922Sgabeblack@google.com//============================================================================= 22912922Sgabeblack@google.comclass sc_int_sigref : public sc_dt::sc_int_subref_r 23012922Sgabeblack@google.com{ 23112922Sgabeblack@google.com public: 23212922Sgabeblack@google.com sc_int_sigref() : sc_dt::sc_int_subref_r() {} 23312922Sgabeblack@google.com virtual ~sc_int_sigref() {} 23412922Sgabeblack@google.com virtual void concat_set(sc_dt::int64 src, int low_i); 23512922Sgabeblack@google.com virtual void concat_set(const sc_dt::sc_signed& src, int low_i); 23612922Sgabeblack@google.com virtual void concat_set(const sc_dt::sc_unsigned& src, int low_i); 23712922Sgabeblack@google.com virtual void concat_set(const sc_dt::sc_lv_base& src, int low_i); 23812922Sgabeblack@google.com virtual void concat_set(sc_dt::uint64 src, int low_i); 23912922Sgabeblack@google.com 24012922Sgabeblack@google.com public: 24112922Sgabeblack@google.com inline void initialize( sc_int_part_if* if_p, int left_, int right_ ); 24212922Sgabeblack@google.com 24312922Sgabeblack@google.com public: 24412922Sgabeblack@google.com inline void operator = ( sc_dt::uint64 v ); 24512922Sgabeblack@google.com inline void operator = ( const char* v ); 24612922Sgabeblack@google.com inline void operator = ( unsigned long v ); 24712922Sgabeblack@google.com inline void operator = ( long v ); 24812922Sgabeblack@google.com inline void operator = ( unsigned int v ); 24912922Sgabeblack@google.com inline void operator = ( int v ); 25012922Sgabeblack@google.com inline void operator = ( sc_dt::int64 v ); 25112922Sgabeblack@google.com inline void operator = ( double v ); 25212922Sgabeblack@google.com inline void operator = ( const sc_int_sigref& v ); 25312922Sgabeblack@google.com template<typename T> 25412922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_generic_base<T>& v ); 25512922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_signed& v ); 25612922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_unsigned& v ); 25712922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_bv_base& v ); 25812922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_lv_base& v ); 25912922Sgabeblack@google.com 26012922Sgabeblack@google.com public: 26112922Sgabeblack@google.com static sc_vpool<sc_int_sigref> m_pool; // Pool of objects to use. 26212922Sgabeblack@google.com 26312922Sgabeblack@google.com protected: 26412922Sgabeblack@google.com sc_int_part_if* m_if_p; // Target for selection. 26512922Sgabeblack@google.com 26612922Sgabeblack@google.com private: 26712922Sgabeblack@google.com 26812922Sgabeblack@google.com // disabled 26912922Sgabeblack@google.com sc_int_sigref( const sc_int_sigref& a ); 27012922Sgabeblack@google.com}; 27112922Sgabeblack@google.com 27212922Sgabeblack@google.com 27312922Sgabeblack@google.com//============================================================================== 27412922Sgabeblack@google.com// CLASS sc_signal<sc_dt::sc_int<W> > 27512922Sgabeblack@google.com// 27612922Sgabeblack@google.com// This class implements a signal whose value acts like an sc_dt::sc_int<W> data 27712922Sgabeblack@google.com// value. This class is a specialization of the generic sc_signal class to 27812922Sgabeblack@google.com// implement tailored support for the sc_dt::sc_int<W> class. 27912922Sgabeblack@google.com// 28012922Sgabeblack@google.com// Notes: 28112922Sgabeblack@google.com// (1) Descriptions of the methods and operators in this class appear with 28212922Sgabeblack@google.com// their implementations. 28312922Sgabeblack@google.com//============================================================================== 28412922Sgabeblack@google.comSC_TEMPLATE 28512922Sgabeblack@google.comclass sc_signal<sc_dt::sc_int<W> > : 28612922Sgabeblack@google.com public sc_signal_inout_if<sc_dt::sc_int<W> >, 28712922Sgabeblack@google.com public sc_prim_channel, 28812922Sgabeblack@google.com public sc_dt::sc_int<W> 28912922Sgabeblack@google.com{ 29012922Sgabeblack@google.com public: // typedefs 29112922Sgabeblack@google.com typedef sc_signal<sc_dt::sc_int<W> > this_type; 29212922Sgabeblack@google.com 29312922Sgabeblack@google.com public: // constructors and destructor: 29412922Sgabeblack@google.com inline sc_signal(); 29512922Sgabeblack@google.com explicit inline sc_signal(const char* name_); 29612922Sgabeblack@google.com virtual inline ~sc_signal(); 29712922Sgabeblack@google.com 29812922Sgabeblack@google.com public: // base methods: 29912922Sgabeblack@google.com inline bool base_event() const; 30012922Sgabeblack@google.com inline const sc_dt::sc_int<W>& base_read() const; 30112922Sgabeblack@google.com inline const sc_event& base_value_changed_event() const; 30212922Sgabeblack@google.com inline void base_write( sc_dt::int64 value ); 30312922Sgabeblack@google.com 30412922Sgabeblack@google.com public: // sc_prim_channel virtual methods: 30512922Sgabeblack@google.com virtual inline const char* kind() const; 30612922Sgabeblack@google.com virtual inline void update(); 30712922Sgabeblack@google.com 30812922Sgabeblack@google.com public: // sc_interface virtual methods: 30912922Sgabeblack@google.com virtual inline const sc_event& default_event() const; 31012922Sgabeblack@google.com virtual inline void register_port( 31112922Sgabeblack@google.com sc_port_base& port_, const char* if_typename_ ); 31212922Sgabeblack@google.com 31312922Sgabeblack@google.com public: // sc_int_part_if virtual methods: 31412922Sgabeblack@google.com virtual inline sc_dt::sc_int_base* part_read_target(); 31512922Sgabeblack@google.com virtual inline sc_dt::uint64 read_part(int left, int right) const; 31612922Sgabeblack@google.com virtual inline sc_int_sigref& select_part(int left, int right); 31712922Sgabeblack@google.com virtual inline void write_part(sc_dt::uint64 v, int left, int right); 31812922Sgabeblack@google.com 31912922Sgabeblack@google.com public: // interface virtual methods: 32012922Sgabeblack@google.com virtual inline bool event() const; 32112922Sgabeblack@google.com virtual inline const sc_dt::sc_int<W>& get_data_ref() const; 32212922Sgabeblack@google.com virtual inline sc_signal<sc_dt::sc_int<W> >& get_signal() ; 32312922Sgabeblack@google.com virtual inline const sc_dt::sc_int<W>& read() const; 32412922Sgabeblack@google.com virtual inline const sc_event& value_changed_event() const; 32512922Sgabeblack@google.com virtual inline void write( const sc_in<sc_dt::sc_int<W> >& value ); 32612922Sgabeblack@google.com virtual inline void write( const sc_inout<sc_dt::sc_int<W> >& value ); 32712922Sgabeblack@google.com virtual inline void write( const sc_dt::sc_int<W>& value ); 32812922Sgabeblack@google.com 32912922Sgabeblack@google.com public: // part selections: 33012922Sgabeblack@google.com inline sc_int_sigref& operator () ( int left, int right ); 33112922Sgabeblack@google.com inline sc_int_sigref& operator [] ( int bit ); 33212922Sgabeblack@google.com 33312922Sgabeblack@google.com public: // operators: 33412922Sgabeblack@google.com inline void operator = ( const this_type& new_val ); 33512922Sgabeblack@google.com inline void operator = ( const char* new_val ); 33612922Sgabeblack@google.com inline void operator = ( sc_dt::uint64 new_val ); 33712922Sgabeblack@google.com inline void operator = ( sc_dt::int64 new_val ); 33812922Sgabeblack@google.com inline void operator = ( int new_val ); 33912922Sgabeblack@google.com inline void operator = ( long new_val ) ; 34012922Sgabeblack@google.com inline void operator = ( short new_val ) ; 34112922Sgabeblack@google.com inline void operator = ( unsigned int new_val ) ; 34212922Sgabeblack@google.com inline void operator = ( unsigned long new_val ); 34312922Sgabeblack@google.com inline void operator = ( unsigned short new_val ); 34412922Sgabeblack@google.com template<typename T> 34512922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ); 34612922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_signed& new_val ); 34712922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_unsigned& new_val ); 34812922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_bv_base& new_val ); 34912922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_lv_base& new_val ); 35012922Sgabeblack@google.com 35112922Sgabeblack@google.com // concatenation methods (we inherit length and gets from sc_dt::sc_int<W>): 35212922Sgabeblack@google.com 35312922Sgabeblack@google.com virtual inline void concat_set(sc_dt::int64 src, int low_i); 35412922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i); 35512922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i); 35612922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i); 35712922Sgabeblack@google.com virtual inline void concat_set(sc_dt::uint64 src, int low_i); 35812922Sgabeblack@google.com 35912922Sgabeblack@google.com protected: // debugging methods: 36012922Sgabeblack@google.com // #### void check_port(); 36112922Sgabeblack@google.com void check_writer(); 36212922Sgabeblack@google.com 36312922Sgabeblack@google.com private: // Disabled operations that sc_dt::sc_int<W> supports: 36412922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator ++ (); // prefix 36512922Sgabeblack@google.com const sc_signal<sc_dt::sc_int<W> >& operator ++ (int); // postfix 36612922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator -- (); // prefix 36712922Sgabeblack@google.com const sc_signal<sc_dt::sc_int<W> >& operator -- (int); // postfix 36812922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator += (sc_dt::int_type); 36912922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator -= (sc_dt::int_type); 37012922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator *= (sc_dt::int_type); 37112922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator /= (sc_dt::int_type); 37212922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator %= (sc_dt::int_type); 37312922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator &= (sc_dt::int_type); 37412922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator |= (sc_dt::int_type); 37512922Sgabeblack@google.com sc_signal<sc_dt::sc_int<W> >& operator ^= (sc_dt::int_type); 37612922Sgabeblack@google.com 37712922Sgabeblack@google.com protected: 37812922Sgabeblack@google.com mutable sc_event* m_changed_event_p; // Value changed event this object. 37912922Sgabeblack@google.com sc_dt::uint64 m_event_delta; // Delta cycle of last event. 38012922Sgabeblack@google.com sc_dt::int64 m_new_val; // New value for this object instance. 38112922Sgabeblack@google.com sc_port_base* m_output_p; // Single write port verify field. 38212922Sgabeblack@google.com sc_process_b* m_writer_p; // Single writer verify field. 38312922Sgabeblack@google.com}; 38412922Sgabeblack@google.com 38512922Sgabeblack@google.com 38612922Sgabeblack@google.comSC_TEMPLATE // Return true if a changed event happened in the last delta cycle. 38712922Sgabeblack@google.cominline bool sc_signal<sc_dt::sc_int<W> >::base_event() const 38812922Sgabeblack@google.com{ 38912922Sgabeblack@google.com return simcontext()->delta_count() == m_event_delta + 1; 39012922Sgabeblack@google.com} 39112922Sgabeblack@google.com 39212922Sgabeblack@google.com 39312922Sgabeblack@google.comSC_TEMPLATE // Return this object's sc_dt::sc_int<W> object instance. 39412922Sgabeblack@google.cominline const sc_dt::sc_int<W>& sc_signal<sc_dt::sc_int<W> >::base_read() const 39512922Sgabeblack@google.com{ 39612922Sgabeblack@google.com return *this; 39712922Sgabeblack@google.com} 39812922Sgabeblack@google.com 39912922Sgabeblack@google.com 40012922Sgabeblack@google.comSC_TEMPLATE // Return the value changed event, allocating it if necessary. 40112922Sgabeblack@google.cominline const sc_event& sc_signal<sc_dt::sc_int<W> >::base_value_changed_event() const 40212922Sgabeblack@google.com{ 40312922Sgabeblack@google.com if ( !m_changed_event_p ) m_changed_event_p = new sc_event; 40412922Sgabeblack@google.com return *m_changed_event_p; 40512922Sgabeblack@google.com} 40612922Sgabeblack@google.com 40712922Sgabeblack@google.com 40812922Sgabeblack@google.comSC_TEMPLATE // Select a portion of a value. 40912922Sgabeblack@google.cominline sc_int_sigref& sc_signal<sc_dt::sc_int<W> >::select_part(int left, int right) 41012922Sgabeblack@google.com{ 41112922Sgabeblack@google.com sc_int_sigref* result_p = sc_int_sigref::m_pool.allocate(); 41212922Sgabeblack@google.com result_p->initialize(this, left, right); 41312922Sgabeblack@google.com return *result_p; 41412922Sgabeblack@google.com} 41512922Sgabeblack@google.com 41612922Sgabeblack@google.com 41712922Sgabeblack@google.comSC_TEMPLATE // Write an sc_dt::uint64 value to this object instance. 41812922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::base_write( sc_dt::int64 value ) 41912922Sgabeblack@google.com{ 42012922Sgabeblack@google.com# if defined(DEBUG_SYSTEMC) 42112922Sgabeblack@google.com check_writer(); 42212922Sgabeblack@google.com# endif 42312922Sgabeblack@google.com m_new_val = value; 42412922Sgabeblack@google.com request_update(); 42512922Sgabeblack@google.com} 42612922Sgabeblack@google.com 42712922Sgabeblack@google.com//------------------------------------------------------------------------------ 42812922Sgabeblack@google.com//"sc_signal<sc_dt::sc_int<W> >::check_writer" 42912922Sgabeblack@google.com// 43012922Sgabeblack@google.com// This method checks to see if there is more than one writer for this 43112922Sgabeblack@google.com// object instance by keeping track of the process performing the write. 43212922Sgabeblack@google.com//------------------------------------------------------------------------------ 43312922Sgabeblack@google.comSC_TEMPLATE 43412922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::check_writer() 43512922Sgabeblack@google.com{ 43612922Sgabeblack@google.com sc_process_b* writer_p = sc_get_curr_process_handle(); 43712922Sgabeblack@google.com if( m_writer_p == 0 ) 43812922Sgabeblack@google.com { 43912922Sgabeblack@google.com m_writer_p = writer_p; 44012922Sgabeblack@google.com } 44112922Sgabeblack@google.com else if( m_writer_p != writer_p ) 44212922Sgabeblack@google.com { 44312922Sgabeblack@google.com sc_signal_invalid_writer( name(), kind(), 44412922Sgabeblack@google.com m_writer_p->name(), writer_p->name() ); 44512922Sgabeblack@google.com } 44612922Sgabeblack@google.com} 44712922Sgabeblack@google.com 44812922Sgabeblack@google.com 44912922Sgabeblack@google.com//------------------------------------------------------------------------------ 45012922Sgabeblack@google.com//"sc_signal<sc_dt::sc_int<W> >::concat_set" 45112922Sgabeblack@google.com// 45212922Sgabeblack@google.com// These virtual methods allow value assignments to this object instance 45312922Sgabeblack@google.com// from various sources. The position within the supplied source of the 45412922Sgabeblack@google.com// low order bit for this object instance's value is low_i. 45512922Sgabeblack@google.com// src = source value. 45612922Sgabeblack@google.com// low_i = bit within src to serve as low order bit of this object 45712922Sgabeblack@google.com// instance's value. 45812922Sgabeblack@google.com//------------------------------------------------------------------------------ 45912922Sgabeblack@google.comSC_TEMPLATE 46012922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::concat_set(sc_dt::int64 src, int low_i) 46112922Sgabeblack@google.com{ 46212922Sgabeblack@google.com if ( low_i < 64 ) 46312922Sgabeblack@google.com { 46412922Sgabeblack@google.com base_write(src >> low_i); 46512922Sgabeblack@google.com } 46612922Sgabeblack@google.com else 46712922Sgabeblack@google.com { 46812922Sgabeblack@google.com base_write( src >> 63 ); 46912922Sgabeblack@google.com } 47012922Sgabeblack@google.com} 47112922Sgabeblack@google.com 47212922Sgabeblack@google.comSC_TEMPLATE 47312922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::concat_set(const sc_dt::sc_lv_base& src, int low_i) 47412922Sgabeblack@google.com{ 47512922Sgabeblack@google.com sc_dt::sc_unsigned tmp(src.length()); 47612922Sgabeblack@google.com tmp = src >> low_i; 47712922Sgabeblack@google.com base_write( tmp.to_int64() ); 47812922Sgabeblack@google.com} 47912922Sgabeblack@google.com 48012922Sgabeblack@google.comSC_TEMPLATE 48112922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::concat_set(const sc_dt::sc_signed& src, int low_i) 48212922Sgabeblack@google.com{ 48312922Sgabeblack@google.com base_write( (src >> low_i).to_int64()); 48412922Sgabeblack@google.com} 48512922Sgabeblack@google.com 48612922Sgabeblack@google.comSC_TEMPLATE 48712922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::concat_set(const sc_dt::sc_unsigned& src, int low_i) 48812922Sgabeblack@google.com{ 48912922Sgabeblack@google.com base_write( (src >> low_i).to_int64()); 49012922Sgabeblack@google.com} 49112922Sgabeblack@google.com 49212922Sgabeblack@google.comSC_TEMPLATE 49312922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::concat_set(sc_dt::uint64 src, int low_i) 49412922Sgabeblack@google.com{ 49512922Sgabeblack@google.com base_write( ( low_i < 64 ) ? src >> low_i : 0 ); 49612922Sgabeblack@google.com} 49712922Sgabeblack@google.com 49812922Sgabeblack@google.com 49912922Sgabeblack@google.com 50012922Sgabeblack@google.comSC_TEMPLATE // Return the default event for this object instance. 50112922Sgabeblack@google.cominline const sc_event& sc_signal<sc_dt::sc_int<W> >::default_event() const 50212922Sgabeblack@google.com { return base_value_changed_event(); } 50312922Sgabeblack@google.com 50412922Sgabeblack@google.com 50512922Sgabeblack@google.comSC_TEMPLATE // Return true if a changed event happened in the last delta cycle. 50612922Sgabeblack@google.cominline bool sc_signal<sc_dt::sc_int<W> >::event() const 50712922Sgabeblack@google.com { return base_event(); } 50812922Sgabeblack@google.com 50912922Sgabeblack@google.com 51012922Sgabeblack@google.comSC_TEMPLATE // Return a reference to the value of this object instance. 51112922Sgabeblack@google.cominline const sc_dt::sc_int<W>& sc_signal<sc_dt::sc_int<W> >::get_data_ref() const 51212922Sgabeblack@google.com { return *this; } 51312922Sgabeblack@google.com 51412922Sgabeblack@google.com 51512922Sgabeblack@google.comSC_TEMPLATE // Return a pointer to this object instance. 51612922Sgabeblack@google.cominline sc_signal<sc_dt::sc_int<W> >& sc_signal<sc_dt::sc_int<W> >::get_signal() 51712922Sgabeblack@google.com { return *this; } 51812922Sgabeblack@google.com 51912922Sgabeblack@google.com 52012922Sgabeblack@google.comSC_TEMPLATE // Return a kind value of "sc_signal". 52112922Sgabeblack@google.cominline const char* sc_signal<sc_dt::sc_int<W> >::kind() const 52212922Sgabeblack@google.com{ 52312922Sgabeblack@google.com return "sc_signal"; 52412922Sgabeblack@google.com} 52512922Sgabeblack@google.com 52612922Sgabeblack@google.com 52712922Sgabeblack@google.com//------------------------------------------------------------------------------ 52812922Sgabeblack@google.com//"sc_signal_uint::operator () 52912922Sgabeblack@google.com// 53012922Sgabeblack@google.com// This operator returns a part selection of this object instance. 53112922Sgabeblack@google.com// left = left-hand bit of the selection. 53212922Sgabeblack@google.com// right = right-hand bit of the selection. 53312922Sgabeblack@google.com//------------------------------------------------------------------------------ 53412922Sgabeblack@google.comSC_TEMPLATE 53512922Sgabeblack@google.cominline sc_int_sigref& sc_signal<sc_dt::sc_int<W> >::operator () (int left, int right) 53612922Sgabeblack@google.com{ 53712922Sgabeblack@google.com sc_int_sigref* result_p; // Value to return. 53812922Sgabeblack@google.com 53912922Sgabeblack@google.com result_p = sc_int_sigref::m_pool.allocate(); 54012922Sgabeblack@google.com result_p->initialize(this, left, right); 54112922Sgabeblack@google.com return *result_p; 54212922Sgabeblack@google.com} 54312922Sgabeblack@google.com 54412922Sgabeblack@google.com 54512922Sgabeblack@google.com//------------------------------------------------------------------------------ 54612922Sgabeblack@google.com//"sc_signal_uint::operator []" 54712922Sgabeblack@google.com// 54812922Sgabeblack@google.com// This operator returns a bit selection of this object instance. 54912922Sgabeblack@google.com// i = bit to be selected. 55012922Sgabeblack@google.com//------------------------------------------------------------------------------ 55112922Sgabeblack@google.comSC_TEMPLATE 55212922Sgabeblack@google.cominline sc_int_sigref& sc_signal<sc_dt::sc_int<W> >::operator [] ( int bit ) 55312922Sgabeblack@google.com{ 55412922Sgabeblack@google.com return operator () (bit,bit); 55512922Sgabeblack@google.com} 55612922Sgabeblack@google.com 55712922Sgabeblack@google.com 55812922Sgabeblack@google.comSC_TEMPLATE 55912922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const this_type& new_val ) 56012922Sgabeblack@google.com { base_write( (sc_dt::int64)new_val ); } 56112922Sgabeblack@google.com 56212922Sgabeblack@google.comSC_TEMPLATE 56312922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const char* new_val ) 56412922Sgabeblack@google.com { m_new_val = sc_dt::sc_int<64>(new_val); request_update(); } 56512922Sgabeblack@google.com 56612922Sgabeblack@google.comSC_TEMPLATE 56712922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( sc_dt::uint64 new_val ) 56812922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 56912922Sgabeblack@google.com 57012922Sgabeblack@google.comSC_TEMPLATE 57112922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( sc_dt::int64 new_val ) 57212922Sgabeblack@google.com { base_write(new_val); } 57312922Sgabeblack@google.com 57412922Sgabeblack@google.comSC_TEMPLATE 57512922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( int new_val ) 57612922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 57712922Sgabeblack@google.com 57812922Sgabeblack@google.comSC_TEMPLATE 57912922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( long new_val ) 58012922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 58112922Sgabeblack@google.com 58212922Sgabeblack@google.comSC_TEMPLATE 58312922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( short new_val ) 58412922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 58512922Sgabeblack@google.com 58612922Sgabeblack@google.comSC_TEMPLATE 58712922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( unsigned int new_val ) 58812922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 58912922Sgabeblack@google.com 59012922Sgabeblack@google.comSC_TEMPLATE 59112922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( unsigned long new_val ) 59212922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 59312922Sgabeblack@google.com 59412922Sgabeblack@google.comSC_TEMPLATE 59512922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( unsigned short new_val ) 59612922Sgabeblack@google.com { base_write((sc_dt::int64)new_val); } 59712922Sgabeblack@google.com 59812922Sgabeblack@google.com 59912922Sgabeblack@google.comSC_TEMPLATE 60012922Sgabeblack@google.comtemplate<typename T> 60112922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( 60212922Sgabeblack@google.com const sc_dt::sc_generic_base<T>& new_val ) 60312922Sgabeblack@google.com { base_write(new_val->to_int64()); } 60412922Sgabeblack@google.com 60512922Sgabeblack@google.comSC_TEMPLATE 60612922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const sc_dt::sc_signed& new_val ) 60712922Sgabeblack@google.com { base_write(new_val.to_int64()); } 60812922Sgabeblack@google.com 60912922Sgabeblack@google.comSC_TEMPLATE 61012922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const sc_dt::sc_unsigned& new_val ) 61112922Sgabeblack@google.com { base_write(new_val.to_int64()); } 61212922Sgabeblack@google.com 61312922Sgabeblack@google.comSC_TEMPLATE 61412922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const sc_dt::sc_bv_base& new_val ) 61512922Sgabeblack@google.com { base_write( (sc_dt::sc_int<W>)new_val ); } 61612922Sgabeblack@google.com 61712922Sgabeblack@google.comSC_TEMPLATE 61812922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::operator = ( const sc_dt::sc_lv_base& new_val ) 61912922Sgabeblack@google.com { base_write( (sc_dt::sc_int<W>)new_val ); } 62012922Sgabeblack@google.com 62112922Sgabeblack@google.com 62212922Sgabeblack@google.comSC_TEMPLATE 62312922Sgabeblack@google.cominline sc_dt::sc_int_base* sc_signal<sc_dt::sc_int<W> >::part_read_target() 62412922Sgabeblack@google.com { return this; } 62512922Sgabeblack@google.com 62612922Sgabeblack@google.com 62712922Sgabeblack@google.comSC_TEMPLATE 62812922Sgabeblack@google.cominline const sc_dt::sc_int<W>& sc_signal<sc_dt::sc_int<W> >::read() const 62912922Sgabeblack@google.com { return *this; } 63012922Sgabeblack@google.com 63112922Sgabeblack@google.com 63212922Sgabeblack@google.comSC_TEMPLATE // Read a portion of a value. 63312922Sgabeblack@google.cominline sc_dt::uint64 sc_signal<sc_dt::sc_int<W> >::read_part( int left, int right ) const 63412922Sgabeblack@google.com{ 63512922Sgabeblack@google.com // This pointer required for HP aCC. 63612922Sgabeblack@google.com return (this->m_val & ~sc_dt::mask_int[left][right]) >> right; 63712922Sgabeblack@google.com} 63812922Sgabeblack@google.com 63912922Sgabeblack@google.comSC_TEMPLATE 64012922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::register_port( 64112922Sgabeblack@google.com sc_port_base& port_, const char* if_typename_ ) 64212922Sgabeblack@google.com{ 64312922Sgabeblack@google.com# ifdef DEBUG_SYSTEMC 64412922Sgabeblack@google.com std::string nm( if_typename_ ); 64512922Sgabeblack@google.com if( nm == typeid( sc_signal_inout_if<sc_dt::sc_int<W> > ).name() ) 64612922Sgabeblack@google.com { 64712922Sgabeblack@google.com if( m_output_p != 0 ) 64812922Sgabeblack@google.com { 64912922Sgabeblack@google.com sc_signal_invalid_writer( name(), kind(), 65012922Sgabeblack@google.com m_output_p->name(), port_.name() ); 65112922Sgabeblack@google.com } 65212922Sgabeblack@google.com m_output_p = &port_; 65312922Sgabeblack@google.com } 65412922Sgabeblack@google.com# else 65512922Sgabeblack@google.com if ( &port_ && if_typename_ ) {} // Silence unused args warning. 65612922Sgabeblack@google.com# endif 65712922Sgabeblack@google.com} 65812922Sgabeblack@google.com 65912922Sgabeblack@google.com 66012922Sgabeblack@google.comSC_TEMPLATE // Autogenerated name object instance constructor. 66112922Sgabeblack@google.cominline sc_signal<sc_dt::sc_int<W> >::sc_signal() : 66212922Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name( "signal" )), 66312922Sgabeblack@google.com m_changed_event_p(0), 66412922Sgabeblack@google.com m_output_p(0), 66512922Sgabeblack@google.com m_writer_p(0) 66612922Sgabeblack@google.com{ } 66712922Sgabeblack@google.com 66812922Sgabeblack@google.com 66912922Sgabeblack@google.comSC_TEMPLATE // Explicitly named object instance constructor. 67012922Sgabeblack@google.cominline sc_signal<sc_dt::sc_int<W> >::sc_signal(const char* name_) : 67112922Sgabeblack@google.com sc_prim_channel(name_), 67212922Sgabeblack@google.com m_changed_event_p(0), 67312922Sgabeblack@google.com m_output_p(0), 67412922Sgabeblack@google.com m_writer_p(0) 67512922Sgabeblack@google.com{ } 67612922Sgabeblack@google.com 67712922Sgabeblack@google.com 67812922Sgabeblack@google.comSC_TEMPLATE // Object instance destructor. 67912922Sgabeblack@google.cominline sc_signal<sc_dt::sc_int<W> >::~sc_signal() 68012922Sgabeblack@google.com{ 68112922Sgabeblack@google.com if ( m_changed_event_p ) delete m_changed_event_p; 68212922Sgabeblack@google.com} 68312922Sgabeblack@google.com 68412922Sgabeblack@google.com 68512922Sgabeblack@google.comSC_TEMPLATE // Update the current value from new value. 68612922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::update() 68712922Sgabeblack@google.com{ 68812922Sgabeblack@google.com if ( m_changed_event_p ) 68912922Sgabeblack@google.com { 69012922Sgabeblack@google.com // This pointer required for HP aCC. 69112922Sgabeblack@google.com sc_dt::int64 old_val = this->m_val; 69212922Sgabeblack@google.com sc_dt::sc_int_base::operator = (m_new_val); 69312922Sgabeblack@google.com if ( old_val != this->m_val ) 69412922Sgabeblack@google.com { 69512922Sgabeblack@google.com m_changed_event_p->notify_delayed(); 69612922Sgabeblack@google.com m_event_delta = simcontext()->delta_count(); 69712922Sgabeblack@google.com } 69812922Sgabeblack@google.com } 69912922Sgabeblack@google.com else 70012922Sgabeblack@google.com { 70112922Sgabeblack@google.com sc_dt::sc_int_base::operator = (m_new_val); 70212922Sgabeblack@google.com } 70312922Sgabeblack@google.com} 70412922Sgabeblack@google.com 70512922Sgabeblack@google.com 70612922Sgabeblack@google.comSC_TEMPLATE // Return the value changed event. 70712922Sgabeblack@google.cominline const sc_event& sc_signal<sc_dt::sc_int<W> >::value_changed_event() const 70812922Sgabeblack@google.com { return base_value_changed_event(); } 70912922Sgabeblack@google.com 71012922Sgabeblack@google.com 71112922Sgabeblack@google.comSC_TEMPLATE // Write a sc_in<sc_dt::sc_int<W> > value to this object instance. 71212922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::write( const sc_in<sc_dt::sc_int<W> >& value ) 71312922Sgabeblack@google.com { base_write( value.operator sc_dt::int64 () ); } 71412922Sgabeblack@google.com 71512922Sgabeblack@google.com 71612922Sgabeblack@google.comSC_TEMPLATE // Write a sc_inout<sc_dt::sc_int<W> > value to this object instance. 71712922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::write( const sc_inout<sc_dt::sc_int<W> >& value ) 71812922Sgabeblack@google.com { base_write( value.operator sc_dt::int64 () ); } 71912922Sgabeblack@google.com 72012922Sgabeblack@google.com 72112922Sgabeblack@google.comSC_TEMPLATE // Write a sc_dt::sc_int<W> value to this object instance. 72212922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::write( const sc_dt::sc_int<W>& value ) 72312922Sgabeblack@google.com { base_write( value); } 72412922Sgabeblack@google.com 72512922Sgabeblack@google.com 72612922Sgabeblack@google.comSC_TEMPLATE // Write a portion of a value. If this is the first write in 72712922Sgabeblack@google.com // a delta cycle we copy the existing value before setting the bits. 72812922Sgabeblack@google.cominline void sc_signal<sc_dt::sc_int<W> >::write_part( sc_dt::uint64 v, int left, int right ) 72912922Sgabeblack@google.com{ 73012922Sgabeblack@google.com sc_dt::int64 new_v; // New value. 73112922Sgabeblack@google.com sc_dt::uint64 keep; // Keep mask value. 73212922Sgabeblack@google.com 73312922Sgabeblack@google.com keep = sc_dt::mask_int[left][right]; 73412922Sgabeblack@google.com new_v = (m_new_val & keep) | ((v << right) & ~keep); 73512922Sgabeblack@google.com if ( m_new_val != new_v ) request_update(); 73612922Sgabeblack@google.com m_new_val = new_v; 73712922Sgabeblack@google.com} 73812922Sgabeblack@google.com 73912922Sgabeblack@google.com 74012922Sgabeblack@google.com//============================================================================== 74112922Sgabeblack@google.com// CLASS sc_in<sc_dt::sc_int<W> > 74212922Sgabeblack@google.com// 74312922Sgabeblack@google.com// This class implements an input port whose target acts like an sc_dt::sc_int<W> data 74412922Sgabeblack@google.com// value. This class is a specialization of the generic sc_in class to 74512922Sgabeblack@google.com// implement tailored support for the sc_dt::sc_int<W> class. 74612922Sgabeblack@google.com//============================================================================== 74712922Sgabeblack@google.comSC_TEMPLATE 74812922Sgabeblack@google.comclass sc_in<sc_dt::sc_int<W> > : 74912922Sgabeblack@google.com public sc_port<sc_signal_in_if<sc_dt::sc_int<W> >, 1>, 75012922Sgabeblack@google.com public sc_dt::sc_value_base 75112922Sgabeblack@google.com{ 75212922Sgabeblack@google.com public: 75312922Sgabeblack@google.com 75412922Sgabeblack@google.com // typedefs 75512922Sgabeblack@google.com 75612922Sgabeblack@google.com typedef sc_dt::sc_int<W> data_type; 75712922Sgabeblack@google.com typedef sc_signal_in_if<sc_dt::sc_int<W> > if_type; 75812922Sgabeblack@google.com typedef sc_port<if_type,1> base_type; 75912922Sgabeblack@google.com typedef sc_in<sc_dt::sc_int<W> > this_type; 76012922Sgabeblack@google.com 76112922Sgabeblack@google.com typedef if_type in_if_type; 76212922Sgabeblack@google.com typedef base_type in_port_type; 76312922Sgabeblack@google.com typedef sc_signal_inout_if<sc_dt::sc_int<W> > inout_if_type; 76412922Sgabeblack@google.com typedef sc_inout<sc_dt::sc_int<W> > inout_port_type; 76512922Sgabeblack@google.com 76612922Sgabeblack@google.com public: 76712922Sgabeblack@google.com 76812922Sgabeblack@google.com // bind methods and operators: 76912922Sgabeblack@google.com 77012922Sgabeblack@google.com void bind( const in_if_type& interface_ ) 77112922Sgabeblack@google.com { sc_port_base::bind( const_cast<in_if_type&>( interface_) );} 77212922Sgabeblack@google.com void operator () ( const in_if_type& interface_ ) 77312922Sgabeblack@google.com { sc_port_base::bind( const_cast<in_if_type&>( interface_) );} 77412922Sgabeblack@google.com void bind( in_port_type& parent_ ) 77512922Sgabeblack@google.com { sc_port_base::bind(parent_);} 77612922Sgabeblack@google.com void operator () ( in_port_type& parent_ ) 77712922Sgabeblack@google.com { sc_port_base::bind(parent_);} 77812922Sgabeblack@google.com void bind( inout_port_type& parent_ ) 77912922Sgabeblack@google.com { sc_port_base::bind(parent_);} 78012922Sgabeblack@google.com void operator () ( inout_port_type& parent_ ) 78112922Sgabeblack@google.com { sc_port_base::bind(parent_);} 78212922Sgabeblack@google.com 78312922Sgabeblack@google.com protected: 78412922Sgabeblack@google.com // called by pbind (for internal use only) 78512922Sgabeblack@google.com virtual inline int vbind( sc_interface& interface_ ) 78612922Sgabeblack@google.com { 78712922Sgabeblack@google.com return sc_port_b<if_type>::vbind( interface_ ); 78812922Sgabeblack@google.com } 78912922Sgabeblack@google.com virtual inline int vbind( sc_port_base& parent_ ) 79012922Sgabeblack@google.com { 79112922Sgabeblack@google.com in_port_type* in_parent = dynamic_cast<in_port_type*>( &parent_ ); 79212922Sgabeblack@google.com if( in_parent != 0 ) { 79312922Sgabeblack@google.com sc_port_base::bind( *in_parent ); 79412922Sgabeblack@google.com return 0; 79512922Sgabeblack@google.com } 79612922Sgabeblack@google.com inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ ); 79712922Sgabeblack@google.com if( inout_parent != 0 ) { 79812922Sgabeblack@google.com sc_port_base::bind( *inout_parent ); 79912922Sgabeblack@google.com return 0; 80012922Sgabeblack@google.com } 80112922Sgabeblack@google.com // type mismatch 80212922Sgabeblack@google.com return 2; 80312922Sgabeblack@google.com } 80412922Sgabeblack@google.com 80512922Sgabeblack@google.com 80612922Sgabeblack@google.com // constructors 80712922Sgabeblack@google.com 80812922Sgabeblack@google.com public: 80912922Sgabeblack@google.com sc_in() 81012922Sgabeblack@google.com : base_type(), m_traces( 0 ) 81112922Sgabeblack@google.com {} 81212922Sgabeblack@google.com 81312922Sgabeblack@google.com explicit sc_in( const char* name_ ) 81412922Sgabeblack@google.com : base_type( name_ ), m_traces( 0 ) 81512922Sgabeblack@google.com {} 81612922Sgabeblack@google.com 81712922Sgabeblack@google.com explicit sc_in( const in_if_type& interface_ ) 81812922Sgabeblack@google.com : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ) 81912922Sgabeblack@google.com {} 82012922Sgabeblack@google.com 82112922Sgabeblack@google.com sc_in( const char* name_, const in_if_type& interface_ ) 82212922Sgabeblack@google.com : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ) 82312922Sgabeblack@google.com {} 82412922Sgabeblack@google.com 82512922Sgabeblack@google.com explicit sc_in( in_port_type& parent_ ) 82612922Sgabeblack@google.com : base_type( parent_ ), m_traces( 0 ) 82712922Sgabeblack@google.com {} 82812922Sgabeblack@google.com 82912922Sgabeblack@google.com sc_in( const char* name_, in_port_type& parent_ ) 83012922Sgabeblack@google.com : base_type( name_, parent_ ), m_traces( 0 ) 83112922Sgabeblack@google.com {} 83212922Sgabeblack@google.com 83312922Sgabeblack@google.com explicit sc_in( inout_port_type& parent_ ) 83412922Sgabeblack@google.com : base_type(), m_traces( 0 ) 83512922Sgabeblack@google.com { sc_port_base::bind( parent_ ); } 83612922Sgabeblack@google.com 83712922Sgabeblack@google.com sc_in( const char* name_, inout_port_type& parent_ ) 83812922Sgabeblack@google.com : base_type( name_ ), m_traces( 0 ) 83912922Sgabeblack@google.com { sc_port_base::bind( parent_ ); } 84012922Sgabeblack@google.com 84112922Sgabeblack@google.com sc_in( this_type& parent_ ) 84212922Sgabeblack@google.com : base_type( parent_ ), m_traces( 0 ) 84312922Sgabeblack@google.com {} 84412922Sgabeblack@google.com 84512922Sgabeblack@google.com sc_in( const char* name_, this_type& parent_ ) 84612922Sgabeblack@google.com : base_type( name_, parent_ ), m_traces( 0 ) 84712922Sgabeblack@google.com {} 84812922Sgabeblack@google.com 84912922Sgabeblack@google.com 85012922Sgabeblack@google.com // destructor 85112922Sgabeblack@google.com 85212922Sgabeblack@google.com virtual inline ~sc_in() 85312922Sgabeblack@google.com { 85412922Sgabeblack@google.com remove_traces(); 85512922Sgabeblack@google.com } 85612922Sgabeblack@google.com 85712922Sgabeblack@google.com // bit and part selection 85812922Sgabeblack@google.com 85912922Sgabeblack@google.com sc_dt::sc_int_bitref_r operator [] ( int i ) const 86012922Sgabeblack@google.com { return (*this)->read()[i]; } 86112922Sgabeblack@google.com sc_dt::sc_int_bitref_r bit( int i ) const 86212922Sgabeblack@google.com { return (*this)->read()[i]; } 86312922Sgabeblack@google.com sc_dt::sc_int_subref_r operator () ( int left, int right ) const 86412922Sgabeblack@google.com { return (*this)->read()(left,right); } 86512922Sgabeblack@google.com sc_dt::sc_int_subref_r range( int left, int right ) const 86612922Sgabeblack@google.com { return (*this)->read()(left,right); } 86712922Sgabeblack@google.com 86812922Sgabeblack@google.com 86912922Sgabeblack@google.com // interface access shortcut methods 87012922Sgabeblack@google.com 87112922Sgabeblack@google.com // get the default event 87212922Sgabeblack@google.com 87312922Sgabeblack@google.com const sc_event& default_event() const 87412922Sgabeblack@google.com { return (*this)->value_changed_event(); } 87512922Sgabeblack@google.com 87612922Sgabeblack@google.com 87712922Sgabeblack@google.com // get the value changed event 87812922Sgabeblack@google.com 87912922Sgabeblack@google.com const sc_event& value_changed_event() const 88012922Sgabeblack@google.com { return (*this)->value_changed_event(); } 88112922Sgabeblack@google.com 88212922Sgabeblack@google.com 88312922Sgabeblack@google.com // read the current value 88412922Sgabeblack@google.com 88512922Sgabeblack@google.com const sc_dt::sc_int<W>& read() const 88612922Sgabeblack@google.com { return (*this)->read(); } 88712922Sgabeblack@google.com 88812922Sgabeblack@google.com operator sc_dt::int64 () const 88912922Sgabeblack@google.com { return (sc_dt::int64)(*this)->read(); } 89012922Sgabeblack@google.com 89112922Sgabeblack@google.com // was there a value changed event? 89212922Sgabeblack@google.com 89312922Sgabeblack@google.com bool event() const 89412922Sgabeblack@google.com { return (*this)->event(); } 89512922Sgabeblack@google.com 89612922Sgabeblack@google.com 89712922Sgabeblack@google.com // (other) event finder method(s) 89812922Sgabeblack@google.com 89912922Sgabeblack@google.com sc_event_finder& value_changed() const 90012922Sgabeblack@google.com { 90112922Sgabeblack@google.com return *new sc_event_finder_t<in_if_type>( 90212922Sgabeblack@google.com *this, &in_if_type::value_changed_event ); 90312922Sgabeblack@google.com } 90412922Sgabeblack@google.com 90512922Sgabeblack@google.com 90612922Sgabeblack@google.com 90712922Sgabeblack@google.com // reduction methods: 90812922Sgabeblack@google.com 90912922Sgabeblack@google.com inline bool and_reduce() const 91012922Sgabeblack@google.com { return (*this)->read().and_reduce(); } 91112922Sgabeblack@google.com inline bool nand_reduce() const 91212922Sgabeblack@google.com { return (*this)->read().nand_reduce(); } 91312922Sgabeblack@google.com inline bool nor_reduce() const 91412922Sgabeblack@google.com { return (*this)->read().nor_reduce(); } 91512922Sgabeblack@google.com inline bool or_reduce() const 91612922Sgabeblack@google.com { return (*this)->read().or_reduce(); } 91712922Sgabeblack@google.com inline bool xnor_reduce() const 91812922Sgabeblack@google.com { return (*this)->read().xnor_reduce(); } 91912922Sgabeblack@google.com inline bool xor_reduce() const 92012922Sgabeblack@google.com { return (*this)->read().xor_reduce(); } 92112922Sgabeblack@google.com 92212922Sgabeblack@google.com 92312922Sgabeblack@google.com // called when elaboration is done 92412922Sgabeblack@google.com /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */ 92512922Sgabeblack@google.com /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */ 92612922Sgabeblack@google.com 92712922Sgabeblack@google.com virtual inline void end_of_elaboration() 92812922Sgabeblack@google.com { 92912922Sgabeblack@google.com if( m_traces != 0 ) { 93012922Sgabeblack@google.com for( unsigned int i = 0; i < m_traces->size(); ++ i ) { 93112922Sgabeblack@google.com sc_trace_params* p = (*m_traces)[i]; 93212922Sgabeblack@google.com sc_trace( p->tf, read(), p->name ); 93312922Sgabeblack@google.com } 93412922Sgabeblack@google.com remove_traces(); 93512922Sgabeblack@google.com } 93612922Sgabeblack@google.com } 93712922Sgabeblack@google.com 93812922Sgabeblack@google.com virtual inline const char* kind() const 93912922Sgabeblack@google.com { return "sc_in"; } 94012922Sgabeblack@google.com 94112922Sgabeblack@google.com 94212922Sgabeblack@google.com // called by sc_trace 94312922Sgabeblack@google.com void add_trace( sc_trace_file* tf_, const std::string& name_ ) const 94412922Sgabeblack@google.com { 94512922Sgabeblack@google.com if( tf_ != 0 ) { 94612922Sgabeblack@google.com if( m_traces == 0 ) { 94712922Sgabeblack@google.com m_traces = new sc_trace_params_vec; 94812922Sgabeblack@google.com } 94912922Sgabeblack@google.com m_traces->push_back( new sc_trace_params( tf_, name_ ) ); 95012922Sgabeblack@google.com } 95112922Sgabeblack@google.com } 95212922Sgabeblack@google.com 95312922Sgabeblack@google.com 95412922Sgabeblack@google.com // concatenation methods 95512922Sgabeblack@google.com 95612922Sgabeblack@google.com virtual inline int concat_length(bool* xz_present_p) const 95712922Sgabeblack@google.com { return (*this)->read().concat_length( xz_present_p ); } 95812922Sgabeblack@google.com virtual inline sc_dt::uint64 concat_get_uint64() const 95912922Sgabeblack@google.com { return (*this)->read().concat_get_uint64(); } 96012922Sgabeblack@google.com virtual 96112922Sgabeblack@google.com inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const 96212922Sgabeblack@google.com { return (*this)->read().concat_get_ctrl(dst_p, low_i); } 96312922Sgabeblack@google.com virtual 96412922Sgabeblack@google.com inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const 96512922Sgabeblack@google.com { return (*this)->read().concat_get_data(dst_p, low_i); } 96612922Sgabeblack@google.com 96712922Sgabeblack@google.com protected: 96812922Sgabeblack@google.com void remove_traces() const 96912922Sgabeblack@google.com { 97012922Sgabeblack@google.com if( m_traces != 0 ) { 97112922Sgabeblack@google.com for( int i = m_traces->size() - 1; i >= 0; -- i ) { 97212922Sgabeblack@google.com delete (*m_traces)[i]; 97312922Sgabeblack@google.com } 97412922Sgabeblack@google.com delete m_traces; 97512922Sgabeblack@google.com m_traces = 0; 97612922Sgabeblack@google.com } 97712922Sgabeblack@google.com } 97812922Sgabeblack@google.com 97912922Sgabeblack@google.com mutable sc_trace_params_vec* m_traces; 98012922Sgabeblack@google.com 98112922Sgabeblack@google.com 98212922Sgabeblack@google.com private: 98312922Sgabeblack@google.com 98412922Sgabeblack@google.com // disabled 98512922Sgabeblack@google.com sc_in( const sc_in<sc_dt::sc_int<W> >& ); 98612922Sgabeblack@google.com sc_in<sc_dt::sc_int<W> >& operator = ( const sc_in<sc_dt::sc_int<W> >& ); 98712922Sgabeblack@google.com 98812922Sgabeblack@google.com#ifdef __GNUC__ 98912922Sgabeblack@google.com // Needed to circumvent a problem in the g++-2.95.2 compiler: 99012922Sgabeblack@google.com // This unused variable forces the compiler to instantiate 99112922Sgabeblack@google.com // an object of T template so an implicit conversion from 99212922Sgabeblack@google.com // read() to a C++ intrinsic data type will work. 99312922Sgabeblack@google.com static data_type dummy; 99412922Sgabeblack@google.com#endif 99512922Sgabeblack@google.com 99612922Sgabeblack@google.com}; 99712922Sgabeblack@google.com 99812922Sgabeblack@google.com 99912922Sgabeblack@google.com 100012922Sgabeblack@google.comSC_TEMPLATE 100112922Sgabeblack@google.cominline std::ostream& operator << (std::ostream& os, const sc_in<sc_dt::sc_int<W> >& a) 100212922Sgabeblack@google.com{ 100312922Sgabeblack@google.com a.read().print( os ); 100412922Sgabeblack@google.com return os; 100512922Sgabeblack@google.com} 100612922Sgabeblack@google.com 100712922Sgabeblack@google.com 100812922Sgabeblack@google.com//============================================================================== 100912922Sgabeblack@google.com// CLASS sc_inout<sc_dt::sc_int<W> > 101012922Sgabeblack@google.com// 101112922Sgabeblack@google.com// This class implements an input/output port whose target acts like an 101212922Sgabeblack@google.com// sc_dt::sc_int<W> data value. It is derived from the sc_int_in. This class is a 101312922Sgabeblack@google.com// specialization of the generic sc_inout class to implement tailored support 101412922Sgabeblack@google.com// for the sc_dt::sc_int<W> class. 101512922Sgabeblack@google.com//============================================================================== 101612922Sgabeblack@google.comSC_TEMPLATE 101712922Sgabeblack@google.comclass sc_inout<sc_dt::sc_int<W> > : 101812922Sgabeblack@google.com public sc_port<sc_signal_inout_if<sc_dt::sc_int<W> >, 1>, 101912922Sgabeblack@google.com public sc_dt::sc_value_base 102012922Sgabeblack@google.com{ 102112922Sgabeblack@google.com public: 102212922Sgabeblack@google.com 102312922Sgabeblack@google.com // typedefs 102412922Sgabeblack@google.com 102512922Sgabeblack@google.com typedef sc_dt::sc_int<W> data_type; 102612922Sgabeblack@google.com typedef sc_signal_inout_if<sc_dt::sc_int<W> > if_type; 102712922Sgabeblack@google.com typedef sc_port<if_type,1> base_type; 102812922Sgabeblack@google.com typedef sc_inout<sc_dt::sc_int<W> > this_type; 102912922Sgabeblack@google.com 103012922Sgabeblack@google.com typedef if_type inout_if_type; 103112922Sgabeblack@google.com typedef base_type inout_port_type; 103212922Sgabeblack@google.com 103312922Sgabeblack@google.com public: 103412922Sgabeblack@google.com 103512922Sgabeblack@google.com // bind methods and operators: 103612922Sgabeblack@google.com 103712922Sgabeblack@google.com void bind( const inout_if_type& interface_ ) 103812922Sgabeblack@google.com { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); } 103912922Sgabeblack@google.com void operator () ( const inout_if_type& interface_ ) 104012922Sgabeblack@google.com { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); } 104112922Sgabeblack@google.com void bind( inout_port_type& parent_ ) 104212922Sgabeblack@google.com { sc_port_base::bind(parent_); } 104312922Sgabeblack@google.com void operator () ( inout_port_type& parent_ ) 104412922Sgabeblack@google.com { sc_port_base::bind(parent_); } 104512922Sgabeblack@google.com 104612922Sgabeblack@google.com protected: 104712922Sgabeblack@google.com // called by pbind (for internal use only) 104812922Sgabeblack@google.com virtual inline int vbind( sc_interface& interface_ ) 104912922Sgabeblack@google.com { 105012922Sgabeblack@google.com return sc_port_b<if_type>::vbind( interface_ ); 105112922Sgabeblack@google.com } 105212922Sgabeblack@google.com virtual inline int vbind( sc_port_base& parent_ ) 105312922Sgabeblack@google.com { 105412922Sgabeblack@google.com inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ ); 105512922Sgabeblack@google.com if( inout_parent != 0 ) { 105612922Sgabeblack@google.com sc_port_base::bind( *inout_parent ); 105712922Sgabeblack@google.com return 0; 105812922Sgabeblack@google.com } 105912922Sgabeblack@google.com // type mismatch 106012922Sgabeblack@google.com return 2; 106112922Sgabeblack@google.com } 106212922Sgabeblack@google.com 106312922Sgabeblack@google.com 106412922Sgabeblack@google.com // constructors 106512922Sgabeblack@google.com 106612922Sgabeblack@google.com public: 106712922Sgabeblack@google.com sc_inout() 106812922Sgabeblack@google.com : base_type(), m_init_val_p(0), m_traces( 0 ) 106912922Sgabeblack@google.com {} 107012922Sgabeblack@google.com 107112922Sgabeblack@google.com explicit sc_inout( const char* name_ ) 107212922Sgabeblack@google.com : base_type( name_ ), m_init_val_p(0), m_traces( 0 ) 107312922Sgabeblack@google.com {} 107412922Sgabeblack@google.com 107512922Sgabeblack@google.com explicit sc_inout( inout_if_type& interface_ ) 107612922Sgabeblack@google.com : base_type( interface_ ), m_init_val_p(0), m_traces( 0 ) 107712922Sgabeblack@google.com {} 107812922Sgabeblack@google.com 107912922Sgabeblack@google.com sc_inout( const char* name_, inout_if_type& interface_ ) 108012922Sgabeblack@google.com : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 ) 108112922Sgabeblack@google.com {} 108212922Sgabeblack@google.com 108312922Sgabeblack@google.com explicit sc_inout( inout_port_type& parent_ ) 108412922Sgabeblack@google.com : base_type( parent_ ), m_init_val_p(0), m_traces( 0 ) 108512922Sgabeblack@google.com {} 108612922Sgabeblack@google.com 108712922Sgabeblack@google.com sc_inout( const char* name_, inout_port_type& parent_ ) 108812922Sgabeblack@google.com : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 ) 108912922Sgabeblack@google.com {} 109012922Sgabeblack@google.com 109112922Sgabeblack@google.com sc_inout( this_type& parent_ ) 109212922Sgabeblack@google.com : base_type( parent_ ), m_init_val_p(0), m_traces( 0 ) 109312922Sgabeblack@google.com {} 109412922Sgabeblack@google.com 109512922Sgabeblack@google.com sc_inout( const char* name_, this_type& parent_ ) 109612922Sgabeblack@google.com : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 ) 109712922Sgabeblack@google.com {} 109812922Sgabeblack@google.com 109912922Sgabeblack@google.com 110012922Sgabeblack@google.com // destructor 110112922Sgabeblack@google.com 110212922Sgabeblack@google.com virtual inline ~sc_inout() 110312922Sgabeblack@google.com { 110412922Sgabeblack@google.com remove_traces(); 110512922Sgabeblack@google.com } 110612922Sgabeblack@google.com 110712922Sgabeblack@google.com // bit and part selection 110812922Sgabeblack@google.com 110912922Sgabeblack@google.com sc_dt::sc_int_bitref_r operator [] ( int i ) const 111012922Sgabeblack@google.com { return (*this)->read()[i]; } 111112922Sgabeblack@google.com sc_dt::sc_int_bitref_r bit( int i ) const 111212922Sgabeblack@google.com { return (*this)->read()[i]; } 111312922Sgabeblack@google.com sc_int_sigref& operator [] ( int i ) 111412922Sgabeblack@google.com { return (*this)->select_part(i,i); } 111512922Sgabeblack@google.com sc_int_sigref& bit( int i ) 111612922Sgabeblack@google.com { return (*this)->select_part(i,i); } 111712922Sgabeblack@google.com sc_dt::sc_int_subref_r operator () ( int left, int right ) const 111812922Sgabeblack@google.com { return (*this)->read()(left,right); } 111912922Sgabeblack@google.com sc_dt::sc_int_subref_r range( int left, int right ) const 112012922Sgabeblack@google.com { return (*this)->read()(left,right); } 112112922Sgabeblack@google.com sc_int_sigref& operator () ( int left, int right ) 112212922Sgabeblack@google.com { return (*this)->select_part(left,right); } 112312922Sgabeblack@google.com sc_int_sigref& range( int left, int right ) 112412922Sgabeblack@google.com { return (*this)->select_part(left,right); } 112512922Sgabeblack@google.com 112612922Sgabeblack@google.com 112712922Sgabeblack@google.com // interface access shortcut methods 112812922Sgabeblack@google.com 112912922Sgabeblack@google.com // get the default event 113012922Sgabeblack@google.com 113112922Sgabeblack@google.com const sc_event& default_event() const 113212922Sgabeblack@google.com { return (*this)->value_changed_event(); } 113312922Sgabeblack@google.com 113412922Sgabeblack@google.com 113512922Sgabeblack@google.com // get the value changed event 113612922Sgabeblack@google.com 113712922Sgabeblack@google.com const sc_event& value_changed_event() const 113812922Sgabeblack@google.com { return (*this)->value_changed_event(); } 113912922Sgabeblack@google.com 114012922Sgabeblack@google.com 114112922Sgabeblack@google.com // read the current value 114212922Sgabeblack@google.com 114312922Sgabeblack@google.com const sc_dt::sc_int<W>& read() const 114412922Sgabeblack@google.com { return (*this)->read(); } 114512922Sgabeblack@google.com 114612922Sgabeblack@google.com operator sc_dt::int64 () const 114712922Sgabeblack@google.com { return (sc_dt::int64)(*this)->read(); } 114812922Sgabeblack@google.com 114912922Sgabeblack@google.com // was there a value changed event? 115012922Sgabeblack@google.com 115112922Sgabeblack@google.com bool event() const 115212922Sgabeblack@google.com { return (*this)->event(); } 115312922Sgabeblack@google.com 115412922Sgabeblack@google.com 115512922Sgabeblack@google.com // (other) event finder method(s) 115612922Sgabeblack@google.com 115712922Sgabeblack@google.com sc_event_finder& value_changed() const 115812922Sgabeblack@google.com { 115912922Sgabeblack@google.com return *new sc_event_finder_t<inout_if_type>( 116012922Sgabeblack@google.com *this, &inout_if_type::value_changed_event ); 116112922Sgabeblack@google.com } 116212922Sgabeblack@google.com 116312922Sgabeblack@google.com 116412922Sgabeblack@google.com 116512922Sgabeblack@google.com // reduction methods: 116612922Sgabeblack@google.com 116712922Sgabeblack@google.com inline bool and_reduce() const 116812922Sgabeblack@google.com { return (*this)->read().and_reduce(); } 116912922Sgabeblack@google.com inline bool nand_reduce() const 117012922Sgabeblack@google.com { return (*this)->read().nand_reduce(); } 117112922Sgabeblack@google.com inline bool nor_reduce() const 117212922Sgabeblack@google.com { return (*this)->read().nor_reduce(); } 117312922Sgabeblack@google.com inline bool or_reduce() const 117412922Sgabeblack@google.com { return (*this)->read().or_reduce(); } 117512922Sgabeblack@google.com inline bool xnor_reduce() const 117612922Sgabeblack@google.com { return (*this)->read().xnor_reduce(); } 117712922Sgabeblack@google.com inline bool xor_reduce() const 117812922Sgabeblack@google.com { return (*this)->read().xor_reduce(); } 117912922Sgabeblack@google.com 118012922Sgabeblack@google.com 118112922Sgabeblack@google.com // called when elaboration is done 118212922Sgabeblack@google.com /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */ 118312922Sgabeblack@google.com /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */ 118412922Sgabeblack@google.com 118512922Sgabeblack@google.com virtual inline void end_of_elaboration() 118612922Sgabeblack@google.com { 118712922Sgabeblack@google.com if( m_init_val_p != 0 ) { 118812922Sgabeblack@google.com (*this)->write( (sc_dt::int64) *m_init_val_p ); 118912922Sgabeblack@google.com delete m_init_val_p; 119012922Sgabeblack@google.com m_init_val_p = 0; 119112922Sgabeblack@google.com } 119212922Sgabeblack@google.com if( m_traces != 0 ) { 119312922Sgabeblack@google.com for( unsigned int i = 0; i < m_traces->size(); ++ i ) { 119412922Sgabeblack@google.com sc_trace_params* p = (*m_traces)[i]; 119512922Sgabeblack@google.com sc_trace( p->tf, read(), p->name ); 119612922Sgabeblack@google.com } 119712922Sgabeblack@google.com remove_traces(); 119812922Sgabeblack@google.com } 119912922Sgabeblack@google.com } 120012922Sgabeblack@google.com 120112922Sgabeblack@google.com virtual inline const char* kind() const 120212922Sgabeblack@google.com { return "sc_inout"; } 120312922Sgabeblack@google.com 120412922Sgabeblack@google.com // value initialization 120512922Sgabeblack@google.com 120612922Sgabeblack@google.com inline void initialize( const sc_dt::sc_int<W>& value_ ) 120712922Sgabeblack@google.com { 120812922Sgabeblack@google.com inout_if_type* iface = this->get_interface(0); 120912922Sgabeblack@google.com if( iface != 0 ) { 121012922Sgabeblack@google.com iface->write( value_ ); 121112922Sgabeblack@google.com } else { 121212922Sgabeblack@google.com if( m_init_val_p == 0 ) { 121312922Sgabeblack@google.com m_init_val_p = new sc_dt::int64; 121412922Sgabeblack@google.com } 121512922Sgabeblack@google.com *m_init_val_p = value_; 121612922Sgabeblack@google.com } 121712922Sgabeblack@google.com } 121812922Sgabeblack@google.com 121912922Sgabeblack@google.com 122012922Sgabeblack@google.com // called by sc_trace 122112922Sgabeblack@google.com void add_trace( sc_trace_file* tf_, const std::string& name_ ) const 122212922Sgabeblack@google.com { 122312922Sgabeblack@google.com if( tf_ != 0 ) { 122412922Sgabeblack@google.com if( m_traces == 0 ) { 122512922Sgabeblack@google.com m_traces = new sc_trace_params_vec; 122612922Sgabeblack@google.com } 122712922Sgabeblack@google.com m_traces->push_back( new sc_trace_params( tf_, name_ ) ); 122812922Sgabeblack@google.com } 122912922Sgabeblack@google.com } 123012922Sgabeblack@google.com 123112922Sgabeblack@google.com 123212922Sgabeblack@google.com // concatenation methods 123312922Sgabeblack@google.com 123412922Sgabeblack@google.com virtual inline int concat_length(bool* xz_present_p) const 123512922Sgabeblack@google.com { return (*this)->read().concat_length( xz_present_p ); } 123612922Sgabeblack@google.com virtual inline sc_dt::uint64 concat_get_uint64() const 123712922Sgabeblack@google.com { return (*this)->read().concat_get_uint64(); } 123812922Sgabeblack@google.com virtual 123912922Sgabeblack@google.com inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const 124012922Sgabeblack@google.com { return (*this)->read().concat_get_ctrl(dst_p, low_i); } 124112922Sgabeblack@google.com virtual 124212922Sgabeblack@google.com inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const 124312922Sgabeblack@google.com { return (*this)->read().concat_get_data(dst_p, low_i); } 124412922Sgabeblack@google.com virtual inline void concat_set(sc_dt::int64 src, int low_i) 124512922Sgabeblack@google.com { *this = src >> (( low_i < 64 ) ? low_i : 63); } 124612922Sgabeblack@google.com#if 0 // #### 124712922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i) 124812922Sgabeblack@google.com { *this = src >> low_i; } 124912922Sgabeblack@google.com#endif // 0 #### 125012922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i) 125112922Sgabeblack@google.com { *this = src >> low_i; } 125212922Sgabeblack@google.com virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i) 125312922Sgabeblack@google.com { *this = src >> low_i; } 125412922Sgabeblack@google.com virtual inline void concat_set(sc_dt::uint64 src, int low_i) 125512922Sgabeblack@google.com { *this = ( low_i < 64 ) ? src >> low_i : (sc_dt::uint64)0; } 125612922Sgabeblack@google.com 125712922Sgabeblack@google.com // assignment operators: 125812922Sgabeblack@google.com 125912922Sgabeblack@google.com public: 126012922Sgabeblack@google.com inline void operator = ( const this_type& new_val ) 126112922Sgabeblack@google.com { (*this)->write( (sc_dt::int64)new_val ); } 126212922Sgabeblack@google.com inline void operator = ( const char* new_val ) 126312922Sgabeblack@google.com { (*this)->write( this_type(new_val) ); } 126412922Sgabeblack@google.com inline void operator = ( sc_dt::uint64 new_val ) 126512922Sgabeblack@google.com { (*this)->write(new_val); } 126612922Sgabeblack@google.com inline void operator = ( sc_dt::int64 new_val ) 126712922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 126812922Sgabeblack@google.com inline void operator = ( int new_val ) 126912922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 127012922Sgabeblack@google.com inline void operator = ( long new_val ) 127112922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 127212922Sgabeblack@google.com inline void operator = ( short new_val ) 127312922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 127412922Sgabeblack@google.com inline void operator = ( unsigned int new_val ) 127512922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 127612922Sgabeblack@google.com inline void operator = ( unsigned long new_val ) 127712922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 127812922Sgabeblack@google.com inline void operator = ( unsigned short new_val ) 127912922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 128012922Sgabeblack@google.com template<typename T> 128112922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ) 128212922Sgabeblack@google.com { (*this)->write(new_val->to_uint64()); } 128312922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_signed& new_val ) 128412922Sgabeblack@google.com { (*this)->write(new_val.to_uint64()); } 128512922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_unsigned& new_val ) 128612922Sgabeblack@google.com { (*this)->write(new_val.to_uint64()); } 128712922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_bv_base& new_val ) 128812922Sgabeblack@google.com { (*this)->write((sc_dt::sc_int<W>)new_val); } 128912922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_lv_base& new_val ) 129012922Sgabeblack@google.com { (*this)->write((sc_dt::sc_int<W>)new_val); } 129112922Sgabeblack@google.com 129212922Sgabeblack@google.com inline void write( const sc_in<sc_dt::sc_int<W> >& new_val ) 129312922Sgabeblack@google.com { (*this)->write( (sc_dt::int64)new_val ); } 129412922Sgabeblack@google.com 129512922Sgabeblack@google.com inline void write( const sc_inout<sc_dt::sc_int<W> >& new_val ) 129612922Sgabeblack@google.com { (*this)->write( (sc_dt::int64)new_val); } 129712922Sgabeblack@google.com 129812922Sgabeblack@google.com inline void write( const sc_dt::sc_int<W>& new_val ) 129912922Sgabeblack@google.com { (*this)->write( (sc_dt::int64)new_val); } 130012922Sgabeblack@google.com 130112922Sgabeblack@google.com protected: 130212922Sgabeblack@google.com void remove_traces() const 130312922Sgabeblack@google.com { 130412922Sgabeblack@google.com if( m_traces != 0 ) { 130512922Sgabeblack@google.com for( int i = m_traces->size() - 1; i >= 0; -- i ) { 130612922Sgabeblack@google.com delete (*m_traces)[i]; 130712922Sgabeblack@google.com } 130812922Sgabeblack@google.com delete m_traces; 130912922Sgabeblack@google.com m_traces = 0; 131012922Sgabeblack@google.com } 131112922Sgabeblack@google.com } 131212922Sgabeblack@google.com 131312922Sgabeblack@google.com sc_dt::int64* m_init_val_p; 131412922Sgabeblack@google.com mutable sc_trace_params_vec* m_traces; 131512922Sgabeblack@google.com 131612922Sgabeblack@google.com 131712922Sgabeblack@google.com private: 131812922Sgabeblack@google.com 131912922Sgabeblack@google.com // disabled 132012922Sgabeblack@google.com sc_inout( const sc_inout<sc_dt::sc_int<W> >& ); 132112922Sgabeblack@google.com 132212922Sgabeblack@google.com#ifdef __GNUC__ 132312922Sgabeblack@google.com // Needed to circumvent a problem in the g++-2.95.2 compiler: 132412922Sgabeblack@google.com // This unused variable forces the compiler to instantiate 132512922Sgabeblack@google.com // an object of T template so an implicit conversion from 132612922Sgabeblack@google.com // read() to a C++ intrinsic data type will work. 132712922Sgabeblack@google.com static data_type dummy; 132812922Sgabeblack@google.com#endif 132912922Sgabeblack@google.com 133012922Sgabeblack@google.com}; 133112922Sgabeblack@google.com 133212922Sgabeblack@google.com 133312922Sgabeblack@google.com 133412922Sgabeblack@google.comSC_TEMPLATE 133512922Sgabeblack@google.cominline std::ostream& operator << ( 133612922Sgabeblack@google.com std::ostream& os, const sc_inout<sc_dt::sc_int<W> >& a ) 133712922Sgabeblack@google.com{ 133812922Sgabeblack@google.com a.read().print( os ); 133912922Sgabeblack@google.com return os; 134012922Sgabeblack@google.com} 134112922Sgabeblack@google.com 134212922Sgabeblack@google.com 134312922Sgabeblack@google.com//============================================================================== 134412922Sgabeblack@google.com// CLASS sc_out<sc_dt::sc_int<W> > 134512922Sgabeblack@google.com// 134612922Sgabeblack@google.com// This class implements an output port whose target acts like an 134712922Sgabeblack@google.com// sc_dt::sc_int<W> data value. This class is a derivation of sc_inout, since 134812922Sgabeblack@google.com// output ports are really no different from input/output ports. 134912922Sgabeblack@google.com//============================================================================== 135012922Sgabeblack@google.comSC_TEMPLATE 135112922Sgabeblack@google.comclass sc_out<sc_dt::sc_int<W> > : public sc_inout<sc_dt::sc_int<W> > 135212922Sgabeblack@google.com{ 135312922Sgabeblack@google.com public: 135412922Sgabeblack@google.com 135512922Sgabeblack@google.com // typedefs 135612922Sgabeblack@google.com 135712922Sgabeblack@google.com typedef sc_dt::sc_int<W> data_type; 135812922Sgabeblack@google.com 135912922Sgabeblack@google.com typedef sc_out<data_type> this_type; 136012922Sgabeblack@google.com typedef sc_inout<data_type> base_type; 136112922Sgabeblack@google.com 136212922Sgabeblack@google.com typedef typename base_type::inout_if_type inout_if_type; 136312922Sgabeblack@google.com typedef typename base_type::inout_port_type inout_port_type; 136412922Sgabeblack@google.com 136512922Sgabeblack@google.com // constructors 136612922Sgabeblack@google.com 136712922Sgabeblack@google.com sc_out() 136812922Sgabeblack@google.com : base_type() 136912922Sgabeblack@google.com {} 137012922Sgabeblack@google.com 137112922Sgabeblack@google.com explicit sc_out( const char* name_ ) 137212922Sgabeblack@google.com : base_type( name_ ) 137312922Sgabeblack@google.com {} 137412922Sgabeblack@google.com 137512922Sgabeblack@google.com explicit sc_out( inout_if_type& interface_ ) 137612922Sgabeblack@google.com : base_type( interface_ ) 137712922Sgabeblack@google.com {} 137812922Sgabeblack@google.com 137912922Sgabeblack@google.com sc_out( const char* name_, inout_if_type& interface_ ) 138012922Sgabeblack@google.com : base_type( name_, interface_ ) 138112922Sgabeblack@google.com {} 138212922Sgabeblack@google.com 138312922Sgabeblack@google.com explicit sc_out( inout_port_type& parent_ ) 138412922Sgabeblack@google.com : base_type( parent_ ) 138512922Sgabeblack@google.com {} 138612922Sgabeblack@google.com 138712922Sgabeblack@google.com sc_out( const char* name_, inout_port_type& parent_ ) 138812922Sgabeblack@google.com : base_type( name_, parent_ ) 138912922Sgabeblack@google.com {} 139012922Sgabeblack@google.com 139112922Sgabeblack@google.com sc_out( this_type& parent_ ) 139212922Sgabeblack@google.com : base_type( parent_ ) 139312922Sgabeblack@google.com {} 139412922Sgabeblack@google.com 139512922Sgabeblack@google.com sc_out( const char* name_, this_type& parent_ ) 139612922Sgabeblack@google.com : base_type( name_, parent_ ) 139712922Sgabeblack@google.com {} 139812922Sgabeblack@google.com 139912922Sgabeblack@google.com 140012922Sgabeblack@google.com // destructor (does nothing) 140112922Sgabeblack@google.com 140212922Sgabeblack@google.com virtual inline ~sc_out() 140312922Sgabeblack@google.com {} 140412922Sgabeblack@google.com 140512922Sgabeblack@google.com 140612922Sgabeblack@google.com // assignment operators: 140712922Sgabeblack@google.com 140812922Sgabeblack@google.com public: 140912922Sgabeblack@google.com inline void operator = ( const this_type& new_val ) 141012922Sgabeblack@google.com { (*this)->write( (sc_dt::int64)new_val ); } 141112922Sgabeblack@google.com inline void operator = ( const char* new_val ) 141212922Sgabeblack@google.com { (*this)->write( this_type(new_val) ); } 141312922Sgabeblack@google.com inline void operator = ( sc_dt::uint64 new_val ) 141412922Sgabeblack@google.com { (*this)->write(new_val); } 141512922Sgabeblack@google.com inline void operator = ( sc_dt::int64 new_val ) 141612922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 141712922Sgabeblack@google.com inline void operator = ( int new_val ) 141812922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 141912922Sgabeblack@google.com inline void operator = ( long new_val ) 142012922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 142112922Sgabeblack@google.com inline void operator = ( short new_val ) 142212922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 142312922Sgabeblack@google.com inline void operator = ( unsigned int new_val ) 142412922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 142512922Sgabeblack@google.com inline void operator = ( unsigned long new_val ) 142612922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 142712922Sgabeblack@google.com inline void operator = ( unsigned short new_val ) 142812922Sgabeblack@google.com { (*this)->write((sc_dt::uint64)new_val); } 142912922Sgabeblack@google.com template<typename T> 143012922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ) 143112922Sgabeblack@google.com { (*this)->write(new_val->to_uint64()); } 143212922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_signed& new_val ) 143312922Sgabeblack@google.com { (*this)->write(new_val); } 143412922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_unsigned& new_val ) 143512922Sgabeblack@google.com { (*this)->write(new_val); } 143612922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_bv_base& new_val ) 143712922Sgabeblack@google.com { (*this)->write((sc_dt::sc_int<W>)new_val); } 143812922Sgabeblack@google.com inline void operator = ( const sc_dt::sc_lv_base& new_val ) 143912922Sgabeblack@google.com { (*this)->write((sc_dt::sc_int<W>)new_val); } 144012922Sgabeblack@google.com 144112922Sgabeblack@google.com private: 144212922Sgabeblack@google.com 144312922Sgabeblack@google.com // disabled 144412922Sgabeblack@google.com sc_out( const this_type& ); 144512922Sgabeblack@google.com}; 144612922Sgabeblack@google.com 144712922Sgabeblack@google.com 144812922Sgabeblack@google.com 144912922Sgabeblack@google.com//------------------------------------------------------------------------------ 145012922Sgabeblack@google.com//"sc_int_sigref::initialize" 145112922Sgabeblack@google.com// 145212922Sgabeblack@google.com// This method initializes an object instance from the supplied arguments. 145312922Sgabeblack@google.com// if_p -> access to target of this selection. 145412922Sgabeblack@google.com// left = left-most bit in selection. 145512922Sgabeblack@google.com// right = right-most bit in selection. 145612922Sgabeblack@google.com//------------------------------------------------------------------------------ 145712922Sgabeblack@google.cominline 145812922Sgabeblack@google.comvoid sc_int_sigref::initialize(sc_int_part_if* if_p, int left, int right) 145912922Sgabeblack@google.com{ 146012922Sgabeblack@google.com m_if_p = if_p; 146112922Sgabeblack@google.com m_left = left; 146212922Sgabeblack@google.com m_right = right; 146312922Sgabeblack@google.com m_obj_p = if_p->part_read_target(); 146412922Sgabeblack@google.com} 146512922Sgabeblack@google.com 146612922Sgabeblack@google.com 146712922Sgabeblack@google.com//------------------------------------------------------------------------------ 146812922Sgabeblack@google.com//"sc_int_sigref::operator =" 146912922Sgabeblack@google.com// 147012922Sgabeblack@google.com// These operators assign a value to the bits associated with this object 147112922Sgabeblack@google.com// instance within this object instance's target signal. 147212922Sgabeblack@google.com//------------------------------------------------------------------------------ 147312922Sgabeblack@google.cominline void sc_int_sigref::operator = ( sc_dt::uint64 v ) 147412922Sgabeblack@google.com{ 147512922Sgabeblack@google.com m_if_p->write_part( v, m_left, m_right ); 147612922Sgabeblack@google.com} 147712922Sgabeblack@google.com 147812922Sgabeblack@google.cominline void sc_int_sigref::operator = ( const char* /*v*/ ) 147912922Sgabeblack@google.com{ 148012922Sgabeblack@google.com} 148112922Sgabeblack@google.com 148212922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( sc_dt::int64 v ) 148312922Sgabeblack@google.com{ 148412922Sgabeblack@google.com *this = (sc_dt::uint64)v; 148512922Sgabeblack@google.com} 148612922Sgabeblack@google.com 148712922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( int v ) 148812922Sgabeblack@google.com{ 148912922Sgabeblack@google.com *this = (sc_dt::uint64)v; 149012922Sgabeblack@google.com} 149112922Sgabeblack@google.com 149212922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( long v ) 149312922Sgabeblack@google.com{ 149412922Sgabeblack@google.com *this = (sc_dt::uint64)v; 149512922Sgabeblack@google.com} 149612922Sgabeblack@google.com 149712922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( unsigned int v ) 149812922Sgabeblack@google.com{ 149912922Sgabeblack@google.com *this = (sc_dt::uint64)v; 150012922Sgabeblack@google.com} 150112922Sgabeblack@google.com 150212922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( unsigned long v ) 150312922Sgabeblack@google.com{ 150412922Sgabeblack@google.com *this = (sc_dt::uint64)v; 150512922Sgabeblack@google.com} 150612922Sgabeblack@google.com 150712922Sgabeblack@google.comvoid sc_int_sigref::operator = ( const sc_int_sigref& v ) 150812922Sgabeblack@google.com{ 150912922Sgabeblack@google.com *this = (sc_dt::uint64)v; 151012922Sgabeblack@google.com} 151112922Sgabeblack@google.com 151212922Sgabeblack@google.comtemplate<typename T> 151312922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( const sc_dt::sc_generic_base<T>& v ) 151412922Sgabeblack@google.com{ 151512922Sgabeblack@google.com *this = v->to_uint64(); 151612922Sgabeblack@google.com} 151712922Sgabeblack@google.com 151812922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( const sc_dt::sc_signed& v ) 151912922Sgabeblack@google.com{ 152012922Sgabeblack@google.com *this = v.to_uint64(); 152112922Sgabeblack@google.com} 152212922Sgabeblack@google.com 152312922Sgabeblack@google.cominline void sc_int_sigref:: operator = ( const sc_dt::sc_unsigned& v ) 152412922Sgabeblack@google.com{ 152512922Sgabeblack@google.com *this = v.to_uint64(); 152612922Sgabeblack@google.com} 152712922Sgabeblack@google.com 152812922Sgabeblack@google.com#undef SC_TEMPLATE 152912922Sgabeblack@google.com#undef TTEST 153012922Sgabeblack@google.com} // namespace sc_core 153112922Sgabeblack@google.com#endif // !defined(SC_SIGNAL_INT_H) 153212922Sgabeblack@google.com 153312922Sgabeblack@google.comnamespace sc_core { 153412922Sgabeblack@google.com 153512922Sgabeblack@google.comextern 153612922Sgabeblack@google.comvoid 153712922Sgabeblack@google.comsc_signal_invalid_writer( const char* name, 153812922Sgabeblack@google.com const char* kind, 153912922Sgabeblack@google.com const char* first_writer, 154012922Sgabeblack@google.com const char* second_writer ); 154112922Sgabeblack@google.com 154212922Sgabeblack@google.com//------------------------------------------------------------------------------ 154312922Sgabeblack@google.com// POOL OF TEMPORARY INSTANCES OF sc_int_sigref 154412922Sgabeblack@google.com// 154512922Sgabeblack@google.com// This allows use to pass const references for part and bit selections 154612922Sgabeblack@google.com// on sc_signal_int object instances. 154712922Sgabeblack@google.com//------------------------------------------------------------------------------ 154812922Sgabeblack@google.comsc_vpool<sc_int_sigref> sc_int_sigref::m_pool(8); 154912922Sgabeblack@google.com 155012922Sgabeblack@google.com 155112922Sgabeblack@google.com//------------------------------------------------------------------------------ 155212922Sgabeblack@google.com//"sc_int_part_if::default methods" 155312922Sgabeblack@google.com// 155412922Sgabeblack@google.com// These versions just produce errors if they are not overloaded but used. 155512922Sgabeblack@google.com//------------------------------------------------------------------------------ 155612922Sgabeblack@google.com 155712922Sgabeblack@google.comsc_dt::sc_int_base* sc_int_part_if::part_read_target() 155812922Sgabeblack@google.com{ 155913324Sgabeblack@google.com SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" ); 156012922Sgabeblack@google.com return 0; 156112922Sgabeblack@google.com} 156212922Sgabeblack@google.comsc_dt::uint64 sc_int_part_if::read_part( int /*left*/, int /*right*/ ) const 156312922Sgabeblack@google.com{ 156413324Sgabeblack@google.com SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" ); 156512922Sgabeblack@google.com return 0; 156612922Sgabeblack@google.com} 156712922Sgabeblack@google.comsc_int_sigref& sc_int_part_if::select_part( int /*left*/, int /*right*/ ) 156812922Sgabeblack@google.com{ 156913324Sgabeblack@google.com SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" ); 157012922Sgabeblack@google.com return *(sc_int_sigref*)0; 157112922Sgabeblack@google.com} 157212922Sgabeblack@google.comvoid sc_int_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ ) 157312922Sgabeblack@google.com{ 157413324Sgabeblack@google.com SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" ); 157512922Sgabeblack@google.com} 157612922Sgabeblack@google.com 157712922Sgabeblack@google.com 157812922Sgabeblack@google.com//------------------------------------------------------------------------------ 157912922Sgabeblack@google.com//"sc_int_sigref::concate_set" 158012922Sgabeblack@google.com// 158112922Sgabeblack@google.com// These methods assign this object instance's value from the supplied 158212922Sgabeblack@google.com// value starting at the supplied bit within that value. 158312922Sgabeblack@google.com// src = value to use to set this object instance's value. 158412922Sgabeblack@google.com// low_i = bit in src that is to be the low order bit of the value to set. 158512922Sgabeblack@google.com// #### OPTIMIZE 158612922Sgabeblack@google.com//------------------------------------------------------------------------------ 158712922Sgabeblack@google.comvoid sc_int_sigref::concat_set(sc_dt::int64 src, int low_i) 158812922Sgabeblack@google.com{ 158912922Sgabeblack@google.com *this = (low_i < 64) ? src >> low_i : src >> 63; 159012922Sgabeblack@google.com} 159112922Sgabeblack@google.com 159212922Sgabeblack@google.com 159312922Sgabeblack@google.comvoid sc_int_sigref::concat_set(const sc_dt::sc_signed& src, int low_i) 159412922Sgabeblack@google.com{ 159512922Sgabeblack@google.com if ( low_i < src.length() ) 159612922Sgabeblack@google.com *this = src >> low_i; 159712922Sgabeblack@google.com else 159812922Sgabeblack@google.com *this = (src < 0) ? (sc_dt::uint64)-1 : 0; 159912922Sgabeblack@google.com} 160012922Sgabeblack@google.com 160112922Sgabeblack@google.com 160212922Sgabeblack@google.comvoid sc_int_sigref::concat_set(const sc_dt::sc_lv_base& src, int low_i) 160312922Sgabeblack@google.com{ 160412922Sgabeblack@google.com if ( low_i < src.length() ) 160512922Sgabeblack@google.com *this = (src >> low_i).to_uint64(); 160612922Sgabeblack@google.com else 160712922Sgabeblack@google.com *this = 0; 160812922Sgabeblack@google.com} 160912922Sgabeblack@google.com 161012922Sgabeblack@google.com 161112922Sgabeblack@google.comvoid sc_int_sigref::concat_set(const sc_dt::sc_unsigned& src, int low_i) 161212922Sgabeblack@google.com{ 161312922Sgabeblack@google.com if ( low_i < src.length() ) 161412922Sgabeblack@google.com *this = src >> low_i; 161512922Sgabeblack@google.com else 161612922Sgabeblack@google.com *this = 0; 161712922Sgabeblack@google.com} 161812922Sgabeblack@google.com 161912922Sgabeblack@google.com 162012922Sgabeblack@google.comvoid sc_int_sigref::concat_set(sc_dt::uint64 src, int low_i) 162112922Sgabeblack@google.com{ 162212922Sgabeblack@google.com *this = (low_i < 64) ? src >> low_i : 0; 162312922Sgabeblack@google.com} 162412922Sgabeblack@google.com 162512922Sgabeblack@google.com} // namespace sc_core 1626