scx_signal_unsigned.h (12922:a4f51f3405ac) scx_signal_unsigned.h (13324:c8b709468e61)
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_signal_unsigned.cpp -- The sc_signal<sc_unsigned<W> > implementations.
23
24 Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31 changes you are making here.
32
33 Name, Affiliation, Date:
34 Description of Modification:
35
36 *****************************************************************************/
37
38/*
39$Log: scx_signal_unsigned.h,v $
40Revision 1.1 2011/08/15 17:31:11 acg
41 Andy Goodrich: moved specialized signals from examples to this tree.
42
43Revision 1.2 2011/08/15 16:43:24 acg
44 Torsten Maehne: changes to remove unused argument warnings.
45
46Revision 1.1.1.1 2006/12/15 20:20:03 acg
47SystemC 2.3
48
49Revision 1.2 2005/12/26 20:11:14 acg
50Fixed up copyright.
51
52Revision 1.1.1.1 2005/12/19 23:16:42 acg
53First check in of SystemC 2.1 into its own archive.
54
55Revision 1.17 2005/09/15 23:01:52 acg
56Added std:: prefix to appropriate methods and types to get around
57issues with the Edison Front End.
58
59Revision 1.16 2005/05/03 19:52:26 acg
60Get proper header locations on includes.
61
62Revision 1.15 2005/05/03 19:50:20 acg
63Name space version.
64
65Revision 1.12 2005/04/11 19:05:36 acg
66Change to sc_clock for Microsoft VCC 6.0. Changes for namespaces
67
68Revision 1.11 2005/04/03 22:52:52 acg
69Namespace changes.
70
71Revision 1.10 2005/03/21 22:31:33 acg
72Changes to sc_core namespace.
73
74Revision 1.9 2004/09/27 21:01:59 acg
75Andy Goodrich - Forte Design Systems, Inc.
76 - This is specialized signal support that allows better use of signals
77 and ports whose target value is a SystemC native type.
78
79*/
80
81
82
83#include <systemc>
84#include <typeinfo>
85
86/*****************************************************************************
87
88 sc_signal_unsigned.h -- The sc_signal<sc_dt::sc_biguint<W> > definitions.
89
90 Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22
91
92 *****************************************************************************/
93
94/*****************************************************************************
95
96 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
97 changes you are making here.
98
99 Name, Affiliation, Date:
100 Description of Modification:
101
102 *****************************************************************************/
103
104/*
105$Log: scx_signal_unsigned.h,v $
106Revision 1.1 2011/08/15 17:31:11 acg
107 Andy Goodrich: moved specialized signals from examples to this tree.
108
109Revision 1.3 2011/08/15 16:43:24 acg
110 Torsten Maehne: changes to remove unused argument warnings.
111
112Revision 1.2 2011/06/28 21:23:02 acg
113 Andy Goodrich: merging of SCV tree.
114
115Revision 1.1.1.1 2006/12/15 20:20:03 acg
116SystemC 2.3
117
118Revision 1.4 2006/10/23 19:40:36 acg
119 Andy Goodrich: added an explicit dynamic cast to keep gcc 4.x happy.
120
121Revision 1.3 2006/03/21 01:31:49 acg
122 Andy Goodrich: changed over to sc_get_current_process_b() from
123 sc_get_current_process_base() since the function's name changed.
124
125Revision 1.2 2005/12/26 20:11:14 acg
126Fixed up copyright.
127
128Revision 1.1.1.1 2005/12/19 23:16:42 acg
129First check in of SystemC 2.1 into its own archive.
130
131Revision 1.28 2005/09/15 23:01:52 acg
132Added std:: prefix to appropriate methods and types to get around
133issues with the Edison Front End.
134
135Revision 1.27 2005/07/30 03:44:11 acg
136Changes from 2.1.
137
138Revision 1.26 2005/05/09 17:17:12 acg
139Changes from 2.1.
140
141Revision 1.25 2005/05/08 19:04:06 acg
142Fix bug in concat_set(int64,off). Other changes from 2.1 examples usage.
143
144Revision 1.24 2005/05/03 19:50:20 acg
145Name space version.
146
147Revision 1.22 2005/03/21 22:31:33 acg
148Changes to sc_core namespace.
149
150Revision 1.21 2005/01/10 17:51:58 acg
151Improvements.
152
153Revision 1.20 2004/11/09 00:11:27 acg
154Added support for sc_generic_base<T> in place of sc_concatref. sc_concatref
155now is derived from sc_generic_base<sc_concatref>.
156
157Revision 1.19 2004/09/27 21:01:59 acg
158Andy Goodrich - Forte Design Systems, Inc.
159 - This is specialized signal support that allows better use of signals
160 and ports whose target value is a SystemC native type.
161
162*/
163
164
165#if !defined(SC_SIGNAL_UNSIGNED_H)
166#define SC_SIGNAL_UNSIGNED_H
167
168#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )
169# define SC_TEMPLATE template<int W>
170#else
171# define SC_TEMPLATE template<> template<int W>
172#endif
173
174
175// FORWARD REFERENCES AND USINGS:
176
177using sc_dt::sc_signed;
178using sc_dt::int64;
179using sc_dt::uint64;
180
181namespace sc_core {
182
183class sc_unsigned_sigref;
184
185//==============================================================================
186// CLASS sc_unsigned_part_if
187//
188// This class provides generic access to part selections for signals whose
189// data type is sc_dt::sc_biguint<W>. This class serves as the base class for the
190// sc_dt::sc_biguint<W> specialization of the sc_signal_in_if<T> class. The methods
191// in this class may be over-ridden individually, those that are not overridden
192// will produce an error message when called. The methods are used by the
193// sc_unsigned_sigref class.
194//
195// Notes:
196// (1) Descriptions of the methods and operators in this class appear with
197// their implementations in sc_signal<sc_dt::sc_biguint<W> >.
198//==============================================================================
199class sc_unsigned_part_if : virtual public sc_interface {
200 protected:
201 // constructor:
202 sc_unsigned_part_if() {}
203
204 public:
205 // perform a part read.
206 virtual sc_dt::sc_unsigned* part_read_target();
207 virtual sc_dt::sc_unsigned read_part( int left, int right ) const;
208
209 // perform a part write.
210 virtual sc_unsigned_sigref& select_part( int left, int right );
211 virtual void write_part( sc_dt::int64 v, int left, int right );
212 virtual void write_part( sc_dt::uint64 v, int left, int right );
213 virtual void write_part( const sc_dt::sc_signed& v, int left, int right );
214 virtual void write_part( const sc_dt::sc_unsigned& v, int left, int right );
215
216
217 private:
218 sc_unsigned_part_if( const sc_unsigned_part_if& );
219 sc_unsigned_part_if& operator = ( const sc_unsigned_part_if& );
220};
221
222
223//==============================================================================
224// CLASS sc_signal_in_if<sc_dt::sc_biguint<W> >
225//
226// This is the class specializations for the sc_signal_in_if<T> class to
227// provide additional features for sc_signal instances whose template is
228// sc_dt::sc_biguint<W>, including part access.
229//
230// Notes:
231// (1) Descriptions of the methods and operators in this class appear with
232// their implementations in sc_signal<sc_dt::sc_biguint<W> >.
233//==============================================================================
234template< int W >
235class sc_signal_in_if<sc_dt::sc_biguint<W> > : public sc_unsigned_part_if {
236 friend class sc_unsigned_sigref;
237 public:
238 typedef sc_signal_in_if<sc_dt::sc_biguint<W> > this_type;
239
240 // get the value changed event
241 virtual const sc_event& value_changed_event() const = 0;
242
243
244 // read the current value
245 virtual const sc_dt::sc_biguint<W>& read() const = 0;
246
247 // get a reference to the current value (for tracing)
248 virtual const sc_dt::sc_biguint<W>& get_data_ref() const = 0;
249
250
251 // was there a value changed event?
252 virtual bool event() const = 0;
253
254 protected:
255 // constructor
256 sc_signal_in_if()
257 {}
258
259 private: // disabled
260 sc_signal_in_if( const this_type& );
261 this_type& operator = ( const this_type& );
262};
263
264//=============================================================================
265// CLASS : sc_unsigned_sigref
266//
267// Proxy class for sc_signal_uint bit and part selection.
268//=============================================================================
269class sc_unsigned_sigref : public sc_dt::sc_unsigned_subref_r
270{
271 public:
272 sc_unsigned_sigref() : sc_dt::sc_unsigned_subref_r() {}
273 virtual ~sc_unsigned_sigref() {}
274 virtual void concat_set(sc_dt::int64 src, int low_i);
275 virtual void concat_set(const sc_dt::sc_signed& src, int low_i);
276 virtual void concat_set(const sc_dt::sc_unsigned& src, int low_i);
277 virtual void concat_set(const sc_dt::sc_lv_base& src, int low_i);
278 virtual void concat_set(sc_dt::uint64 src, int low_i);
279
280 public:
281 inline void initialize( sc_unsigned_part_if* if_p, int left_, int right_ );
282
283 public:
284 inline void operator = ( sc_dt::uint64 v );
285 inline void operator = ( const char* v );
286 inline void operator = ( unsigned long v );
287 inline void operator = ( long v );
288 inline void operator = ( unsigned int v );
289 inline void operator = ( int v );
290 inline void operator = ( sc_dt::int64 v );
291 inline void operator = ( double v );
292 inline void operator = ( const sc_unsigned_sigref& v );
293 template<typename T>
294 inline void operator = ( const sc_dt::sc_generic_base<T>& v );
295 inline void operator = ( const sc_dt::sc_signed& v );
296 inline void operator = ( const sc_dt::sc_unsigned& v );
297 inline void operator = ( const sc_dt::sc_bv_base& v );
298 inline void operator = ( const sc_dt::sc_lv_base& v );
299
300 public:
301 static sc_vpool<sc_unsigned_sigref> m_pool; // Pool of objects to use.
302
303 protected:
304 sc_unsigned_part_if* m_if_p; // Target for selection.
305
306 private:
307
308 // disabled
309 sc_unsigned_sigref( const sc_unsigned_sigref& a );
310};
311
312
313//==============================================================================
314// CLASS sc_signal<sc_dt::sc_biguint<W> >
315//
316// This class implements a signal whose value acts like an sc_dt::sc_biguint<W> data
317// value. This class is a specialization of the generic sc_signal class to
318// implement tailored support for the sc_dt::sc_biguint<W> class.
319//
320// Notes:
321// (1) Descriptions of the methods and operators in this class appear with
322// their implementations.
323//==============================================================================
324SC_TEMPLATE
325class sc_signal<sc_dt::sc_biguint<W> > :
326 public sc_dt::sc_biguint<W>,
327 public sc_prim_channel,
328 public sc_signal_inout_if<sc_dt::sc_biguint<W> >
329{
330 public: // typedefs
331 typedef sc_signal<sc_dt::sc_biguint<W> > this_type;
332
333 public: // constructors and destructor:
334 inline sc_signal();
335 explicit inline sc_signal(const char* name_);
336 virtual inline ~sc_signal();
337
338 public: // base methods:
339 inline bool base_event() const;
340 inline const sc_dt::sc_biguint<W>& base_read() const;
341 inline const sc_event& base_value_changed_event() const;
342 inline void base_write( sc_dt::int64 value );
343 inline void base_write( sc_dt::uint64 value );
344 inline void base_write( const sc_dt::sc_signed& value );
345 inline void base_write( const sc_dt::sc_unsigned& value );
346
347 public: // sc_prim_channel virtual methods:
348 virtual inline const char* kind() const;
349 virtual inline void update();
350
351 public: // sc_interface virtual methods:
352 virtual inline const sc_event& default_event() const;
353 virtual inline void register_port(
354 sc_port_base& port_, const char* if_typename_ );
355
356 public: // sc_unsigned_channel virtual methods:
357 virtual inline sc_dt::sc_unsigned* part_read_target();
358 virtual inline sc_dt::sc_unsigned read_part(int left, int right) const;
359 virtual sc_unsigned_sigref& select_part( int left, int right );
360 virtual inline void write_part( sc_dt::int64 v, int left, int right );
361 virtual inline void write_part( sc_dt::uint64 v, int left, int right );
362 virtual inline void write_part( const sc_dt::sc_signed& v, int left, int right );
363 virtual inline void write_part(const sc_dt::sc_unsigned& v, int left, int right);
364
365 public: // interface virtual methods:
366 virtual inline bool event() const;
367 virtual inline const sc_dt::sc_biguint<W>& get_data_ref() const;
368 virtual inline sc_signal<sc_dt::sc_biguint<W> >& get_signal();
369 virtual inline const sc_dt::sc_biguint<W>& read() const;
370 virtual inline const sc_event& value_changed_event() const;
371 virtual inline void write( const sc_in<sc_dt::sc_biguint<W> >& value );
372 virtual inline void write( const sc_inout<sc_dt::sc_biguint<W> >& value );
373 virtual inline void write( const sc_dt::sc_biguint<W>& value );
374
375 public: // part selections:
376 inline sc_unsigned_sigref& operator () ( int left, int right );
377 // #### Need to add range() and bit()!
378 inline sc_unsigned_sigref& operator [] ( int bit );
379
380 public: // operators:
381 inline void operator = ( const this_type& new_val );
382 inline void operator = ( const char* new_val );
383 inline void operator = ( sc_dt::uint64 new_val );
384 inline void operator = ( sc_dt::int64 new_val );
385 inline void operator = ( int new_val );
386 inline void operator = ( long new_val );
387 inline void operator = ( short new_val );
388 inline void operator = ( unsigned int new_val );
389 inline void operator = ( unsigned long new_val );
390 inline void operator = ( unsigned short new_val );
391 template<typename T>
392 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val );
393 inline void operator = ( const sc_dt::sc_signed& new_val );
394 inline void operator = ( const sc_dt::sc_unsigned& new_val );
395 inline void operator = ( const sc_dt::sc_bv_base& new_val );
396 inline void operator = ( const sc_dt::sc_lv_base& new_val );
397
398 // concatenation methods (we inherit length and gets from sc_dt::sc_biguint<W>):
399
400 virtual inline void concat_set(sc_dt::int64 src, int low_i);
401 virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i);
402 virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i);
403 virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i);
404 virtual inline void concat_set(sc_dt::uint64 src, int low_i);
405
406 protected: // debugging methods:
407 // #### void check_port();
408 void check_writer();
409
410 private: // Disabled operations that sc_dt::sc_biguint<W> supports:
411 sc_dt::sc_unsigned& operator ++ (); // prefix
412 const sc_dt::sc_unsigned& operator ++ (int); // postfix
413 sc_dt::sc_unsigned& operator -- (); // prefix
414 const sc_dt::sc_unsigned& operator -- (int); // postfix
415 sc_dt::sc_unsigned& operator += (const sc_dt::sc_signed& );
416 sc_dt::sc_unsigned& operator += (const sc_dt::sc_unsigned& );
417 sc_dt::sc_unsigned& operator += (sc_dt::int64 );
418 sc_dt::sc_unsigned& operator += (sc_dt::uint64 );
419 sc_dt::sc_unsigned& operator += (long );
420 sc_dt::sc_unsigned& operator += (unsigned long );
421 sc_dt::sc_unsigned& operator += (int );
422 sc_dt::sc_unsigned& operator += (unsigned int );
423 sc_dt::sc_unsigned& operator -= (const sc_dt::sc_signed& );
424 sc_dt::sc_unsigned& operator -= (const sc_dt::sc_unsigned& );
425 sc_dt::sc_unsigned& operator -= (sc_dt::int64 );
426 sc_dt::sc_unsigned& operator -= (sc_dt::uint64 );
427 sc_dt::sc_unsigned& operator -= (long );
428 sc_dt::sc_unsigned& operator -= (unsigned long );
429 sc_dt::sc_unsigned& operator -= (int );
430 sc_dt::sc_unsigned& operator -= (unsigned int );
431 sc_dt::sc_unsigned& operator *= (const sc_dt::sc_signed& );
432 sc_dt::sc_unsigned& operator *= (const sc_dt::sc_unsigned& );
433 sc_dt::sc_unsigned& operator *= (sc_dt::int64 );
434 sc_dt::sc_unsigned& operator *= (sc_dt::uint64 );
435 sc_dt::sc_unsigned& operator *= (long );
436 sc_dt::sc_unsigned& operator *= (unsigned long );
437 sc_dt::sc_unsigned& operator *= (int );
438 sc_dt::sc_unsigned& operator *= (unsigned int );
439 sc_dt::sc_unsigned& operator /= (const sc_dt::sc_signed& );
440 sc_dt::sc_unsigned& operator /= (const sc_dt::sc_unsigned& );
441 sc_dt::sc_unsigned& operator /= (sc_dt::int64 );
442 sc_dt::sc_unsigned& operator /= (sc_dt::uint64 );
443 sc_dt::sc_unsigned& operator /= (long );
444 sc_dt::sc_unsigned& operator /= (unsigned long );
445 sc_dt::sc_unsigned& operator /= (int );
446 sc_dt::sc_unsigned& operator /= (unsigned int );
447 sc_dt::sc_unsigned& operator %= (const sc_dt::sc_signed& );
448 sc_dt::sc_unsigned& operator %= (const sc_dt::sc_unsigned& );
449 sc_dt::sc_unsigned& operator %= (sc_dt::int64 );
450 sc_dt::sc_unsigned& operator %= (sc_dt::uint64 );
451 sc_dt::sc_unsigned& operator %= (long );
452 sc_dt::sc_unsigned& operator %= (unsigned long );
453 sc_dt::sc_unsigned& operator %= (int );
454 sc_dt::sc_unsigned& operator %= (unsigned int );
455 sc_dt::sc_unsigned& operator &= (const sc_dt::sc_signed& );
456 sc_dt::sc_unsigned& operator &= (const sc_dt::sc_unsigned& );
457 sc_dt::sc_unsigned& operator &= (sc_dt::int64 );
458 sc_dt::sc_unsigned& operator &= (sc_dt::uint64 );
459 sc_dt::sc_unsigned& operator &= (long );
460 sc_dt::sc_unsigned& operator &= (unsigned long );
461 sc_dt::sc_unsigned& operator &= (int );
462 sc_dt::sc_unsigned& operator &= (unsigned int );
463 sc_dt::sc_unsigned& operator |= (const sc_dt::sc_signed& );
464 sc_dt::sc_unsigned& operator |= (const sc_dt::sc_unsigned& );
465 sc_dt::sc_unsigned& operator |= (sc_dt::int64 );
466 sc_dt::sc_unsigned& operator |= (sc_dt::uint64 );
467 sc_dt::sc_unsigned& operator |= (long );
468 sc_dt::sc_unsigned& operator |= (unsigned long );
469 sc_dt::sc_unsigned& operator |= (int );
470 sc_dt::sc_unsigned& operator |= (unsigned int );
471 sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_signed& );
472 sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_unsigned& );
473 sc_dt::sc_unsigned& operator ^= (sc_dt::int64 );
474 sc_dt::sc_unsigned& operator ^= (sc_dt::uint64 );
475 sc_dt::sc_unsigned& operator ^= (long );
476 sc_dt::sc_unsigned& operator ^= (unsigned long );
477 sc_dt::sc_unsigned& operator ^= (int );
478 sc_dt::sc_unsigned& operator ^= (unsigned int );
479
480 protected:
481 mutable sc_event* m_changed_event_p; // Value changed event this object.
482 sc_dt::uint64 m_event_delta; // Delta cycle of last event.
483 sc_dt::sc_unsigned m_new_val; // New value for this object instance.
484 sc_port_base* m_output_p; // Single write port verify field.
485 sc_process_b* m_writer_p; // Single writer verify field.
486};
487
488
489SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
490inline bool sc_signal<sc_dt::sc_biguint<W> >::base_event() const
491{
492 return simcontext()->delta_count() == m_event_delta + 1;
493}
494
495
496SC_TEMPLATE // Return this object's sc_dt::sc_biguint<W> object instance.
497inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::base_read() const
498{
499 return *this;
500}
501
502
503SC_TEMPLATE // Return the value changed event, allocating it if necessary.
504inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::base_value_changed_event() const
505{
506 if ( !m_changed_event_p ) m_changed_event_p = new sc_event;
507 return *m_changed_event_p;
508}
509
510
511SC_TEMPLATE // Write a const sc_dt::sc_signed& value to this object instance.
512inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_signed& value )
513{
514# if defined(DEBUG_SYSTEMC)
515 check_writer();
516# endif
517 m_new_val = value;
518 request_update();
519}
520
521SC_TEMPLATE // Write a const sc_dt::sc_unsigned& value to this object instance.
522inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_unsigned& value )
523{
524# if defined(DEBUG_SYSTEMC)
525 check_writer();
526# endif
527 m_new_val = value;
528 request_update();
529}
530
531SC_TEMPLATE // Write a sc_dt::int64 value to this object instance.
532inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::int64 value )
533{
534# if defined(DEBUG_SYSTEMC)
535 check_writer();
536# endif
537 m_new_val = value;
538 request_update();
539}
540
541
542SC_TEMPLATE // Write a sc_dt::uint64 value to this object instance.
543inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::uint64 value )
544{
545# if defined(DEBUG_SYSTEMC)
546 check_writer();
547# endif
548 m_new_val = value;
549 request_update();
550}
551
552
553//------------------------------------------------------------------------------
554//"sc_signal<sc_dt::sc_biguint<W> >::check_writer"
555//
556// This method checks to see if there is more than one writer for this
557// object instance by keeping track of the process performing the write.
558//------------------------------------------------------------------------------
559SC_TEMPLATE
560inline void sc_signal<sc_dt::sc_biguint<W> >::check_writer()
561{
562 sc_process_b* writer_p = sc_get_current_process_b();
563 if( m_writer_p == 0 )
564 {
565 m_writer_p = writer_p;
566 }
567 else if( m_writer_p != writer_p )
568 {
569 sc_signal_invalid_writer( name(), kind(),
570 m_writer_p->name(), writer_p->name() );
571 }
572}
573
574
575//------------------------------------------------------------------------------
576//"sc_signal<sc_dt::sc_biguint<W> >::concat_set"
577//
578// These virtual methods allow value assignments to this object instance
579// from various sources. The position within the supplied source of the
580// low order bit for this object instance's value is low_i.
581// src = source value.
582// low_i = bit within src to serve as low order bit of this object
583// instance's value.
584//------------------------------------------------------------------------------
585SC_TEMPLATE
586inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::int64 src, int low_i)
587{
588 if ( low_i < 64 )
589 {
590 base_write(src >> low_i);
591 }
592 else
593 {
594 base_write( (sc_dt::int64)((src < 0 ) ? -1 : 0 ));
595 }
596}
597
598SC_TEMPLATE
599inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
600 const sc_dt::sc_lv_base& src, int low_i)
601{
602 sc_dt::sc_unsigned tmp(src.length());
603 tmp = src >> low_i;
604 base_write( tmp );
605}
606
607SC_TEMPLATE
608inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
609 const sc_dt::sc_signed& src, int low_i)
610{
611 base_write( (src >> low_i) );
612}
613
614SC_TEMPLATE
615inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
616 const sc_dt::sc_unsigned& src, int low_i)
617{
618 base_write( (src >> low_i) );
619}
620
621SC_TEMPLATE
622inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::uint64 src, int low_i)
623{
624 base_write( (sc_dt::uint64)(( low_i < 64 ) ? src >> low_i : 0));
625}
626
627
628
629SC_TEMPLATE // Return the default event for this object instance.
630inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::default_event() const
631 { return base_value_changed_event(); }
632
633
634SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
635inline bool sc_signal<sc_dt::sc_biguint<W> >::event() const
636 { return base_event(); }
637
638
639SC_TEMPLATE // Return a reference to the value of this object instance.
640inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::get_data_ref() const
641 { return *this; }
642
643
644SC_TEMPLATE // Return a pointer to this object instance.
645inline sc_signal<sc_dt::sc_biguint<W> >& sc_signal<sc_dt::sc_biguint<W> >::get_signal()
646 { return *this; }
647
648
649SC_TEMPLATE // Return a kind value of "sc_signal".
650inline const char* sc_signal<sc_dt::sc_biguint<W> >::kind() const
651{
652 return "sc_signal";
653}
654
655
656//------------------------------------------------------------------------------
657//"sc_signal_uint::operator ()
658//
659// This operator returns a part selection of this object instance.
660// left = left-hand bit of the selection.
661// right = right-hand bit of the selection.
662//------------------------------------------------------------------------------
663SC_TEMPLATE
664inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator () (int left, int right)
665{
666 sc_unsigned_sigref* result_p; // Value to return.
667
668 result_p = sc_unsigned_sigref::m_pool.allocate();
669 result_p->initialize(this, left, right);
670 return *result_p;
671}
672
673
674//------------------------------------------------------------------------------
675//"sc_signal_uint::operator []"
676//
677// This operator returns a bit selection of this object instance.
678// i = bit to be selected.
679//------------------------------------------------------------------------------
680SC_TEMPLATE
681inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator [] ( int bit )
682{
683 return operator () (bit,bit);
684}
685
686
687SC_TEMPLATE
688inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const this_type& new_val )
689 { base_write( new_val ); }
690
691SC_TEMPLATE
692inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const char* new_val )
693 { sc_dt::sc_biguint<W> tmp = new_val; m_new_val = tmp; request_update(); }
694
695
696SC_TEMPLATE
697inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_unsigned& new_val )
698 { base_write(new_val); }
699
700
701SC_TEMPLATE
702inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::uint64 new_val )
703 { base_write(new_val); }
704
705
706SC_TEMPLATE
707inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::int64 new_val )
708 { base_write(new_val); }
709
710
711SC_TEMPLATE
712inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( int new_val )
713 { base_write((sc_dt::int64)new_val); }
714
715
716SC_TEMPLATE
717inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( long new_val )
718 { base_write((sc_dt::int64)new_val); }
719
720
721SC_TEMPLATE
722inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( short new_val )
723 { base_write((sc_dt::int64)new_val); }
724
725
726SC_TEMPLATE
727inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned int new_val )
728 { base_write((sc_dt::int64)new_val); }
729
730
731SC_TEMPLATE
732inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned long new_val )
733 { base_write((sc_dt::int64)new_val); }
734
735
736SC_TEMPLATE
737inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned short new_val )
738 { base_write((sc_dt::int64)new_val); }
739
740
741SC_TEMPLATE
742template<typename T>
743inline void sc_signal<sc_dt::sc_biguint<W> >::operator = (
744 const sc_dt::sc_generic_base<T>& new_val )
745{
746 sc_dt::sc_unsigned temp(W);
747 new_val->to_sc_unsigned(temp);
748 base_write(temp);
749}
750
751
752SC_TEMPLATE
753inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_signed& new_val )
754 { base_write(new_val); }
755
756SC_TEMPLATE
757inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_bv_base& new_val )
758 { base_write( (sc_dt::sc_biguint<W>)new_val ); }
759
760SC_TEMPLATE
761inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_lv_base& new_val )
762 { base_write( (sc_dt::sc_biguint<W>)new_val ); }
763
764
765SC_TEMPLATE
766inline sc_dt::sc_unsigned* sc_signal<sc_dt::sc_biguint<W> >::part_read_target()
767 { return this; }
768
769
770SC_TEMPLATE
771inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::read() const
772 { return *this; }
773
774
775SC_TEMPLATE // Read a portion of a value.
776inline sc_dt::sc_unsigned sc_signal<sc_dt::sc_biguint<W> >::read_part(
777 int left, int right ) const
778{
779 sc_dt::sc_unsigned tmp(left-right+1);
780 tmp = (*(const sc_dt::sc_biguint<W>*)this)(left,right);
781 return tmp;
782}
783
784SC_TEMPLATE
785inline void sc_signal<sc_dt::sc_biguint<W> >::register_port(
786 sc_port_base& port_, const char* if_typename_ )
787{
788# ifdef DEBUG_SYSTEMC
789 std::string nm( if_typename_ );
790 if( nm == typeid( sc_signal_inout_if<sc_dt::sc_biguint<W> > ).name() )
791 {
792 if( m_output_p != 0 )
793 {
794 sc_signal_invalid_writer( name(), kind(),
795 m_output_p->name(), port_.name() );
796 }
797 m_output_p = &port_;
798 }
799# else
800 if ( &port_ && if_typename_ ) {} // Silence unused args warning.
801# endif
802}
803
804
805SC_TEMPLATE // Autogenerated name object instance constructor.
806inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal() :
807 sc_prim_channel(sc_gen_unique_name( "signal" )),
808 m_changed_event_p(0),
809 m_new_val(W),
810 m_output_p(0),
811 m_writer_p(0)
812{ }
813
814
815SC_TEMPLATE // Explicitly named object instance constructor.
816inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal(const char* name_) :
817 sc_prim_channel(name_),
818 m_changed_event_p(0),
819 m_new_val(W),
820 m_output_p(0),
821 m_writer_p(0)
822{ }
823
824
825SC_TEMPLATE // Object instance destructor.
826inline sc_signal<sc_dt::sc_biguint<W> >::~sc_signal()
827{
828 if ( m_changed_event_p ) delete m_changed_event_p;
829}
830
831
832SC_TEMPLATE // Update the current value from new value.
833inline void sc_signal<sc_dt::sc_biguint<W> >::update()
834{
835 if ( m_changed_event_p )
836 {
837 if ( m_new_val != *this )
838 {
839 m_changed_event_p->notify_delayed();
840 m_event_delta = simcontext()->delta_count();
841 }
842 }
843 sc_dt::sc_unsigned::operator = (m_new_val);
844}
845
846
847SC_TEMPLATE // Return the value changed event.
848inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::value_changed_event() const
849 { return base_value_changed_event(); }
850
851
852SC_TEMPLATE // Write a sc_in<sc_dt::sc_biguint<W> > value to this object instance.
853inline void sc_signal<sc_dt::sc_biguint<W> >::write(
854 const sc_in<sc_dt::sc_biguint<W> >& value )
855 { base_write( value ); }
856
857
858SC_TEMPLATE // Write a sc_inout<sc_dt::sc_biguint<W> > value to this object instance.
859inline void sc_signal<sc_dt::sc_biguint<W> >::write(
860 const sc_inout<sc_dt::sc_biguint<W> >& value )
861{ base_write( value ); }
862
863
864SC_TEMPLATE // Write a sc_dt::sc_biguint<W> value to this object instance.
865inline void sc_signal<sc_dt::sc_biguint<W> >::write( const sc_dt::sc_biguint<W>& value )
866 { base_write( value); }
867
868
869SC_TEMPLATE // Write a portion of a value. If this is the first write in
870 // a delta cycle we copy the existing value before setting the bits.
871inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::int64 v, int left, int right)
872{
873 m_new_val(left, right) = v;
874 request_update();
875}
876
877
878SC_TEMPLATE // Select a portion of a value.
879inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::select_part(
880 int left, int right)
881{
882 sc_unsigned_sigref* result_p = sc_unsigned_sigref::m_pool.allocate();
883 result_p->initialize(dynamic_cast<sc_unsigned_part_if*>(this), left, right);
884 return *result_p;
885}
886
887
888SC_TEMPLATE // Write a portion of a value. If this is the first write in
889 // a delta cycle we copy the existing value before setting the bits.
890inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::uint64 v, int left, int right)
891{
892 m_new_val(left, right) = v;
893 request_update();
894}
895
896
897SC_TEMPLATE // Write a portion of a value. If this is the first write in
898 // a delta cycle we copy the existing value before setting the bits.
899inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
900 const sc_dt::sc_signed& v, int left, int right )
901{
902 m_new_val(left, right) = v;
903 request_update();
904}
905
906
907SC_TEMPLATE // Write a portion of a value. If this is the first write in
908 // a delta cycle we copy the existing value before setting the bits.
909inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
910 const sc_dt::sc_unsigned& v, int left, int right )
911{
912 m_new_val(left, right) = v;
913 request_update();
914}
915
916
917//==============================================================================
918// CLASS sc_in<sc_dt::sc_biguint<W> >
919//
920// This class implements an input port whose target acts like an sc_dt::sc_biguint<W> data
921// value. This class is a specialization of the generic sc_in class to
922// implement tailored support for the sc_dt::sc_biguint<W> class.
923//==============================================================================
924SC_TEMPLATE
925class sc_in<sc_dt::sc_biguint<W> > :
926 public sc_port<sc_signal_in_if<sc_dt::sc_biguint<W> >, 1,
927 SC_ONE_OR_MORE_BOUND>,
928 public sc_dt::sc_value_base
929{
930 public:
931
932 // typedefs
933
934 typedef sc_dt::sc_biguint<W> data_type;
935 typedef sc_signal_in_if<sc_dt::sc_biguint<W> > if_type;
936 typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND> base_type;
937 typedef sc_in<sc_dt::sc_biguint<W> > this_type;
938
939 typedef if_type in_if_type;
940 typedef base_type in_port_type;
941 typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > inout_if_type;
942 typedef sc_inout<sc_dt::sc_biguint<W> > inout_port_type;
943
944 public:
945
946 // bind methods and operators:
947
948 void bind( const in_if_type& interface_ )
949 { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
950 void operator () ( const in_if_type& interface_ )
951 { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
952 void bind( in_port_type& parent_ )
953 { sc_port_base::bind(parent_);}
954 void operator () ( in_port_type& parent_ )
955 { sc_port_base::bind(parent_);}
956 void bind( inout_port_type& parent_ )
957 { sc_port_base::bind(parent_);}
958 void operator () ( inout_port_type& parent_ )
959 { sc_port_base::bind(parent_);}
960
961 protected:
962 // called by pbind (for internal use only)
963 virtual inline int vbind( sc_interface& interface_ )
964 {
965 return sc_port_b<if_type>::vbind( interface_ );
966 }
967 virtual inline int vbind( sc_port_base& parent_ )
968 {
969 in_port_type* in_parent = dynamic_cast<in_port_type*>( &parent_ );
970 if( in_parent != 0 ) {
971 sc_port_base::bind( *in_parent );
972 return 0;
973 }
974 inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
975 if( inout_parent != 0 ) {
976 sc_port_base::bind( *inout_parent );
977 return 0;
978 }
979 // type mismatch
980 return 2;
981 }
982
983
984 // constructors
985
986 public:
987 sc_in()
988 : base_type(), m_traces( 0 )
989 {}
990
991 explicit sc_in( const char* name_ )
992 : base_type( name_ ), m_traces( 0 )
993 {}
994
995 explicit sc_in( const in_if_type& interface_ )
996 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
997 {}
998
999 sc_in( const char* name_, const in_if_type& interface_ )
1000 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
1001 {}
1002
1003 explicit sc_in( in_port_type& parent_ )
1004 : base_type( parent_ ), m_traces( 0 )
1005 {}
1006
1007 sc_in( const char* name_, in_port_type& parent_ )
1008 : base_type( name_, parent_ ), m_traces( 0 )
1009 {}
1010
1011 explicit sc_in( inout_port_type& parent_ )
1012 : base_type(), m_traces( 0 )
1013 { sc_port_base::bind( parent_ ); }
1014
1015 sc_in( const char* name_, inout_port_type& parent_ )
1016 : base_type( name_ ), m_traces( 0 )
1017 { sc_port_base::bind( parent_ ); }
1018
1019 sc_in( this_type& parent_ )
1020 : base_type( parent_ ), m_traces( 0 )
1021 {}
1022
1023 sc_in( const char* name_, this_type& parent_ )
1024 : base_type( name_, parent_ ), m_traces( 0 )
1025 {}
1026
1027
1028 // destructor
1029
1030 virtual inline ~sc_in()
1031 {
1032 remove_traces();
1033 }
1034
1035 // bit and part selection
1036
1037 sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
1038 { return (*this)->read()[i]; }
1039 sc_dt::sc_unsigned_bitref_r bit( int i ) const
1040 { return (*this)->read()[i]; }
1041 sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
1042 { return (*this)->read()(left,right); }
1043 sc_dt::sc_unsigned_subref_r range( int left, int right ) const
1044 { return (*this)->read()(left,right); }
1045
1046
1047 // interface access shortcut methods
1048
1049 // get the default event
1050
1051 const sc_event& default_event() const
1052 { return (*this)->value_changed_event(); }
1053
1054
1055 // get the value changed event
1056
1057 const sc_event& value_changed_event() const
1058 { return (*this)->value_changed_event(); }
1059
1060
1061 // read the current value
1062
1063 const sc_dt::sc_biguint<W>& read() const
1064 { return (*this)->read(); }
1065
1066 operator const sc_dt::sc_biguint<W>& () const
1067 { return (*this)->read(); }
1068
1069 // was there a value changed event?
1070
1071 bool event() const
1072 { return (*this)->event(); }
1073
1074
1075 // (other) event finder method(s)
1076
1077 sc_event_finder& value_changed() const
1078 {
1079 return *new sc_event_finder_t<in_if_type>(
1080 *this, &in_if_type::value_changed_event );
1081 }
1082
1083
1084
1085 // reduction methods:
1086
1087 inline bool and_reduce() const
1088 { return (*this)->read().and_reduce(); }
1089 inline bool nand_reduce() const
1090 { return (*this)->read().nand_reduce(); }
1091 inline bool nor_reduce() const
1092 { return (*this)->read().nor_reduce(); }
1093 inline bool or_reduce() const
1094 { return (*this)->read().or_reduce(); }
1095 inline bool xnor_reduce() const
1096 { return (*this)->read().xnor_reduce(); }
1097 inline bool xor_reduce() const
1098 { return (*this)->read().xor_reduce(); }
1099
1100
1101 // called when elaboration is done
1102 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1103 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1104
1105 virtual inline void end_of_elaboration()
1106 {
1107 if( m_traces != 0 ) {
1108 for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
1109 sc_trace_params* p = (*m_traces)[i];
1110 sc_trace( p->tf, read(), p->name );
1111 }
1112 remove_traces();
1113 }
1114 }
1115
1116 virtual inline const char* kind() const
1117 { return "sc_in"; }
1118
1119
1120 // called by sc_trace
1121 void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
1122 {
1123 if( tf_ != 0 ) {
1124 if( m_traces == 0 ) {
1125 m_traces = new sc_trace_params_vec;
1126 }
1127 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
1128 }
1129 }
1130
1131
1132 // concatenation methods
1133
1134 virtual inline int concat_length(bool* xz_present_p) const
1135 { return (*this)->read().concat_length( xz_present_p ); }
1136 virtual inline sc_dt::uint64 concat_get_uint64() const
1137 { return (*this)->read().concat_get_uint64(); }
1138 virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
1139 { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1140 virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
1141 { return (*this)->read().concat_get_data(dst_p, low_i); }
1142
1143 protected:
1144 void remove_traces() const
1145 {
1146 if( m_traces != 0 ) {
1147 for( int i = m_traces->size() - 1; i >= 0; -- i ) {
1148 delete (*m_traces)[i];
1149 }
1150 delete m_traces;
1151 m_traces = 0;
1152 }
1153 }
1154
1155 mutable sc_trace_params_vec* m_traces;
1156
1157
1158 private:
1159
1160 // disabled
1161 sc_in( const sc_in<sc_dt::sc_biguint<W> >& );
1162 sc_in<sc_dt::sc_biguint<W> >& operator = ( const sc_in<sc_dt::sc_biguint<W> >& );
1163
1164#ifdef __GNUC__
1165 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1166 // This unused variable forces the compiler to instantiate
1167 // an object of T template so an implicit conversion from
1168 // read() to a C++ intrinsic data type will work.
1169 static data_type dummy;
1170#endif
1171
1172};
1173
1174
1175
1176SC_TEMPLATE
1177inline std::ostream& operator << (
1178 std::ostream& os, const sc_in<sc_dt::sc_biguint<W> >& a )
1179{
1180 a.read().print( os );
1181 return os;
1182}
1183
1184
1185//==============================================================================
1186// CLASS sc_inout<sc_dt::sc_biguint<W> >
1187//
1188// This class implements an input/output port whose target acts like an
1189// sc_dt::sc_biguint<W> data value. It is derived from the sc_unsigned_in. This class is a
1190// specialization of the generic sc_inout class to implement tailored support
1191// for the sc_dt::sc_biguint<W> class.
1192//==============================================================================
1193SC_TEMPLATE
1194class sc_inout<sc_dt::sc_biguint<W> > :
1195 public sc_port<sc_signal_inout_if<sc_dt::sc_biguint<W> >, 1,
1196 SC_ONE_OR_MORE_BOUND>,
1197 public sc_dt::sc_value_base
1198{
1199 public:
1200
1201 // typedefs
1202
1203 typedef sc_dt::sc_biguint<W> data_type;
1204 typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > if_type;
1205 typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND> base_type;
1206 typedef sc_inout<sc_dt::sc_biguint<W> > this_type;
1207
1208 typedef if_type inout_if_type;
1209 typedef base_type inout_port_type;
1210
1211 public:
1212
1213 // bind methods and operators:
1214
1215 void bind( const inout_if_type& interface_ )
1216 { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
1217 void operator () ( const inout_if_type& interface_ )
1218 { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
1219 void bind( inout_port_type& parent_ )
1220 { sc_port_base::bind(parent_); }
1221 void operator () ( inout_port_type& parent_ )
1222 { sc_port_base::bind(parent_); }
1223
1224 protected:
1225 // called by pbind (for internal use only)
1226 virtual inline int vbind( sc_interface& interface_ )
1227 {
1228 return sc_port_b<if_type>::vbind( interface_ );
1229 }
1230 virtual inline int vbind( sc_port_base& parent_ )
1231 {
1232 inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
1233 if( inout_parent != 0 ) {
1234 sc_port_base::bind( *inout_parent );
1235 return 0;
1236 }
1237 // type mismatch
1238 return 2;
1239 }
1240
1241
1242 // constructors
1243
1244 public:
1245 sc_inout()
1246 : base_type(), m_init_val_p(0), m_traces( 0 )
1247 {}
1248
1249 explicit sc_inout( const char* name_ )
1250 : base_type( name_ ), m_init_val_p(0), m_traces( 0 )
1251 {}
1252
1253 explicit sc_inout( inout_if_type& interface_ )
1254 : base_type( interface_ ), m_init_val_p(0), m_traces( 0 )
1255 {}
1256
1257 sc_inout( const char* name_, inout_if_type& interface_ )
1258 : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 )
1259 {}
1260
1261 explicit sc_inout( inout_port_type& parent_ )
1262 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1263 {}
1264
1265 sc_inout( const char* name_, inout_port_type& parent_ )
1266 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1267 {}
1268
1269 sc_inout( this_type& parent_ )
1270 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1271 {}
1272
1273 sc_inout( const char* name_, this_type& parent_ )
1274 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1275 {}
1276
1277
1278 // destructor
1279
1280 virtual inline ~sc_inout()
1281 {
1282 remove_traces();
1283 }
1284
1285 // bit and part selection
1286
1287 sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
1288 { return (*this)->read()[i]; }
1289 sc_dt::sc_unsigned_bitref_r bit( int i ) const
1290 { return (*this)->read()[i]; }
1291 sc_unsigned_sigref& operator [] ( int i )
1292 { return (*this)->select_part(i,i); }
1293 sc_unsigned_sigref& bit( int i )
1294 { return (*this)->select_part(i,i); }
1295 sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
1296 { return (*this)->read()(left,right); }
1297 sc_dt::sc_unsigned_subref_r range( int left, int right ) const
1298 { return (*this)->read()(left,right); }
1299 sc_unsigned_sigref& operator () ( int left, int right )
1300 { return (*this)->select_part(left,right); }
1301 sc_unsigned_sigref& range( int left, int right )
1302 { return (*this)->select_part(left,right); }
1303
1304
1305 // interface access shortcut methods
1306
1307 // get the default event
1308
1309 const sc_event& default_event() const
1310 { return (*this)->value_changed_event(); }
1311
1312
1313 // get the value changed event
1314
1315 const sc_event& value_changed_event() const
1316 { return (*this)->value_changed_event(); }
1317
1318
1319 // read the current value
1320
1321 const sc_dt::sc_biguint<W>& read() const
1322 { return (*this)->read(); }
1323
1324 operator const sc_dt::sc_biguint<W>& () const
1325 { return (*this)->read(); }
1326
1327 // was there a value changed event?
1328
1329 bool event() const
1330 { return (*this)->event(); }
1331
1332
1333 // (other) event finder method(s)
1334
1335 sc_event_finder& value_changed() const
1336 {
1337 return *new sc_event_finder_t<inout_if_type>(
1338 *this, &inout_if_type::value_changed_event );
1339 }
1340
1341
1342
1343 // reduction methods:
1344
1345 inline bool and_reduce() const
1346 { return (*this)->read().and_reduce(); }
1347 inline bool nand_reduce() const
1348 { return (*this)->read().nand_reduce(); }
1349 inline bool nor_reduce() const
1350 { return (*this)->read().nor_reduce(); }
1351 inline bool or_reduce() const
1352 { return (*this)->read().or_reduce(); }
1353 inline bool xnor_reduce() const
1354 { return (*this)->read().xnor_reduce(); }
1355 inline bool xor_reduce() const
1356 { return (*this)->read().xor_reduce(); }
1357
1358
1359 // called when elaboration is done
1360 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1361 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1362
1363 virtual inline void end_of_elaboration()
1364 {
1365 if( m_init_val_p != 0 ) {
1366 (*this)->write( *m_init_val_p );
1367 delete m_init_val_p;
1368 m_init_val_p = 0;
1369 }
1370 if( m_traces != 0 ) {
1371 for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
1372 sc_trace_params* p = (*m_traces)[i];
1373 sc_trace( p->tf, read(), p->name );
1374 }
1375 remove_traces();
1376 }
1377 }
1378
1379 virtual inline const char* kind() const
1380 { return "sc_inout"; }
1381
1382 // value initialization
1383
1384 inline void initialize( const sc_dt::sc_biguint<W>& value_ )
1385 {
1386 inout_if_type* iface = dynamic_cast<inout_if_type*>( this->get_interface() );
1387 if( iface != 0 ) {
1388 iface->write( value_ );
1389 } else {
1390 if( m_init_val_p == 0 ) {
1391 m_init_val_p = new sc_dt::sc_biguint<W>;
1392 }
1393 *m_init_val_p = value_;
1394 }
1395 }
1396
1397
1398 // called by sc_trace
1399 void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
1400 {
1401 if( tf_ != 0 ) {
1402 if( m_traces == 0 ) {
1403 m_traces = new sc_trace_params_vec;
1404 }
1405 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
1406 }
1407 }
1408
1409
1410 // concatenation methods
1411
1412 virtual inline int concat_length(bool* xz_present_p) const
1413 { return (*this)->read().concat_length( xz_present_p ); }
1414 virtual inline sc_dt::uint64 concat_get_uint64() const
1415 { return (*this)->read().concat_get_uint64(); }
1416 virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
1417 { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1418 virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
1419 { return (*this)->read().concat_get_data(dst_p, low_i); }
1420 virtual inline void concat_set(sc_dt::int64 src, int low_i)
1421 { *this = (src >> ((low_i < 64) ? low_i : 63)); }
1422#if 0 // ####
1423 virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i)
1424 { *this = src >> low_i; }
1425#endif // 0 ####
1426 virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i)
1427 { *this = (src >> low_i); }
1428 virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i)
1429 { *this = (src >> low_i); }
1430 virtual inline void concat_set(sc_dt::uint64 src, int low_i)
1431 { *this = (low_i < 64 ) ? src >> low_i : (sc_dt::uint64)0; }
1432
1433 // assignment operators:
1434
1435 public:
1436 inline void operator = ( const this_type& new_val )
1437 { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
1438 inline void operator = ( const char* new_val )
1439 { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
1440 inline void operator = ( sc_dt::uint64 new_val )
1441 { (*this)->write(new_val); }
1442 inline void operator = ( sc_dt::int64 new_val )
1443 { (*this)->write((sc_dt::int64)new_val); }
1444 inline void operator = ( int new_val )
1445 { (*this)->write((sc_dt::int64)new_val); }
1446 inline void operator = ( long new_val )
1447 { (*this)->write((sc_dt::int64)new_val); }
1448 inline void operator = ( short new_val )
1449 { (*this)->write((sc_dt::uint64)new_val); }
1450 inline void operator = ( unsigned int new_val )
1451 { (*this)->write((sc_dt::uint64)new_val); }
1452 inline void operator = ( unsigned long new_val )
1453 { (*this)->write((sc_dt::uint64)new_val); }
1454 inline void operator = ( unsigned short new_val )
1455 { (*this)->write((sc_dt::uint64)new_val); }
1456 template<typename T>
1457 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
1458 {
1459 sc_dt::sc_unsigned temp(W);
1460 new_val->to_sc_unsigned(temp);
1461 (*this)->write(temp);
1462 }
1463 inline void operator = ( const sc_dt::sc_signed& new_val )
1464 { (*this)->write(new_val); }
1465 inline void operator = ( const sc_dt::sc_unsigned& new_val )
1466 { (*this)->write(new_val); }
1467 inline void operator = ( const sc_dt::sc_bv_base& new_val )
1468 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1469 inline void operator = ( const sc_dt::sc_lv_base& new_val )
1470 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1471
1472 inline void write( const sc_in<sc_dt::sc_biguint<W> >& new_val )
1473 { (*this)->write( new_val.read() ); }
1474 inline void write( const sc_inout<sc_dt::sc_biguint<W> >& new_val )
1475 { (*this)->write( new_val.read() ); }
1476 inline void write( const sc_dt::sc_biguint<W>& new_val )
1477 { (*this)->write( new_val ); }
1478
1479 protected:
1480 void remove_traces() const
1481 {
1482 if( m_traces != 0 ) {
1483 for( int i = m_traces->size() - 1; i >= 0; -- i ) {
1484 delete (*m_traces)[i];
1485 }
1486 delete m_traces;
1487 m_traces = 0;
1488 }
1489 }
1490
1491 sc_dt::sc_biguint<W>* m_init_val_p;
1492 mutable sc_trace_params_vec* m_traces;
1493
1494
1495 private:
1496
1497 // disabled
1498 sc_inout( const sc_inout<sc_dt::sc_biguint<W> >& );
1499
1500#ifdef __GNUC__
1501 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1502 // This unused variable forces the compiler to instantiate
1503 // an object of T template so an implicit conversion from
1504 // read() to a C++ intrinsic data type will work.
1505 static data_type dummy;
1506#endif
1507
1508};
1509
1510
1511
1512SC_TEMPLATE
1513inline std::ostream& operator << (
1514 std::ostream& os, const sc_inout<sc_dt::sc_biguint<W> >& a )
1515{
1516 a.read().print( os );
1517 return os;
1518}
1519
1520
1521//==============================================================================
1522// CLASS sc_out<sc_dt::sc_biguint<W> >
1523//
1524// This class implements an output port whose target acts like an
1525// sc_dt::sc_biguint<W> data value. This class is a derivation of sc_inout, since
1526// output ports are really no different from input/output ports.
1527//==============================================================================
1528SC_TEMPLATE
1529class sc_out<sc_dt::sc_biguint<W> > : public sc_inout<sc_dt::sc_biguint<W> >
1530{
1531 public:
1532
1533 // typedefs
1534
1535 typedef sc_dt::sc_biguint<W> data_type;
1536
1537 typedef sc_out<data_type> this_type;
1538 typedef sc_inout<data_type> base_type;
1539
1540 typedef typename base_type::inout_if_type inout_if_type;
1541 typedef typename base_type::inout_port_type inout_port_type;
1542
1543 // constructors
1544
1545 sc_out()
1546 : base_type()
1547 {}
1548
1549 explicit sc_out( const char* name_ )
1550 : base_type( name_ )
1551 {}
1552
1553 explicit sc_out( inout_if_type& interface_ )
1554 : base_type( interface_ )
1555 {}
1556
1557 sc_out( const char* name_, inout_if_type& interface_ )
1558 : base_type( name_, interface_ )
1559 {}
1560
1561 explicit sc_out( inout_port_type& parent_ )
1562 : base_type( parent_ )
1563 {}
1564
1565 sc_out( const char* name_, inout_port_type& parent_ )
1566 : base_type( name_, parent_ )
1567 {}
1568
1569 sc_out( this_type& parent_ )
1570 : base_type( parent_ )
1571 {}
1572
1573 sc_out( const char* name_, this_type& parent_ )
1574 : base_type( name_, parent_ )
1575 {}
1576
1577
1578 // destructor (does nothing)
1579
1580 virtual inline ~sc_out()
1581 {}
1582
1583
1584 // assignment operators:
1585
1586 public:
1587 inline void operator = ( const this_type& new_val )
1588 { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
1589 inline void operator = ( const char* new_val )
1590 { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
1591 inline void operator = ( sc_dt::uint64 new_val )
1592 { (*this)->write(new_val); }
1593 inline void operator = ( sc_dt::int64 new_val )
1594 { (*this)->write((sc_dt::uint64)new_val); }
1595 inline void operator = ( int new_val )
1596 { (*this)->write((sc_dt::uint64)new_val); }
1597 inline void operator = ( long new_val )
1598 { (*this)->write((sc_dt::uint64)new_val); }
1599 inline void operator = ( short new_val )
1600 { (*this)->write((sc_dt::uint64)new_val); }
1601 inline void operator = ( unsigned int new_val )
1602 { (*this)->write((sc_dt::uint64)new_val); }
1603 inline void operator = ( unsigned long new_val )
1604 { (*this)->write((sc_dt::uint64)new_val); }
1605 inline void operator = ( unsigned short new_val )
1606 { (*this)->write((sc_dt::uint64)new_val); }
1607 template<typename T>
1608 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
1609 {
1610 sc_dt::sc_unsigned temp(W);
1611 new_val->to_sc_unsigned(temp);
1612 (*this)->write(temp);
1613 }
1614 inline void operator = ( const sc_dt::sc_signed& new_val )
1615 { (*this)->write(new_val); }
1616 inline void operator = ( const sc_dt::sc_unsigned& new_val )
1617 { (*this)->write(new_val); }
1618 inline void operator = ( const sc_dt::sc_bv_base& new_val )
1619 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1620 inline void operator = ( const sc_dt::sc_lv_base& new_val )
1621 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1622
1623 private:
1624
1625 // disabled
1626 sc_out( const this_type& );
1627};
1628
1629
1630
1631//------------------------------------------------------------------------------
1632//"sc_unsigned_sigref::initialize"
1633//
1634// This method initializes an object instance from the supplied arguments.
1635// if_p -> target of this selection.
1636// left_ = left-most bit in selection.
1637// right_ = right-most bit in selection.
1638//------------------------------------------------------------------------------
1639inline void sc_unsigned_sigref::initialize(
1640 sc_unsigned_part_if* if_p, int left_, int right_ )
1641{
1642 m_if_p = if_p;
1643 m_left = left_;
1644 m_right = right_;
1645 m_obj_p = if_p->part_read_target();
1646}
1647
1648
1649//------------------------------------------------------------------------------
1650//"sc_unsigned_sigref::operator ="
1651//
1652// These operators assign a value to the bits associated with this object
1653// instance within this object instance's target signal.
1654//------------------------------------------------------------------------------
1655inline void sc_unsigned_sigref::operator = ( sc_dt::uint64 v )
1656{
1657 m_if_p->write_part( v, m_left, m_right );
1658}
1659
1660inline void sc_unsigned_sigref::operator = ( const char* v )
1661{
1662 sc_dt::sc_unsigned tmp(length());
1663 tmp = v;
1664 *this = tmp;
1665}
1666
1667inline void sc_unsigned_sigref:: operator = ( sc_dt::int64 v )
1668{
1669 *this = (sc_dt::uint64)v;
1670}
1671
1672inline void sc_unsigned_sigref:: operator = ( int v )
1673{
1674 *this = (sc_dt::uint64)v;
1675}
1676
1677inline void sc_unsigned_sigref:: operator = ( long v )
1678{
1679 *this = (sc_dt::uint64)v;
1680}
1681
1682inline void sc_unsigned_sigref:: operator = ( unsigned int v )
1683{
1684 *this = (sc_dt::uint64)v;
1685}
1686
1687inline void sc_unsigned_sigref:: operator = ( unsigned long v )
1688{
1689 *this = (sc_dt::uint64)v;
1690}
1691
1692void sc_unsigned_sigref::operator = ( const sc_unsigned_sigref& v )
1693{
1694 *this = (sc_dt::sc_unsigned)v;
1695}
1696
1697
1698inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_signed& v )
1699{
1700 m_if_p->write_part( v, m_left, m_right );
1701}
1702
1703inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_unsigned& v )
1704{
1705 m_if_p->write_part( v, m_left, m_right );
1706}
1707
1708template<typename T>
1709inline void sc_unsigned_sigref:: operator = (
1710 const sc_dt::sc_generic_base<T>& v )
1711{
1712 sc_dt::sc_unsigned temp(m_left-m_right+1);
1713 v->to_sc_unsigned(temp);
1714 m_if_p->write_part( temp, m_left, m_right );
1715}
1716
1717#undef SC_TEMPLATE
1718} // namespace sc_core
1719#endif // !defined(SC_SIGNAL_UNSIGNED_H)
1720
1721namespace sc_core {
1722
1723extern
1724void
1725sc_signal_invalid_writer( const char* name,
1726 const char* kind,
1727 const char* first_writer,
1728 const char* second_writer );
1729
1730//------------------------------------------------------------------------------
1731// POOL OF TEMPORARY INSTANCES OF sc_unsigned_sigref
1732//
1733// This allows use to pass const references for part and bit selections
1734// on sc_signal_signed object instances.
1735//------------------------------------------------------------------------------
1736sc_vpool<sc_unsigned_sigref> sc_unsigned_sigref::m_pool(8);
1737
1738
1739//------------------------------------------------------------------------------
1740//"sc_unsigned_part_if::default methods"
1741//
1742// These versions just produce errors if they are not overloaded but used.
1743//------------------------------------------------------------------------------
1744sc_dt::sc_unsigned* sc_unsigned_part_if::part_read_target()
1745{
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_signal_unsigned.cpp -- The sc_signal<sc_unsigned<W> > implementations.
23
24 Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31 changes you are making here.
32
33 Name, Affiliation, Date:
34 Description of Modification:
35
36 *****************************************************************************/
37
38/*
39$Log: scx_signal_unsigned.h,v $
40Revision 1.1 2011/08/15 17:31:11 acg
41 Andy Goodrich: moved specialized signals from examples to this tree.
42
43Revision 1.2 2011/08/15 16:43:24 acg
44 Torsten Maehne: changes to remove unused argument warnings.
45
46Revision 1.1.1.1 2006/12/15 20:20:03 acg
47SystemC 2.3
48
49Revision 1.2 2005/12/26 20:11:14 acg
50Fixed up copyright.
51
52Revision 1.1.1.1 2005/12/19 23:16:42 acg
53First check in of SystemC 2.1 into its own archive.
54
55Revision 1.17 2005/09/15 23:01:52 acg
56Added std:: prefix to appropriate methods and types to get around
57issues with the Edison Front End.
58
59Revision 1.16 2005/05/03 19:52:26 acg
60Get proper header locations on includes.
61
62Revision 1.15 2005/05/03 19:50:20 acg
63Name space version.
64
65Revision 1.12 2005/04/11 19:05:36 acg
66Change to sc_clock for Microsoft VCC 6.0. Changes for namespaces
67
68Revision 1.11 2005/04/03 22:52:52 acg
69Namespace changes.
70
71Revision 1.10 2005/03/21 22:31:33 acg
72Changes to sc_core namespace.
73
74Revision 1.9 2004/09/27 21:01:59 acg
75Andy Goodrich - Forte Design Systems, Inc.
76 - This is specialized signal support that allows better use of signals
77 and ports whose target value is a SystemC native type.
78
79*/
80
81
82
83#include <systemc>
84#include <typeinfo>
85
86/*****************************************************************************
87
88 sc_signal_unsigned.h -- The sc_signal<sc_dt::sc_biguint<W> > definitions.
89
90 Original Author: Andy Goodrich, Forte Design Systems, 2002-10-22
91
92 *****************************************************************************/
93
94/*****************************************************************************
95
96 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
97 changes you are making here.
98
99 Name, Affiliation, Date:
100 Description of Modification:
101
102 *****************************************************************************/
103
104/*
105$Log: scx_signal_unsigned.h,v $
106Revision 1.1 2011/08/15 17:31:11 acg
107 Andy Goodrich: moved specialized signals from examples to this tree.
108
109Revision 1.3 2011/08/15 16:43:24 acg
110 Torsten Maehne: changes to remove unused argument warnings.
111
112Revision 1.2 2011/06/28 21:23:02 acg
113 Andy Goodrich: merging of SCV tree.
114
115Revision 1.1.1.1 2006/12/15 20:20:03 acg
116SystemC 2.3
117
118Revision 1.4 2006/10/23 19:40:36 acg
119 Andy Goodrich: added an explicit dynamic cast to keep gcc 4.x happy.
120
121Revision 1.3 2006/03/21 01:31:49 acg
122 Andy Goodrich: changed over to sc_get_current_process_b() from
123 sc_get_current_process_base() since the function's name changed.
124
125Revision 1.2 2005/12/26 20:11:14 acg
126Fixed up copyright.
127
128Revision 1.1.1.1 2005/12/19 23:16:42 acg
129First check in of SystemC 2.1 into its own archive.
130
131Revision 1.28 2005/09/15 23:01:52 acg
132Added std:: prefix to appropriate methods and types to get around
133issues with the Edison Front End.
134
135Revision 1.27 2005/07/30 03:44:11 acg
136Changes from 2.1.
137
138Revision 1.26 2005/05/09 17:17:12 acg
139Changes from 2.1.
140
141Revision 1.25 2005/05/08 19:04:06 acg
142Fix bug in concat_set(int64,off). Other changes from 2.1 examples usage.
143
144Revision 1.24 2005/05/03 19:50:20 acg
145Name space version.
146
147Revision 1.22 2005/03/21 22:31:33 acg
148Changes to sc_core namespace.
149
150Revision 1.21 2005/01/10 17:51:58 acg
151Improvements.
152
153Revision 1.20 2004/11/09 00:11:27 acg
154Added support for sc_generic_base<T> in place of sc_concatref. sc_concatref
155now is derived from sc_generic_base<sc_concatref>.
156
157Revision 1.19 2004/09/27 21:01:59 acg
158Andy Goodrich - Forte Design Systems, Inc.
159 - This is specialized signal support that allows better use of signals
160 and ports whose target value is a SystemC native type.
161
162*/
163
164
165#if !defined(SC_SIGNAL_UNSIGNED_H)
166#define SC_SIGNAL_UNSIGNED_H
167
168#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )
169# define SC_TEMPLATE template<int W>
170#else
171# define SC_TEMPLATE template<> template<int W>
172#endif
173
174
175// FORWARD REFERENCES AND USINGS:
176
177using sc_dt::sc_signed;
178using sc_dt::int64;
179using sc_dt::uint64;
180
181namespace sc_core {
182
183class sc_unsigned_sigref;
184
185//==============================================================================
186// CLASS sc_unsigned_part_if
187//
188// This class provides generic access to part selections for signals whose
189// data type is sc_dt::sc_biguint<W>. This class serves as the base class for the
190// sc_dt::sc_biguint<W> specialization of the sc_signal_in_if<T> class. The methods
191// in this class may be over-ridden individually, those that are not overridden
192// will produce an error message when called. The methods are used by the
193// sc_unsigned_sigref class.
194//
195// Notes:
196// (1) Descriptions of the methods and operators in this class appear with
197// their implementations in sc_signal<sc_dt::sc_biguint<W> >.
198//==============================================================================
199class sc_unsigned_part_if : virtual public sc_interface {
200 protected:
201 // constructor:
202 sc_unsigned_part_if() {}
203
204 public:
205 // perform a part read.
206 virtual sc_dt::sc_unsigned* part_read_target();
207 virtual sc_dt::sc_unsigned read_part( int left, int right ) const;
208
209 // perform a part write.
210 virtual sc_unsigned_sigref& select_part( int left, int right );
211 virtual void write_part( sc_dt::int64 v, int left, int right );
212 virtual void write_part( sc_dt::uint64 v, int left, int right );
213 virtual void write_part( const sc_dt::sc_signed& v, int left, int right );
214 virtual void write_part( const sc_dt::sc_unsigned& v, int left, int right );
215
216
217 private:
218 sc_unsigned_part_if( const sc_unsigned_part_if& );
219 sc_unsigned_part_if& operator = ( const sc_unsigned_part_if& );
220};
221
222
223//==============================================================================
224// CLASS sc_signal_in_if<sc_dt::sc_biguint<W> >
225//
226// This is the class specializations for the sc_signal_in_if<T> class to
227// provide additional features for sc_signal instances whose template is
228// sc_dt::sc_biguint<W>, including part access.
229//
230// Notes:
231// (1) Descriptions of the methods and operators in this class appear with
232// their implementations in sc_signal<sc_dt::sc_biguint<W> >.
233//==============================================================================
234template< int W >
235class sc_signal_in_if<sc_dt::sc_biguint<W> > : public sc_unsigned_part_if {
236 friend class sc_unsigned_sigref;
237 public:
238 typedef sc_signal_in_if<sc_dt::sc_biguint<W> > this_type;
239
240 // get the value changed event
241 virtual const sc_event& value_changed_event() const = 0;
242
243
244 // read the current value
245 virtual const sc_dt::sc_biguint<W>& read() const = 0;
246
247 // get a reference to the current value (for tracing)
248 virtual const sc_dt::sc_biguint<W>& get_data_ref() const = 0;
249
250
251 // was there a value changed event?
252 virtual bool event() const = 0;
253
254 protected:
255 // constructor
256 sc_signal_in_if()
257 {}
258
259 private: // disabled
260 sc_signal_in_if( const this_type& );
261 this_type& operator = ( const this_type& );
262};
263
264//=============================================================================
265// CLASS : sc_unsigned_sigref
266//
267// Proxy class for sc_signal_uint bit and part selection.
268//=============================================================================
269class sc_unsigned_sigref : public sc_dt::sc_unsigned_subref_r
270{
271 public:
272 sc_unsigned_sigref() : sc_dt::sc_unsigned_subref_r() {}
273 virtual ~sc_unsigned_sigref() {}
274 virtual void concat_set(sc_dt::int64 src, int low_i);
275 virtual void concat_set(const sc_dt::sc_signed& src, int low_i);
276 virtual void concat_set(const sc_dt::sc_unsigned& src, int low_i);
277 virtual void concat_set(const sc_dt::sc_lv_base& src, int low_i);
278 virtual void concat_set(sc_dt::uint64 src, int low_i);
279
280 public:
281 inline void initialize( sc_unsigned_part_if* if_p, int left_, int right_ );
282
283 public:
284 inline void operator = ( sc_dt::uint64 v );
285 inline void operator = ( const char* v );
286 inline void operator = ( unsigned long v );
287 inline void operator = ( long v );
288 inline void operator = ( unsigned int v );
289 inline void operator = ( int v );
290 inline void operator = ( sc_dt::int64 v );
291 inline void operator = ( double v );
292 inline void operator = ( const sc_unsigned_sigref& v );
293 template<typename T>
294 inline void operator = ( const sc_dt::sc_generic_base<T>& v );
295 inline void operator = ( const sc_dt::sc_signed& v );
296 inline void operator = ( const sc_dt::sc_unsigned& v );
297 inline void operator = ( const sc_dt::sc_bv_base& v );
298 inline void operator = ( const sc_dt::sc_lv_base& v );
299
300 public:
301 static sc_vpool<sc_unsigned_sigref> m_pool; // Pool of objects to use.
302
303 protected:
304 sc_unsigned_part_if* m_if_p; // Target for selection.
305
306 private:
307
308 // disabled
309 sc_unsigned_sigref( const sc_unsigned_sigref& a );
310};
311
312
313//==============================================================================
314// CLASS sc_signal<sc_dt::sc_biguint<W> >
315//
316// This class implements a signal whose value acts like an sc_dt::sc_biguint<W> data
317// value. This class is a specialization of the generic sc_signal class to
318// implement tailored support for the sc_dt::sc_biguint<W> class.
319//
320// Notes:
321// (1) Descriptions of the methods and operators in this class appear with
322// their implementations.
323//==============================================================================
324SC_TEMPLATE
325class sc_signal<sc_dt::sc_biguint<W> > :
326 public sc_dt::sc_biguint<W>,
327 public sc_prim_channel,
328 public sc_signal_inout_if<sc_dt::sc_biguint<W> >
329{
330 public: // typedefs
331 typedef sc_signal<sc_dt::sc_biguint<W> > this_type;
332
333 public: // constructors and destructor:
334 inline sc_signal();
335 explicit inline sc_signal(const char* name_);
336 virtual inline ~sc_signal();
337
338 public: // base methods:
339 inline bool base_event() const;
340 inline const sc_dt::sc_biguint<W>& base_read() const;
341 inline const sc_event& base_value_changed_event() const;
342 inline void base_write( sc_dt::int64 value );
343 inline void base_write( sc_dt::uint64 value );
344 inline void base_write( const sc_dt::sc_signed& value );
345 inline void base_write( const sc_dt::sc_unsigned& value );
346
347 public: // sc_prim_channel virtual methods:
348 virtual inline const char* kind() const;
349 virtual inline void update();
350
351 public: // sc_interface virtual methods:
352 virtual inline const sc_event& default_event() const;
353 virtual inline void register_port(
354 sc_port_base& port_, const char* if_typename_ );
355
356 public: // sc_unsigned_channel virtual methods:
357 virtual inline sc_dt::sc_unsigned* part_read_target();
358 virtual inline sc_dt::sc_unsigned read_part(int left, int right) const;
359 virtual sc_unsigned_sigref& select_part( int left, int right );
360 virtual inline void write_part( sc_dt::int64 v, int left, int right );
361 virtual inline void write_part( sc_dt::uint64 v, int left, int right );
362 virtual inline void write_part( const sc_dt::sc_signed& v, int left, int right );
363 virtual inline void write_part(const sc_dt::sc_unsigned& v, int left, int right);
364
365 public: // interface virtual methods:
366 virtual inline bool event() const;
367 virtual inline const sc_dt::sc_biguint<W>& get_data_ref() const;
368 virtual inline sc_signal<sc_dt::sc_biguint<W> >& get_signal();
369 virtual inline const sc_dt::sc_biguint<W>& read() const;
370 virtual inline const sc_event& value_changed_event() const;
371 virtual inline void write( const sc_in<sc_dt::sc_biguint<W> >& value );
372 virtual inline void write( const sc_inout<sc_dt::sc_biguint<W> >& value );
373 virtual inline void write( const sc_dt::sc_biguint<W>& value );
374
375 public: // part selections:
376 inline sc_unsigned_sigref& operator () ( int left, int right );
377 // #### Need to add range() and bit()!
378 inline sc_unsigned_sigref& operator [] ( int bit );
379
380 public: // operators:
381 inline void operator = ( const this_type& new_val );
382 inline void operator = ( const char* new_val );
383 inline void operator = ( sc_dt::uint64 new_val );
384 inline void operator = ( sc_dt::int64 new_val );
385 inline void operator = ( int new_val );
386 inline void operator = ( long new_val );
387 inline void operator = ( short new_val );
388 inline void operator = ( unsigned int new_val );
389 inline void operator = ( unsigned long new_val );
390 inline void operator = ( unsigned short new_val );
391 template<typename T>
392 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val );
393 inline void operator = ( const sc_dt::sc_signed& new_val );
394 inline void operator = ( const sc_dt::sc_unsigned& new_val );
395 inline void operator = ( const sc_dt::sc_bv_base& new_val );
396 inline void operator = ( const sc_dt::sc_lv_base& new_val );
397
398 // concatenation methods (we inherit length and gets from sc_dt::sc_biguint<W>):
399
400 virtual inline void concat_set(sc_dt::int64 src, int low_i);
401 virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i);
402 virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i);
403 virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i);
404 virtual inline void concat_set(sc_dt::uint64 src, int low_i);
405
406 protected: // debugging methods:
407 // #### void check_port();
408 void check_writer();
409
410 private: // Disabled operations that sc_dt::sc_biguint<W> supports:
411 sc_dt::sc_unsigned& operator ++ (); // prefix
412 const sc_dt::sc_unsigned& operator ++ (int); // postfix
413 sc_dt::sc_unsigned& operator -- (); // prefix
414 const sc_dt::sc_unsigned& operator -- (int); // postfix
415 sc_dt::sc_unsigned& operator += (const sc_dt::sc_signed& );
416 sc_dt::sc_unsigned& operator += (const sc_dt::sc_unsigned& );
417 sc_dt::sc_unsigned& operator += (sc_dt::int64 );
418 sc_dt::sc_unsigned& operator += (sc_dt::uint64 );
419 sc_dt::sc_unsigned& operator += (long );
420 sc_dt::sc_unsigned& operator += (unsigned long );
421 sc_dt::sc_unsigned& operator += (int );
422 sc_dt::sc_unsigned& operator += (unsigned int );
423 sc_dt::sc_unsigned& operator -= (const sc_dt::sc_signed& );
424 sc_dt::sc_unsigned& operator -= (const sc_dt::sc_unsigned& );
425 sc_dt::sc_unsigned& operator -= (sc_dt::int64 );
426 sc_dt::sc_unsigned& operator -= (sc_dt::uint64 );
427 sc_dt::sc_unsigned& operator -= (long );
428 sc_dt::sc_unsigned& operator -= (unsigned long );
429 sc_dt::sc_unsigned& operator -= (int );
430 sc_dt::sc_unsigned& operator -= (unsigned int );
431 sc_dt::sc_unsigned& operator *= (const sc_dt::sc_signed& );
432 sc_dt::sc_unsigned& operator *= (const sc_dt::sc_unsigned& );
433 sc_dt::sc_unsigned& operator *= (sc_dt::int64 );
434 sc_dt::sc_unsigned& operator *= (sc_dt::uint64 );
435 sc_dt::sc_unsigned& operator *= (long );
436 sc_dt::sc_unsigned& operator *= (unsigned long );
437 sc_dt::sc_unsigned& operator *= (int );
438 sc_dt::sc_unsigned& operator *= (unsigned int );
439 sc_dt::sc_unsigned& operator /= (const sc_dt::sc_signed& );
440 sc_dt::sc_unsigned& operator /= (const sc_dt::sc_unsigned& );
441 sc_dt::sc_unsigned& operator /= (sc_dt::int64 );
442 sc_dt::sc_unsigned& operator /= (sc_dt::uint64 );
443 sc_dt::sc_unsigned& operator /= (long );
444 sc_dt::sc_unsigned& operator /= (unsigned long );
445 sc_dt::sc_unsigned& operator /= (int );
446 sc_dt::sc_unsigned& operator /= (unsigned int );
447 sc_dt::sc_unsigned& operator %= (const sc_dt::sc_signed& );
448 sc_dt::sc_unsigned& operator %= (const sc_dt::sc_unsigned& );
449 sc_dt::sc_unsigned& operator %= (sc_dt::int64 );
450 sc_dt::sc_unsigned& operator %= (sc_dt::uint64 );
451 sc_dt::sc_unsigned& operator %= (long );
452 sc_dt::sc_unsigned& operator %= (unsigned long );
453 sc_dt::sc_unsigned& operator %= (int );
454 sc_dt::sc_unsigned& operator %= (unsigned int );
455 sc_dt::sc_unsigned& operator &= (const sc_dt::sc_signed& );
456 sc_dt::sc_unsigned& operator &= (const sc_dt::sc_unsigned& );
457 sc_dt::sc_unsigned& operator &= (sc_dt::int64 );
458 sc_dt::sc_unsigned& operator &= (sc_dt::uint64 );
459 sc_dt::sc_unsigned& operator &= (long );
460 sc_dt::sc_unsigned& operator &= (unsigned long );
461 sc_dt::sc_unsigned& operator &= (int );
462 sc_dt::sc_unsigned& operator &= (unsigned int );
463 sc_dt::sc_unsigned& operator |= (const sc_dt::sc_signed& );
464 sc_dt::sc_unsigned& operator |= (const sc_dt::sc_unsigned& );
465 sc_dt::sc_unsigned& operator |= (sc_dt::int64 );
466 sc_dt::sc_unsigned& operator |= (sc_dt::uint64 );
467 sc_dt::sc_unsigned& operator |= (long );
468 sc_dt::sc_unsigned& operator |= (unsigned long );
469 sc_dt::sc_unsigned& operator |= (int );
470 sc_dt::sc_unsigned& operator |= (unsigned int );
471 sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_signed& );
472 sc_dt::sc_unsigned& operator ^= (const sc_dt::sc_unsigned& );
473 sc_dt::sc_unsigned& operator ^= (sc_dt::int64 );
474 sc_dt::sc_unsigned& operator ^= (sc_dt::uint64 );
475 sc_dt::sc_unsigned& operator ^= (long );
476 sc_dt::sc_unsigned& operator ^= (unsigned long );
477 sc_dt::sc_unsigned& operator ^= (int );
478 sc_dt::sc_unsigned& operator ^= (unsigned int );
479
480 protected:
481 mutable sc_event* m_changed_event_p; // Value changed event this object.
482 sc_dt::uint64 m_event_delta; // Delta cycle of last event.
483 sc_dt::sc_unsigned m_new_val; // New value for this object instance.
484 sc_port_base* m_output_p; // Single write port verify field.
485 sc_process_b* m_writer_p; // Single writer verify field.
486};
487
488
489SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
490inline bool sc_signal<sc_dt::sc_biguint<W> >::base_event() const
491{
492 return simcontext()->delta_count() == m_event_delta + 1;
493}
494
495
496SC_TEMPLATE // Return this object's sc_dt::sc_biguint<W> object instance.
497inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::base_read() const
498{
499 return *this;
500}
501
502
503SC_TEMPLATE // Return the value changed event, allocating it if necessary.
504inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::base_value_changed_event() const
505{
506 if ( !m_changed_event_p ) m_changed_event_p = new sc_event;
507 return *m_changed_event_p;
508}
509
510
511SC_TEMPLATE // Write a const sc_dt::sc_signed& value to this object instance.
512inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_signed& value )
513{
514# if defined(DEBUG_SYSTEMC)
515 check_writer();
516# endif
517 m_new_val = value;
518 request_update();
519}
520
521SC_TEMPLATE // Write a const sc_dt::sc_unsigned& value to this object instance.
522inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( const sc_dt::sc_unsigned& value )
523{
524# if defined(DEBUG_SYSTEMC)
525 check_writer();
526# endif
527 m_new_val = value;
528 request_update();
529}
530
531SC_TEMPLATE // Write a sc_dt::int64 value to this object instance.
532inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::int64 value )
533{
534# if defined(DEBUG_SYSTEMC)
535 check_writer();
536# endif
537 m_new_val = value;
538 request_update();
539}
540
541
542SC_TEMPLATE // Write a sc_dt::uint64 value to this object instance.
543inline void sc_signal<sc_dt::sc_biguint<W> >::base_write( sc_dt::uint64 value )
544{
545# if defined(DEBUG_SYSTEMC)
546 check_writer();
547# endif
548 m_new_val = value;
549 request_update();
550}
551
552
553//------------------------------------------------------------------------------
554//"sc_signal<sc_dt::sc_biguint<W> >::check_writer"
555//
556// This method checks to see if there is more than one writer for this
557// object instance by keeping track of the process performing the write.
558//------------------------------------------------------------------------------
559SC_TEMPLATE
560inline void sc_signal<sc_dt::sc_biguint<W> >::check_writer()
561{
562 sc_process_b* writer_p = sc_get_current_process_b();
563 if( m_writer_p == 0 )
564 {
565 m_writer_p = writer_p;
566 }
567 else if( m_writer_p != writer_p )
568 {
569 sc_signal_invalid_writer( name(), kind(),
570 m_writer_p->name(), writer_p->name() );
571 }
572}
573
574
575//------------------------------------------------------------------------------
576//"sc_signal<sc_dt::sc_biguint<W> >::concat_set"
577//
578// These virtual methods allow value assignments to this object instance
579// from various sources. The position within the supplied source of the
580// low order bit for this object instance's value is low_i.
581// src = source value.
582// low_i = bit within src to serve as low order bit of this object
583// instance's value.
584//------------------------------------------------------------------------------
585SC_TEMPLATE
586inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::int64 src, int low_i)
587{
588 if ( low_i < 64 )
589 {
590 base_write(src >> low_i);
591 }
592 else
593 {
594 base_write( (sc_dt::int64)((src < 0 ) ? -1 : 0 ));
595 }
596}
597
598SC_TEMPLATE
599inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
600 const sc_dt::sc_lv_base& src, int low_i)
601{
602 sc_dt::sc_unsigned tmp(src.length());
603 tmp = src >> low_i;
604 base_write( tmp );
605}
606
607SC_TEMPLATE
608inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
609 const sc_dt::sc_signed& src, int low_i)
610{
611 base_write( (src >> low_i) );
612}
613
614SC_TEMPLATE
615inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(
616 const sc_dt::sc_unsigned& src, int low_i)
617{
618 base_write( (src >> low_i) );
619}
620
621SC_TEMPLATE
622inline void sc_signal<sc_dt::sc_biguint<W> >::concat_set(sc_dt::uint64 src, int low_i)
623{
624 base_write( (sc_dt::uint64)(( low_i < 64 ) ? src >> low_i : 0));
625}
626
627
628
629SC_TEMPLATE // Return the default event for this object instance.
630inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::default_event() const
631 { return base_value_changed_event(); }
632
633
634SC_TEMPLATE // Return true if a changed event happened in the last delta cycle.
635inline bool sc_signal<sc_dt::sc_biguint<W> >::event() const
636 { return base_event(); }
637
638
639SC_TEMPLATE // Return a reference to the value of this object instance.
640inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::get_data_ref() const
641 { return *this; }
642
643
644SC_TEMPLATE // Return a pointer to this object instance.
645inline sc_signal<sc_dt::sc_biguint<W> >& sc_signal<sc_dt::sc_biguint<W> >::get_signal()
646 { return *this; }
647
648
649SC_TEMPLATE // Return a kind value of "sc_signal".
650inline const char* sc_signal<sc_dt::sc_biguint<W> >::kind() const
651{
652 return "sc_signal";
653}
654
655
656//------------------------------------------------------------------------------
657//"sc_signal_uint::operator ()
658//
659// This operator returns a part selection of this object instance.
660// left = left-hand bit of the selection.
661// right = right-hand bit of the selection.
662//------------------------------------------------------------------------------
663SC_TEMPLATE
664inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator () (int left, int right)
665{
666 sc_unsigned_sigref* result_p; // Value to return.
667
668 result_p = sc_unsigned_sigref::m_pool.allocate();
669 result_p->initialize(this, left, right);
670 return *result_p;
671}
672
673
674//------------------------------------------------------------------------------
675//"sc_signal_uint::operator []"
676//
677// This operator returns a bit selection of this object instance.
678// i = bit to be selected.
679//------------------------------------------------------------------------------
680SC_TEMPLATE
681inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::operator [] ( int bit )
682{
683 return operator () (bit,bit);
684}
685
686
687SC_TEMPLATE
688inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const this_type& new_val )
689 { base_write( new_val ); }
690
691SC_TEMPLATE
692inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const char* new_val )
693 { sc_dt::sc_biguint<W> tmp = new_val; m_new_val = tmp; request_update(); }
694
695
696SC_TEMPLATE
697inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_unsigned& new_val )
698 { base_write(new_val); }
699
700
701SC_TEMPLATE
702inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::uint64 new_val )
703 { base_write(new_val); }
704
705
706SC_TEMPLATE
707inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( sc_dt::int64 new_val )
708 { base_write(new_val); }
709
710
711SC_TEMPLATE
712inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( int new_val )
713 { base_write((sc_dt::int64)new_val); }
714
715
716SC_TEMPLATE
717inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( long new_val )
718 { base_write((sc_dt::int64)new_val); }
719
720
721SC_TEMPLATE
722inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( short new_val )
723 { base_write((sc_dt::int64)new_val); }
724
725
726SC_TEMPLATE
727inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned int new_val )
728 { base_write((sc_dt::int64)new_val); }
729
730
731SC_TEMPLATE
732inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned long new_val )
733 { base_write((sc_dt::int64)new_val); }
734
735
736SC_TEMPLATE
737inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( unsigned short new_val )
738 { base_write((sc_dt::int64)new_val); }
739
740
741SC_TEMPLATE
742template<typename T>
743inline void sc_signal<sc_dt::sc_biguint<W> >::operator = (
744 const sc_dt::sc_generic_base<T>& new_val )
745{
746 sc_dt::sc_unsigned temp(W);
747 new_val->to_sc_unsigned(temp);
748 base_write(temp);
749}
750
751
752SC_TEMPLATE
753inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_signed& new_val )
754 { base_write(new_val); }
755
756SC_TEMPLATE
757inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_bv_base& new_val )
758 { base_write( (sc_dt::sc_biguint<W>)new_val ); }
759
760SC_TEMPLATE
761inline void sc_signal<sc_dt::sc_biguint<W> >::operator = ( const sc_dt::sc_lv_base& new_val )
762 { base_write( (sc_dt::sc_biguint<W>)new_val ); }
763
764
765SC_TEMPLATE
766inline sc_dt::sc_unsigned* sc_signal<sc_dt::sc_biguint<W> >::part_read_target()
767 { return this; }
768
769
770SC_TEMPLATE
771inline const sc_dt::sc_biguint<W>& sc_signal<sc_dt::sc_biguint<W> >::read() const
772 { return *this; }
773
774
775SC_TEMPLATE // Read a portion of a value.
776inline sc_dt::sc_unsigned sc_signal<sc_dt::sc_biguint<W> >::read_part(
777 int left, int right ) const
778{
779 sc_dt::sc_unsigned tmp(left-right+1);
780 tmp = (*(const sc_dt::sc_biguint<W>*)this)(left,right);
781 return tmp;
782}
783
784SC_TEMPLATE
785inline void sc_signal<sc_dt::sc_biguint<W> >::register_port(
786 sc_port_base& port_, const char* if_typename_ )
787{
788# ifdef DEBUG_SYSTEMC
789 std::string nm( if_typename_ );
790 if( nm == typeid( sc_signal_inout_if<sc_dt::sc_biguint<W> > ).name() )
791 {
792 if( m_output_p != 0 )
793 {
794 sc_signal_invalid_writer( name(), kind(),
795 m_output_p->name(), port_.name() );
796 }
797 m_output_p = &port_;
798 }
799# else
800 if ( &port_ && if_typename_ ) {} // Silence unused args warning.
801# endif
802}
803
804
805SC_TEMPLATE // Autogenerated name object instance constructor.
806inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal() :
807 sc_prim_channel(sc_gen_unique_name( "signal" )),
808 m_changed_event_p(0),
809 m_new_val(W),
810 m_output_p(0),
811 m_writer_p(0)
812{ }
813
814
815SC_TEMPLATE // Explicitly named object instance constructor.
816inline sc_signal<sc_dt::sc_biguint<W> >::sc_signal(const char* name_) :
817 sc_prim_channel(name_),
818 m_changed_event_p(0),
819 m_new_val(W),
820 m_output_p(0),
821 m_writer_p(0)
822{ }
823
824
825SC_TEMPLATE // Object instance destructor.
826inline sc_signal<sc_dt::sc_biguint<W> >::~sc_signal()
827{
828 if ( m_changed_event_p ) delete m_changed_event_p;
829}
830
831
832SC_TEMPLATE // Update the current value from new value.
833inline void sc_signal<sc_dt::sc_biguint<W> >::update()
834{
835 if ( m_changed_event_p )
836 {
837 if ( m_new_val != *this )
838 {
839 m_changed_event_p->notify_delayed();
840 m_event_delta = simcontext()->delta_count();
841 }
842 }
843 sc_dt::sc_unsigned::operator = (m_new_val);
844}
845
846
847SC_TEMPLATE // Return the value changed event.
848inline const sc_event& sc_signal<sc_dt::sc_biguint<W> >::value_changed_event() const
849 { return base_value_changed_event(); }
850
851
852SC_TEMPLATE // Write a sc_in<sc_dt::sc_biguint<W> > value to this object instance.
853inline void sc_signal<sc_dt::sc_biguint<W> >::write(
854 const sc_in<sc_dt::sc_biguint<W> >& value )
855 { base_write( value ); }
856
857
858SC_TEMPLATE // Write a sc_inout<sc_dt::sc_biguint<W> > value to this object instance.
859inline void sc_signal<sc_dt::sc_biguint<W> >::write(
860 const sc_inout<sc_dt::sc_biguint<W> >& value )
861{ base_write( value ); }
862
863
864SC_TEMPLATE // Write a sc_dt::sc_biguint<W> value to this object instance.
865inline void sc_signal<sc_dt::sc_biguint<W> >::write( const sc_dt::sc_biguint<W>& value )
866 { base_write( value); }
867
868
869SC_TEMPLATE // Write a portion of a value. If this is the first write in
870 // a delta cycle we copy the existing value before setting the bits.
871inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::int64 v, int left, int right)
872{
873 m_new_val(left, right) = v;
874 request_update();
875}
876
877
878SC_TEMPLATE // Select a portion of a value.
879inline sc_unsigned_sigref& sc_signal<sc_dt::sc_biguint<W> >::select_part(
880 int left, int right)
881{
882 sc_unsigned_sigref* result_p = sc_unsigned_sigref::m_pool.allocate();
883 result_p->initialize(dynamic_cast<sc_unsigned_part_if*>(this), left, right);
884 return *result_p;
885}
886
887
888SC_TEMPLATE // Write a portion of a value. If this is the first write in
889 // a delta cycle we copy the existing value before setting the bits.
890inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(sc_dt::uint64 v, int left, int right)
891{
892 m_new_val(left, right) = v;
893 request_update();
894}
895
896
897SC_TEMPLATE // Write a portion of a value. If this is the first write in
898 // a delta cycle we copy the existing value before setting the bits.
899inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
900 const sc_dt::sc_signed& v, int left, int right )
901{
902 m_new_val(left, right) = v;
903 request_update();
904}
905
906
907SC_TEMPLATE // Write a portion of a value. If this is the first write in
908 // a delta cycle we copy the existing value before setting the bits.
909inline void sc_signal<sc_dt::sc_biguint<W> >::write_part(
910 const sc_dt::sc_unsigned& v, int left, int right )
911{
912 m_new_val(left, right) = v;
913 request_update();
914}
915
916
917//==============================================================================
918// CLASS sc_in<sc_dt::sc_biguint<W> >
919//
920// This class implements an input port whose target acts like an sc_dt::sc_biguint<W> data
921// value. This class is a specialization of the generic sc_in class to
922// implement tailored support for the sc_dt::sc_biguint<W> class.
923//==============================================================================
924SC_TEMPLATE
925class sc_in<sc_dt::sc_biguint<W> > :
926 public sc_port<sc_signal_in_if<sc_dt::sc_biguint<W> >, 1,
927 SC_ONE_OR_MORE_BOUND>,
928 public sc_dt::sc_value_base
929{
930 public:
931
932 // typedefs
933
934 typedef sc_dt::sc_biguint<W> data_type;
935 typedef sc_signal_in_if<sc_dt::sc_biguint<W> > if_type;
936 typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND> base_type;
937 typedef sc_in<sc_dt::sc_biguint<W> > this_type;
938
939 typedef if_type in_if_type;
940 typedef base_type in_port_type;
941 typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > inout_if_type;
942 typedef sc_inout<sc_dt::sc_biguint<W> > inout_port_type;
943
944 public:
945
946 // bind methods and operators:
947
948 void bind( const in_if_type& interface_ )
949 { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
950 void operator () ( const in_if_type& interface_ )
951 { sc_port_base::bind( const_cast<in_if_type&>( interface_) );}
952 void bind( in_port_type& parent_ )
953 { sc_port_base::bind(parent_);}
954 void operator () ( in_port_type& parent_ )
955 { sc_port_base::bind(parent_);}
956 void bind( inout_port_type& parent_ )
957 { sc_port_base::bind(parent_);}
958 void operator () ( inout_port_type& parent_ )
959 { sc_port_base::bind(parent_);}
960
961 protected:
962 // called by pbind (for internal use only)
963 virtual inline int vbind( sc_interface& interface_ )
964 {
965 return sc_port_b<if_type>::vbind( interface_ );
966 }
967 virtual inline int vbind( sc_port_base& parent_ )
968 {
969 in_port_type* in_parent = dynamic_cast<in_port_type*>( &parent_ );
970 if( in_parent != 0 ) {
971 sc_port_base::bind( *in_parent );
972 return 0;
973 }
974 inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
975 if( inout_parent != 0 ) {
976 sc_port_base::bind( *inout_parent );
977 return 0;
978 }
979 // type mismatch
980 return 2;
981 }
982
983
984 // constructors
985
986 public:
987 sc_in()
988 : base_type(), m_traces( 0 )
989 {}
990
991 explicit sc_in( const char* name_ )
992 : base_type( name_ ), m_traces( 0 )
993 {}
994
995 explicit sc_in( const in_if_type& interface_ )
996 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
997 {}
998
999 sc_in( const char* name_, const in_if_type& interface_ )
1000 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
1001 {}
1002
1003 explicit sc_in( in_port_type& parent_ )
1004 : base_type( parent_ ), m_traces( 0 )
1005 {}
1006
1007 sc_in( const char* name_, in_port_type& parent_ )
1008 : base_type( name_, parent_ ), m_traces( 0 )
1009 {}
1010
1011 explicit sc_in( inout_port_type& parent_ )
1012 : base_type(), m_traces( 0 )
1013 { sc_port_base::bind( parent_ ); }
1014
1015 sc_in( const char* name_, inout_port_type& parent_ )
1016 : base_type( name_ ), m_traces( 0 )
1017 { sc_port_base::bind( parent_ ); }
1018
1019 sc_in( this_type& parent_ )
1020 : base_type( parent_ ), m_traces( 0 )
1021 {}
1022
1023 sc_in( const char* name_, this_type& parent_ )
1024 : base_type( name_, parent_ ), m_traces( 0 )
1025 {}
1026
1027
1028 // destructor
1029
1030 virtual inline ~sc_in()
1031 {
1032 remove_traces();
1033 }
1034
1035 // bit and part selection
1036
1037 sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
1038 { return (*this)->read()[i]; }
1039 sc_dt::sc_unsigned_bitref_r bit( int i ) const
1040 { return (*this)->read()[i]; }
1041 sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
1042 { return (*this)->read()(left,right); }
1043 sc_dt::sc_unsigned_subref_r range( int left, int right ) const
1044 { return (*this)->read()(left,right); }
1045
1046
1047 // interface access shortcut methods
1048
1049 // get the default event
1050
1051 const sc_event& default_event() const
1052 { return (*this)->value_changed_event(); }
1053
1054
1055 // get the value changed event
1056
1057 const sc_event& value_changed_event() const
1058 { return (*this)->value_changed_event(); }
1059
1060
1061 // read the current value
1062
1063 const sc_dt::sc_biguint<W>& read() const
1064 { return (*this)->read(); }
1065
1066 operator const sc_dt::sc_biguint<W>& () const
1067 { return (*this)->read(); }
1068
1069 // was there a value changed event?
1070
1071 bool event() const
1072 { return (*this)->event(); }
1073
1074
1075 // (other) event finder method(s)
1076
1077 sc_event_finder& value_changed() const
1078 {
1079 return *new sc_event_finder_t<in_if_type>(
1080 *this, &in_if_type::value_changed_event );
1081 }
1082
1083
1084
1085 // reduction methods:
1086
1087 inline bool and_reduce() const
1088 { return (*this)->read().and_reduce(); }
1089 inline bool nand_reduce() const
1090 { return (*this)->read().nand_reduce(); }
1091 inline bool nor_reduce() const
1092 { return (*this)->read().nor_reduce(); }
1093 inline bool or_reduce() const
1094 { return (*this)->read().or_reduce(); }
1095 inline bool xnor_reduce() const
1096 { return (*this)->read().xnor_reduce(); }
1097 inline bool xor_reduce() const
1098 { return (*this)->read().xor_reduce(); }
1099
1100
1101 // called when elaboration is done
1102 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1103 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1104
1105 virtual inline void end_of_elaboration()
1106 {
1107 if( m_traces != 0 ) {
1108 for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
1109 sc_trace_params* p = (*m_traces)[i];
1110 sc_trace( p->tf, read(), p->name );
1111 }
1112 remove_traces();
1113 }
1114 }
1115
1116 virtual inline const char* kind() const
1117 { return "sc_in"; }
1118
1119
1120 // called by sc_trace
1121 void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
1122 {
1123 if( tf_ != 0 ) {
1124 if( m_traces == 0 ) {
1125 m_traces = new sc_trace_params_vec;
1126 }
1127 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
1128 }
1129 }
1130
1131
1132 // concatenation methods
1133
1134 virtual inline int concat_length(bool* xz_present_p) const
1135 { return (*this)->read().concat_length( xz_present_p ); }
1136 virtual inline sc_dt::uint64 concat_get_uint64() const
1137 { return (*this)->read().concat_get_uint64(); }
1138 virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
1139 { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1140 virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
1141 { return (*this)->read().concat_get_data(dst_p, low_i); }
1142
1143 protected:
1144 void remove_traces() const
1145 {
1146 if( m_traces != 0 ) {
1147 for( int i = m_traces->size() - 1; i >= 0; -- i ) {
1148 delete (*m_traces)[i];
1149 }
1150 delete m_traces;
1151 m_traces = 0;
1152 }
1153 }
1154
1155 mutable sc_trace_params_vec* m_traces;
1156
1157
1158 private:
1159
1160 // disabled
1161 sc_in( const sc_in<sc_dt::sc_biguint<W> >& );
1162 sc_in<sc_dt::sc_biguint<W> >& operator = ( const sc_in<sc_dt::sc_biguint<W> >& );
1163
1164#ifdef __GNUC__
1165 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1166 // This unused variable forces the compiler to instantiate
1167 // an object of T template so an implicit conversion from
1168 // read() to a C++ intrinsic data type will work.
1169 static data_type dummy;
1170#endif
1171
1172};
1173
1174
1175
1176SC_TEMPLATE
1177inline std::ostream& operator << (
1178 std::ostream& os, const sc_in<sc_dt::sc_biguint<W> >& a )
1179{
1180 a.read().print( os );
1181 return os;
1182}
1183
1184
1185//==============================================================================
1186// CLASS sc_inout<sc_dt::sc_biguint<W> >
1187//
1188// This class implements an input/output port whose target acts like an
1189// sc_dt::sc_biguint<W> data value. It is derived from the sc_unsigned_in. This class is a
1190// specialization of the generic sc_inout class to implement tailored support
1191// for the sc_dt::sc_biguint<W> class.
1192//==============================================================================
1193SC_TEMPLATE
1194class sc_inout<sc_dt::sc_biguint<W> > :
1195 public sc_port<sc_signal_inout_if<sc_dt::sc_biguint<W> >, 1,
1196 SC_ONE_OR_MORE_BOUND>,
1197 public sc_dt::sc_value_base
1198{
1199 public:
1200
1201 // typedefs
1202
1203 typedef sc_dt::sc_biguint<W> data_type;
1204 typedef sc_signal_inout_if<sc_dt::sc_biguint<W> > if_type;
1205 typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND> base_type;
1206 typedef sc_inout<sc_dt::sc_biguint<W> > this_type;
1207
1208 typedef if_type inout_if_type;
1209 typedef base_type inout_port_type;
1210
1211 public:
1212
1213 // bind methods and operators:
1214
1215 void bind( const inout_if_type& interface_ )
1216 { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
1217 void operator () ( const inout_if_type& interface_ )
1218 { sc_port_base::bind( const_cast<inout_if_type&>( interface_) ); }
1219 void bind( inout_port_type& parent_ )
1220 { sc_port_base::bind(parent_); }
1221 void operator () ( inout_port_type& parent_ )
1222 { sc_port_base::bind(parent_); }
1223
1224 protected:
1225 // called by pbind (for internal use only)
1226 virtual inline int vbind( sc_interface& interface_ )
1227 {
1228 return sc_port_b<if_type>::vbind( interface_ );
1229 }
1230 virtual inline int vbind( sc_port_base& parent_ )
1231 {
1232 inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
1233 if( inout_parent != 0 ) {
1234 sc_port_base::bind( *inout_parent );
1235 return 0;
1236 }
1237 // type mismatch
1238 return 2;
1239 }
1240
1241
1242 // constructors
1243
1244 public:
1245 sc_inout()
1246 : base_type(), m_init_val_p(0), m_traces( 0 )
1247 {}
1248
1249 explicit sc_inout( const char* name_ )
1250 : base_type( name_ ), m_init_val_p(0), m_traces( 0 )
1251 {}
1252
1253 explicit sc_inout( inout_if_type& interface_ )
1254 : base_type( interface_ ), m_init_val_p(0), m_traces( 0 )
1255 {}
1256
1257 sc_inout( const char* name_, inout_if_type& interface_ )
1258 : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 )
1259 {}
1260
1261 explicit sc_inout( inout_port_type& parent_ )
1262 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1263 {}
1264
1265 sc_inout( const char* name_, inout_port_type& parent_ )
1266 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1267 {}
1268
1269 sc_inout( this_type& parent_ )
1270 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1271 {}
1272
1273 sc_inout( const char* name_, this_type& parent_ )
1274 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1275 {}
1276
1277
1278 // destructor
1279
1280 virtual inline ~sc_inout()
1281 {
1282 remove_traces();
1283 }
1284
1285 // bit and part selection
1286
1287 sc_dt::sc_unsigned_bitref_r operator [] ( int i ) const
1288 { return (*this)->read()[i]; }
1289 sc_dt::sc_unsigned_bitref_r bit( int i ) const
1290 { return (*this)->read()[i]; }
1291 sc_unsigned_sigref& operator [] ( int i )
1292 { return (*this)->select_part(i,i); }
1293 sc_unsigned_sigref& bit( int i )
1294 { return (*this)->select_part(i,i); }
1295 sc_dt::sc_unsigned_subref_r operator () ( int left, int right ) const
1296 { return (*this)->read()(left,right); }
1297 sc_dt::sc_unsigned_subref_r range( int left, int right ) const
1298 { return (*this)->read()(left,right); }
1299 sc_unsigned_sigref& operator () ( int left, int right )
1300 { return (*this)->select_part(left,right); }
1301 sc_unsigned_sigref& range( int left, int right )
1302 { return (*this)->select_part(left,right); }
1303
1304
1305 // interface access shortcut methods
1306
1307 // get the default event
1308
1309 const sc_event& default_event() const
1310 { return (*this)->value_changed_event(); }
1311
1312
1313 // get the value changed event
1314
1315 const sc_event& value_changed_event() const
1316 { return (*this)->value_changed_event(); }
1317
1318
1319 // read the current value
1320
1321 const sc_dt::sc_biguint<W>& read() const
1322 { return (*this)->read(); }
1323
1324 operator const sc_dt::sc_biguint<W>& () const
1325 { return (*this)->read(); }
1326
1327 // was there a value changed event?
1328
1329 bool event() const
1330 { return (*this)->event(); }
1331
1332
1333 // (other) event finder method(s)
1334
1335 sc_event_finder& value_changed() const
1336 {
1337 return *new sc_event_finder_t<inout_if_type>(
1338 *this, &inout_if_type::value_changed_event );
1339 }
1340
1341
1342
1343 // reduction methods:
1344
1345 inline bool and_reduce() const
1346 { return (*this)->read().and_reduce(); }
1347 inline bool nand_reduce() const
1348 { return (*this)->read().nand_reduce(); }
1349 inline bool nor_reduce() const
1350 { return (*this)->read().nor_reduce(); }
1351 inline bool or_reduce() const
1352 { return (*this)->read().or_reduce(); }
1353 inline bool xnor_reduce() const
1354 { return (*this)->read().xnor_reduce(); }
1355 inline bool xor_reduce() const
1356 { return (*this)->read().xor_reduce(); }
1357
1358
1359 // called when elaboration is done
1360 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1361 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1362
1363 virtual inline void end_of_elaboration()
1364 {
1365 if( m_init_val_p != 0 ) {
1366 (*this)->write( *m_init_val_p );
1367 delete m_init_val_p;
1368 m_init_val_p = 0;
1369 }
1370 if( m_traces != 0 ) {
1371 for( unsigned int i = 0; i < m_traces->size(); ++ i ) {
1372 sc_trace_params* p = (*m_traces)[i];
1373 sc_trace( p->tf, read(), p->name );
1374 }
1375 remove_traces();
1376 }
1377 }
1378
1379 virtual inline const char* kind() const
1380 { return "sc_inout"; }
1381
1382 // value initialization
1383
1384 inline void initialize( const sc_dt::sc_biguint<W>& value_ )
1385 {
1386 inout_if_type* iface = dynamic_cast<inout_if_type*>( this->get_interface() );
1387 if( iface != 0 ) {
1388 iface->write( value_ );
1389 } else {
1390 if( m_init_val_p == 0 ) {
1391 m_init_val_p = new sc_dt::sc_biguint<W>;
1392 }
1393 *m_init_val_p = value_;
1394 }
1395 }
1396
1397
1398 // called by sc_trace
1399 void add_trace( sc_trace_file* tf_, const std::string& name_ ) const
1400 {
1401 if( tf_ != 0 ) {
1402 if( m_traces == 0 ) {
1403 m_traces = new sc_trace_params_vec;
1404 }
1405 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
1406 }
1407 }
1408
1409
1410 // concatenation methods
1411
1412 virtual inline int concat_length(bool* xz_present_p) const
1413 { return (*this)->read().concat_length( xz_present_p ); }
1414 virtual inline sc_dt::uint64 concat_get_uint64() const
1415 { return (*this)->read().concat_get_uint64(); }
1416 virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const
1417 { return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1418 virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const
1419 { return (*this)->read().concat_get_data(dst_p, low_i); }
1420 virtual inline void concat_set(sc_dt::int64 src, int low_i)
1421 { *this = (src >> ((low_i < 64) ? low_i : 63)); }
1422#if 0 // ####
1423 virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i)
1424 { *this = src >> low_i; }
1425#endif // 0 ####
1426 virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i)
1427 { *this = (src >> low_i); }
1428 virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i)
1429 { *this = (src >> low_i); }
1430 virtual inline void concat_set(sc_dt::uint64 src, int low_i)
1431 { *this = (low_i < 64 ) ? src >> low_i : (sc_dt::uint64)0; }
1432
1433 // assignment operators:
1434
1435 public:
1436 inline void operator = ( const this_type& new_val )
1437 { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
1438 inline void operator = ( const char* new_val )
1439 { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
1440 inline void operator = ( sc_dt::uint64 new_val )
1441 { (*this)->write(new_val); }
1442 inline void operator = ( sc_dt::int64 new_val )
1443 { (*this)->write((sc_dt::int64)new_val); }
1444 inline void operator = ( int new_val )
1445 { (*this)->write((sc_dt::int64)new_val); }
1446 inline void operator = ( long new_val )
1447 { (*this)->write((sc_dt::int64)new_val); }
1448 inline void operator = ( short new_val )
1449 { (*this)->write((sc_dt::uint64)new_val); }
1450 inline void operator = ( unsigned int new_val )
1451 { (*this)->write((sc_dt::uint64)new_val); }
1452 inline void operator = ( unsigned long new_val )
1453 { (*this)->write((sc_dt::uint64)new_val); }
1454 inline void operator = ( unsigned short new_val )
1455 { (*this)->write((sc_dt::uint64)new_val); }
1456 template<typename T>
1457 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
1458 {
1459 sc_dt::sc_unsigned temp(W);
1460 new_val->to_sc_unsigned(temp);
1461 (*this)->write(temp);
1462 }
1463 inline void operator = ( const sc_dt::sc_signed& new_val )
1464 { (*this)->write(new_val); }
1465 inline void operator = ( const sc_dt::sc_unsigned& new_val )
1466 { (*this)->write(new_val); }
1467 inline void operator = ( const sc_dt::sc_bv_base& new_val )
1468 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1469 inline void operator = ( const sc_dt::sc_lv_base& new_val )
1470 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1471
1472 inline void write( const sc_in<sc_dt::sc_biguint<W> >& new_val )
1473 { (*this)->write( new_val.read() ); }
1474 inline void write( const sc_inout<sc_dt::sc_biguint<W> >& new_val )
1475 { (*this)->write( new_val.read() ); }
1476 inline void write( const sc_dt::sc_biguint<W>& new_val )
1477 { (*this)->write( new_val ); }
1478
1479 protected:
1480 void remove_traces() const
1481 {
1482 if( m_traces != 0 ) {
1483 for( int i = m_traces->size() - 1; i >= 0; -- i ) {
1484 delete (*m_traces)[i];
1485 }
1486 delete m_traces;
1487 m_traces = 0;
1488 }
1489 }
1490
1491 sc_dt::sc_biguint<W>* m_init_val_p;
1492 mutable sc_trace_params_vec* m_traces;
1493
1494
1495 private:
1496
1497 // disabled
1498 sc_inout( const sc_inout<sc_dt::sc_biguint<W> >& );
1499
1500#ifdef __GNUC__
1501 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1502 // This unused variable forces the compiler to instantiate
1503 // an object of T template so an implicit conversion from
1504 // read() to a C++ intrinsic data type will work.
1505 static data_type dummy;
1506#endif
1507
1508};
1509
1510
1511
1512SC_TEMPLATE
1513inline std::ostream& operator << (
1514 std::ostream& os, const sc_inout<sc_dt::sc_biguint<W> >& a )
1515{
1516 a.read().print( os );
1517 return os;
1518}
1519
1520
1521//==============================================================================
1522// CLASS sc_out<sc_dt::sc_biguint<W> >
1523//
1524// This class implements an output port whose target acts like an
1525// sc_dt::sc_biguint<W> data value. This class is a derivation of sc_inout, since
1526// output ports are really no different from input/output ports.
1527//==============================================================================
1528SC_TEMPLATE
1529class sc_out<sc_dt::sc_biguint<W> > : public sc_inout<sc_dt::sc_biguint<W> >
1530{
1531 public:
1532
1533 // typedefs
1534
1535 typedef sc_dt::sc_biguint<W> data_type;
1536
1537 typedef sc_out<data_type> this_type;
1538 typedef sc_inout<data_type> base_type;
1539
1540 typedef typename base_type::inout_if_type inout_if_type;
1541 typedef typename base_type::inout_port_type inout_port_type;
1542
1543 // constructors
1544
1545 sc_out()
1546 : base_type()
1547 {}
1548
1549 explicit sc_out( const char* name_ )
1550 : base_type( name_ )
1551 {}
1552
1553 explicit sc_out( inout_if_type& interface_ )
1554 : base_type( interface_ )
1555 {}
1556
1557 sc_out( const char* name_, inout_if_type& interface_ )
1558 : base_type( name_, interface_ )
1559 {}
1560
1561 explicit sc_out( inout_port_type& parent_ )
1562 : base_type( parent_ )
1563 {}
1564
1565 sc_out( const char* name_, inout_port_type& parent_ )
1566 : base_type( name_, parent_ )
1567 {}
1568
1569 sc_out( this_type& parent_ )
1570 : base_type( parent_ )
1571 {}
1572
1573 sc_out( const char* name_, this_type& parent_ )
1574 : base_type( name_, parent_ )
1575 {}
1576
1577
1578 // destructor (does nothing)
1579
1580 virtual inline ~sc_out()
1581 {}
1582
1583
1584 // assignment operators:
1585
1586 public:
1587 inline void operator = ( const this_type& new_val )
1588 { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); }
1589 inline void operator = ( const char* new_val )
1590 { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); }
1591 inline void operator = ( sc_dt::uint64 new_val )
1592 { (*this)->write(new_val); }
1593 inline void operator = ( sc_dt::int64 new_val )
1594 { (*this)->write((sc_dt::uint64)new_val); }
1595 inline void operator = ( int new_val )
1596 { (*this)->write((sc_dt::uint64)new_val); }
1597 inline void operator = ( long new_val )
1598 { (*this)->write((sc_dt::uint64)new_val); }
1599 inline void operator = ( short new_val )
1600 { (*this)->write((sc_dt::uint64)new_val); }
1601 inline void operator = ( unsigned int new_val )
1602 { (*this)->write((sc_dt::uint64)new_val); }
1603 inline void operator = ( unsigned long new_val )
1604 { (*this)->write((sc_dt::uint64)new_val); }
1605 inline void operator = ( unsigned short new_val )
1606 { (*this)->write((sc_dt::uint64)new_val); }
1607 template<typename T>
1608 inline void operator = ( const sc_dt::sc_generic_base<T>& new_val )
1609 {
1610 sc_dt::sc_unsigned temp(W);
1611 new_val->to_sc_unsigned(temp);
1612 (*this)->write(temp);
1613 }
1614 inline void operator = ( const sc_dt::sc_signed& new_val )
1615 { (*this)->write(new_val); }
1616 inline void operator = ( const sc_dt::sc_unsigned& new_val )
1617 { (*this)->write(new_val); }
1618 inline void operator = ( const sc_dt::sc_bv_base& new_val )
1619 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1620 inline void operator = ( const sc_dt::sc_lv_base& new_val )
1621 { (*this)->write((sc_dt::sc_biguint<W>)new_val); }
1622
1623 private:
1624
1625 // disabled
1626 sc_out( const this_type& );
1627};
1628
1629
1630
1631//------------------------------------------------------------------------------
1632//"sc_unsigned_sigref::initialize"
1633//
1634// This method initializes an object instance from the supplied arguments.
1635// if_p -> target of this selection.
1636// left_ = left-most bit in selection.
1637// right_ = right-most bit in selection.
1638//------------------------------------------------------------------------------
1639inline void sc_unsigned_sigref::initialize(
1640 sc_unsigned_part_if* if_p, int left_, int right_ )
1641{
1642 m_if_p = if_p;
1643 m_left = left_;
1644 m_right = right_;
1645 m_obj_p = if_p->part_read_target();
1646}
1647
1648
1649//------------------------------------------------------------------------------
1650//"sc_unsigned_sigref::operator ="
1651//
1652// These operators assign a value to the bits associated with this object
1653// instance within this object instance's target signal.
1654//------------------------------------------------------------------------------
1655inline void sc_unsigned_sigref::operator = ( sc_dt::uint64 v )
1656{
1657 m_if_p->write_part( v, m_left, m_right );
1658}
1659
1660inline void sc_unsigned_sigref::operator = ( const char* v )
1661{
1662 sc_dt::sc_unsigned tmp(length());
1663 tmp = v;
1664 *this = tmp;
1665}
1666
1667inline void sc_unsigned_sigref:: operator = ( sc_dt::int64 v )
1668{
1669 *this = (sc_dt::uint64)v;
1670}
1671
1672inline void sc_unsigned_sigref:: operator = ( int v )
1673{
1674 *this = (sc_dt::uint64)v;
1675}
1676
1677inline void sc_unsigned_sigref:: operator = ( long v )
1678{
1679 *this = (sc_dt::uint64)v;
1680}
1681
1682inline void sc_unsigned_sigref:: operator = ( unsigned int v )
1683{
1684 *this = (sc_dt::uint64)v;
1685}
1686
1687inline void sc_unsigned_sigref:: operator = ( unsigned long v )
1688{
1689 *this = (sc_dt::uint64)v;
1690}
1691
1692void sc_unsigned_sigref::operator = ( const sc_unsigned_sigref& v )
1693{
1694 *this = (sc_dt::sc_unsigned)v;
1695}
1696
1697
1698inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_signed& v )
1699{
1700 m_if_p->write_part( v, m_left, m_right );
1701}
1702
1703inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_unsigned& v )
1704{
1705 m_if_p->write_part( v, m_left, m_right );
1706}
1707
1708template<typename T>
1709inline void sc_unsigned_sigref:: operator = (
1710 const sc_dt::sc_generic_base<T>& v )
1711{
1712 sc_dt::sc_unsigned temp(m_left-m_right+1);
1713 v->to_sc_unsigned(temp);
1714 m_if_p->write_part( temp, m_left, m_right );
1715}
1716
1717#undef SC_TEMPLATE
1718} // namespace sc_core
1719#endif // !defined(SC_SIGNAL_UNSIGNED_H)
1720
1721namespace sc_core {
1722
1723extern
1724void
1725sc_signal_invalid_writer( const char* name,
1726 const char* kind,
1727 const char* first_writer,
1728 const char* second_writer );
1729
1730//------------------------------------------------------------------------------
1731// POOL OF TEMPORARY INSTANCES OF sc_unsigned_sigref
1732//
1733// This allows use to pass const references for part and bit selections
1734// on sc_signal_signed object instances.
1735//------------------------------------------------------------------------------
1736sc_vpool<sc_unsigned_sigref> sc_unsigned_sigref::m_pool(8);
1737
1738
1739//------------------------------------------------------------------------------
1740//"sc_unsigned_part_if::default methods"
1741//
1742// These versions just produce errors if they are not overloaded but used.
1743//------------------------------------------------------------------------------
1744sc_dt::sc_unsigned* sc_unsigned_part_if::part_read_target()
1745{
1746 SC_REPORT_ERROR( "attempted specalized signal operation on "
1747 "non-specialized signal", "int" );
1746 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1748 return 0;
1749}
1750sc_dt::sc_unsigned sc_unsigned_part_if::read_part( int /*left*/, int /*right*/ ) const
1751{
1747 return 0;
1748}
1749sc_dt::sc_unsigned sc_unsigned_part_if::read_part( int /*left*/, int /*right*/ ) const
1750{
1752 SC_REPORT_ERROR( "attempted specalized signal operation on "
1753 "non-specialized signal", "int" );
1751 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1754 return sc_dt::sc_unsigned(1);
1755}
1756sc_unsigned_sigref& sc_unsigned_part_if::select_part(int /*left*/, int /*right*/)
1757{
1752 return sc_dt::sc_unsigned(1);
1753}
1754sc_unsigned_sigref& sc_unsigned_part_if::select_part(int /*left*/, int /*right*/)
1755{
1758 SC_REPORT_ERROR( "attempted specalized signal operation on "
1759 "non-specialized signal", "int" );
1756 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1760 return *(sc_unsigned_sigref*)0;
1761}
1762void sc_unsigned_part_if::write_part( sc_dt::int64 v, int /*left*/, int /*right*/ )
1763{
1757 return *(sc_unsigned_sigref*)0;
1758}
1759void sc_unsigned_part_if::write_part( sc_dt::int64 v, int /*left*/, int /*right*/ )
1760{
1764 SC_REPORT_ERROR( "attempted specalized signal operation on "
1765 "non-specialized signal", "int" );
1761 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1766}
1767void sc_unsigned_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
1768{
1762}
1763void sc_unsigned_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
1764{
1769 SC_REPORT_ERROR( "attempted specalized signal operation on "
1770 "non-specialized signal", "int" );
1765 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1771}
1772void sc_unsigned_part_if::write_part(
1773 const sc_dt::sc_signed& v, int /*left*/, int /*right*/ )
1774{
1766}
1767void sc_unsigned_part_if::write_part(
1768 const sc_dt::sc_signed& v, int /*left*/, int /*right*/ )
1769{
1775 SC_REPORT_ERROR( "attempted specalized signal operation on "
1776 "non-specialized signal", "int" );
1770 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1777}
1778void sc_unsigned_part_if::write_part(
1779 const sc_dt::sc_unsigned& v, int /*left*/, int /*right*/ )
1780{
1771}
1772void sc_unsigned_part_if::write_part(
1773 const sc_dt::sc_unsigned& v, int /*left*/, int /*right*/ )
1774{
1781 SC_REPORT_ERROR( "attempted specalized signal operation on "
1782 "non-specialized signal", "int" );
1775 SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
1783}
1784
1785
1786
1787//------------------------------------------------------------------------------
1788//"sc_unsigned_sigref::concate_set"
1789//
1790// These methods assign this object instance's value from the supplied
1791// value starting at the supplied bit within that value.
1792// src = value to use to set this object instance's value.
1793// low_i = bit in src that is to be the low order bit of the value to set.
1794// #### OPTIMIZE
1795//------------------------------------------------------------------------------
1796void sc_unsigned_sigref::concat_set(sc_dt::int64 src, int low_i)
1797{
1798 sc_dt::int64 tmp;
1799 if ( low_i < 63 )
1800 tmp = src >> low_i;
1801 else
1802 tmp = (src < 0) ? -1 : 0;
1803 m_if_p->write_part( tmp, m_left, m_right );
1804}
1805
1806
1807void sc_unsigned_sigref::concat_set(const sc_dt::sc_signed& src, int low_i)
1808{
1809 m_if_p->write_part( src >> low_i, m_left, m_right );
1810}
1811
1812
1813void sc_unsigned_sigref::concat_set(const sc_dt::sc_lv_base& src, int low_i)
1814{
1815 sc_dt::sc_unsigned tmp(src.length());
1816 tmp = src;
1817 m_if_p->write_part( tmp >> low_i, m_left, m_right );
1818}
1819
1820
1821void sc_unsigned_sigref::concat_set(const sc_dt::sc_unsigned& src, int low_i)
1822{
1823 m_if_p->write_part( src >> low_i, m_left, m_right );
1824}
1825
1826
1827void sc_unsigned_sigref::concat_set(sc_dt::uint64 src, int low_i)
1828{
1829 sc_dt::uint64 tmp = (low_i < 63) ? (src >> low_i) : 0;
1830 m_if_p->write_part( tmp, m_left, m_right );
1831}
1832
1833
1834} // namespace sc_core
1776}
1777
1778
1779
1780//------------------------------------------------------------------------------
1781//"sc_unsigned_sigref::concate_set"
1782//
1783// These methods assign this object instance's value from the supplied
1784// value starting at the supplied bit within that value.
1785// src = value to use to set this object instance's value.
1786// low_i = bit in src that is to be the low order bit of the value to set.
1787// #### OPTIMIZE
1788//------------------------------------------------------------------------------
1789void sc_unsigned_sigref::concat_set(sc_dt::int64 src, int low_i)
1790{
1791 sc_dt::int64 tmp;
1792 if ( low_i < 63 )
1793 tmp = src >> low_i;
1794 else
1795 tmp = (src < 0) ? -1 : 0;
1796 m_if_p->write_part( tmp, m_left, m_right );
1797}
1798
1799
1800void sc_unsigned_sigref::concat_set(const sc_dt::sc_signed& src, int low_i)
1801{
1802 m_if_p->write_part( src >> low_i, m_left, m_right );
1803}
1804
1805
1806void sc_unsigned_sigref::concat_set(const sc_dt::sc_lv_base& src, int low_i)
1807{
1808 sc_dt::sc_unsigned tmp(src.length());
1809 tmp = src;
1810 m_if_p->write_part( tmp >> low_i, m_left, m_right );
1811}
1812
1813
1814void sc_unsigned_sigref::concat_set(const sc_dt::sc_unsigned& src, int low_i)
1815{
1816 m_if_p->write_part( src >> low_i, m_left, m_right );
1817}
1818
1819
1820void sc_unsigned_sigref::concat_set(sc_dt::uint64 src, int low_i)
1821{
1822 sc_dt::uint64 tmp = (low_i < 63) ? (src >> low_i) : 0;
1823 m_if_p->write_part( tmp, m_left, m_right );
1824}
1825
1826
1827} // namespace sc_core