Jump to content

Assigning value to parametrized signals

Recommended Posts

Consider the following signal:


sc_signal<sc_lv<size>  > aux;


Suppose "size" is something passed to the module through the use of template parametrization. How can I set the value of this guy to 0b0000....0000 or 0b1111....111 ?


In VHDL there is the OTHERS keyword:


aux <= (OTHERS => '1');


What about systemC? How can I achieve the same effect?

Share this post

Link to post
Share on other sites



Achieving the full flexibility of VHDL aggregates is very hard in SystemC. But if only OTHERS is your goal, there are workarounds. 


If you know the length of aux, you can use the sc_lv constructor with initialization:

sc_lv<7> tmp('1');


A more general approach is to use a template function: 

template < int W > 
init_lv(sc_signal_inout_if < sc_lv < W > > & sig, const char val)
  sig.write( sc_lv<W>(val) );




Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now