//==========================
//Gate level Full Adder
//==========================
module FA_gatelevel( A, B, Cin, Sum, Cout );
input A, B, Cin;
output Sum, Cout;
wire W1, W2, W3;
xor xor1( W1, A, B );
and and1( W2, W1, Cin );
and and2( W3, A, B );
xor xor2( Sum, W1, Cin );
or or1( Cout, W2, W3 );
endmodule
//==================================
`timescale 10ns/10ps
module T;
reg A = 1'b0;
reg B = 1'b0;
reg Cin = 1'b0;
wire Cout;
wire Sum;
FA_gatelevel UUT (
.A(A),
.B(B),
.Cin(Cin),
.Cout(Cout),
.Sum(Sum));
initial
begin
#800; // Final time: 1000 ns
$stop;
end
initial
begin
// ------------- Current Time: 100ns
#100;
A = 1'b0;B = 1'b0; Cin = 1'b1;
// -------------------------------------
// ------------- Current Time: 200ns
#100;
A = 1'b0;B = 1'b1; Cin = 1'b0;
// -------------------------------------
// ------------- Current Time: 300ns
#100;
A = 1'b0;B = 1'b1; Cin = 1'b1;
// -------------------------------------
// ------------- Current Time: 400ns
#100;
A = 1'b1; B = 1'b0; Cin = 1'b0;
// -------------------------------------
// ------------- Current Time: 500ns
#100;
A = 1'b1; B = 1'b0;Cin = 1'b1;
// -------------------------------------
// ------------- Current Time: 600ns
#100;
A = 1'b1; B = 1'b1; Cin = 1'b0;
// -------------------------------------
// ------------- Current Time: 700ns
#100;
A = 1'b1; B = 1'b1; Cin = 1'b1;
// -------------------------------------
// ------------- Current Time: 1000ns
end
endmodule
//=====================================
沒有留言:
張貼留言