HDL & Verification

What does the generate statement above do?

genvar i;
generate
    for (i = 0; i < 4; i = i + 1) begin : g
        fifo u_fifo (.clk(clk), .din(din[i]), .dout(dout[i]));
    end
endgenerate
  1. AIt reuses one fifo four times over four clocks
  2. BIt displays the fifo four times only during simulation
  3. CIt creates four instances of the fifo module, each connected to a different element of din and dout
Show answer and explanation

Answer: C. It creates four instances of the fifo module, each connected to a different element of din and dout

A for loop inside a generate block expands its contents for each genvar value, replicating hardware descriptions. Here four fifo instances, g[0].u_fifo through g[3].u_fifo, are created, each connected to din[i] and dout[i]. Making the channel or bit count a parameter lets the number of instances change accordingly, so regularly structured circuits can be written concisely.

  • A. It does not reuse; four circuits are placed side by side.
  • B. It creates hardware, not display output.
  • C. Correct. It is expanded into four circuits at synthesis.
Practice this topic Back to topic

More HDL & Verification questions

  1. What is the role of a lint tool in HDL verification?
  2. What is the main purpose of simulating the post-synthesis or post-layout gate-level netlist with delay information?
  3. 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?
  4. When the code above is synthesized for an FPGA, how is it generally implemented?
  5. In combinational logic, how does a long if/else-if chain compare with a case statement whose conditions are mutually exclusive?