Jump to content

what is default time unit in systemC


milind.shende5

Recommended Posts

Hello All, 

this could be very primitive question, but haunts me from some time.

 

what is default time unit in systemC and how it can be set ?

In case of setting clock in the top level module, the clock period can be defined using number of time steps, But I don't know what is the time unit of my module.

Where the default time unit can be seen ???  

 

I also want to know this for using advanced simulation controls.

 

thanks in advance,

regards,

 

Milind 

Link to comment
Share on other sites

Thanks for the replies. 

in SystemC Version 2.0 User's Guide, on page 80, the description about Clock is given. In the example on the same page, the clock is defined as follows

 

sc_clock ck1("ck1", 20, 0.5, 0, true);

 

It states in the description that "This declaration will create a clock object named clock with a period of 20 time units, a duty cycle of 50%, the first edge will occur at 2 time units, and the first value will be true."

 

In the given example, the time resolution is not specified, that means as per the IEEE std 1666-2011, page 102, the  default time resolution is 1 ns and above clock declaration has clock period of 20 ns. is this correct ?

 

and if I want to set other clock period, I have two options

 

1st Option: sc_clock clk1(clk1, 20, SC_US, 0.5, 0, true);

 

2nd Option: define time resolution in constructor before clock definition sc_set_time_resolution (1.0, SC_US);

and then define the clock as sc_clock clk1(clk1, 20, 0.5, 0, true);

 

what you say, is this correct?

 

thanks, 

 

Milind.

Link to comment
Share on other sites

As per my understanding:

 

sc_clock ck1("ck1", 20, 0.5, 0, true);
It states in the description that "This declaration will create a clock object named clock with a period of 20 time units, a duty cycle of 50%, the first edge will occur at 2 time units, and the first value will be true."

 

As per your declaration for clock object sc_clock ck1("ck1", 20,SC_NS,  0.5, 0,SC_NS,  true); the first edge will occur at 0 not at 2 time units.

 

In the given example, the time resolution is not specified, that means as per the IEEE std 1666-2011, page 102, the default time resolution is 1 ns and above clock declaration has clock period of 20 ns. is this correct ?

Yes , its correct.

 

1st Option: sc_clock clk1(clk1, 20, SC_US, 0.5, 0, true);

2nd Option: define time resolution in constructor before clock definition sc_set_time_resolution (1.0, SC_US);
and then define the clock as sc_clock clk1(clk1, 20, 0.5, 0, true);

 

1st  Option: will produce the clock of time period 20 micro seconds,

2nd Options: I am not sure that whether it should work without specifying the time unit for clock period. Ideally , it should give an syntax error i guess for missing the time unit argument for clock period.

 

Correct me if I am wrong. ;)

 

----

Karandeep

Link to comment
Share on other sites

Thanks for the replies. 

in SystemC Version 2.0 User's Guide, on page 80, the description about Clock is given. In the example on the same page, the clock is defined as follows

That is an obsolete document, I do not recommend using it. It was never a standard.

 

Use the IEEE 1666-2011 standard. If you read that standard, there is a list of deprecated features, including on page 583 the information that default time unit is deprecated.

 

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)

 

sc_clock ck1("ck1", 20, 0.5, 0, true);

 

It states in the description that "This declaration will create a clock object named clock with a period of 20 time units, a duty cycle of 50%, the first edge will occur at 2 time units, and the first value will be true."

 

In the given example, the time resolution is not specified, that means as per the IEEE std 1666-2011, page 102, the  default time resolution is 1 ns and above clock declaration has clock period of 20 ns. is this correct ?

 

No, there is no default time unit. You are quoting an obsolete document which was never a standard.

 

However there is a default constructor for sc_clock, which sets the default clock *period* to 1 ns. So if you wrote

 

sc_clock clock;  // name is "clock_0", period 1, SC_NS, posedge_first true, delay to first edge 0, SC_NS

 

See the LRM description of sc_clock, p149ff.

 

There is a default time *resolution* of 1 ps. What that means is if you say

 

wait(1.0001, SC_NS);

 

you will lose the fractional part of the time delay as it is less than 1 ps. You can change the *resolution* using sc_set_time_resolution() (see page 102).

 

and if I want to set other clock period, I have two options

 

1st Option: sc_clock clk1(clk1, 20, SC_US, 0.5, 0, true);

 

Yes that works.

 

2nd Option: define time resolution in constructor before clock definition sc_set_time_resolution (1.0, SC_US);

and then define the clock as sc_clock clk1(clk1, 20, 0.5, 0, true);

No that doesn't work. You still have to use 20, SC_US with SystemC 2.1, 2.2, 2.3 (LRM 1666-2005 1666-2011).

 

There is no default time unit.

 

Don't mix up the time resolution (the minimum representable time value) and default time unit (a deprecated feature of SystemC before it was standardised).

 

regards

Alan

 

what you say, is this correct?

 

thanks, 

 

Milind.

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