SystemVerilog Simulation Timers Released
Thursday, March 12th, 2009I’m now sharing a collection of SystemVerilog timers that includes a simulation countdown timer and a watchdog timer.
If you find yourself forking off countdown timers in your BFMs – then you already have an idea of what this is. I’ve encapsulated that common fork…join_any call as an egg-timer with start, stop, reset, and restart methods.
Instead of the confusing fork..join_any syntax (and having to remember to disable the fork!) you can simply instantiate an idv timer and start it.
An example:
idv_timer_sim timeout_timer = new(10us, 1); // constructs and forks off a 10us countdown timer do_bfm_activity(...); timeout_timer.stop(); // stops the timer
If the do_bfm_activity(…) takes more than 10us then the timerout_timer will alarm() and end the simulation with an error.
That’s much clearer than:
fork: bfm_timeout
do_bfm_activity(...); // do the bfm task
begin
#10us; // fork off timeout time
$display("Timer Expired!");
$finish;
end
join_any
disable bfm_timeout; // disable the fork
AND – you can extend the timer and redefine the alarm() behaviour to actually do some task; rather than do the default and stop the simulation with an error message.
The included watchdog timer is handy for situations where you expect a regular event within some time window.
More details:
- Countdown timer “idv_timer_sim”: a simulation countdown timer
- This timer behaves like an ‘egg timer’ for simulation time. (We say simulation time to differentiate from a ‘wall time’ countdown timer.)
- This timer can started, stopped, restarted (from stopped time), and reset to the initial time.
- Use for any situation where you want your sim to stop (or do some activity) after a given amount of simulation time has expired.
- Use to timeout on a hanging task call: start the timer, call the task, stop the timer; if the task call hangs then the timer alarm will sound.
- Extend and redefine the alarm() method to define the timer expiration activity (the default is to end the simulation)
- Watchdog timer “idv_watchdog_sim”: a simulation watchdog timer
- A watchdog timer is a special type of countdown timer that restarts itself on the occurance of a watched event.
- Use to monitor a system heartbeat — if the duration between beats gets too long then timeout
- Use to timeout a hanging bus — map an interface signal to an event; if it takes to long between events then the bus is hung
- Like the timer – extend and redefine the alarm() method to define the timer expiration activity (the default is to end the simulation)
- VMM Implementation: individual extensions of both the timer and the watchdog for vmm (uses vmm_log objects for console messaging)
- allows message instance name to be passed at timer construction – makes it clear which timer was triggered.
Download the timer release tarball from the timers page here:
http://intelligentdv.com/downloads/index.html#svtimers
Bugs and feature requests can be filed here:
http://bugs.intelligentdv.com/
Project: SVtimers
-Timer Expired!