SystemVerilog #68 · 2026-11-30 · Ascending ranges · Easy · about 12 min

Reading a byte numbered from the left

bit_view receives a byte a from a link whose bits are numbered from the left: it is declared logic [0:7] a, so a[0] is its leftmost bit and a[7] its rightmost. The module hands that byte to logic that uses ordinary [7:0] and [3:0] vectors. It is purely combinational, with four outputs:

  • same (8 bits): same[i] is a[i] for every i from 0 to 7.
  • flip (8 bits): flip[i] is a[7-i] for every i.
  • head (4 bits): the four leftmost bits of a, with a[0] as the most significant bit of head (so head[3] is a[0] and head[0] is a[3]).
  • tail (4 bits): the four rightmost bits of a, with a[4] as the least significant bit of tail (so tail[0] is a[4] and tail[3] is a[7]).

Examples:

a (printed left to right) same flip head tail
1111_1111 1111_1111 1111_1111 1111 1111
1001_1001 1001_1001 1001_1001 1001 1001

Fill in bit_view in bit_view.sv. Don't change the port declarations.

Write and run your answer in the browser. The hidden tests check it, and it’s free.