Jump to content
pmatheusvinhas

Getting a bit from bus

Recommended Posts

Hey.

It's my first time with SystemC and I'm having the following problem:

I made a control matrix that generates a 12 bits control word (sc_bv<12> CON) and I'm trying to get the 10th bit of that word. On my top level cpp I did the following:

sc_signal<sc_bit<12> > bus_CON;

sc_bv<12> var_bus_CON;

var_bus_CON = bus_CON;

sc_signal<bool> busCON10;

busCON10 = var_bus_CON[10];

and after I'm connecting the ref. variable that I want with that previous signal:

programcounter.Ep( busCON10 );

And It's not working. My signal gives me hi impedance at all simulation time. A case that should happen when Ep = 0.

p.s: matrix.CON( bus_CON );

Did I make anything wrong?

Share this post


Link to post
Share on other sites

First thing you need to realize is that sc_signal<> is not a wire and it is not a data type. sc_signal<> is a channel with a non-blocking write and a blocking read. You cannot "connect" a variable to a signal. You have to explicitly make the transfer each time the value changes. There is no equivalent to a Verilog continuous assignment.

How do you know if a signal has changed? You have to explicitly watch/wait for the change using additional methods value_changed_event() or possibly posedge_event() if using sc_signal<bool> or sc_signal<sc_logic>.

Due to overloading of operator=(), the innocuous looking busCON10 = var_bus_CON[10] turns into:

busCON10.write(var_bus_CON[10].read()); which will not return a value until the end of the next delta cycle. Using a cout << busCON directly after this will yield the current delta's value.

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

×