简单的Verilog测试模板结构

2023-02-17,,,,

这里记录一下曾经用到的简单测试模板,如下所示:

//timescale
`timescale 1ns/1ns
module tb_module();
//the Internal motivation variable(register) and output wire //the External motivation storage variable //Sub module signal,example: wire [1:0] xxx == xxx_inst.xxx_inst.xxx; // Global variable initialization ,such as 'clk'、'rst_n'
initial begin
# rst_n = ;
clk = ;
# rst_n = ;
end //Internal motivation variable initialization
//initial begin
//end //cloclk signal generation
always # clk = ~clk ; //Cases of sub module xxxx xxxx_inst(.(),.(), ... ,.()); // Internal motivation variable assignment using task or random
/* example
task data_assign(xx); | task rand_bit();
integer xx,xx,...; | integer i;
begin | begin
for( ; ; )begin | for(i=0; i<255; i=i+1)begin
@(posedge clock) | @(posedge sclk);
Internal motivation variable <= xxxxx; | Internal motivation variable <={$random} %2;
end | end
end | end
endtask | endtask
*/ endmodule

整个测试模块(结构)很简单,并没有结果捕捉模块,因此如果有错的话,并不会打印出来,需要在波形中查看,仅限于简单模块使用。

另外一个简单的verilog测试模板结构如下所示:

module tb_module;
//drive the input port with reg type //sample the output with the wire type //task1 create the instance //task2 clock and reset generator
parameter CLK_PERIOD = ;
reg clk ,rst_n;
initial begin
clk = ;
forever begin
#(CLK_PERIOD/) clk = ~clk ;
end
end initial begin
rst_n = ;
#
rst_n = ;
end //task3 drive the stimulus and capture the response
//testcase //task4 check the result //task5 dump waveform with the compile option -debug_all,for the VCS
initial begin
$vcdpluson;
end endmodule

这些结构都没有给出具体的内容。有空补上一个简单的例子。

简单的Verilog测试模板结构的相关教程结束。

《简单的Verilog测试模板结构.doc》

下载本文的Word格式文档,以方便收藏与打印。