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

/*Write your code here*/
module sub4_2c(
    input [3:0] a,
    input [3:0] b,
    output reg [3:0] diff,
    output reg bout
);

always @(*)
begin
    if(a < b)
    begin
        bout <= 1'b1;
        diff <= a - b;
    end
    else
    begin
        bout <= 1'b0;
        diff <= a - b;
    end
end

endmodule

 

Was this helpful?
Upvote
Downvote