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 post
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 post
Share on other sites

Hi Sachin,

 

For concatenation one of the arguments should be a vector.

 

 

bus_output = (bit2.read(), bit1.read(), bit0.read())

 

This will fail as all the arguments are sc_logic.

 

See LRM section 7.2.7

 

Regards,

Hans.

www.ht-lab.com

Link to post
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 post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...