Full Subtractor Dataflow

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Full Subtractor

Data flow modeling:


module full_subtractor_dataflow(A,B,CDiff,Borrow);
input A,B,C;
output Diff,Borrow;
assign Diff=A^B^C;
assign Borrow=(~A)&(B^C)|B&C;
endmodule

Test code:
module test3_v;

reg A,B,C;
wire Diff,Borrow;

half_subtractor_dataflow uut(
.A(A)
.B(B)
.C(C)
.Diff(Diff)
.Borrow(Borrow)
);

initial begin
A=0;
B=0;
C=0;
#100;

A=0;
B=0;
C=1;
#100;

A=0;
B=1;
C=0;
#100;

A=0;
B=1;
C=1;
#100;

A=1;
B=0;
C=0;
#100;

A=1;
B=0;
C=1;
#100;

A=1;
B=1;
C=0;
#100;

A=1;
B=1;
C=1;
#100;

end
endmodule

You might also like