Amol Nikade Posted March 13, 2020 Report Share Posted March 13, 2020 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; } Quote Link to comment Share on other sites More sharing options...
Eyck Posted March 13, 2020 Report Share Posted March 13, 2020 sc_clock triggers itself based on the period and the (in your case default) constructor settings. The period is the default_time_unit. swami-cst and Amol Nikade 1 1 Quote Link to comment Share on other sites More sharing options...
David Black Posted March 13, 2020 Report Share Posted March 13, 2020 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 Amol Nikade 1 Quote Link to comment Share on other sites More sharing options...
Eyck Posted March 26, 2020 Report Share Posted March 26, 2020 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.... Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 27, 2020 Report Share Posted March 27, 2020 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: Function sc_simulation_time Function sc_set_default_time_unit Function sc_get_default_time_unit Function sc_start(double) Constructor sc_clock(const char*, double, double, double, bool) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.