Jump to content

Why do not get a right value after operation with sc_time


Recommended Posts

Hello everybody,

I have a statement that should return a half of a period, but instead it returns me a zero. Why?

struct PWM::states
    sc_core::sc_time period;

        sc_core::sc_time period(4.0,sc_core::SC_MS);


Thanks in advance


Link to comment
Share on other sites

It is unclear where your std::cout is located. The earliest I would expect is inside start_of_simulation() or as the first thing inside an SC_THREAD.

But your code has another issue. You are declaring two independent variables. One in the struct, and the other as a stack located version with an initial value of 4 ms.

Perhaps you meant to do something like: https://www.edaplayground.com/x/2c9j


Link to comment
Share on other sites

Hello Mr. Black,

Unfortunately I do not have today my code with me. I have created a module with SC_THREAD process. And in this module this process is made with constructor. I have probably understood my mistake but I can check it only on Monday when I will have access to my code. Thanks for the help!


How could I register on edaplayground? My e-mail is not accepted by a system check.

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.

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