San1
1
Hi,
I am trying to extract a time delay value from simulation run command.
Below is what I am trying to achieve:
time switch_startup_delay;
if (!($value$plusargs("SWITCH_STARTUP_DELAY=%t", switch_startup_delay)))
switch_startup_delay = "1us";
ovm_report_info(get_type_name(), $psprintf("SW_STARTUP_DELAY: %t", switch_startup_delay));
…
…
#switch_startup_delay;
…
…
I understand that $vaule$plusargs do not accept a time value (%t is not supported), so above code won’t work.
Can someone suggest an alternative of how to achieve above requirement. I do not want to use +define+
Thanks,
San
Unfortunately, dealing with physical time units is something that has never been properly addressed in Verilog/SystemVerilog.
One suggestion is to assume your delay will always be expressed as a real number in microseconds.
realtime switch_startup_delay;
if (!($value$plusargs("SWITCH_STARTUP_DELAY=%f", switch_startup_delay)))
switch_startup_delay = 1;
ovm_report_info(get_type_name(), $psprintf("SW_STARTUP_DELAY: %t", switch_startup_delay));
......
......
#(switch_startup_delay*1us);
Another suggestion is to provide another argument to set the timescale.
realtime switch_startup_delay;
string switch_startup_scale;
if (!($value$plusargs("SWITCH_STARTUP_DELAY=%f", switch_startup_delay)))
switch_startup_delay = 1;
if ($value$plusargs("SWITCH_STARTUP_SCALE=%s", switch_startup_scale))
case(switch_startup_scale) // normalize to us
"s": switch_startup_delay *= 1s/1us;
"ms": switch_startup_delay *= 1m/1us;
"us": switch_startup_delay *= 1us/1us;
"ps": switch_startup_delay *= 1ps/1us;
default: $error("bad scale specified");
endcase
ovm_report_info(get_type_name(), $psprintf("SW_STARTUP_DELAY: %t", switch_startup_delay));
......
......
#(switch_startup_delay*1us);