Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation time computed incorrectly when clock period is different from 1ns #85

Open
dtesch opened this issue Jan 4, 2019 · 1 comment

Comments

@dtesch
Copy link

dtesch commented Jan 4, 2019

Dear Davide,

When the clock period is different from 1ns, the simulation time is computed incorrectly.

I made the following changes in the Main.cpp to to work around the issue:

- sc_start(GlobalParams::reset_time, SC_NS);

+ sc_start(GlobalParams::reset_time * GlobalParams::clock_period_ps, SC_PS);

- sc_start(GlobalParams::simulation_time, SC_NS);

+ sc_start(GlobalParams::simulation_time * GlobalParams::clock_period_ps, SC_PS);

- (sc_time_stamp().to_double() / GlobalParams::clock_period_ps - GlobalParams::reset_time >= GlobalParams::simulation_time)) {

+ (sc_time_stamp().to_double() / GlobalParams::clock_period_ps - GlobalParams::reset_time * GlobalParams::clock_period_ps >= GlobalParams::simulation_time * GlobalParams::clock_period_ps)) {

Is this correct?

Thank you!

@davidepatti
Copy link
Owner

Hi,
I delayed any modification of the code until now, because the default 1ns scenario worked fine.
you were correct for the first two suggestions, which have been applied in the latest version to support different clock_period_ps.

The last two are not correct, since the subtraction is done between clock cycles, and reset_time and simulation_time, despite their names, are expressed in clock cycles.

If you are still reading here, thank you very much and sorry for the late reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants