SystemVerilog #61 · 2026-11-23 · Indexed part-selects · Easy · about 15 min
Pick and patch a field
Write field_slice: a combinational block that reads and writes fields of a 32-bit word w with variable positions.
extis nibblenofw. Nibble 0 is bits[3:0], nibble 7 is bits[31:28].insiswwith nibblenreplaced byd. All other bits are unchanged.topis bytejofwcounted from the top:j = 0is bits[31:24],j = 3is bits[7:0].
Example with w = 32'h76543210: n = 3 gives ext = 3. With d = A, ins = 76 54 A2 10. j = 1 gives top = 54.
Fill in field_slice.sv. Run tries three cases.
Write and run your answer in the browser. The hidden tests check it, and it’s free.