Jump to content

Reading/Using an sc_out internally


Moberg

Recommended Posts

It is almost always stupid to try to read from your own output signal (right?)(I just got an infinite loop because it didn't update). I had code along these lines:

sc_out<bool> access1;
sc_out<bool> access2;

for(;
{
   while(!(condition1 || condition2))
   {
       wait(sensor_ev);
   }

   if(condition1)
   {
       access1 = true;
   }

   if(condition2)
   {
       access2 = true;
   }
   if(access1 or access2)
   {
       wait(5, SC_SEC);
       access1 = false;
       access2 = false;
   }
}

The last if could be changed to cond1 or 2 instead of access1 or 2 to remedy this. Any way to make the compiler or the simulator warn me on this kind of code? i.e. whenever an sc_out is being read?

Maybe there are cases when I want to read an output?

Link to post
Share on other sites

It can make sense to read an output. The classic example is to implement a counter, where you want to increment the count using

count = count + 1;

This will work in SystemC for an output signal port of an integer type.

Of course a counter has a clock.

I would guess your example is a case of combinational feedback, though I can't tell without knowing the sensitivity of your process,

regards

Alan

Link to post
Share on other sites

Archived

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

×
×
  • Create New...