← ProblemsVerilog Language / Vectors

More replication

15%vectors

Given five 1-bit inputs a, b, c, d, e, compute all 25 pairwise comparisons (XNOR — output bit is 1 when the pair is equal).

out[24] = ~a ^ a;   // a == a, so out[24] is always 1
out[23] = ~a ^ b;
out[22] = ~a ^ c;
...
out[ 0] = ~e ^ e;

The replication and concatenation operators make this a one-liner.