Jump to content

tlm model with clocks & code sample


Recommended Posts

Hi,

 

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,

Shubham

 

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.

 

 

  

initiator.h.txt

main.cpp.txt

target.h.txt

image.png

initiator2.h.txt

target2.h.txt

top.h.txt

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
  wait(clk.posedge_event());
  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 ,

image.png.14e80f33abbf330cc228611a2c889ab4.png

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.

 

Regards,

Shubham

 

 

 

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.

BR

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