132#if !defined(SC_SIGNAL_INT_H)
133#define SC_SIGNAL_INT_H
135#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )
136# define SC_TEMPLATE template<int W>
138# define SC_TEMPLATE template<> template<int W>
212 virtual bool event()
const = 0;
295 explicit inline sc_signal(
const char* name_);
299 inline bool base_event()
const;
301 inline const sc_event& base_value_changed_event()
const;
305 virtual inline const char*
kind()
const;
306 virtual inline void update();
315 virtual inline sc_dt::uint64 read_part(
int left,
int right)
const;
316 virtual inline sc_int_sigref& select_part(
int left,
int right);
317 virtual inline void write_part(
sc_dt::uint64 v,
int left,
int right);
320 virtual inline bool event()
const;
334 inline void operator = (
const this_type& new_val );
335 inline void operator = (
const char* new_val );
341 inline void operator = (
unsigned int new_val ) ;
342 inline void operator = (
unsigned long new_val );
343 inline void operator = (
unsigned short new_val );
353 virtual inline void concat_set(
sc_dt::int64 src,
int low_i);
357 virtual inline void concat_set(
sc_dt::uint64 src,
int low_i);
378 mutable sc_event* m_changed_event_p;
389 return simcontext()->delta_count() == m_event_delta + 1;
403 if ( !m_changed_event_p ) m_changed_event_p =
new sc_event;
404 return *m_changed_event_p;
412 result_p->initialize(
this, left, right);
420# if defined(DEBUG_SYSTEMC)
437 if( m_writer_p == 0 )
439 m_writer_p = writer_p;
441 else if( m_writer_p != writer_p )
444 m_writer_p->name(), writer_p->name() );
464 base_write(src >> low_i);
468 base_write( src >> 63 );
475 sc_dt::sc_unsigned tmp(src.
length());
477 base_write( tmp.to_int64() );
483 base_write( (src >> low_i).to_int64());
489 base_write( (src >> low_i).to_int64());
495 base_write( ( low_i < 64 ) ? src >> low_i : 0 );
502 {
return base_value_changed_event(); }
507 {
return base_event(); }
540 result_p->initialize(
this, left, right);
554 return operator () (bit,bit);
564 { m_new_val = sc_dt::sc_int<64>(new_val); request_update(); }
572 { base_write(new_val); }
602 const sc_dt::sc_generic_base<T>& new_val )
603 { base_write(new_val->to_int64()); }
607 { base_write(new_val.to_int64()); }
611 { base_write(new_val.to_int64()); }
615 { base_write( (sc_dt::sc_int<W>)new_val ); }
619 { base_write( (sc_dt::sc_int<W>)new_val ); }
644 std::string nm( if_typename_ );
647 if( m_output_p != 0 )
650 m_output_p->name(), port_.name() );
655 if ( &port_ && if_typename_ ) {}
663 m_changed_event_p(0),
672 m_changed_event_p(0),
681 if ( m_changed_event_p )
delete m_changed_event_p;
688 if ( m_changed_event_p )
693 if ( old_val != this->m_val )
695 m_changed_event_p->notify_delayed();
696 m_event_delta = simcontext()->delta_count();
708 {
return base_value_changed_event(); }
723 { base_write( value); }
734 new_v = (m_new_val & keep) | ((v << right) & ~keep);
735 if ( m_new_val != new_v ) request_update();
748class sc_in<sc_dt::sc_int<W> > :
749 public sc_port<sc_signal_in_if<sc_dt::sc_int<W> >, 1>,
750 public sc_dt::sc_value_base
756 typedef sc_dt::sc_int<W> data_type;
757 typedef sc_signal_in_if<sc_dt::sc_int<W> > if_type;
761 typedef if_type in_if_type;
762 typedef base_type in_port_type;
763 typedef sc_signal_inout_if<sc_dt::sc_int<W> > inout_if_type;
764 typedef sc_inout<sc_dt::sc_int<W> > inout_port_type;
770 void bind(
const in_if_type& interface_ )
774 void bind( in_port_type& parent_ )
778 void bind( inout_port_type& parent_ )
785 virtual inline int vbind( sc_interface& interface_ )
791 in_port_type* in_parent =
dynamic_cast<in_port_type*
>( &parent_ );
792 if( in_parent != 0 ) {
796 inout_port_type* inout_parent =
dynamic_cast<inout_port_type*
>( &parent_ );
797 if( inout_parent != 0 ) {
810 : base_type(), m_traces( 0 )
813 explicit sc_in(
const char* name_ )
814 : base_type( name_ ), m_traces( 0 )
817 explicit sc_in(
const in_if_type& interface_ )
818 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
821 sc_in(
const char* name_,
const in_if_type& interface_ )
822 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
825 explicit sc_in( in_port_type& parent_ )
826 : base_type( parent_ ), m_traces( 0 )
829 sc_in(
const char* name_, in_port_type& parent_ )
830 : base_type( name_, parent_ ), m_traces( 0 )
833 explicit sc_in( inout_port_type& parent_ )
834 : base_type(), m_traces( 0 )
837 sc_in(
const char* name_, inout_port_type& parent_ )
838 : base_type( name_ ), m_traces( 0 )
841 sc_in( this_type& parent_ )
842 : base_type( parent_ ), m_traces( 0 )
845 sc_in(
const char* name_, this_type& parent_ )
846 : base_type( name_, parent_ ), m_traces( 0 )
860 {
return (*this)->read()[
i]; }
861 sc_dt::sc_int_bitref_r bit(
int i )
const
862 {
return (*this)->read()[
i]; }
863 sc_dt::sc_int_subref_r
operator () (
int left,
int right )
const
864 {
return (*this)->read()(left,right); }
865 sc_dt::sc_int_subref_r range(
int left,
int right )
const
866 {
return (*this)->read()(left,right); }
874 {
return (*this)->value_changed_event(); }
880 {
return (*this)->value_changed_event(); }
885 const sc_dt::sc_int<W>&
read()
const
886 {
return (*this)->read(); }
894 {
return (*this)->event(); }
901 return *
new sc_event_finder_t<in_if_type>(
902 *
this, &in_if_type::value_changed_event );
910 {
return (*this)->read().and_reduce(); }
912 {
return (*this)->read().nand_reduce(); }
914 {
return (*this)->read().nor_reduce(); }
916 {
return (*this)->read().or_reduce(); }
918 {
return (*this)->read().xnor_reduce(); }
920 {
return (*this)->read().xor_reduce(); }
929 if( m_traces != 0 ) {
930 for(
unsigned int i = 0;
i < m_traces->size(); ++
i ) {
931 sc_trace_params*
p = (*m_traces)[
i];
938 virtual inline const char*
kind()
const
943 void add_trace( sc_trace_file* tf_,
const std::string& name_ )
const
946 if( m_traces == 0 ) {
949 m_traces->push_back(
new sc_trace_params( tf_, name_ ) );
956 virtual inline int concat_length(
bool* xz_present_p)
const
957 {
return (*this)->read().concat_length( xz_present_p ); }
959 {
return (*this)->read().concat_get_uint64(); }
962 {
return (*this)->read().concat_get_ctrl(dst_p, low_i); }
965 {
return (*this)->read().concat_get_data(dst_p, low_i); }
968 void remove_traces()
const
970 if( m_traces != 0 ) {
971 for(
int i = m_traces->size() - 1; i >= 0; -- i ) {
972 delete (*m_traces)[
i];
993 static data_type dummy;
1003 a.read().print( os );
1018 public sc_port<sc_signal_inout_if<sc_dt::sc_int<W> >, 1>,
1030 typedef if_type inout_if_type;
1031 typedef base_type inout_port_type;
1037 void bind(
const inout_if_type& interface_ )
1039 void operator () (
const inout_if_type& interface_ )
1041 void bind( inout_port_type& parent_ )
1048 virtual inline int vbind( sc_interface& interface_ )
1054 inout_port_type* inout_parent =
dynamic_cast<inout_port_type*
>( &parent_ );
1055 if( inout_parent != 0 ) {
1068 : base_type(), m_init_val_p(0), m_traces( 0 )
1071 explicit sc_inout(
const char* name_ )
1072 : base_type( name_ ), m_init_val_p(0), m_traces( 0 )
1075 explicit sc_inout( inout_if_type& interface_ )
1076 : base_type( interface_ ), m_init_val_p(0), m_traces( 0 )
1079 sc_inout(
const char* name_, inout_if_type& interface_ )
1080 : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 )
1083 explicit sc_inout( inout_port_type& parent_ )
1084 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1087 sc_inout(
const char* name_, inout_port_type& parent_ )
1088 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1092 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1095 sc_inout(
const char* name_, this_type& parent_ )
1096 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1109 sc_dt::sc_int_bitref_r
operator [] (
int i )
const
1110 {
return (*this)->read()[
i]; }
1111 sc_dt::sc_int_bitref_r bit(
int i )
const
1112 {
return (*this)->read()[
i]; }
1114 {
return (*this)->select_part(i,i); }
1115 sc_int_sigref& bit(
int i )
1116 {
return (*this)->select_part(i,i); }
1117 sc_dt::sc_int_subref_r
operator () (
int left,
int right )
const
1118 {
return (*this)->read()(left,right); }
1119 sc_dt::sc_int_subref_r range(
int left,
int right )
const
1120 {
return (*this)->read()(left,right); }
1121 sc_int_sigref&
operator () (
int left,
int right )
1122 {
return (*this)->select_part(left,right); }
1123 sc_int_sigref& range(
int left,
int right )
1124 {
return (*this)->select_part(left,right); }
1132 {
return (*this)->value_changed_event(); }
1138 {
return (*this)->value_changed_event(); }
1143 const sc_dt::sc_int<W>&
read()
const
1144 {
return (*this)->read(); }
1152 {
return (*this)->event(); }
1159 return *
new sc_event_finder_t<inout_if_type>(
1160 *
this, &inout_if_type::value_changed_event );
1168 {
return (*this)->read().and_reduce(); }
1170 {
return (*this)->read().nand_reduce(); }
1172 {
return (*this)->read().nor_reduce(); }
1174 {
return (*this)->read().or_reduce(); }
1176 {
return (*this)->read().xnor_reduce(); }
1178 {
return (*this)->read().xor_reduce(); }
1187 if( m_init_val_p != 0 ) {
1189 delete m_init_val_p;
1192 if( m_traces != 0 ) {
1193 for(
unsigned int i = 0;
i < m_traces->size(); ++
i ) {
1194 sc_trace_params*
p = (*m_traces)[
i];
1201 virtual inline const char*
kind()
const
1202 {
return "sc_inout"; }
1206 inline void initialize(
const sc_dt::sc_int<W>& value_ )
1210 iface->write( value_ );
1212 if( m_init_val_p == 0 ) {
1215 *m_init_val_p = value_;
1221 void add_trace( sc_trace_file* tf_,
const std::string& name_ )
const
1224 if( m_traces == 0 ) {
1227 m_traces->push_back(
new sc_trace_params( tf_, name_ ) );
1234 virtual inline int concat_length(
bool* xz_present_p)
const
1235 {
return (*this)->read().concat_length( xz_present_p ); }
1237 {
return (*this)->read().concat_get_uint64(); }
1239 inline bool concat_get_ctrl(
sc_dt::sc_digit* dst_p,
int low_i )
const
1240 {
return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1242 inline bool concat_get_data(
sc_dt::sc_digit* dst_p,
int low_i )
const
1243 {
return (*this)->read().concat_get_data(dst_p, low_i); }
1244 virtual inline void concat_set(
sc_dt::int64 src,
int low_i)
1245 { *
this = src >> (( low_i < 64 ) ? low_i : 63); }
1247 virtual inline void concat_set(
const sc_dt::sc_lv_base& src,
int low_i)
1248 { *
this = src >> low_i; }
1250 virtual inline void concat_set(
const sc_dt::sc_signed& src,
int low_i)
1251 { *
this = src >> low_i; }
1252 virtual inline void concat_set(
const sc_dt::sc_unsigned& src,
int low_i)
1253 { *
this = src >> low_i; }
1254 virtual inline void concat_set(
sc_dt::uint64 src,
int low_i)
1255 { *
this = ( low_i < 64 ) ? src >> low_i : (
sc_dt::uint64)0; }
1260 inline void operator = (
const this_type& new_val )
1262 inline void operator = (
const char* new_val )
1263 { (*this)->write( this_type(new_val) ); }
1265 { (*this)->write(new_val); }
1274 inline void operator = (
unsigned int new_val )
1276 inline void operator = (
unsigned long new_val )
1278 inline void operator = (
unsigned short new_val )
1280 template<
typename T>
1281 inline void operator = (
const sc_dt::sc_generic_base<T>& new_val )
1282 { (*this)->write(new_val->to_uint64()); }
1283 inline void operator = (
const sc_dt::sc_signed& new_val )
1284 { (*this)->write(new_val.
to_uint64()); }
1285 inline void operator = (
const sc_dt::sc_unsigned& new_val )
1286 { (*this)->write(new_val.
to_uint64()); }
1287 inline void operator = (
const sc_dt::sc_bv_base& new_val )
1288 { (*this)->write((sc_dt::sc_int<W>)new_val); }
1289 inline void operator = (
const sc_dt::sc_lv_base& new_val )
1290 { (*this)->write((sc_dt::sc_int<W>)new_val); }
1292 inline void write(
const sc_in<sc_dt::sc_int<W> >& new_val )
1295 inline void write(
const sc_inout<sc_dt::sc_int<W> >& new_val )
1298 inline void write(
const sc_dt::sc_int<W>& new_val )
1302 void remove_traces()
const
1304 if( m_traces != 0 ) {
1305 for(
int i = m_traces->size() - 1; i >= 0; -- i ) {
1306 delete (*m_traces)[
i];
1327 static data_type dummy;
1338 a.read().print( os );
1412 { (*this)->write(
this_type(new_val) ); }
1414 { (*this)->write(new_val); }
1429 template<
typename T>
1431 { (*this)->write(new_val->to_uint64()); }
1433 { (*this)->write(new_val); }
1435 { (*this)->write(new_val); }
1515 *
this = v->to_uint64();
1520 *
this = v.to_uint64();
1525 *
this = v.to_uint64();
1539 const char* first_writer,
1540 const char* second_writer );
1589 *
this = (low_i < 64) ? src >> low_i : src >> 63;
1595 if ( low_i < src.
length() )
1596 *
this = src >> low_i;
1604 if ( low_i < src.
length() )
1613 if ( low_i < src.
length() )
1614 *
this = src >> low_i;
1622 *
this = (low_i < 64) ? src >> low_i : 0;
sc_in< T > & operator=(const sc_in< T > &)
void add_trace(sc_trace_file *tf, const std::string &name) const
void operator()(const sc_signal_in_if< T > &i)
virtual const char * kind() const
const sc_event & value_changed_event() const
const sc_event & default_event() const
virtual void end_of_elaboration()
virtual void bind(const sc_signal_in_if< T > &i)
sc_event_finder & value_changed() const
virtual const char * kind() const
void initialize(const T &t)
void add_trace(sc_trace_file *tf, const std::string &name) const
const sc_event & value_changed_event() const
sc_event_finder & value_changed() const
const sc_event & default_event() const
virtual void end_of_elaboration()
sc_inout< T > & operator=(const T &t)
virtual sc_dt::uint64 read_part(int left, int right) const
sc_int_part_if & operator=(const sc_int_part_if &)
virtual sc_dt::sc_int_base * part_read_target()
sc_int_part_if(const sc_int_part_if &)
virtual void write_part(sc_dt::uint64 v, int left, int right)
virtual sc_int_sigref & select_part(int left, int right)
void operator=(sc_dt::uint64 v)
void initialize(sc_int_part_if *if_p, int left_, int right_)
virtual void concat_set(sc_dt::int64 src, int low_i)
static sc_vpool< sc_int_sigref > m_pool
sc_int_sigref(const sc_int_sigref &a)
sc_out(inout_port_type &parent_)
sc_out(const char *name_)
sc_out(this_type &parent_)
sc_out(const char *name_, inout_if_type &interface_)
sc_out(const this_type &)
base_type::inout_port_type inout_port_type
sc_out(const char *name_, this_type &parent_)
base_type::inout_if_type inout_if_type
sc_dt::sc_int< W > data_type
sc_out< data_type > this_type
sc_inout< data_type > base_type
sc_out(inout_if_type &interface_)
sc_out(const char *name_, inout_port_type &parent_)
sc_out< T > & operator=(const T &t)
int vbind(sc_interface &i) override
void bind(sc_interface &)
sc_port_base(const char *name, int n, sc_port_policy p)
virtual const sc_event & value_changed_event() const =0
sc_signal_in_if< T > & operator=(const sc_signal_in_if< T > &)
virtual bool event() const =0
virtual const T & read() const =0
sc_signal< T, WRITER_POLICY > & operator=(const T &t)
sc_int_base & operator=(int_type v)
virtual const sc_core::sc_event & default_event() const
virtual const T & read() const
virtual const sc_core::sc_event & value_changed_event() const
virtual void register_port(sc_core::sc_port_base &port, const char *iface_type_name)
virtual bool event() const
virtual void write(const T &t)
virtual const char * kind() const
int vbind(sc_interface &i) override
sc_interface * get_interface()
sc_signal_in_if< T > * operator[](int n)
virtual void bind(sc_signal_inout_if< T > &i)
void operator()(sc_signal_inout_if< T > &i)
std::vector< sc_trace_params * > sc_trace_params_vec
sc_process_b * sc_get_curr_process_handle()
void sc_signal_invalid_writer(const char *name, const char *kind, const char *first_writer, const char *second_writer)
std::ostream & operator<<(std::ostream &os, sc_status s)
void sc_trace(sc_trace_file *tf, const sc_in< T > &i, const std::string &name)
const char * sc_gen_unique_name(const char *seed)
const char SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_[]
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH]
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
#define SC_REPORT_ERROR(msg_type, msg)
const std::string & name()