SystemVerilog #60 · 2026-11-22 · Signed arithmetic · Easy · about 12 min

The average of two signed bytes

Write avg_floor: it takes two signed 8-bit numbers a and b (two's complement) and drives y, their average rounded down (toward negative infinity), combinationally. The true average (a + b) / 2 always fits in 8 bits, whatever the inputs.

Examples: 4 and 10 give 7. -3 and 0 give -2, not -1. 100 and 100 give 100, and -128 and -127 give -128.

Fill in avg_floor.sv. Run tries five pairs.

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