Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ713
Page ↗
Q713FWASIC interview problem

Insert a packed bit field

TechniquesBitsField mask
DifficultyMedium
TopicBit Manipulation
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Replace bits [hi:lo] of a 32-bit word with the low bits of field while preserving all other bits.

Example input and output

Use this case to check your interpretation
Input
x = 32'h0000_A55A, field = 4'h3, hi = 7, lo = 4
Output
32'h0000_A53A
Explanation

The nibble mask clears bits [7:4] before the new packed field is ORed into that position.

02

Requirements (4)

  • Require indices that satisfy 0 <= lo <= hi <= 31.
  • Create a mask covering hi through lo, inclusive.
  • Clear the destination region before inserting the shifted field.
  • Handle a full-width [31:0] field without shifting a 32-bit value by 32.