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 interpretationInput
N = 6, W = 8, sel = 6Output
y = 8'h00Explanation
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.
