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