From: Adam Krolnik (adamk@cyrix.com)
Date: Tue Apr 27 1999 - 09:29:05 PDT
Good afternoon:
Thinking about the FileIO tasks we proposed, I though about this type
of 'input' that we haven't addressed and yet many people still write
stuff like this all the time.
There is no support for retrieving a value off of a plusarg without
a large contortion of verilog code or opening up the PLI chapters
to write a C routine.
I would like to propose a system function to address this common
operation.
ystem function $plusargs$value();
exists = $plusargs$value(plusarg_string, type_string, value_register);
The function tests for the existance of the plusarg passed as the first
argument. If it exists, the postfix text is converted to the type listed
in type_string and written to the value_register argument.
Examples:
// Get clock to terminate simulation if specified.
if ($plusargs$value("finish=", "d", stop_clock))
begin
repeat (stop_clock) @(posedge clk);
$finish;
end
// Get testname from plusarg.
if ($plusargs$value("TESTNAME=", "s", testname[255:0]))
begin
$display("Running test %0s.", testname);
startTest();
end
// Get frequency from command line; set default if not specified.
if (!$plusargs$value("FREQ=", "r", frequency[63:0]))
frequency = 8.33333; // 166MHz;
forever begin
#frequency clk = 0;
#frequency clk = 1;
end
Features of this request:
1. Returns existance information
2. Sets register to value if available.
3. Multiple value conversion formats.
4. Not limited to 32 bits.
5. List plusarg name once!
Specification:
exists = $plusargs$value(plusarg_string, type_string, value_register);
The system function $plusargs$value will test for the specified plusarg
string in parameter position 1. This is equivalent to the $test$plusargs()
functionality.
The return code will be the return code of the $test$plusargs() function.
If the plusarg string does exist, the remainder of the matching plusarg string
will be converted to a value as specified by the type field.
The type field may be one of the characters (dhobrs) and they have this
corresponding type:
d - decimal
h - hexadecimal
o - octal
b - binary
r - real
s - string
All other values will set the value_register to 'bx. The value shall be converted
and placed into the value_register in parameter position 3. If the value exceeds
the size of the value_register, the value will be truncated to fit into the
register. If the value_register exceeds the value size, the value will be padded
with 0's to the size of the value_register.
If the value contains characters not compatible with the base specified, the
value stored for the character shall be 'bx. In the case of the string base,
there are no incompatible characters.
<p> Adam Krolnik
Verification Engineer
Cyrix - NSC.
Richardson TX. 75085
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:53:26 PDT
and
sponsored by Boyd Technology, Inc.