HDL & Verification

What is the advantage of writing a module with a parameter as above?

module adder #(parameter W = 8) (
    input  [W-1:0] a, b,
    output [W:0]   s
);
    assign s = a + b;
endmodule
  1. AUsing a parameter automatically makes the circuit faster
  2. BThe parameter value can be changed freely while the chip is running
  3. CSpecifying W at each use creates adders of different widths, such as 8 or 16 bits, from the same code
Show answer and explanation

Answer: C. Specifying W at each use creates adders of different widths, such as 8 or 16 bits, from the same code

A parameter is a constant whose value can be specified when the module is used. Making bit widths or FIFO depths parameters lets one description be reused at various sizes, reducing the effort and errors of writing similar circuits repeatedly. Values are fixed at synthesis, and a circuit of the matching size is built for each. They do not change while the chip runs, so settings that must change at run time are held in registers.

  • A. Speed does not change.
  • B. It is a constant fixed at synthesis and cannot change at run time.
  • C. Correct. It makes design reuse easier.
Practice this topic Back to topic

More HDL & Verification questions

  1. What does the generate statement above do?
  2. What is the role of a lint tool in HDL verification?
  3. What is the main purpose of simulating the post-synthesis or post-layout gate-level netlist with delay information?
  4. What is a structure like the code above, where a combinational output feeds back to its own input without passing through a flip-flop, called, and why should it be avoided?
  5. When the code above is synthesized for an FPGA, how is it generally implemented?