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,b,output [3:0]diff,output bout);
assign bout=(a<b)?1:0;
assign diff=a-b;//diff = a+(~b+1) => -b = 2's complement of b;

endmodule

 

Was this helpful?
Upvote
Downvote