Jump to content

Assigning value to parametrized signals


ecco
 Share

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?

Link to comment
Share on other sites

Hi. 

 

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');
aux.write(tmp);

 

A more general approach is to use a template function: 

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

 

Greetings 

Ralph

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...