SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_signal_ports.h
Go to the documentation of this file.
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_ports.h -- The sc_signal<T> port classes.
23
24 Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
25
26 CHANGE LOG APPEARS AT THE END OF THE FILE
27 *****************************************************************************/
28
29#ifndef SC_SIGNAL_PORTS_H
30#define SC_SIGNAL_PORTS_H
31
32
38
39#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
40#pragma warning(push)
41#pragma warning(disable: 4251) // DLL import for std::string
42#endif
43
44namespace sc_core {
45
46// ----------------------------------------------------------------------------
47// STRUCT : sc_trace_params
48//
49// Struct for storing the trace file and object name of an sc_trace call.
50// FOR INTERNAL USE ONLY!
51// ----------------------------------------------------------------------------
52
54
56{
58 std::string name;
59
60 sc_trace_params( sc_trace_file* tf_, const std::string& name_ )
61 : tf( tf_ ), name( name_ )
62 {}
63};
64
65
66typedef std::vector<sc_trace_params*> sc_trace_params_vec;
67
68
69// ----------------------------------------------------------------------------
70// CLASS : sc_in<T>
71//
72// The sc_signal<T> input port class.
73// ----------------------------------------------------------------------------
74
75template <class T>
76class sc_in
77: public sc_port<sc_signal_in_if<T>,1,SC_ONE_OR_MORE_BOUND>
78{
79public:
80
81 // typedefs
82
83 typedef T data_type;
84
89
94
95public:
96
97 // constructors
98
100 : base_type(), m_traces( 0 ),
101 m_change_finder_p(0)
102 {}
103
104 explicit sc_in( const char* name_ )
105 : base_type( name_ ), m_traces( 0 ),
106 m_change_finder_p(0)
107 {}
108
109 explicit sc_in( const in_if_type& interface_ )
110 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
111 m_change_finder_p(0)
112 {}
113
114 sc_in( const char* name_, const in_if_type& interface_ )
115 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
116 m_change_finder_p(0)
117 {}
118
119 explicit sc_in( in_port_type& parent_ )
120 : base_type( parent_ ), m_traces( 0 ),
121 m_change_finder_p(0)
122 {}
123
124 sc_in( const char* name_, in_port_type& parent_ )
125 : base_type( name_, parent_ ), m_traces( 0 ),
126 m_change_finder_p(0)
127 {}
128
129 explicit sc_in( inout_port_type& parent_ )
130 : base_type(), m_traces( 0 ),
131 m_change_finder_p(0)
132 { sc_port_base::bind( parent_ ); }
133
134 sc_in( const char* name_, inout_port_type& parent_ )
135 : base_type( name_ ), m_traces( 0 ),
136 m_change_finder_p(0)
137 { sc_port_base::bind( parent_ ); }
138
139 sc_in( this_type& parent_ )
140 : base_type( parent_ ), m_traces( 0 ),
141 m_change_finder_p(0)
142 {}
143
144 sc_in( const char* name_, this_type& parent_ )
145 : base_type( name_, parent_ ), m_traces( 0 ),
146 m_change_finder_p(0)
147 {}
148
149
150 // destructor
151
152 virtual ~sc_in()
153 {
155 delete m_change_finder_p;
156 }
157
158
159 // bind to in interface
160
161 virtual void bind( const in_if_type& interface_ )
162 { sc_port_base::bind( const_cast<in_if_type&>( interface_ ) ); }
163
164 virtual void bind( in_if_type& interface_ )
165 { this->bind( const_cast<const in_if_type&>( interface_ ) ); }
166
167 void operator () ( const in_if_type& interface_ )
168 { this->bind( interface_ ); }
169
170
171 // bind to parent in port
172
173 virtual void bind( in_port_type& parent_ )
174 { sc_port_base::bind( parent_ ); }
175
176 void operator () ( in_port_type& parent_ )
177 { this->bind( parent_ ); }
178
179
180 // bind to parent inout port
181
182 virtual void bind( inout_port_type& parent_ )
183 { sc_port_base::bind( parent_ ); }
184
186 { this->bind( parent_ ); }
187
188
189 // interface access shortcut methods
190
191 // get the default event
192
193 const sc_event& default_event() const
194 { return (*this)->default_event(); }
195
196
197 // get the value changed event
198
200 { return (*this)->value_changed_event(); }
201
202
203 // read the current value
204
205 const data_type& read() const
206 { return (*this)->read(); }
207
208 operator const data_type& () const
209 { return (*this)->read(); }
210
211
212 // was there a value changed event?
213
214 bool event() const
215 { return (*this)->event(); }
216
217
218 // (other) event finder method(s)
219
221 {
223 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
224 }
225
226
227 // called when elaboration is done
228 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
229 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
230
231 virtual void end_of_elaboration();
232
233 virtual const char* kind() const
234 { return "sc_in"; }
235
236
237 void add_trace( sc_trace_file*, const std::string& ) const;
238
239 // called by sc_trace
240 void add_trace_internal( sc_trace_file*, const std::string& ) const;
241
242protected:
243
244 void remove_traces() const;
245
247
248protected:
249
250 // called by pbind (for internal use only)
251 virtual int vbind( sc_interface& );
252 virtual int vbind( sc_port_base& );
253
254 // implement virtual base_type port-binding function
255 // - avoids warnings on some compilers
256 // - should only be called, when using sc_port_b explicitly
257 // - errors are detected during elaboration
258
259 virtual void bind( base_port_type& parent_ )
260 { sc_port_base::bind( parent_ ); }
261
262
263private:
264 mutable sc_event_finder* m_change_finder_p;
265
266private:
267
268 // disabled
269 sc_in( const this_type& );
270 this_type& operator = ( const this_type& );
271
272#ifdef __GNUC__
273 // Needed to circumvent a problem in the g++-2.95.2 compiler:
274 // This unused variable forces the compiler to instantiate
275 // an object of T template so an implicit conversion from
276 // read() to a C++ intrinsic data type will work.
277 static data_type dummy;
278#endif
279};
280
281template<typename T>
282::std::ostream& operator << ( ::std::ostream& os, const sc_in<T>& a )
283{
284 return os << a->read();
285}
286
287// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
288
289
290// called when elaboration is done
291
292template <class T>
293inline
294void
296{
297 if( m_traces != 0 ) {
298 for( int i = 0; i < (int)m_traces->size(); ++ i ) {
299 sc_trace_params* p = (*m_traces)[i];
300 in_if_type* iface = dynamic_cast<in_if_type*>( this->get_interface() );
301 sc_trace( p->tf, iface->read(), p->name );
302 }
303 remove_traces();
304 }
305}
306
307
308// called by sc_trace
309
310template <class T>
311inline
312void
313sc_in<T>::add_trace_internal( sc_trace_file* tf_, const std::string& name_ )
314const
315{
316 if( tf_ != 0 ) {
317 if( m_traces == 0 ) {
318 m_traces = new sc_trace_params_vec;
319 }
320 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
321 }
322}
323
324template <class T>
325inline
326void
327sc_in<T>::add_trace( sc_trace_file* tf_, const std::string& name_ )
328const
329{
331 add_trace_internal(tf_, name_);
332}
333
334template <class T>
335inline
336void
338{
339 if( m_traces != 0 ) {
340 for( int i = (int)m_traces->size() - 1; i >= 0; -- i ) {
341 delete (*m_traces)[i];
342 }
343 delete m_traces;
344 m_traces = 0;
345 }
346}
347
348
349// called by pbind (for internal use only)
350
351template <class T>
352inline
353int
355{
356 return sc_port_b<if_type>::vbind( interface_ );
357}
358
359template <class T>
360inline
361int
363{
364 in_port_type* in_parent = dynamic_cast<in_port_type*>( &parent_ );
365 if( in_parent != 0 ) {
366 sc_port_base::bind( *in_parent );
367 return 0;
368 }
369 inout_port_type* inout_parent = dynamic_cast<inout_port_type*>( &parent_ );
370 if( inout_parent != 0 ) {
371 sc_port_base::bind( *inout_parent );
372 return 0;
373 }
374 // type mismatch
375 return 2;
376}
377
378
379// ----------------------------------------------------------------------------
380// CLASS : sc_in<bool>
381//
382// Specialization of sc_in<T> for type bool.
383// ----------------------------------------------------------------------------
384
386
387template <>
388class SC_API sc_in<bool> :
389 public sc_port<sc_signal_in_if<bool>,1,SC_ONE_OR_MORE_BOUND>
390{
391public:
392
393 // typedefs
394
395 typedef bool data_type;
396
400 typedef /* typename */ base_type::port_type base_port_type;
401
406
407public:
408
409 // constructors
410
412 : base_type(), m_traces( 0 ), m_change_finder_p(0),
413 m_neg_finder_p(0), m_pos_finder_p(0)
414 {}
415
416 explicit sc_in( const char* name_ )
417 : base_type( name_ ), m_traces( 0 ), m_change_finder_p(0),
418 m_neg_finder_p(0), m_pos_finder_p(0)
419 {}
420
421 explicit sc_in( const in_if_type& interface_ )
422 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
423 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
424 {}
425
426 sc_in( const char* name_, const in_if_type& interface_ )
427 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
428 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
429 {}
430
431 explicit sc_in( in_port_type& parent_ )
432 : base_type( parent_ ), m_traces( 0 ),
433 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
434 {}
435
436 sc_in( const char* name_, in_port_type& parent_ )
437 : base_type( name_, parent_ ), m_traces( 0 ),
438 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
439 {}
440
441 explicit sc_in( inout_port_type& parent_ )
442 : base_type(), m_traces( 0 ),
443 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
444 { sc_port_base::bind( parent_ ); }
445
446 sc_in( const char* name_, inout_port_type& parent_ )
447 : base_type( name_ ), m_traces( 0 ),
448 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
449 { sc_port_base::bind( parent_ ); }
450
451 sc_in( this_type& parent_ )
452 : base_type( parent_ ), m_traces( 0 ),
453 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
454 {}
455
456#if defined(TESTING)
457 sc_in( const this_type& parent_ )
458 : base_type( *(in_if_type*)parent_.get_interface() ) , m_traces( 0 ),
459 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
460 {}
461#endif
462
463 sc_in( const char* name_, this_type& parent_ )
464 : base_type( name_, parent_ ), m_traces( 0 ),
465 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
466 {}
467
468
469 // destructor
470
471 virtual ~sc_in()
472 {
473 remove_traces();
474 delete m_change_finder_p;
475 delete m_neg_finder_p;
476 delete m_pos_finder_p;
477 }
478
479
480 // bind to in interface
481
482 virtual void bind( const in_if_type& interface_ )
483 { sc_port_base::bind( const_cast<in_if_type&>( interface_ ) ); }
484
485 virtual void bind( in_if_type& interface_ )
486 { this->bind( const_cast<const in_if_type&>( interface_ ) ); }
487
488 void operator () ( const in_if_type& interface_ )
489 { this->bind( interface_ ); }
490
491
492 // bind to parent in port
493
494 virtual void bind( in_port_type& parent_ )
495 { sc_port_base::bind( parent_ ); }
496
497 void operator () ( in_port_type& parent_ )
498 { this->bind( parent_ ); }
499
500
501 // bind to parent inout port
502
503 virtual void bind( inout_port_type& parent_ )
504 { sc_port_base::bind( parent_ ); }
505
506 void operator () ( inout_port_type& parent_ )
507 { this->bind( parent_ ); }
508
509
510 // interface access shortcut methods
511
512 // get the default event
513
514 const sc_event& default_event() const
515 { return (*this)->default_event(); }
516
517
518 // get the value changed event
519
521 { return (*this)->value_changed_event(); }
522
523 // get the positive edge event
524
525 const sc_event& posedge_event() const
526 { return (*this)->posedge_event(); }
527
528 // get the negative edge event
529
530 const sc_event& negedge_event() const
531 { return (*this)->negedge_event(); }
532
533
534 // read the current value
535
536 const data_type& read() const
537 { return (*this)->read(); }
538
539 operator const data_type& () const
540 { return (*this)->read(); }
541
542
543 // use for positive edge sensitivity
544
546 {
548 ( m_pos_finder_p, *this, &in_if_type::posedge_event );
549 }
550
551 // use for negative edge sensitivity
552
554 {
556 ( m_neg_finder_p, *this, &in_if_type::negedge_event );
557 }
558
559
560 // was there a value changed event?
561
562 bool event() const
563 { return (*this)->event(); }
564
565 // was there a positive edge event?
566
567 bool posedge() const
568 { return (*this)->posedge(); }
569
570 // was there a negative edge event?
571
572 bool negedge() const
573 { return (*this)->negedge(); }
574
575 // (other) event finder method(s)
576
578 {
580 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
581 }
582
583
584 // called when elaboration is done
585 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
586 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
587
588 virtual void end_of_elaboration();
589
590 virtual const char* kind() const
591 { return "sc_in"; }
592
593
594 void add_trace( sc_trace_file*, const std::string& ) const;
595
596 // called by sc_trace
597 void add_trace_internal( sc_trace_file*, const std::string& ) const;
598
599protected:
600
601 void remove_traces() const;
602
604
605protected:
606
607 // called by pbind (for internal use only)
608 virtual int vbind( sc_interface& );
609 virtual int vbind( sc_port_base& );
610
611 // implement virtual base_type port-binding function
612 // - avoids warnings on some compilers
613 // - should only be called, when using sc_port_b explicitly
614 // - errors are detected during elaboration
615
616 virtual void bind( base_port_type& parent_ )
617 { sc_port_base::bind( parent_ ); }
618
619private:
620 mutable sc_event_finder* m_change_finder_p;
621 mutable sc_event_finder* m_neg_finder_p;
622 mutable sc_event_finder* m_pos_finder_p;
623
624private:
625
626 // disabled
627#if defined(TESTING)
628#else
629 sc_in( const this_type& );
630#endif
631 this_type& operator = ( const this_type& );
632
633#ifdef __GNUC__
634 // Needed to circumvent a problem in the g++-2.95.2 compiler:
635 // This unused variable forces the compiler to instantiate
636 // an object of T template so an implicit conversion from
637 // read() to a C++ intrinsic data type will work.
638 static data_type dummy;
639#endif
640};
641
642
643// ----------------------------------------------------------------------------
644// CLASS : sc_in<sc_dt::sc_logic>
645//
646// Specialization of sc_in<T> for type sc_dt::sc_logic.
647// ----------------------------------------------------------------------------
648
649SC_API_TEMPLATE_DECL_ sc_port<sc_signal_in_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>;
650
651template <>
653: public sc_port<sc_signal_in_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>
654{
655public:
656
657 // typedefs
658
660
664 typedef /* typename */ base_type::port_type base_port_type;
665
670
671public:
672
673 // constructors
674
676 : base_type(), m_traces( 0 ),
677 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
678 {}
679
680 explicit sc_in( const char* name_ )
681 : base_type( name_ ), m_traces( 0 ),
682 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
683 {}
684
685 explicit sc_in( const in_if_type& interface_ )
686 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
687 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
688 {}
689
690 sc_in( const char* name_, const in_if_type& interface_ )
691 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 ),
692 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
693 {}
694
695 explicit sc_in( in_port_type& parent_ )
696 : base_type( parent_ ), m_traces( 0 ),
697 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
698 {}
699
700 sc_in( const char* name_, in_port_type& parent_ )
701 : base_type( name_, parent_ ), m_traces( 0 ),
702 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
703 {}
704
705 explicit sc_in( inout_port_type& parent_ )
706 : base_type(), m_traces( 0 ),
707 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
708 { sc_port_base::bind( parent_ ); }
709
710 sc_in( const char* name_, inout_port_type& parent_ )
711 : base_type( name_ ), m_traces( 0 ),
712 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
713 { sc_port_base::bind( parent_ ); }
714
715 sc_in( this_type& parent_ )
716 : base_type( parent_ ), m_traces( 0 ),
717 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
718 {}
719
720 sc_in( const char* name_, this_type& parent_ )
721 : base_type( name_, parent_ ), m_traces( 0 ),
722 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
723 {}
724
725
726 // destructor
727
728 virtual ~sc_in()
729 {
730 remove_traces();
731 delete m_change_finder_p;
732 delete m_neg_finder_p;
733 delete m_pos_finder_p;
734 }
735
736
737 // bind to in interface
738
739 virtual void bind( const in_if_type& interface_ )
740 { sc_port_base::bind( const_cast<in_if_type&>( interface_ ) ); }
741
742 virtual void bind( in_if_type& interface_ )
743 { this->bind( const_cast<const in_if_type&>( interface_ ) ); }
744
745 void operator () ( const in_if_type& interface_ )
746 { this->bind( interface_ ); }
747
748
749 // bind to parent in port
750
751 virtual void bind( in_port_type& parent_ )
752 { sc_port_base::bind( parent_ ); }
753
754 void operator () ( in_port_type& parent_ )
755 { this->bind( parent_ ); }
756
757
758 // bind to parent inout port
759
760 virtual void bind( inout_port_type& parent_ )
761 { sc_port_base::bind( parent_ ); }
762
763 void operator () ( inout_port_type& parent_ )
764 { this->bind( parent_ ); }
765
766
767 // interface access shortcut methods
768
769 // get the default event
770
771 const sc_event& default_event() const
772 { return (*this)->default_event(); }
773
774
775 // get the value changed event
776
778 { return (*this)->value_changed_event(); }
779
780 // get the positive edge event
781
782 const sc_event& posedge_event() const
783 { return (*this)->posedge_event(); }
784
785 // get the negative edge event
786
787 const sc_event& negedge_event() const
788 { return (*this)->negedge_event(); }
789
790
791 // read the current value
792
793 const data_type& read() const
794 { return (*this)->read(); }
795
796 operator const data_type& () const
797 { return (*this)->read(); }
798
799
800 // use for positive edge sensitivity
801
803 {
805 ( m_pos_finder_p, *this, &in_if_type::posedge_event );
806 }
807
808 // use for negative edge sensitivity
809
811 {
813 ( m_neg_finder_p, *this, &in_if_type::negedge_event );
814 }
815
816
817 // was there a value changed event?
818
819 bool event() const
820 { return (*this)->event(); }
821
822 // was there a positive edge event?
823
824 bool posedge() const
825 { return (*this)->posedge(); }
826
827 // was there a negative edge event?
828
829 bool negedge() const
830 { return (*this)->negedge(); }
831
832 // (other) event finder method(s)
833
835 {
837 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
838 }
839
840
841 // called when elaboration is done
842 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
843 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
844
845 virtual void end_of_elaboration();
846
847 virtual const char* kind() const
848 { return "sc_in"; }
849
850
851 void add_trace( sc_trace_file*, const std::string& ) const;
852
853 // called by sc_trace
854 void add_trace_internal( sc_trace_file*, const std::string& ) const;
855
856protected:
857
858 void remove_traces() const;
859
861
862protected:
863
864 // called by pbind (for internal use only)
865 virtual int vbind( sc_interface& );
866 virtual int vbind( sc_port_base& );
867
868 // implement virtual base_type port-binding function
869 // - avoids warnings on some compilers
870 // - should only be called, when using sc_port_b explicitly
871 // - errors are detected during elaboration
872
873 virtual void bind( base_port_type& parent_ )
874 { sc_port_base::bind( parent_ ); }
875
876private:
877 mutable sc_event_finder* m_change_finder_p;
878 mutable sc_event_finder* m_neg_finder_p;
879 mutable sc_event_finder* m_pos_finder_p;
880
881private:
882
883 // disabled
884 sc_in( const this_type& );
885 this_type& operator = ( const this_type& );
886
887#ifdef __GNUC__
888 // Needed to circumvent a problem in the g++-2.95.2 compiler:
889 // This unused variable forces the compiler to instantiate
890 // an object of T template so an implicit conversion from
891 // read() to a C++ intrinsic data type will work.
892 static data_type dummy;
893#endif
894};
895
896
897// ----------------------------------------------------------------------------
898// CLASS : sc_inout<T>
899//
900// The sc_signal<T> input/output port class.
901// ----------------------------------------------------------------------------
902
903template <class T>
905: public sc_port<sc_signal_inout_if<T>,1,SC_ONE_OR_MORE_BOUND>
906{
907public:
908
909 // typedefs
910
911 typedef T data_type;
912
916
921
922public:
923
924 // constructors
925
927 : base_type(), m_init_val( 0 ), m_traces( 0 ),
928 m_change_finder_p(0)
929 {}
930
931 explicit sc_inout( const char* name_ )
932 : base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
933 m_change_finder_p(0)
934 {}
935
936 explicit sc_inout( inout_if_type& interface_ )
937 : base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
938 m_change_finder_p(0)
939 {}
940
941 sc_inout( const char* name_, inout_if_type& interface_ )
942 : base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
943 m_change_finder_p(0)
944 {}
945
946 explicit sc_inout( inout_port_type& parent_ )
947 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
948 m_change_finder_p(0)
949 {}
950
951 sc_inout( const char* name_, inout_port_type& parent_ )
952 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
953 m_change_finder_p(0)
954 {}
955
956 sc_inout( this_type& parent_ )
957 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
958 m_change_finder_p(0)
959 {}
960
961 sc_inout( const char* name_, this_type& parent_ )
962 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
963 m_change_finder_p(0)
964 {}
965
966
967 // destructor
968
969 virtual ~sc_inout();
970
971
972 // interface access shortcut methods
973
974 // get the default event
975
976 const sc_event& default_event() const
977 { return (*this)->default_event(); }
978
979
980 // get the value changed event
981
983 { return (*this)->value_changed_event(); }
984
985
986 // read the current value
987
988 const data_type& read() const
989 { return (*this)->read(); }
990
991 operator const data_type& () const
992 { return (*this)->read(); }
993
994
995 // was there a value changed event?
996
997 bool event() const
998 { return (*this)->event(); }
999
1000
1001 // write the new value
1002
1003 void write( const data_type& value_ )
1004 { (*this)->write( value_ ); }
1005
1007 { write( value_ ); return *this; }
1008
1009 this_type& operator = ( const in_if_type& interface_ )
1010 { return *this = interface_.read(); }
1011
1013 { return *this = port_->read(); }
1014
1016 { return *this = port_->read(); }
1017
1019 { return *this = port_->read(); }
1020
1021
1022 // set initial value (can also be called when port is not bound yet)
1023
1024 void initialize( const data_type& value_ );
1025
1026 void initialize( const in_if_type& interface_ )
1027 { initialize( interface_.read() ); }
1028
1029
1030 // called when elaboration is done
1031 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1032 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1033
1034 virtual void end_of_elaboration();
1035
1036
1037 // (other) event finder method(s)
1038
1040 {
1042 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
1043 }
1044
1045 virtual const char* kind() const
1046 { return "sc_inout"; }
1047
1048protected:
1049
1051
1052public:
1053
1054 // called by sc_trace
1055 void add_trace_internal( sc_trace_file*, const std::string& ) const;
1056
1057 void add_trace( sc_trace_file*, const std::string& ) const;
1058
1059protected:
1060
1061 void remove_traces() const;
1062
1064
1065private:
1066 mutable sc_event_finder* m_change_finder_p;
1067
1068private:
1069
1070 // disabled
1071 sc_inout( const this_type& );
1072
1073#ifdef __GNUC__
1074 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1075 // This unused variable forces the compiler to instantiate
1076 // an object of T template so an implicit conversion from
1077 // read() to a C++ intrinsic data type will work.
1078 static data_type dummy;
1079#endif
1080};
1081
1082template<typename T>
1083::std::ostream& operator << ( ::std::ostream& os, const sc_inout<T>& a )
1084{
1085 return os << a->read();
1086}
1087
1088// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
1089
1090
1091// destructor
1092
1093template <class T>
1094inline
1096{
1097 delete m_change_finder_p;
1098 delete m_init_val;
1099 remove_traces();
1100}
1101
1102
1103// set initial value (can also be called when port is not bound yet)
1104
1105template <class T>
1106inline
1107void
1109{
1110 inout_if_type* iface = dynamic_cast<inout_if_type*>( this->get_interface() );
1111 if( iface != 0 ) {
1112 iface->write( value_ );
1113 } else {
1114 if( m_init_val == 0 ) {
1115 m_init_val = new data_type;
1116 }
1117 *m_init_val = value_;
1118 }
1119}
1120
1121
1122// called when elaboration is done
1123
1124template <class T>
1125inline
1126void
1128{
1129 if( m_init_val != 0 ) {
1130 write( *m_init_val );
1131 delete m_init_val;
1132 m_init_val = 0;
1133 }
1134 if( m_traces != 0 ) {
1135 for( int i = 0; i < (int)m_traces->size(); ++ i ) {
1136 sc_trace_params* p = (*m_traces)[i];
1137 in_if_type* iface = dynamic_cast<in_if_type*>( this->get_interface() );
1138 sc_trace( p->tf, iface->read(), p->name );
1139 }
1140 remove_traces();
1141 }
1142}
1143
1144
1145// called by sc_trace
1146
1147template <class T>
1148inline
1149void
1150sc_inout<T>::add_trace_internal( sc_trace_file* tf_, const std::string& name_)
1151const
1152{
1153 if( tf_ != 0 ) {
1154 if( m_traces == 0 ) {
1155 m_traces = new sc_trace_params_vec;
1156 }
1157 m_traces->push_back( new sc_trace_params( tf_, name_ ) );
1158 }
1159}
1160
1161template <class T>
1162inline
1163void
1164sc_inout<T>::add_trace( sc_trace_file* tf_, const std::string& name_) const
1165{
1167 add_trace_internal(tf_, name_);
1168}
1169
1170template <class T>
1171inline
1172void
1174{
1175 if( m_traces != 0 ) {
1176 for( int i = static_cast<int>(m_traces->size()) - 1; i >= 0; -- i ) {
1177 delete (*m_traces)[i];
1178 }
1179 delete m_traces;
1180 m_traces = 0;
1181 }
1182}
1183
1184
1185// ----------------------------------------------------------------------------
1186// CLASS : sc_inout<bool>
1187//
1188// Specialization of sc_inout<T> for type bool.
1189// ----------------------------------------------------------------------------
1190
1192
1193template <>
1194class SC_API sc_inout<bool> :
1195 public sc_port<sc_signal_inout_if<bool>,1,SC_ONE_OR_MORE_BOUND>
1196{
1197public:
1198
1199 // typedefs
1200
1201 typedef bool data_type;
1202
1206
1211
1212public:
1213
1214 // constructors
1215
1217 : base_type(), m_init_val( 0 ), m_traces( 0 ),
1218 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1219 {}
1220
1221 explicit sc_inout( const char* name_ )
1222 : base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
1223 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1224 {}
1225
1226 explicit sc_inout( inout_if_type& interface_ )
1227 : base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
1228 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1229 {}
1230
1231 sc_inout( const char* name_, inout_if_type& interface_ )
1232 : base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
1233 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1234 {}
1235
1236 explicit sc_inout( inout_port_type& parent_ )
1237 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
1238 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1239 {}
1240
1241 sc_inout( const char* name_, inout_port_type& parent_ )
1242 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
1243 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1244 {}
1245
1247 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
1248 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1249 {}
1250
1251 sc_inout( const char* name_, this_type& parent_ )
1252 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
1253 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1254 {}
1255
1256
1257 // destructor
1258
1259 virtual ~sc_inout();
1260
1261
1262 // interface access shortcut methods
1263
1264 // get the default event
1265
1267 { return (*this)->default_event(); }
1268
1269
1270 // get the value changed event
1271
1273 { return (*this)->value_changed_event(); }
1274
1275 // get the positive edge event
1276
1278 { return (*this)->posedge_event(); }
1279
1280 // get the negative edge event
1281
1283 { return (*this)->negedge_event(); }
1284
1285
1286 // read the current value
1287
1288 const data_type& read() const
1289 { return (*this)->read(); }
1290
1291 operator const data_type& () const
1292 { return (*this)->read(); }
1293
1294
1295 // use for positive edge sensitivity
1296
1298 {
1300 ( m_pos_finder_p, *this, &in_if_type::posedge_event );
1301 }
1302
1303 // use for negative edge sensitivity
1304
1306 {
1308 ( m_neg_finder_p, *this, &in_if_type::negedge_event );
1309 }
1310
1311
1312 // was there a value changed event?
1313
1314 bool event() const
1315 { return (*this)->event(); }
1316
1317 // was there a positive edge event?
1318
1319 bool posedge() const
1320 { return (*this)->posedge(); }
1321
1322 // was there a negative edge event?
1323
1324 bool negedge() const
1325 { return (*this)->negedge(); }
1326
1327 // write the new value
1328
1329 void write( const data_type& value_ )
1330 { (*this)->write( value_ ); }
1331
1332 this_type& operator = ( const data_type& value_ )
1333 { write( value_ ); return *this; }
1334
1335 this_type& operator = ( const in_if_type& interface_ )
1336 { return *this = interface_.read(); }
1337
1338 this_type& operator = ( const in_port_type& port_ )
1339 { return *this = port_->read(); }
1340
1341 this_type& operator = ( const inout_port_type& port_ )
1342 { return *this = port_->read(); }
1343
1344 this_type& operator = ( const this_type& port_ )
1345 { return *this = port_->read(); }
1346
1347
1348 // set initial value (can also be called when port is not bound yet)
1349
1350 void initialize( const data_type& value_ );
1351
1352 void initialize( const in_if_type& interface_ )
1353 { initialize( interface_.read() ); }
1354
1355
1356 // called when elaboration is done
1357 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1358 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1359
1360 virtual void end_of_elaboration();
1361
1362
1363 // (other) event finder method(s)
1364
1366 {
1368 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
1369 }
1370
1371 virtual const char* kind() const
1372 { return "sc_inout"; }
1373
1374protected:
1375
1377
1378public:
1379
1380 // called by sc_trace
1381 void add_trace_internal( sc_trace_file*, const std::string& ) const;
1382
1383 void add_trace( sc_trace_file*, const std::string& ) const;
1384
1385protected:
1386
1387 void remove_traces() const;
1388
1390
1391private:
1392 mutable sc_event_finder* m_change_finder_p;
1393 mutable sc_event_finder* m_neg_finder_p;
1394 mutable sc_event_finder* m_pos_finder_p;
1395
1396private:
1397
1398 // disabled
1399 sc_inout( const this_type& );
1400
1401#ifdef __GNUC__
1402 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1403 // This unused variable forces the compiler to instantiate
1404 // an object of T template so an implicit conversion from
1405 // read() to a C++ intrinsic data type will work.
1406 static data_type dummy;
1407#endif
1408};
1409
1410
1411// ----------------------------------------------------------------------------
1412// CLASS : sc_inout<sc_dt::sc_logic>
1413//
1414// Specialization of sc_inout<T> for type sc_dt::sc_logic.
1415// ----------------------------------------------------------------------------
1416
1418
1419template <>
1421: public sc_port<sc_signal_inout_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>
1422{
1423public:
1424
1425 // typedefs
1426
1428
1432
1437
1438public:
1439
1440 // constructors
1441
1443 : base_type(), m_init_val( 0 ), m_traces( 0 ),
1444 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1445 {}
1446
1447 explicit sc_inout( const char* name_ )
1448 : base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
1449 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1450 {}
1451
1452 explicit sc_inout( inout_if_type& interface_ )
1453 : base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
1454 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1455 {}
1456
1457 sc_inout( const char* name_, inout_if_type& interface_ )
1458 : base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
1459 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1460 {}
1461
1462 explicit sc_inout( inout_port_type& parent_ )
1463 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
1464 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1465 {}
1466
1467 sc_inout( const char* name_, inout_port_type& parent_ )
1468 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
1469 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1470 {}
1471
1473 : base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
1474 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1475 {}
1476
1477 sc_inout( const char* name_, this_type& parent_ )
1478 : base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
1479 m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
1480 {}
1481
1482
1483 // destructor
1484
1485 virtual ~sc_inout();
1486
1487
1488 // interface access shortcut methods
1489
1490 // get the default event
1491
1493 { return (*this)->default_event(); }
1494
1495
1496 // get the value changed event
1497
1499 { return (*this)->value_changed_event(); }
1500
1501 // get the positive edge event
1502
1504 { return (*this)->posedge_event(); }
1505
1506 // get the negative edge event
1507
1509 { return (*this)->negedge_event(); }
1510
1511
1512 // read the current value
1513
1514 const data_type& read() const
1515 { return (*this)->read(); }
1516
1517 operator const data_type& () const
1518 { return (*this)->read(); }
1519
1520
1521 // use for positive edge sensitivity
1522
1524 {
1526 ( m_pos_finder_p, *this, &in_if_type::posedge_event );
1527 }
1528
1529 // use for negative edge sensitivity
1530
1532 {
1534 ( m_neg_finder_p, *this, &in_if_type::negedge_event );
1535 }
1536
1537
1538 // was there a value changed event?
1539
1540 bool event() const
1541 { return (*this)->event(); }
1542
1543 // was there a positive edge event?
1544
1545 bool posedge() const
1546 { return (*this)->posedge(); }
1547
1548 // was there a negative edge event?
1549
1550 bool negedge() const
1551 { return (*this)->negedge(); }
1552
1553 // write the new value
1554
1555 void write( const data_type& value_ )
1556 { (*this)->write( value_ ); }
1557
1558 this_type& operator = ( const data_type& value_ )
1559 { write( value_ ); return *this; }
1560
1561 this_type& operator = ( const in_if_type& interface_ )
1562 { return *this = interface_.read(); }
1563
1564 this_type& operator = ( const in_port_type& port_ )
1565 { return *this = port_->read(); }
1566
1567 this_type& operator = ( const inout_port_type& port_ )
1568 { return *this = port_->read(); }
1569
1570 this_type& operator = ( const this_type& port_ )
1571 { return *this = port_->read(); }
1572
1573
1574 // set initial value (can also be called when port is not bound yet)
1575
1576 void initialize( const data_type& value_ );
1577
1578 void initialize( const in_if_type& interface_ )
1579 { initialize( interface_.read() ); }
1580
1581
1582 // called when elaboration is done
1583 /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
1584 /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
1585
1586 virtual void end_of_elaboration();
1587
1588
1589 // (other) event finder method(s)
1590
1592 {
1594 ( m_change_finder_p, *this, &in_if_type::value_changed_event );
1595 }
1596
1597 virtual const char* kind() const
1598 { return "sc_inout"; }
1599
1600protected:
1601
1603
1604public:
1605
1606 // called by sc_trace
1607 void add_trace_internal( sc_trace_file*, const std::string& ) const;
1608
1609 void add_trace( sc_trace_file*, const std::string& ) const;
1610
1611protected:
1612
1613 void remove_traces() const;
1614
1616
1617private:
1618 mutable sc_event_finder* m_change_finder_p;
1619 mutable sc_event_finder* m_neg_finder_p;
1620 mutable sc_event_finder* m_pos_finder_p;
1621
1622private:
1623
1624 // disabled
1625 sc_inout( const this_type& );
1626
1627#ifdef __GNUC__
1628 // Needed to circumvent a problem in the g++-2.95.2 compiler:
1629 // This unused variable forces the compiler to instantiate
1630 // an object of T template so an implicit conversion from
1631 // read() to a C++ intrinsic data type will work.
1632 static data_type dummy;
1633#endif
1634};
1635
1636
1637// ----------------------------------------------------------------------------
1638// CLASS : sc_out<T>
1639//
1640// The sc_signal<T> output port class.
1641// ----------------------------------------------------------------------------
1642
1643// sc_out can also read from its port, hence no difference with sc_inout.
1644// For debugging reasons, a class is provided instead of a define.
1645
1646template <class T>
1648: public sc_inout<T>
1649{
1650public:
1651
1652 // typedefs
1653
1654 typedef T data_type;
1655
1658
1663
1664public:
1665
1666 // constructors
1667
1669 : base_type()
1670 {}
1671
1672 explicit sc_out( const char* name_ )
1673 : base_type( name_ )
1674 {}
1675
1676 explicit sc_out( inout_if_type& interface_ )
1677 : base_type( interface_ )
1678 {}
1679
1680 sc_out( const char* name_, inout_if_type& interface_ )
1681 : base_type( name_, interface_ )
1682 {}
1683
1684 explicit sc_out( inout_port_type& parent_ )
1685 : base_type( parent_ )
1686 {}
1687
1688 sc_out( const char* name_, inout_port_type& parent_ )
1689 : base_type( name_, parent_ )
1690 {}
1691
1692 sc_out( this_type& parent_ )
1693 : base_type( parent_ )
1694 {}
1695
1696 sc_out( const char* name_, this_type& parent_ )
1697 : base_type( name_, parent_ )
1698 {}
1699
1700
1701 // destructor (does nothing)
1702
1703 virtual ~sc_out()
1704 {}
1705
1706
1707 // write the new value
1708
1709 using base_type::operator=;
1711 { base_type::operator=(port_); return *this; }
1712
1713 virtual const char* kind() const
1714 { return "sc_out"; }
1715
1716private:
1717
1718 // disabled
1719 sc_out( const this_type& );
1720};
1721
1722
1723// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
1724
1725
1726// ----------------------------------------------------------------------------
1727// FUNCTION : sc_trace
1728// ----------------------------------------------------------------------------
1729
1730template <class T>
1731inline
1732void
1733sc_trace(sc_trace_file* tf, const sc_in<T>& port, const std::string& name)
1734{
1735 const sc_signal_in_if<T>* iface = 0;
1736 if (sc_get_curr_simcontext()->elaboration_done() )
1737 {
1738 iface = dynamic_cast<const sc_signal_in_if<T>*>( port.get_interface() );
1739 }
1740
1741 if ( iface )
1742 sc_trace( tf, iface->read(), name );
1743 else
1744 port.add_trace_internal( tf, name );
1745}
1746
1747template <class T>
1748inline
1749void
1751 const std::string& name )
1752{
1753 const sc_signal_in_if<T>* iface = 0;
1754 if (sc_get_curr_simcontext()->elaboration_done() )
1755 {
1756 iface = dynamic_cast<const sc_signal_in_if<T>*>( port.get_interface() );
1757 }
1758
1759 if ( iface )
1760 sc_trace( tf, iface->read(), name );
1761 else
1762 port.add_trace_internal( tf, name );
1763}
1764
1765} // namespace sc_core
1766
1767#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
1768#pragma warning(pop)
1769#endif
1770
1771/*****************************************************************************
1772
1773 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
1774 changes you are making here.
1775
1776 Name, Affiliation, Date: Jason Elbaum, Motorola, Inc., 2001-11-12
1777 Description of Modification: Added a static, private, otherwise
1778 unused data member to the sc_in
1779 and sc_inout classes to address
1780 a bug in the GNU compiler *only*.
1781 This works around a bug in g++ 2.95.2
1782 regarding implicit casting from a
1783 templated class to a C++ intrinsic type.
1784
1785 *****************************************************************************/
1786//$Log: sc_signal_ports.h,v $
1787//Revision 1.10 2011/08/29 18:04:32 acg
1788// Philipp A. Hartmann: miscellaneous clean ups.
1789//
1790//Revision 1.9 2011/08/26 20:45:43 acg
1791// Andy Goodrich: moved the modification log to the end of the file to
1792// eliminate source line number skew when check-ins are done.
1793//
1794//Revision 1.8 2011/08/07 19:08:01 acg
1795// Andy Goodrich: moved logs to end of file so line number synching works
1796// better between versions.
1797//
1798//Revision 1.7 2011/08/07 18:53:09 acg
1799// Philipp A. Hartmann: add virtual instances of the bind function for
1800// base classes to eliminate warning messages for clang platforms.
1801//
1802//Revision 1.6 2011/04/02 00:03:23 acg
1803// Andy Goodrich: catch the other bind()'s that I missed in Philipp's update.
1804//
1805//Revision 1.5 2011/04/01 22:33:31 acg
1806// Philipp A. Harmann: Use const interface signature to implement non-const
1807// interface signature for virtual bind(...).
1808//
1809//Revision 1.4 2011/03/30 16:46:10 acg
1810// Andy Goodrich: added a signature and removed a virtual specification
1811// to eliminate warnings with certain compilers.
1812//
1813//Revision 1.3 2011/02/18 20:23:45 acg
1814// Andy Goodrich: Copyright update.
1815//
1816//Revision 1.2 2011/01/20 16:52:15 acg
1817// Andy Goodrich: changes for IEEE 1666 2011.
1818//
1819//Revision 1.1.1.1 2006/12/15 20:20:04 acg
1820//SystemC 2.3
1821//
1822//Revision 1.11 2006/04/18 23:36:50 acg
1823// Andy Goodrich: made add_trace_internal public until I can figure out
1824// how to do a friend specification for sc_trace in an environment where
1825// there are partial template and full template specifications for its
1826// arguments.
1827//
1828//Revision 1.10 2006/04/18 18:01:26 acg
1829// Andy Goodrich: added an add_trace_internal() method to the various port
1830// classes so that sc_trace has something to call that won't emit an
1831// IEEE 1666 deprecation message.
1832//
1833//Revision 1.9 2006/03/13 20:19:44 acg
1834// Andy Goodrich: changed sc_event instances into pointers to sc_event instances
1835// that are allocated as needed. This saves considerable storage for large
1836// numbers of signals, etc.
1837//
1838//Revision 1.8 2006/02/02 23:42:37 acg
1839// Andy Goodrich: implemented a much better fix to the sc_event_finder
1840// proliferation problem. This new version allocates only a single event
1841// finder for each port for each type of event, e.g., pos(), neg(), and
1842// value_change(). The event finder persists as long as the port does,
1843// which is what the LRM dictates. Because only a single instance is
1844// allocated for each event type per port there is not a potential
1845// explosion of storage as was true in the 2.0.1/2.1 versions.
1846//
1847//Revision 1.7 2006/02/02 21:38:12 acg
1848// Andy Goodrich: fix to the comment log.
1849//
1850//Revision 1.4 2006/01/24 20:46:32 acg
1851//Andy Goodrich: changes to eliminate use of deprecated features. For instance,
1852//using notify(SC_ZERO_TIME) in place of notify_delayed().
1853//
1854//Revision 1.3 2006/01/13 18:47:42 acg
1855//Added $Log command so that CVS comments are reproduced in the source.
1856//
1857//Revision 1.2 2006/01/03 23:18:26 acg
1858//Changed copyright to include 2006.
1859//
1860//Revision 1.1.1.1 2005/12/19 23:16:43 acg
1861//First check in of SystemC 2.1 into its own archive.
1862//
1863//Revision 1.18 2005/09/15 23:01:52 acg
1864//Added std:: prefix to appropriate methods and types to get around
1865//issues with the Edison Front End.
1866//
1867//Revision 1.17 2005/06/10 22:43:55 acg
1868//Added CVS change log annotation.
1869//
1870
1871#endif
1872
1873// Taf!
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:157
#define SC_API
Definition: sc_cmnhdr.h:148
std::vector< sc_trace_params * > sc_trace_params_vec
inline::std::ostream & operator<<(::std::ostream &os, const sc_fifo< T > &a)
Definition: sc_fifo.h:428
void sc_trace(sc_trace_file *tf, const sc_in< T > &port, const std::string &name)
sc_simcontext * sc_get_curr_simcontext()
@ SC_ONE_OR_MORE_BOUND
Definition: sc_port.h:55
SC_API void sc_deprecated_add_trace()
class SC_API sc_logic
Definition: sc_signal_ifs.h:39
static sc_event_finder & cached_create(sc_event_finder *&cache_p, const sc_port_base &port_, const sc_event &(IF::*ef_p)() const)
void bind(sc_interface &interface_)
virtual int vbind(sc_interface &)
Definition: sc_port.h:514
const IF * get_interface(int iface_i) const
Definition: sc_port.h:502
virtual const sc_event & value_changed_event() const =0
virtual const T & read() const =0
virtual void write(const T &)=0
sc_trace_params(sc_trace_file *tf_, const std::string &name_)
virtual int vbind(sc_port_base &)
sc_in(this_type &parent_)
void remove_traces() const
void add_trace_internal(sc_trace_file *, const std::string &) const
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
const data_type & read() const
virtual void bind(inout_port_type &parent_)
base_type::port_type base_port_type
virtual int vbind(sc_interface &)
sc_signal_inout_if< data_type > inout_if_type
sc_in(const char *name_, inout_port_type &parent_)
void add_trace(sc_trace_file *, const std::string &) const
sc_in(const char *name_)
virtual const char * kind() const
base_type in_port_type
virtual void bind(in_port_type &parent_)
sc_signal_in_if< data_type > if_type
virtual void bind(base_port_type &parent_)
sc_in(const in_if_type &interface_)
sc_in(in_port_type &parent_)
sc_in(const char *name_, this_type &parent_)
const sc_event & value_changed_event() const
sc_in< data_type > this_type
const sc_event & default_event() const
sc_in(const char *name_, const in_if_type &interface_)
bool event() const
void operator()(const in_if_type &interface_)
virtual void bind(const in_if_type &interface_)
sc_port< inout_if_type, 1, SC_ONE_OR_MORE_BOUND > inout_port_type
sc_in(const char *name_, in_port_type &parent_)
sc_trace_params_vec * m_traces
virtual void end_of_elaboration()
sc_in(inout_port_type &parent_)
virtual void bind(in_if_type &interface_)
sc_event_finder & value_changed() const
sc_in(const char *name_)
const sc_event & default_event() const
base_type::port_type base_port_type
const sc_event & posedge_event() const
virtual void bind(in_if_type &interface_)
virtual void end_of_elaboration()
virtual const char * kind() const
sc_event_finder & value_changed() const
virtual void bind(base_port_type &parent_)
sc_in(const in_if_type &interface_)
sc_in(const char *name_, this_type &parent_)
sc_in(const char *name_, const in_if_type &interface_)
sc_signal_inout_if< data_type > inout_if_type
virtual int vbind(sc_interface &)
const sc_event & value_changed_event() const
void add_trace_internal(sc_trace_file *, const std::string &) const
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
const sc_event & negedge_event() const
sc_in< data_type > this_type
void add_trace(sc_trace_file *, const std::string &) const
sc_in(const char *name_, in_port_type &parent_)
sc_trace_params_vec * m_traces
sc_port< inout_if_type, 1, SC_ONE_OR_MORE_BOUND > inout_port_type
sc_in(inout_port_type &parent_)
virtual void bind(const in_if_type &interface_)
sc_in(this_type &parent_)
sc_event_finder & pos() const
const data_type & read() const
virtual void bind(in_port_type &parent_)
sc_signal_in_if< data_type > if_type
sc_event_finder & neg() const
virtual int vbind(sc_port_base &)
virtual void bind(inout_port_type &parent_)
void remove_traces() const
sc_in(const char *name_, inout_port_type &parent_)
sc_in(in_port_type &parent_)
virtual void bind(in_port_type &parent_)
sc_signal_in_if< data_type > if_type
const sc_event & posedge_event() const
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
base_type::port_type base_port_type
sc_in(inout_port_type &parent_)
virtual void bind(in_if_type &interface_)
virtual int vbind(sc_interface &)
sc_in(const char *name_, const in_if_type &interface_)
virtual int vbind(sc_port_base &)
const sc_event & default_event() const
void add_trace(sc_trace_file *, const std::string &) const
const data_type & read() const
virtual const char * kind() const
sc_event_finder & value_changed() const
sc_signal_inout_if< data_type > inout_if_type
const sc_event & negedge_event() const
sc_port< inout_if_type, 1, SC_ONE_OR_MORE_BOUND > inout_port_type
virtual void bind(base_port_type &parent_)
sc_in(const char *name_, in_port_type &parent_)
sc_in(const char *name_, this_type &parent_)
sc_in(const in_if_type &interface_)
sc_in(const char *name_, inout_port_type &parent_)
virtual void bind(inout_port_type &parent_)
void add_trace_internal(sc_trace_file *, const std::string &) const
const sc_event & value_changed_event() const
virtual void bind(const in_if_type &interface_)
sc_event_finder & pos() const
sc_event_finder & neg() const
virtual const char * kind() const
void remove_traces() const
const sc_event & value_changed_event() const
sc_signal_inout_if< data_type > if_type
sc_inout(const char *name_, this_type &parent_)
base_type inout_port_type
sc_port< in_if_type, 1, SC_ONE_OR_MORE_BOUND > in_port_type
void add_trace_internal(sc_trace_file *, const std::string &) const
sc_inout(inout_port_type &parent_)
data_type * m_init_val
sc_trace_params_vec * m_traces
sc_event_finder & value_changed() const
const data_type & read() const
bool event() const
sc_inout(this_type &parent_)
void add_trace(sc_trace_file *, const std::string &) const
const sc_event & default_event() const
sc_inout(inout_if_type &interface_)
void initialize(const in_if_type &interface_)
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
sc_inout(const char *name_, inout_port_type &parent_)
void write(const data_type &value_)
virtual void end_of_elaboration()
sc_inout< data_type > this_type
sc_signal_in_if< data_type > in_if_type
sc_inout(const char *name_, inout_if_type &interface_)
this_type & operator=(const data_type &value_)
sc_inout(const char *name_)
void initialize(const data_type &value_)
sc_inout(this_type &parent_)
void write(const data_type &value_)
const sc_event & posedge_event() const
const sc_event & value_changed_event() const
sc_inout(const char *name_, inout_if_type &interface_)
sc_inout(const char *name_)
const sc_event & negedge_event() const
sc_inout(inout_port_type &parent_)
sc_port< in_if_type, 1, SC_ONE_OR_MORE_BOUND > in_port_type
sc_event_finder & neg() const
const sc_event & default_event() const
sc_signal_in_if< data_type > in_if_type
void add_trace(sc_trace_file *, const std::string &) const
sc_inout(inout_if_type &interface_)
sc_event_finder & pos() const
sc_event_finder & value_changed() const
void initialize(const in_if_type &interface_)
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
sc_signal_inout_if< data_type > if_type
sc_inout(const char *name_, this_type &parent_)
const data_type & read() const
virtual const char * kind() const
virtual void end_of_elaboration()
void initialize(const data_type &value_)
sc_inout< data_type > this_type
sc_inout(const char *name_, inout_port_type &parent_)
sc_trace_params_vec * m_traces
void add_trace_internal(sc_trace_file *, const std::string &) const
virtual const char * kind() const
sc_inout(const char *name_, inout_if_type &interface_)
const sc_event & default_event() const
sc_signal_in_if< data_type > in_if_type
void write(const data_type &value_)
sc_event_finder & value_changed() const
sc_inout(inout_port_type &parent_)
void initialize(const data_type &value_)
sc_port< in_if_type, 1, SC_ONE_OR_MORE_BOUND > in_port_type
const sc_event & value_changed_event() const
void add_trace_internal(sc_trace_file *, const std::string &) const
void initialize(const in_if_type &interface_)
sc_port< if_type, 1, SC_ONE_OR_MORE_BOUND > base_type
void add_trace(sc_trace_file *, const std::string &) const
sc_inout(inout_if_type &interface_)
sc_inout(const char *name_, inout_port_type &parent_)
const sc_event & negedge_event() const
sc_signal_inout_if< data_type > if_type
sc_inout(const char *name_, this_type &parent_)
const sc_event & posedge_event() const
base_type::inout_port_type inout_port_type
sc_out(const char *name_, inout_if_type &interface_)
base_type::in_if_type in_if_type
sc_out< data_type > this_type
base_type::inout_if_type inout_if_type
sc_out(inout_port_type &parent_)
sc_out(inout_if_type &interface_)
base_type::in_port_type in_port_type
virtual const char * kind() const
sc_out(this_type &parent_)
this_type & operator=(const this_type &port_)
sc_out(const char *name_, inout_port_type &parent_)
sc_inout< data_type > base_type
sc_out(const char *name_, this_type &parent_)
sc_out(const char *name_)