//==============================
// Ch04 full_adder1.v
// 一位元全加法器 (閘層敘述)
module full_adder(A, B, Ci, Co, S);
input A, B, Ci; // A, B, Ci 一位元輸入
output Co, S; // S 和, Co 進位
and (AB, A, B);
and (ACi, A, Ci);
and (BCi, B, Ci);
or (Co, AB, ACi, BCi);
xor (S, A, B, Ci);
endmodule
//==============================
`timescale 10ns/10ps
module T;
reg A = 1'b0;
reg B = 1'b0;
reg Ci = 1'b0;
wire Co;
wire S;
full_adder UUT (
.A(A),
.B(B),
.Ci(Ci),
.Co(Co),
.S(S));
initial
begin
#1000; // Final time: 1000 ns
$stop;
end
initial
begin
// ------------- Current Time: 100ns
#100;
A = 1'b0;B = 1'b0; Ci = 1'b1;
// -------------------------------------
// ------------- Current Time: 200ns
#100;
A = 1'b0;B = 1'b1; Ci = 1'b0;
// -------------------------------------
// ------------- Current Time: 300ns
#100;
A = 1'b0;B = 1'b1; Ci = 1'b1;
// -------------------------------------
// ------------- Current Time: 400ns
#100;
A = 1'b1; B = 1'b0; Ci = 1'b0;
// -------------------------------------
// ------------- Current Time: 500ns
#100;
A = 1'b1; B = 1'b0;Ci = 1'b1;
// -------------------------------------
// ------------- Current Time: 600ns
#100;
A = 1'b1; B = 1'b1; Ci = 1'b0;
// -------------------------------------
// ------------- Current Time: 700ns
#100;
A = 1'b1; B = 1'b1; Ci = 1'b1;
// -------------------------------------
// ------------- Current Time: 1000ns
#300;
A = 1'b0;
end
endmodule
//==============================
沒有留言:
張貼留言