Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ518
Q518DesignASIC interview problem

Build a parameterized N-to-1 multiplexer

TechniquesDesignSystemVerilogMultiplexerParametersCombinational logic
DifficultyMedium
TopicCombinational RTL
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

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.

Starting declarationSystemVerilog
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;

Example input and output

Use this case to check your interpretation
Input
N = 6, W = 8, sel = 6
Output
y = 8'h00
Explanation

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

02

Requirements (4)

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