Jump to content

sc_signal concatenation


gsachin

Recommended Posts

Hi,

I have a set of signals defined as:

sc_signal<sc_logic>  bit0;
sc_signal<sc_logic>  bit1;
sc_signal<sc_logic>  bit2;

I have another buses defined as

sc_signal<sc_bv<3> > bus_input;
sc_signal<sc_bv<3> > bus_output;

I would like to do this operation:

bus_output = bit(i) & bus_input  where i = 0,1,2

For this, I am writing this code:

bus_output = (bit2.read(), bit1.read(), bit0.read()) & bus_input.read();

But this does not work. Compile is fine but only the bus_output[0] is correctly being written. other bits are not getting updated.

Can you please let me know what is the issue?

Thanks,
Sachin
 

Link to comment
Share on other sites

I'm not sure what's wrong - but it's probably better to use a temporary variable, e.g.

// SC_METHOD
void proc() {
     sc_lv<3> bv3 = (bit2.read(), bit1.read(), bit0.read());
     bus_output.write ( bv3 & bus_input.read() );
}

Can you try that and see if it works?

If it doesn't, then something else is wrong.

 

regards

Alan

Link to comment
Share on other sites

Hi,

I have a set of signals defined as:

sc_signal<sc_logic>  bit0;

sc_signal<sc_logic>  bit1;

sc_signal<sc_logic>  bit2;

I have another buses defined as

sc_signal<sc_bv<3> > bus_input;

sc_signal<sc_bv<3> > bus_output;

I would like to do this operation:

bus_output = bit(i) & bus_input  where i = 0,1,2

For this, I am writing this code:

bus_output = (bit2.read(), bit1.read(), bit0.read()) & bus_input.read();

But this does not work. Compile is fine but only the bus_output[0] is correctly being written. other bits are not getting updated.

Can you please let me know what is the issue?

Thanks,

Sachin

 

Hello Sir,

there appears to be some confusion here.

You have defined :

sc_signal<sc_bv<3> > bus_output;

that is bus_output is an object of type sc_core::sc_signal,

and the template type is sc_dt::sc_bv<3>.

 

So, ONLY bit vectors of size 3 can be written into signal

channel bus_output; To do that, declare/define a bit vector

f size 3, concatenate all bits as desired, and then write that

bit vector into the output sugnal channel. Hope that helps.

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.

×
×
  • Create New...