1. 程式人生 > 實用技巧 >modelsim 模擬過程

modelsim 模擬過程

以一個計數程式為例,記 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能看到波形

在這裡插入圖片描述