Jump to content

How to handle single-cycle inter-thread depedencies?


richpodraza

Recommended Posts

I hope this description makes sense. In the model I'm working on (which is a port of an existing model in SystemVerilog), there are two threads (rx and tx) that modify some shared flags. I am working on getting my timing as close to the SystemVerilog model as possible, and currently there is a problem of falling behind a few cycles because each cycle, the rx runs after the tx, where in the SV model the tx runs after the rx.

 

I believe that conceptually both threads are supposed to executing concurrently, so I know it may not make good sense to think of one thread executing before the other. So I am wondering what the best way to approach this is.

 

Is there a way to change the order in which threads sensitive to the same clock signal are executed? OR, do I need to concentrate on the shared data and communicate between threads with events?

Link to comment
Share on other sites

The SystemC scheduler is  co-operative (though there are now ways in SystemC 2.3.0 for one thread to kill another), i.e. one thread must suspend before another can run. The danger with shared variables is that your code is not deterministic - not only can thread execution order be different between SV and SystemC, it can be different between two implementations of SystemC (or two implementations of SV for that matter).

 

So if you require deterministic simulation with shared variables, you should control the order of execution of your threads explicitly, using e.g. events,

 

regards

Alan

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...