Hardware interview practice
Compare values safely with X and Z
Implement exact four-state equality and a known-value equality policy for two 32-bit logic vectors.
Reviewed example
Work through one case
Input
a=32'h0000_00XZ, b=32'h0000_00XZ, c=32'h0000_0009Expected output
equal_exact_4state(a,b)=1; equal_when_known(a,b)=0; equal_when_known(c,c)=1Case equality accepts matching X/Z positions, while known-value equality first rejects any operand containing an unknown or high-impedance bit.
What to cover
Requirements
- Exact equality must allow matching X and Z bits.
- Known-value equality must reject either operand when it contains X or Z.
- Both helpers must return a two-state bit result.
