A zero detector answers one question about an n-bit word: is every bit 0? It's how an ALU produces its zero flag Z.
The logic follows from the definition. A word is nonzero if any bit is 1, which is the OR of all the bits. Zero is the opposite, so for a 4-bit result:
Z = , a single 4-input NOR.
By De Morgan, that's the same as an AND of the inverted bits, . Both say "every bit is 0".
For wide words, real gates don't have 32 or 64 inputs, so the NOR is built as a tree: ORs in stages, then one inverter at the end.
Two things to get right in an ALU:
- Feed the detector from the ALU output, after the result multiplexer, not from the adder's sum. Otherwise Z is wrong whenever the ALU outputs a logic result.
- Combined with subtraction, Z becomes an equality test: A − B is zero exactly when A = B. See comparison by subtraction.