Jump to content
Sign in to follow this  
Moberg

Reading/Using an sc_out internally

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?

Share this post


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

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
Sign in to follow this  

×