VLSI DV Interview Puzzles · All levels

Build XOR Using Only 2:1 MUXes

Construct Y = A ^ B using only 2:1 multiplexers and constants 0/1. Give one concrete implementation.

Puzzle

Difficulty: Medium · Puzzle 1 of 6 · Topic: Digital Logic Puzzles

Construct Y = A ^ B using only 2:1 multiplexers and constants 0/1. Give one concrete implementation.

Code

systemverilog
module mux_xor(input logic A, B, output logic Y);
  logic nB;
  // MUX form: Z = S ? D1 : D0
  assign nB = B ? 1'b0 : 1'b1;      // ~B
  assign Y  = A ? nB   : B;         // A?~B:B = A^B
endmodule

Hint

Use one MUX to create ~B, then select between B and ~B using A.

Step-by-step solution

diagram
1) Recall 2:1 MUX equation: Z = S?D1:D0.
2) Invert B by setting S=B, D1=0, D0=1 => nB = ~B.
3) Build XOR with S=A, D1=nB, D0=B => Y = A?~B:B.
4) Verify truth table: A=0 => Y=B; A=1 => Y=~B, which equals A^B.

Answer

Answer: Two MUXes suffice: one for ~B and one for A-select between B and ~B.

Why candidates get it wrong

Trying to do XOR in one MUX without a complemented input source.

Interviewer follow-up

Can you build XNOR with same structure and same MUX count?

Related topics