passing arguments to ncverilog

J

junk_no_spam

Guest
Is there any way to pass an argument from a Cshell into the
the ncverilog simulator to be used in the top-level testbench?

For instance a variable "i" which takes on the values i = 1,2,3,4 ...
in the Cshell, and can be passed into the top-level testbench as
an argument to the ncverilog that I invoke in a Cshell.

Currently I set the variable "i" in a tb_defines.h file using
a 'define statement. Then in the top-level testbench I include
tb_defines.h file, so that I can access the value of "i" inside
the testbench.

But what I really want to do is pass it in from the Cshell.

thanks,
steve M.
at comcast.net
 
On 23 Mar, 06:23, junk_no_spam <j...@comcast.net> wrote:
Is there any way to pass an argument from a Cshell into the
the ncverilog simulator to be used in the top-level testbench?

For instance a variable "i" which takes on the values i = 1,2,3,4 ...
in the Cshell, and can be passed into the top-level testbench as
an argument to the ncverilog that I invoke in a Cshell.

Currently I set the variable "i" in a tb_defines.h file using
a 'define statement. Then in the top-level testbench I include
tb_defines.h file, so that I can access the value of "i" inside
the testbench.

But what I really want to do is pass it in from the Cshell.

thanks,
steve M.
at comcast.net
You can use the +define ncverilog command line argument to set a
'define from your script. Its a while since I used NC, but I think the
syntax is:

+define+i=1

From a C-Shell script you will need to be careful about escaping the
=.
 
junk_no_spam wrote:
Is there any way to pass an argument from a Cshell into the
the ncverilog simulator to be used in the top-level testbench?
If the value is something that is required to be a compile-time
constant (e.g. the value of a Verilog parameter or the size of
a vector), then you could use the +define option to set the value
of a macro, just as if you had used a `define in the source. This
would then require ncverilog to recompile the source every
time.

If the value does not have to be a compile-time constant, but
just something tested at runtime, there is a better way that does
not require recompiling. You can pass it in as part of a plusarg
that you can give any name you want, and then retrieve the
value at runtime in your testbench code using the system function
$value$plusargs.

For example, you could have your testbench execute

if ($value$plusargs("testnum=%d", testnum))
case (testnum)
...
else
$display("testnum not provided");

Then execute ncverilog with an option like

ncverilog +testnum=3 ...

Presumably you can get your Cshell to produce the proper
command line with the number filled in from the Cshell
variable.
 

Welcome to EDABoard.com

Sponsor

Back
Top