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



// ============================================================
// XOR Gate
// ============================================================
module xor_gate (
    input  a, b,
    output  reg y
);
   
    // TODO: instantiate required gates
    always @(*) begin
        // Mô tả logic: y = (a AND NOT b) OR (NOT a AND b)
        // Đây chính là logic mà đoạn code nối dây cũ thực hiện
        y = (a & ~b) | (~a & b);
    end

endmodule

 

Was this helpful?
Upvote
Downvote