The ordered dither matrix is a 2n × 2n matrix. The 2 × 2 matrix is
and the 4 × 4 matrix is
In software a lookup table is often used, but in hardware deriving the dither value is straightforward.
Separating the 2 × 2 matrix into powers of two makes the pattern clearer:
So the Verilog to compute this dither value from the x,y pixel coordinates is:
wire [1:0] odith = {x[0] ^ y[0], y[0]};
Similarly for the 4 × 4 matrix:
which can be computed directly with:
wire [3:0] odith = {x[0] ^ y[0], y[0], x[1] ^ y[1], y[1]};
and similarly the 8 × 8 dither is:
wire [5:0] odith = {x[0] ^ y[0], y[0], x[1] ^ y[1], y[1], x[2] ^ y[2], y[2]};