Set_global_timeout() doesn't obey time units

Hi there,

I’ve just tried to use set_global_timeout() in my testbench and noticed some strange behaviour. I was hoping someone could point out the gotcha that I’m missing.

I assumed that in order to set a watchdog timeout value of 1us, I would need to add the following line to my build() function:
set_global_timeout(1us);

However, this doesn’t have the desired effect. Instead the time units don’t seem to be being obeyed and are out by a factor of 1000.

set_global_timeout(1s) results in a timeout after 1ms.
set_global_timeout(1ms) results in a timeout after 1us. set_global_timeout(1us) results in a timeout after 1ns.
set_global_timeout(1ns) results in a timeout after 1ps.
set_global_timeout(1000) results in a timeout after 1ns.
set_global_timeout(1000000) results in a timeout after 1us.

Thanks, Shareef.

Communicating time values across multiple timescale domains has been a gotchain Verilog since day one. Timescales only apply to scaling of literal time values, not values of variables or passed arguments. Therefore, you should always use a literal time value in any expression involving time to a normalized time unit.

Unfortunately, they didn’t do this inside the OVM library. So if your OVM package is compiled with a default of timescale of 1ps, then you should do this to normalize it :

set_global_timeout(1us/1ps);

Dave Rich

Thanks a lot, that nailed it.

Communicating time values across multiple timescale domains has been a gotchain Verilog since day one. Timescales only apply to scaling of literal time values, not values of variables or passed arguments. Therefore, you should always use a literal time value in any expression involving time to a normalized time unit.
Unfortunately, they didn’t do this inside the OVM library. So if your OVM package is compiled with a default of timescale of 1ps, then you should do this to normalize it :

set_global_timeout(1us/1ps);
Dave Rich

Hi dave,
the syntax that you mentioned “
set_global_timeout(1us/1ps);
” will result in such compile error:
: near “ps”: syntax error, unexpected “IDENTIFIER”, expecting ‘)’
Actually why not set such timescale in makefile and be decided by users rather than in OVM lib?

In reply to daniel13:

There must be no space between the 1 and ps.