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
- AUsing a parameter automatically makes the circuit faster
- BThe parameter value can be changed freely while the chip is running
- 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.