FPGA各种门的验证
- 创建andtest类:
module andtest();
reg p0;
reg p1;
wire p2;
//----Code starts here: integrated by Robei-----
initial begin
p0 = 0;
p1 = 0;
#1
p0 = 1;
#1
p1 = 1;
#1
p0 = 0;
#1
p1 = 0;
#1
$finish;
end
initial begin
$dumpfile ("D:/FPGA/FPGA_code/andtest.vcd");
$dumpvars;
end
//---Module instantiation---
andgate andgate1(
.a(p0),
.b(p1),
.y(p2));
endmodule //andtest
#1
:表示间隔一秒钟
- 注意: testbench 中的input(p0,p1) 一定要声明为
reg
1. 与门:
module andgate(
a,
b,
y);
//---Ports declearation: generated by Robei---
input a;
input b;
output y;
wire a;
wire b;
wire y;
//----Code starts here: integrated by Robei-----
assign y = a&b;
endmodule //andgate