Jump to content

Why do not get a right value after operation with sc_time


Recommended Posts

Posted

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

 

Posted

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

 

Posted

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.

Posted

Logging in with a social accounts gives you access to all non-commercial simulators and some commercial simulators. If you want to use all the commercial simulators, you need a commercial/work e-mail address. For SystemC you don't need the commercial simulators.

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