2
\$\begingroup\$

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 ?

asked May 4, 2018 at 22:17
\$\endgroup\$
1
  • \$\begingroup\$ Have you tried simply instanceName.ADD? \$\endgroup\$ Commented May 4, 2018 at 22:37

1 Answer 1

3
\$\begingroup\$

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
answered May 4, 2018 at 22:42
\$\endgroup\$
1
  • \$\begingroup\$ I tried that before and didn't work !! I use iverilog and when it fails it prints I gave up I've just tried it now and it worked... \$\endgroup\$ Commented May 4, 2018 at 22:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.