// Ch03 wire_and_or.v
// 連接線 (wire, wired-and, wired-or)
module wire_and_or(A, B, C, D, E);
input A,B;
output C,D,E;
wire An; // 宣告中繼信號 An 為 wire 資料
wand D; // 宣告輸出埠 D 為 wand 資料
wor E; // 宣告輸出埠 E 為 wor 資料
// wire
assign An = ~A;
assign C = An & B; // C = /A.B
// wired-and
assign D = A;
assign D = B;
// wired-or
assign E = A;
assign E = B;
endmodule
//=============================
`timescale 100ns/10ps
module T;
reg A = 1'b0;
reg B = 1'b0;
wire C; // C = /A.B
wire D; //wired-and
wire E; //wired-or
wire_and_or UUT (
.A(A),
.B(B),
.C(C),
.D(D),
.E(E));
initial
begin
#500; // Final time: 500 ns
$stop;
end
initial
begin
// ------------- Current Time: 100ns
#100;
A = 1'b1;
// -------------------------------------
// ------------- Current Time: 200ns
#100;
A = 1'b0;
B = 1'b1;
// -------------------------------------
// ------------- Current Time: 300ns
#100;
A = 1'b1;
end
endmodule
沒有留言:
張貼留言