Average of Two Numbers

Output the integer average of two unsigned 4-bit numbers: (a + b) / 2, rounding down. Add in 5 bits so the sum cannot overflow, then shift right by one.

Inputs: a and b, 4 bits.
Output: avg, 4 bits.

The testbench applies all 256 pairs.

Contributed by Indicore

Compiler Output
Waveform Viewer