Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Map packed words to unpacked bytes

Q005·Free·SystemVerilog

Map packed words to unpacked bytes

Difficulty
Easy
Topic
Bit Manipulation
Language
SV
Interview prompt

Question

Split a 32-bit packed word into four unpacked bytes using little-endian byte lanes, then rebuild the original word.

Thirty-two-bit word A1B2C3D4 mapped from packed bit slices to little-endian unpacked byte indices and rebuilt
Indexed part-selects map bits 7 through 0 to bytes[0] through bits 31 through 24 to bytes[3], then reconstruct the original word.
Candidate starting point

Implementation scaffold

function automatic void split_and_rebuild_le(
  input logic [31:0] word,
  output logic [7:0] bytes [0:3],
  output logic [31:0] rebuilt
);
  // TODO: implement.
endfunction
Reviewed example

Trace one case

Input
word = 32'hA1B2_C3D4
Expected output
bytes[0:3] = [D4, C3, B2, A1]; rebuilt_word = 32'hA1B2_C3D4

Little-endian lane zero is word[7:0], and the inverse indexed part-select mapping reproduces every source bit.

What to cover

Requirements

  1. Define byte 0 as word[7:0].
  2. Use indexed part-selects rather than an implicit array assignment.
  3. Rebuilding the word must reproduce every input bit.
Exact question handoffPractice Q005

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Special Types and Conversion

Review enums, strings, casts, packing, streaming, DPI values, and representation changes.

  • Bit Manipulation
  • Packed array
  • Unpacked array
  • Endianness
Special Types and Conversion →
Continue practicing

Related questions

Q301 · SystemVerilogPacked and unpacked array meaningEasyP→Q016 · Data StructuresPacked and unpacked arraysEasy→Q1055 · Bit ManipulationBuild parameterized pack and unpack helpersMediumP→Q576 · Hardware-Software IntegrationDetect machine endianness in CEasyP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi