SystemVerilog #72 · 2026-12-04 · Reduction vs bitwise vs logical · Easy · about 10 min

Three flags from one byte and a mask

Write bitflags, a combinational module that looks at an 8-bit value a and an 8-bit mask and produces three one-bit flags:

  • none is 1 when no bit of a is 1 (a is all zeros).
  • all is 1 when every bit of a is 1.
  • hit is 1 when there is at least one bit position where both a and mask are 1.

Examples: a = 8'h00 gives none = 1, all = 0. a = 8'hFF gives none = 0, all = 1. a = 8'h81, mask = 8'h01 gives hit = 1. a = 8'hF0, mask = 8'h0F gives hit = 0, because they never have a 1 in the same position.

Fill in bitflags.sv. Run tries four value pairs.

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