Prev Problem
Next Problem

9. XOR Gate Using Basic Gates

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

// ============================================================
// 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 not_out0, not_out1, and_out0, and_out1;
    not_gate not_gate0(b, not_out0);
    not_gate not_gate1(a, not_out1);
    and_gate and_gate0(a, not_out0, and_out0);
    and_gate and_gate1(not_out1, b, and_out1);
    or_gate gate(and_out0, and_out1, y);
endmodule

 

Was this helpful?
Upvote
Downvote