DescriptionQ985
Q985FWASIC interview problem
Build parameterized pack and unpack helpers
TechniquesParameterized classPacked vectorData layout
DifficultyMedium
TopicBit Manipulation
LanguageSystemVerilog
Requirements3 checkpoints
01
Problem
Create reusable helpers that pack N words of W bits into one vector and unpack that vector with word 0 in the least-significant lane.
Example input and output
Use this case to check your interpretationInput
N=3, W=4, words[0:2] = [4'hA, 4'h3, 4'hF]Output
packed = 12'hF3A; unpack(packed) = [A, 3, F]Explanation
Word zero occupies the least-significant nibble, so the same indexed part-select convention makes pack and unpack exact inverses.
02
Requirements (3)
- Support compile-time N and W parameters.
- Use one explicit indexed part-select mapping in both directions.
- Initialize the packed result before assigning slices.
