Prev Problem
Next Problem

69. Binary Subtractor

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

module sub4_2c(
    input [3:0] a, b,
    output bout, 
    output [3:0] diff
);
    wire [4:0] excess;

    assign excess = {1'b0, a} + {1'b0, (~b + 1'b1)};

    assign diff = excess[3:0];
    assign bout = (a<b);
endmodule

 

Was this helpful?
Upvote
Downvote