Jump to content

tlm model with clocks & code sample

Recommended Posts



I have declared and defined the clock in my example and able to generate and transport the transactions successfullly.

As its is a blocking transport interface of tlm,so we are using wait statement.

But what i observed here is, i am not able to control the triggering of process by using clocks for both the modules.Thiugh , i am able to controll the thread awakening by using delay statements.

What if i want to use clocks to controll the trigger ,thats why i had put them in the sensitivity list.

Please let me know,what would be my approach for the triggering by clocks.?

do i need to look out for other interface method in tlm or should i go back to system c interface approach ? 

Please help me out with this.


Thanks & regards,



Ps:- I am attaching the code along with the block diagram below,please let me know the solution for it.The block diagram represents 2 blocks of initiator and target modules with clock supplied.

      Iam able to compile and run the code succesfully,if you get any error while compiling i might have done mistake while copying.











Link to comment
Share on other sites

You should consult the LRM again.:SC_THREAD does not have a sensitivity list. Moreover you create a memory leak creating the transaction object using new and not deleting it. And your thread ends after 10 accesses.

Basically you need to wait for the clock explicitly

while (1) {
  // wait for the rising edge
  tlm::tlm_generic_payload trans;
  // setup the transaction
  // execute the access
  i_socket->b_transport(*trans, delay);

In your solution the loop in your threads are based on timed delays hence it is not reactiong on your clocks at all.

Best regards

Link to comment
Share on other sites

Hi @eyck,

As far as lrm is concerned with,i can see sensitive list in sc_thread.It is as follows ,


So, i had missed this concept of posedge event.

When i included pos_edge  event ,i was able to controll the process.

Just to cross check ,i included only wait() without any arguments in second thread,during that time my second thread was not running.So ,process is controlled by clock now.

 Yes, i had forgotten to delete the pointer created payload.Thank you for pointing it out.







Link to comment
Share on other sites

My fault, SC_THREAD has a sensitivity list and you can call wait() for the default event. In my experience -and this guided my answer- it is better to have no sensitivity list and wait explicitly for events.

When specifying a port in the sensitivity list you need to use an event finder (with .pos()) as the port is not bound yet and hence does not have an event associated. In the thread itself you can use the pos_edge event. So your code shown above is correct.


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.

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