// ============================================================
// Basic Gates (given)
// ============================================================
module and_gate(input a, b, output y);
assign y = a & b;
endmodule
module or_gate(input a, b, output y);
assign y = a | b;
endmodule
module not_gate(input a, output y);
assign y = ~a;
endmodule
// ============================================================
// XOR Gate
// ============================================================
module xor_gate (
input a, b,
output y
);
wire notA, notB, andY1, andY2;
not_gate not1 (.a(b), .y(notB));
not_gate not2 (.a(a), .y(notA));
and_gate and1 (.a(a), .b(notB), .y(andY1));
and_gate and2 (.a(b), .b(notA), .y(andY2));
or_gate or1 (.a(andY1), .b(andY2), .y(y));
endmodule