Jump to content

Time resolution in SystemC 3.0.0


Julien

Recommended Posts

Hi SystemC experts.

SystemC 3.0.0 supports new time units: attoseconds, zeptoseconds and yoctoseconds.

As a consequence, the field time_resolution (which is a double) of the sc_time_params structure has a different unit compared to SystemC 2.3.4. The unit is yoctoseconds and no longer femtoseconds. The comment on line 475 of the file sc_time.h is thus probably wrong.

When sc_set_time_resolution is called with 1 second, time_resolution is set to 1e24.

The function sc_time_tuple::init() converts the time_resolution from double to sc_dt::int64: see sc_time.cpp line 84.

But the 64-bit sc_dt::int64 type is not large enough to contain values like 1e24, and this causes an overflow.

Example:

#include <systemc>

int sc_main(int, char **) {
  sc_core::sc_set_time_resolution(1, sc_core::SC_SEC);
  sc_core::sc_time t = sc_core::sc_time(1, sc_core::SC_SEC);
  sc_core::sc_time_tuple time_tuple(t);
  return 0;
}

The execution of the above code results into an assertion failure:


        SystemC 3.0.0-Accellera --- Sep 30 2024 14:19:10
        Copyright (c) 1996-2024 by all Contributors,
        ALL RIGHTS RESERVED

Warning: (W516) default time unit changed to time resolution
In file: kernel/sc_time.cpp:393

Fatal: (F4) assertion failed: tr == 1
In file: kernel/sc_time.cpp:90

Info: (I99) simulation aborted
Aborted (core dumped)

The above example works fine with SystemC 2.3.4.

The function sc_time_tuple::init() should probably be modified to use a larger type than sc_dt::int64.

Or maybe the computation of the scale could be done using the log10() function.

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