BTF: Please review and vote on B39

From: Anders Nordstrom (andersn@nortelnetworks.com)
Date: Tue Jul 06 1999 - 14:48:22 PDT


Content-Type: text/html; charset="us-ascii"
X-Sun-Content-Length: 520

<x-html>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" alink="#000088">
Team,
<p>Please review and vote for the updated proposal for $plusargs$.
<br>This proposal have been updated with input from Tom Fitzpatrick about
the
<br>integer return value of system functions.
<p>Please vote via email to the btf reflector before July 14.
<p>Thanks,
<p> Anders
</body>
</html>

</x-html>
Content-Type: text/html; charset="us-ascii"; name="B39.html"
Content-Disposition: inline;
 filename="B39.html"
X-Sun-Content-Length: 8133

<x-html>
<HTML>
<HEAD>
<TITLE> B39 </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
 
<BR>
<HR SIZE=5 NOSHADE>
 
<H2> B39 - $plusargs$value() </H2>

<TABLE BORDER COLS=2 WIDTH="75%" >
<TR><TD>
Section: </TD><TD> TBD
</TD></TR><TR><TD>
Date Submitted: </TD><TD> 990427
</TD></TR><TR><TD>
Requestor: </TD><TD> Adam Krolnik (adamk@cyrix.com)
</TD></TR><TR><TD>
Status: </TD><TD> Proposal
</TD></TR><TR><TD>
Analyzed by: </TD><TD> Anders Nordstrom, Adam Krolnik & Tom Fitzpatrick
</TD></TR><TR><TD>
Synthesizable: </TD><TD> No
</TD></TR>
</TABLE>

<H3> Details </H3>
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.

system 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:
<PRE>
// 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!
</PRE>
Specification:
<PRE>
exists = $plusargs$value(plusarg_string, type_string, value_register);
</PRE>
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:
<PRE>
d - decimal
h - hexadecimal
o - octal
b - binary
r - real
s - string
</PRE>
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.

<PRE>
    Adam Krolnik
    Verification Engineer
    Cyrix - NSC.
    Richardson TX. 75085
</PRE>

<H3> Proposal </H3>

<p>It was noted that the more fundamental (and existing) system function
$test$plusargs() is not part of the standard. This proposal will
define both of these system functions for consideration in the standard.

Add to section 16,

Command line input [16.11] <BR>
$test$plusargs <BR>
$value$plusargs

Add sections:

16.11 "Command line input"

An alternative to reading a file to obtain information for
use in the simulation is specifying information with the
command to invoke the simulator. This information is in
the form of a optional argument provided to the simulation.
These arguments are visually distinguished from other
simulator arguments by the starting with the plus ('+') character.
These arguments, referred to below as plusargs, are accessible
through the following system functions.

16.11.1 $test$plusargs (string)

This system function searches the list of plusargs for the provided
string. The plusargs present on the command line are searched in
the order provided. If one matches all characters in the provided
string, a non-zero integer is returned. If no plusarg from the command
line matches the string provided, the integer value zero is returned.

Example:
<PRE>
Run simulator with command:

% <simulator> +HELLO

Verilog code

initial begin
  if ($test$plusargs("HELLO")) $display("Hello argument found.")
  if ($test$plusargs("HE")) $display("The user wants male outputs.");
  if ($test$plusargs("H")) $display("Argument starting with H found.");
  if ($test$plusargs("HELLO_HERE")) $display("Long argument.");
  if ($test$plusargs("HI")) $display("Simple greeting.");
end
</PRE>
This would produce the following output:
<PRE>
Hello argument found.
The user wants male outputs.
Argument starting with H found.
</PRE>

<p>16.11.2 $value$plusargs (user_string, variable)

This system function searches the list of plusargs (like the $test$plusargs
system function) for a user specified plusarg string. If the string is found,
the remainder of the string is converted to the type specified in the
user_string and the resulting value stored in the variable provided. If
a string is found the function returns the a non-zero integer. If no string
is found matching, the function returns the integer value zero and the variable
provided is not modified.

The user string must be of the form: "'plusarg_string''format_string'". The
format strings are the same as the $display system tasks. These
are the only valid ones (upper and lower case as well as a leading 0
forms are valid):
<PRE>
%d - decimal conversion
%o - octal conversion
%h - hexadecimal conversion
%b - binary conversion
%e - real exponential conversion
%f - real decimal conversion
%g - real decimal or exponential conversion
%s - string (no conversion)
</PRE>
The first string, from the list of plusargs provided to the simuator,
that matches the plusarg_string portion of the user_string specified
will be the plusarg string available for conversion.
The remainder string of the matching plusarg (the remainder is the
part of the plusarg string after the portion that matches the users
plusarg_string) will be converted from a string into the format
indicated by the format string and stored in the variable provided.
If the size of the variable is larger than the value after conversion,
the value stored is zero padded to the width of the variable. If the
variable can not contain the value after conversion, the
value will be truncated. If the value is negative, the value shall be
considered larger than the variable provided. If characters exist in
the string available for conversion that are illegal for the
specified conversion, the register should be written with the value 'bx.

Examples:
<PRE>
<simulator> +FINISH=10000 +TESTNAME=this_test +FREQ+5.6666 +FREQUENCY

<p>// Get clock to terminate simulation if specified.
if ($value$plusargs("FINISH=%d", stop_clock))
  begin
  repeat (stop_clock) @(posedge clk);
  $finish;
  end

// Get testname from plusarg.
if ($value$plusargs("TESTNAME=%s", testname[255:0]))
  begin
  $display("Running test %0s.", testname);
  startTest();
  end
  
// Get frequency from command line; set default if not specified.
if (!$value$plusargs("FREQ+%0F", frequency[63:0]))
  frequency = 8.33333; // 166MHz;
  
  forever begin
  #frequency clk = 0;
  #frequency clk = 1;
  end

This code would have the following effects:

1. The variable 'stop_clock' obtains the value 10000.
2. The variable 'testname' obtains the value 'this_test'.
3. The variable 'frequency' obtains the value '5.6666'; note
   the final plusarg +FREQUENCY does not affect the value of
   the variable 'frequency'
   
</PRE>

<HR SIZE=5 NOSHADE>
</BODY>
</HTML>

</x-html>
Content-Type: text/x-vcard; charset="us-ascii"; name="andersn.vcf"
Content-Description: Card for Nordstrom, Anders [SKY:1V29-I:EXCH]
Content-Disposition: attachment;
 filename="andersn.vcf"
X-Sun-Content-Length: 313

Attachment Converted: "C:\Documents and Settings\stefen\Application Data\Qualcomm\Eudora\andersn1.vcf"



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:53:28 PDT and
sponsored by Boyd Technology, Inc.