nand2Tetris
This commit is contained in:
26
iverilog/tobb/lab2/Fulladder.v
Normal file
26
iverilog/tobb/lab2/Fulladder.v
Normal file
@ -0,0 +1,26 @@
|
||||
module Fulladder (
|
||||
input A,
|
||||
input B,
|
||||
input Cin,
|
||||
output S,
|
||||
output Cout
|
||||
);
|
||||
wire AxB, AnB1, AnB2;
|
||||
|
||||
|
||||
halfadder h1 (
|
||||
.A(A),
|
||||
.B(B),
|
||||
.Sum(AxB),
|
||||
.Carry(AnB2)
|
||||
);
|
||||
|
||||
halfadder h2 (
|
||||
.A(AxB),
|
||||
.B(Cin),
|
||||
.Sum(S),
|
||||
.Carry(AnB1)
|
||||
);
|
||||
|
||||
or o1 (.Y(Cout), .A(AnB1), .B(AnB2));
|
||||
endmodule
|
@ -1,13 +0,0 @@
|
||||
module fullAdder (
|
||||
input A,
|
||||
input B,
|
||||
input Cin,
|
||||
output S,
|
||||
output Cout
|
||||
);
|
||||
wire AxB, AnB1, AnB2;
|
||||
halfadder h1(A, B, AxB, AnB2);
|
||||
halfadder h2(AxB, Cin, S, AnB1);
|
||||
|
||||
or o1(Cout, AnB1, AnB2);
|
||||
endmodule
|
@ -3,7 +3,7 @@ module fulladdertb ();
|
||||
reg r1, r2, r3;
|
||||
wire w1, w2;
|
||||
|
||||
fullAdder uut(
|
||||
FullAdder uut(
|
||||
.A(r1),
|
||||
.B(r2),
|
||||
.Cin(r3),
|
||||
@ -26,4 +26,4 @@ initial begin
|
||||
$display(w2);
|
||||
end
|
||||
|
||||
endmodule
|
||||
endmodule
|
||||
|
@ -14,5 +14,5 @@ initial begin
|
||||
A = 1'b1; B = 1'b0; #10;
|
||||
A = 1'b1; B = 1'b1; #10;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
endmodule
|
||||
|
Reference in New Issue
Block a user