Jump to content
Amol Nikade

sc_clock Doubt

Recommended Posts

Hi All,

 

I have the below code, I am not understanding how clock instance will get time period/how it will be triggered ?

int sc_main( int, char* [] )
{
    sc_clock      clock;
    dpipe<atom,4> delay("pipe");
    Reader        reader("reader");
    Writer        writer("writer");

    delay.m_clk(clock);

    reader.m_clk(clock);
    reader.m_from_pipe(delay.m_out);

    writer.m_clk(clock);
    writer.m_to_pipe(delay.m_in);

    sc_start(10, SC_NS);

    return 0;
}
 

Share this post


Link to post
Share on other sites

There is no default_time_unit in SystemC; however, the sc_clock default constructor does supply a default value of 1 ns. Be careful you don't set the time resolution larger than 1 ns, if you are going to use the default time. You could of course be more explict:

sc_time clock{ "clock", 1, SC_NS }; //< assumes C++11 or better and using namespace sc_core

 

Share this post


Link to post
Share on other sites

Actually there is a default time unit in sc_time.h:

// ----------------------------------------------------------------------------
//  STRUCT : sc_time_params
//
//  Struct that holds the time resolution and default time unit.
// ----------------------------------------------------------------------------

struct SC_API sc_time_params
{
    double time_resolution;		// in femto seconds
    bool   time_resolution_specified;
    bool   time_resolution_fixed;

    sc_time::value_type default_time_unit;		// in time resolution
    bool                default_time_unit_specified;

    sc_time_params();
    ~sc_time_params();
};

Instantiating it you get the default values....

Share this post


Link to post
Share on other sites

 

22 hours ago, Eyck said:

Actually there is a default time unit in sc_time.h

 

Looking at the source code of any SystemC implementation is sometimes misleading. Check IEEE 1666-2011, Annex C (deprecated features), item (n):

Quote

n) Default time units and all the associated functions and constructors, including:

  1. Function sc_simulation_time
  2. Function sc_set_default_time_unit
  3. Function sc_get_default_time_unit
  4. Function sc_start(double)
  5. Constructor sc_clock(const char*, double, double, double, bool)

 

Share this post


Link to post
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...