0
\$\begingroup\$

I'm studying the way of passing parameters from one module to another and I have one question.

I have this instance in the top level module.

parameter a= 100;
parameter b = 200 ;

test#(b/(a*2)) test(
    .clk(clk), 
    .reset(reset), 
    .out(out)
    ); 

In test module, I have this header:

module test#(parameter max = 33 )(
  input clk,
  input reset,
  output out
);

So, my question is:

Which value will the module take as input parameter? 33 or 1 ? I mean, Is max=33 overwritten by the one I'm passing from the top level module?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Yes, the value will be overwritten by the one passed from the top module. The value 33 will only be used when there is nothing passed. You can think of it as a default value.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ FYI, In SystemVerilog, you can remove default = 33, and you are then required to provide an override in the instance. \$\endgroup\$
    – dave_59
    Commented Jun 29, 2017 at 16:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.