// ============================================================
// 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 o1, o2, o3, o4;
not_gate n1(b, o1);
and_gate a1(a, o1, o2);
not_gate n2(a, o3);
and_gate a2(o3, b, o4);
or_gate o(o2, o4, y);
endmodule