I have an ALU module with a set of parameters used as opcodes.
parameter ADD=0,
SUB = 1,
MUL = 2,
DIV = 3;
Currently building a testbench for that module, I just want to read these values in the testbench, something like C language alu.ADD
.
Is that possible ?
1 Answer 1
You can access any variable within a hierarchy, including parameters, in Verilog testbenches pretty much exactly as you have shown.
instanceName.variableName
Say you instantiated your module and called the instance alu
, then you could access the value of the parameter ADD
in that instance by simply accessing:
alu.ADD
You can even do multi-level. Say your alu
instance instantiated something called adder
, which had a signal called cout
. You could access that with:
alu.adder.cout
-
\$\begingroup\$ I tried that before and didn't work !! I use
iverilog
and when it fails it printsI gave up
I've just tried it now and it worked... \$\endgroup\$Shady Atef– Shady Atef2018年05月04日 22:49:34 +00:00Commented May 4, 2018 at 22:49
instanceName.ADD
? \$\endgroup\$