feat:接入iverilog工具
- 将iverilog可以随着插件的下载而下载 - 用户输入自然语言就可以控制生成对应的VCD文件
This commit is contained in:
54
tools/iverilog/examples/counter_tb.v
Normal file
54
tools/iverilog/examples/counter_tb.v
Normal file
@ -0,0 +1,54 @@
|
||||
// counter_tb.v - 计数器测试平台
|
||||
|
||||
`timescale 1ns/1ps
|
||||
|
||||
module counter_tb;
|
||||
|
||||
// 信号声明
|
||||
reg clk;
|
||||
reg rst_n;
|
||||
wire [3:0] count;
|
||||
|
||||
// 实例化被测模块
|
||||
counter uut (
|
||||
.clk(clk),
|
||||
.rst_n(rst_n),
|
||||
.count(count)
|
||||
);
|
||||
|
||||
// 生成时钟信号 (10ns 周期 = 100MHz)
|
||||
initial begin
|
||||
clk = 0;
|
||||
forever #5 clk = ~clk;
|
||||
end
|
||||
|
||||
// 测试序列
|
||||
initial begin
|
||||
// 生成 VCD 波形文件
|
||||
$dumpfile("output.vcd");
|
||||
$dumpvars(0, counter_tb);
|
||||
|
||||
// 初始化信号
|
||||
rst_n = 0;
|
||||
|
||||
// 等待 20ns 后释放复位
|
||||
#20;
|
||||
rst_n = 1;
|
||||
|
||||
// 运行 200ns 让计数器计数
|
||||
#200;
|
||||
|
||||
// 显示最终计数值
|
||||
$display("Final count value: %d", count);
|
||||
|
||||
// 结束仿真
|
||||
$finish;
|
||||
end
|
||||
|
||||
// 监控输出变化
|
||||
initial begin
|
||||
$monitor("Time=%0t ns, rst_n=%b, count=%d (0x%h)",
|
||||
$time, rst_n, count, count);
|
||||
end
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user