Jump to content
Khushi

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

@Khushi This is not a good solution since this way you enforce a quantum from a component maybe deep in the hierarchy. This sacrifies compatibility and makes reuse pretty difficult. You should follow the guidlines outlined by David.

Share this post


Link to post
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

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

×