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