Khushi Posted July 24, 2019 Report Share Posted July 24, 2019 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 Quote Link to comment Share on other sites More sharing options...
Eyck Posted July 24, 2019 Report Share Posted July 24, 2019 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 Quote Link to comment Share on other sites More sharing options...
Khushi Posted July 24, 2019 Author Report Share Posted July 24, 2019 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 Quote Link to comment Share on other sites More sharing options...
David Black Posted July 25, 2019 Report Share Posted July 25, 2019 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 swami060 1 Quote Link to comment Share on other sites More sharing options...
Eyck Posted July 30, 2019 Report Share Posted July 30, 2019 @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. Quote Link to comment Share on other sites More sharing options...
Khushi Posted August 1, 2019 Author Report Share Posted August 1, 2019 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.