Prev Problem
Next Problem

12. Vector Bitwise Operators

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

// ============================================================
// Module: bitwise_ops_demo
// Description: Demonstrates vector bitwise operations (AND, OR, XOR, XNOR)
// ============================================================
module bitwise_ops_demo (
    input  [3:0] A,        // 4-bit input A
    input  [3:0] B,        // 4-bit input B
    output [3:0] AND_OUT,  // Bitwise AND
    output [3:0] OR_OUT,   // Bitwise OR
    output [3:0] XOR_OUT,  // Bitwise XOR
    output [3:0] XNOR_OUT  // Bitwise XNOR
);

    // Bitwise operations
    assign AND_OUT  = A & B;     // Bitwise AND
    assign OR_OUT   = A | B;     // Bitwise OR
    assign XOR_OUT  = A ^ B;     // Bitwise XOR
    assign XNOR_OUT = ~(A ^ B);  // Bitwise XNOR

endmodule

 

Was this helpful?
Upvote
Downvote