Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Build a parameterized N-to-1 multiplexer

Hardware interview practice

Build a parameterized N-to-1 multiplexer

MediumCombinational RTLSystemVerilog

Write a reusable combinational block that selects one W-bit word from N inputs when N does not have to be a power of two.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

parameter int N = 6;
parameter int W = 8;

input  logic [N-1:0][W-1:0] data;
input  logic [$clog2(N)-1:0] sel;
output logic [W-1:0] y;
Reviewed example

Work through one case

Input
N = 6, W = 8, sel = 6
Expected output
y = 8'h00

The three-bit select can encode 0 through 7, leaving two unused codes, 6 and 7. Code 6 therefore takes the explicit invalid path.

What to cover

Requirements

  1. Return data[sel] for every select value below N.
  2. Return all zeros for an unused select code.
  3. Support every N >= 2 and W >= 1.
  4. Assign y completely and never evaluate an out-of-range array element.
Continue practicing

Related questions

RTL DesignReverse a physical bus at the lane boundary→RTL DesignDiagnose storage from an incomplete always_comb block→RTL DesignImplement a parameterized binary-to-Gray converter→
asic.fyi · Learn silicon end to end.info@asic.fyi