Timescale issue

HI ,

I am compiling pll model which has internal clock generation::
// internal clock //
always
#(0.5) internalclk = !internalclk; // an internal 1GHz clock.

with timescale::1ns/100fs

The clock should generate 1Ghz, in my simulation it is generating 500Mhz.

in tb top, time scale is given as::`timescale 1ns/1ns

Also in Makefile i give this option as timescale::
VLOGAN_OPTS += -timescale=1ns/1ns +define+simulation_mode_timings
VLOGAN_OPTS += -unit_timescale=1ns/1ns

Quick help is really appreciated.

Thanks,
Taahir

The timescale contains timeunit and timeprecision elements to specify the unit of measurement for time and precision of time in specific design elements. The time_precision argument shall be at least as precise as the time_unit argument; it cannot specify a longer unit of time than time_unit.

Referring to IEEE 1800-2012 section 13.4.2, changing timescales in modules could cause very different simulation results, depending on timevalues specified in different modules.

If multiple timescales are provided, the last timescale persists. Hence it depends on the compilation order of files. SystemVerilog provides timeprecision keyword to set the precision of time within a module. Use timeprecision 100fs; in your module to override the default timeprecision.

So, here you might want to use timescale as 1ns/100ps. Also, the clock toggling should be done using ~ (tilde) operator. The ! (negation) operator is boolean negation, while ~ (tilde) is bitwise negation.

I have created an example at EDAPlayground Link. Observe that clk is generated using default timeprecision (that is, 1ns), while internalclk is generated using overridden timeprecision (that is, 100fs), thereby giving 1GHz clock frequency.

In reply to sharvil111:

Also, the clock toggling should be done using ~ (tilde) operator. The ! (negation) operator is boolean negation, while ~ (tilde) is bitwise negation.

There is no difference between the two operators when dealing with a single bit.

In reply to dave_59:

Oh yes. Thanks for the pointers. Just an old coding practice.

In reply to sharvil111:

Awesome, it worked.

regards,
Taahir