Half Subtractor:
module hs(d,bout,a,b);
output d,bout;
input a,b;
//assign {bout,d} = a-b;
assign d = a ^ b;
assign bout = ~a & b;
endmodule
Full Subtractor:
module fs(d,bout,a,b,c);
output d,bout;
input a,b,c;
//assign {bout,d} = a - b - c;
assign d = a ^ b ^ c;
assign bout = (~a & b) | (~(a^b)&c);
endmodule
0 comments:
Post a Comment
if you have any doubt please let me know