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