Jump to content

Where to set the global quantum value


Recommended Posts

Hi

While modeling an initiator can we assume that the top.cpp/main.cpp somewhere have set the global quantum value ?

I see a case where an initiator is using quantum keeper to sync on multiple of global quantum and global quantum is not set in main.cpp and due to this the initiator is syncing after every b_transport call because the need_sync() always returns true because the global quantum is not set and it defaults is 0.

I can set the global quantum explicitly in the initiators but to what value, as each initiator is developed independently and can set different values global quantum values and also it will override the global quantum defined at the top.

Is there any strict guide line we need to follow ?

Thanks

Khushi

Link to comment
Share on other sites

Well, the global quantum is as the name says global. So there is only one variable and it should be set at on central point. In many cases this is sc_main but it might also be some configuration unit. This depends on the requirement and implementation.

I would refrain to set it in the initiators as then you dont know which one is the last one to set the quantum esp.if they want to set it to different values. Usually the leads to hard-to-debug problems.

Best regards

Link to comment
Share on other sites

Hi Eyck

This is clear. But if the initiator is using quantum keeper and the global quantum is not set in sc_main, then there will be a lot to context switching in that initiator because it get the global quantum as 0.

Can we check the global quantum in the initiator (with get_global_quantum) and if it is 0, set it explicitly in the initiator constructor ? Is this a good modeling recommendation ?

Thanks

Khushi

Link to comment
Share on other sites

You should have a top level. If you don’t, create one and instantiate everything there. Set the global quantum in your top level module st end_of_elaboration and reset local quantum’s at start_of_simulation. Set a default and allow for override. You can obtain the override value to use at run time from any of:

- command-line argument using sc_argv()

- read a file or database if it exists 

- Enviroment variable set prior to invocation

- user input prompt

 

Link to comment
Share on other sites

Thanks. I was following the examples/tlm/lt_temporal_decouple example in SystemC package and there the global quantum is set in initiator constructor instead of main. This is why I asked this particular question whether the initiator is allowed to set the global quantum.

May be we can update this example to put the global quantum setting in sc_main.

Thanks

Khushi

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