通常说来有两种方法可以向ncverilog/ncvhdl/ncsim 传递参数。
如果该参数是在编译阶段(compile phase)中被用到的常量(如一个vector的size),则可以使用ncsim/ncvrilog/ncvhdl 命令+define来传递,大概的命令行格式为:
+define+变量名=特定值(字符串/数字),就好像在代码中使用了`define.这种用法的不足是每次运行时都需要重新进行编译。
如果该参数并非是编译中使用的常量,只是在运行时用到。你可以将它通过plusarg在命令行中传递,在你的testbench中使用系统函数 $value$plusargs在运行时获取.例如,你可以在testbench中使用:
if ($value$plusargs("testnum=%d", testnum))
case (testnum)
...
else
$display("testnum not provided");
然后在ncverilog 中使用:
ncverilog +testnum=3 ...
责任编辑:5life
本文共有0条评论,现在显示最新的5条。