Jump to content

Why do not get a right value after operation with sc_time


Retvisan

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;

    states()
    {
        sc_core::sc_time period(4.0,sc_core::SC_MS);
    }

};
std::cout<<s.period/2.0;

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!

P.S.

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.

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