以一个计数程序为例,记 fluorescentG1,fluorescentG2,fluorescentG3在70ms的计数值 , 这三个数的计数值。
testbench如下:
`timescale 1ns/1ps
module FluorescentAC_Test;
reg clk_16M;
reg rst_n;
reg go;
reg fluorescentG1;
reg fluorescentG2;
reg fluorescentG3;
wire[15:0] G1CNT;
wire[15:0] G2CNT;
wire[15:0] G3CNT;
FluorescentAC FluorescentAC_vt
(
.clk_16M(clk_16M),
.rst_n(rst_n),
.go(go),
.fluorescentG1(fluorescentG1),
.fluorescentG2(fluorescentG2),
.fluorescentG3(fluorescentG3),
.G1CNT(G1CNT),
.G2CNT(G2CNT),
.G3CNT(G3CNT)
);
initial
begin
rst_n=1;
clk_16M=0;
fluorescentG1=0;
fluorescentG2=0;
fluorescentG3=0;
#600 rst_n=0;
#600 rst_n=1;
end
always begin #100 clk_16M = ~clk_16M; end
always begin #850 fluorescentG1=~fluorescentG1;end
always begin #1050 fluorescentG2=~fluorescentG2;end
always begin #2050 fluorescentG3=~fluorescentG3;end
endmodule
打开modelsim,file–new project。添加两个文件.v和.vt。
之后编译compile all。点击work下面的test文件,ok
之后点击最左侧add–add to wave–all items in region
进入如下界面,点击run能看到波形