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