166#if !defined(SC_SIGNAL_UINT_H)
167#define SC_SIGNAL_UINT_H
169#if ( !defined(_MSC_VER) || _MSC_VER > 1200 )
170# define SC_TEMPLATE template<int W>
172# define SC_TEMPLATE template<> template<int W>
244 virtual bool event()
const = 0;
327 explicit inline sc_signal(
const char* name_);
331 inline bool base_event()
const;
333 inline const sc_event& base_value_changed_event()
const;
337 virtual inline const char*
kind()
const;
338 virtual inline void update();
347 virtual inline sc_dt::uint64 read_part(
int left,
int right)
const;
349 virtual inline void write_part(
sc_dt::uint64 v,
int left,
int right);
352 virtual inline bool event()
const;
366 inline void operator = (
const this_type& new_val );
367 inline void operator = (
const char* new_val );
373 inline void operator = (
unsigned int new_val ) ;
374 inline void operator = (
unsigned long new_val );
375 inline void operator = (
unsigned short new_val );
384 virtual inline void concat_set(
sc_dt::int64 src,
int low_i);
388 virtual inline void concat_set(
sc_dt::uint64 src,
int low_i);
409 mutable sc_event* m_changed_event_p;
420 return simcontext()->delta_count() == m_event_delta + 1;
434 if ( !m_changed_event_p ) m_changed_event_p =
new sc_event;
435 return *m_changed_event_p;
442# if defined(DEBUG_SYSTEMC)
459 if( m_writer_p == 0 )
461 m_writer_p = writer_p;
463 else if( m_writer_p != writer_p )
466 m_writer_p->name(), writer_p->name() );
487 base_write(src >> low_i);
491 base_write( (src < 0 ) ? src >> 63 : 0 );
497 const sc_dt::sc_lv_base& src,
int low_i)
499 sc_dt::sc_unsigned tmp(src.
length());
501 base_write( tmp.to_uint64() );
506 const sc_dt::sc_signed& src,
int low_i)
508 base_write( (src >> low_i).to_uint64());
513 const sc_dt::sc_unsigned& src,
int low_i)
515 base_write( (src >> low_i).to_uint64());
522 base_write( ( low_i < 64 ) ? src >> low_i : 0 );
529 {
return base_value_changed_event(); }
534 {
return base_event(); }
538inline const sc_dt::sc_uint<W>&
566 (
int left,
int right)
571 result_p->initialize(
this, left, right);
585 return operator () (bit,bit);
590 const this_type& new_val )
595 { base_write(new_val); }
600 { m_new_val = sc_dt::sc_uint<64>(new_val); request_update(); }
641 const sc_dt::sc_generic_base<T>& new_val )
642 { base_write(new_val->to_uint64()); }
647 const sc_dt::sc_signed& new_val )
648 { base_write(new_val.to_uint64()); }
653 const sc_dt::sc_unsigned& new_val )
654 { base_write(new_val.to_uint64()); }
658 const sc_dt::sc_bv_base& new_val )
659 { base_write( (sc_dt::sc_uint<W>)new_val ); }
663 const sc_dt::sc_lv_base& new_val )
664 { base_write( (sc_dt::sc_uint<W>)new_val ); }
689 std::string nm( if_typename_ );
692 if( m_output_p != 0 )
695 m_output_p->name(), port_.name() );
700 if ( &port_ && if_typename_ ) {}
708 m_changed_event_p(0),
717 m_changed_event_p(0),
726 if ( m_changed_event_p )
delete m_changed_event_p;
733 if ( m_changed_event_p )
738 if ( old_val != this->m_val )
740 m_changed_event_p->notify_delayed();
741 m_event_delta = simcontext()->delta_count();
753 {
return base_value_changed_event(); }
768 const sc_dt::sc_uint<W>& value )
769 { base_write( value); }
776 result_p->initialize(
this, left, right);
789 new_v = (m_new_val & keep) | ((v << right) & ~keep);
803class sc_in<sc_dt::sc_uint<W> > :
804 public sc_port<sc_signal_in_if<sc_dt::sc_uint<W> >, 1,
805 SC_ONE_OR_MORE_BOUND>,
806 public sc_dt::sc_value_base
812 typedef sc_dt::sc_uint<W> data_type;
813 typedef sc_signal_in_if<sc_dt::sc_uint<W> > if_type;
817 typedef if_type in_if_type;
818 typedef base_type in_port_type;
819 typedef sc_signal_inout_if<sc_dt::sc_uint<W> > inout_if_type;
820 typedef sc_inout<sc_dt::sc_uint<W> > inout_port_type;
826 void bind(
const in_if_type& interface_ )
830 void bind( in_port_type& parent_ )
834 void bind( inout_port_type& parent_ )
841 virtual inline int vbind( sc_interface& interface_ )
847 in_port_type* in_parent =
dynamic_cast<in_port_type*
>( &parent_ );
848 if( in_parent != 0 ) {
852 inout_port_type* inout_parent =
dynamic_cast<inout_port_type*
>( &parent_ );
853 if( inout_parent != 0 ) {
866 : base_type(), m_traces( 0 )
869 explicit sc_in(
const char* name_ )
870 : base_type( name_ ), m_traces( 0 )
873 explicit sc_in(
const in_if_type& interface_ )
874 : base_type( const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
877 sc_in(
const char* name_,
const in_if_type& interface_ )
878 : base_type( name_, const_cast<in_if_type&>( interface_ ) ), m_traces( 0 )
881 explicit sc_in( in_port_type& parent_ )
882 : base_type( parent_ ), m_traces( 0 )
885 sc_in(
const char* name_, in_port_type& parent_ )
886 : base_type( name_, parent_ ), m_traces( 0 )
889 explicit sc_in( inout_port_type& parent_ )
890 : base_type(), m_traces( 0 )
893 sc_in(
const char* name_, inout_port_type& parent_ )
894 : base_type( name_ ), m_traces( 0 )
897 sc_in( this_type& parent_ )
898 : base_type( parent_ ), m_traces( 0 )
901 sc_in(
const char* name_, this_type& parent_ )
902 : base_type( name_, parent_ ), m_traces( 0 )
915 sc_dt::sc_uint_bitref_r
operator [] (
int i )
const
916 {
return (*this)->read()[
i]; }
917 sc_dt::sc_uint_bitref_r bit(
int i )
const
918 {
return (*this)->read()[
i]; }
919 sc_dt::sc_uint_subref_r
operator () (
int left,
int right )
const
920 {
return (*this)->read()(left,right); }
921 sc_dt::sc_uint_subref_r range(
int left,
int right )
const
922 {
return (*this)->read()(left,right); }
930 {
return (*this)->value_changed_event(); }
936 {
return (*this)->value_changed_event(); }
941 const sc_dt::sc_uint<W>&
read()
const
942 {
return (*this)->read(); }
950 {
return (*this)->event(); }
957 return *
new sc_event_finder_t<in_if_type>(
958 *
this, &in_if_type::value_changed_event );
966 {
return (*this)->read().and_reduce(); }
968 {
return (*this)->read().nand_reduce(); }
970 {
return (*this)->read().nor_reduce(); }
972 {
return (*this)->read().or_reduce(); }
974 {
return (*this)->read().xnor_reduce(); }
976 {
return (*this)->read().xor_reduce(); }
985 if( m_traces != 0 ) {
986 for(
unsigned int i = 0;
i < m_traces->size(); ++
i ) {
987 sc_trace_params*
p = (*m_traces)[
i];
994 virtual inline const char*
kind()
const
999 void add_trace( sc_trace_file* tf_,
const std::string& name_ )
const
1002 if( m_traces == 0 ) {
1005 m_traces->push_back(
new sc_trace_params( tf_, name_ ) );
1012 virtual inline int concat_length(
bool* xz_present_p)
const
1013 {
return (*this)->read().concat_length( xz_present_p ); }
1015 {
return (*this)->read().concat_get_uint64(); }
1016 virtual inline bool concat_get_ctrl(
1018 {
return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1019 virtual inline bool concat_get_data(
1021 {
return (*this)->read().concat_get_data(dst_p, low_i); }
1024 void remove_traces()
const
1026 if( m_traces != 0 ) {
1027 for(
int i = m_traces->size() - 1; i >= 0; -- i ) {
1028 delete (*m_traces)[
i];
1049 static data_type dummy;
1060 a.read().print( os );
1075 public sc_port<sc_signal_inout_if<sc_dt::sc_uint<W> >, 1,
1076 SC_ONE_OR_MORE_BOUND>,
1088 typedef if_type inout_if_type;
1089 typedef base_type inout_port_type;
1095 void bind(
const inout_if_type& interface_ )
1097 void operator () (
const inout_if_type& interface_ )
1099 void bind( inout_port_type& parent_ )
1106 virtual inline int vbind( sc_interface& interface_ )
1112 inout_port_type* inout_parent =
dynamic_cast<inout_port_type*
>( &parent_ );
1113 if( inout_parent != 0 ) {
1126 : base_type(), m_init_val_p(0), m_traces( 0 )
1129 explicit sc_inout(
const char* name_ )
1130 : base_type( name_ ), m_init_val_p(0), m_traces( 0 )
1133 explicit sc_inout( inout_if_type& interface_ )
1134 : base_type( interface_ ), m_init_val_p(0), m_traces( 0 )
1137 sc_inout(
const char* name_, inout_if_type& interface_ )
1138 : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 )
1141 explicit sc_inout( inout_port_type& parent_ )
1142 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1145 sc_inout(
const char* name_, inout_port_type& parent_ )
1146 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1150 : base_type( parent_ ), m_init_val_p(0), m_traces( 0 )
1153 sc_inout(
const char* name_, this_type& parent_ )
1154 : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 )
1167 sc_dt::sc_uint_bitref_r
operator [] (
int i )
const
1168 {
return (*this)->read()[
i]; }
1169 sc_dt::sc_uint_bitref_r bit(
int i )
const
1170 {
return (*this)->read()[
i]; }
1172 {
return (*this)->select_part(i,i); }
1173 sc_uint_sigref& bit(
int i )
1174 {
return (*this)->select_part(i,i); }
1175 sc_dt::sc_uint_subref_r
operator () (
int left,
int right )
const
1176 {
return (*this)->read()(left,right); }
1177 sc_dt::sc_uint_subref_r range(
int left,
int right )
const
1178 {
return (*this)->read()(left,right); }
1179 sc_uint_sigref&
operator () (
int left,
int right )
1180 {
return (*this)->select_part(left,right); }
1181 sc_uint_sigref& range(
int left,
int right )
1182 {
return (*this)->select_part(left,right); }
1190 {
return (*this)->value_changed_event(); }
1196 {
return (*this)->value_changed_event(); }
1201 const sc_dt::sc_uint<W>&
read()
const
1202 {
return (*this)->read(); }
1210 {
return (*this)->event(); }
1217 return *
new sc_event_finder_t<inout_if_type>(
1218 *
this, &inout_if_type::value_changed_event );
1226 {
return (*this)->read().and_reduce(); }
1228 {
return (*this)->read().nand_reduce(); }
1230 {
return (*this)->read().nor_reduce(); }
1232 {
return (*this)->read().or_reduce(); }
1234 {
return (*this)->read().xnor_reduce(); }
1236 {
return (*this)->read().xor_reduce(); }
1245 if( m_init_val_p != 0 ) {
1247 delete m_init_val_p;
1250 if( m_traces != 0 ) {
1251 for(
unsigned int i = 0;
i < m_traces->size(); ++
i ) {
1252 sc_trace_params*
p = (*m_traces)[
i];
1259 virtual inline const char*
kind()
const
1260 {
return "sc_inout"; }
1264 inline void initialize(
const sc_dt::sc_uint<W>& value_ )
1268 iface->write( value_ );
1270 if( m_init_val_p == 0 ) {
1273 *m_init_val_p = value_;
1279 void add_trace( sc_trace_file* tf_,
const std::string& name_ )
const
1282 if( m_traces == 0 ) {
1285 m_traces->push_back(
new sc_trace_params( tf_, name_ ) );
1292 virtual inline int concat_length(
bool* xz_present_p)
const
1293 {
return (*this)->read().concat_length( xz_present_p ); }
1295 {
return (*this)->read().concat_get_uint64(); }
1296 virtual inline bool concat_get_ctrl(
1298 {
return (*this)->read().concat_get_ctrl(dst_p, low_i); }
1299 virtual inline bool concat_get_data(
1301 {
return (*this)->read().concat_get_data(dst_p, low_i); }
1302 virtual inline void concat_set(
sc_dt::int64 src,
int low_i)
1303 { *
this = (src >> ((low_i < 64) ? low_i : 63)); }
1305 virtual inline void concat_set(
const sc_dt::sc_lv_base& src,
int low_i)
1306 {
if (low_i < 64) *
this = src >> low_i;
else *
this = 0; }
1308 virtual inline void concat_set(
const sc_dt::sc_signed& src,
int low_i)
1309 { *
this = (src >> low_i); }
1310 virtual inline void concat_set(
const sc_dt::sc_unsigned& src,
int low_i)
1311 { *
this = (src >> low_i); }
1312 virtual inline void concat_set(
sc_dt::uint64 src,
int low_i)
1318 inline void operator = (
const this_type& new_val )
1320 inline void operator = (
const char* new_val )
1321 { (*this)->write( this_type(new_val) ); }
1323 { (*this)->write(new_val); }
1332 inline void operator = (
unsigned int new_val )
1334 inline void operator = (
unsigned long new_val )
1336 inline void operator = (
unsigned short new_val )
1338 template<
typename T>
1339 inline void operator = (
const sc_dt::sc_generic_base<T>& new_val )
1340 { (*this)->write(new_val->to_uint64()); }
1341 inline void operator = (
const sc_dt::sc_signed& new_val )
1342 { (*this)->write(new_val.
to_uint64()); }
1343 inline void operator = (
const sc_dt::sc_unsigned& new_val )
1344 { (*this)->write(new_val.
to_uint64()); }
1345 inline void operator = (
const sc_dt::sc_bv_base& new_val )
1346 { (*this)->write((sc_dt::sc_uint<W>)new_val); }
1347 inline void operator = (
const sc_dt::sc_lv_base& new_val )
1348 { (*this)->write((sc_dt::sc_uint<W>)new_val); }
1350 inline void write(
const sc_in<sc_dt::sc_uint<W> >& new_val )
1352 inline void write(
const sc_inout<sc_dt::sc_uint<W> >& new_val )
1354 inline void write(
const sc_dt::sc_uint<W>& new_val )
1358 void remove_traces()
const
1360 if( m_traces != 0 ) {
1361 for(
int i = m_traces->size() - 1; i >= 0; -- i ) {
1362 delete (*m_traces)[
i];
1383 static data_type dummy;
1394 a.read().print( os );
1468 { (*this)->write(
this_type(new_val) ); }
1470 { (*this)->write(new_val); }
1485 template<
typename T>
1487 { (*this)->write(new_val->to_uint64()); }
1489 { (*this)->write(new_val); }
1491 { (*this)->write(new_val); }
1571 *
this = v->to_uint64();
1576 *
this = v.to_uint64();
1581 *
this = v.to_uint64();
1636 *
this = (low_i < 64) ? src >> low_i : src >> 63;
1642 if ( low_i < src.
length() )
1643 *
this = src >> low_i;
1651 if ( low_i < src.
length() )
1660 if ( low_i < src.
length() )
1661 *
this = src >> low_i;
1669 *
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)
sc_out(const char *name_, inout_port_type &parent_)
sc_dt::sc_uint< W > data_type
sc_out(inout_if_type &interface_)
base_type::inout_if_type inout_if_type
sc_out(inout_port_type &parent_)
sc_out(this_type &parent_)
base_type::inout_port_type inout_port_type
sc_out(const this_type &)
sc_out(const char *name_)
sc_inout< data_type > base_type
sc_out< data_type > this_type
sc_out(const char *name_, this_type &parent_)
sc_out(const char *name_, inout_if_type &interface_)
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)
virtual sc_dt::sc_uint_base * part_read_target()
sc_uint_part_if(const sc_uint_part_if &)
virtual sc_uint_sigref & select_part(int left, int right)
sc_uint_part_if & operator=(const sc_uint_part_if &)
virtual void write_part(sc_dt::uint64 v, int left, int right)
virtual sc_dt::uint64 read_part(int left, int right) const
virtual void concat_set(sc_dt::int64 src, int low_i)
void operator=(sc_dt::uint64 v)
void initialize(sc_uint_part_if *if_p, int left_, int right_)
virtual ~sc_uint_sigref()
static sc_vpool< sc_uint_sigref > m_pool
sc_uint_sigref(const sc_uint_sigref &a)
sc_uint_base & operator=(uint_type v)
sc_uint_subref_r(const sc_uint_subref_r &init)
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)
static sc_process_b * sc_get_current_process_b()
std::vector< sc_trace_params * > sc_trace_params_vec
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()