Jump to content

sc_set_time_resolution fails due to "sc_time object(s) constructed"


Recommended Posts

Hi,

I have a complicated logger which uses sc_time().value() to print the value of the time. Currently everything is printed in ps resolution. My system at best runs in ms resolution.

I want to change the time resolution using sc_set_time_resolution. So I put sc_set_time_resolution(1,sc_core::SC_MS); as the very first line in my sc_main(argc, argv).

However the model fails in run-time due to "sc_time object(s) constructed". I'm not quite sure how on the very first line of sc_main() a sc_time object has been created.

Any insight is very much appreciated.

Also if my approach is incorrect in the first place, please let me know.

Link to post
Share on other sites

Very good point. If that's the case (which probably is), is there any way to ever setting time resolution?

I knew the compiler would take space for global/static variables and will zero out that piece of memory. Didn't think constructors for those objects will be called prior to sc_main execution! Trying a piece of code and sounds like that's the case. So back to my question, how can I ever set the time resolution assuming that I can't change the current structure of the code?

Link to post
Share on other sites

If you can avoid global variables at all cost. The will bite you more you think. If you need to have static global variables (e.g. for loggers or memory managers) use the Meyers-SIngleton. Those will be initialized upone first use which usually gives you some control over the live cycle. Another example can be found here: https://github.com/Minres/SystemC-Components/blob/master/incl/tlm/tlm_mm.h

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