Art of Writing TestBenches(of verilog HDL) Part - IV
来源:互联网 发布:推荐翻墙工具 .知乎 编辑:程序博客网 时间:2024/05/22 02:23
To make any testbench self checking/automated, first we need to develop a model that mimics the DUT in functionality.
为了是测试基准程序能偶自动校验,我首先要开发一个模型能够反应DuT的功能。
In our example, it's going to be very easy, but at times if the DUT is complex, then to mimic it will be very complex and will require a lot of innovative techniques to make self-checking work.
1 reg [3:0] count_compare; 2 3 always @ (posedge clk) 4 if (reset == 1'b1) begin 5 count_compare <= 0; 6 end else if ( enable == 1'b1) begin 7 count_compare <= count_compare + 1; 8 endYou could download file counter_tb10.v here
Once we have the logic to mimic the DUT functionality, we need to add the checker logic, which at any given point keeps checking the expected value with the actual value. Whenever there is any error, it prints out the expected and actual value, and also terminates the simulation by triggering the event "terminate_sim".
1 always @ (posedge clk) 2 if (count_compare ! = count) begin 3 $display ("DUT Error at time %d", $time); 4 $display (" Expected value %d, Got Value %d", count_compare, count); 5 #5 -> terminate_sim; 6 end
You could download file counter_tb11.v here Now that we have the all the logic in place, we can remove $display and $monitor, as our testbench have become fully automatic, and we don't require to manually verify the DUT input and output. Try changing the count_compare = count_compare +2, and see how compare logic works. This is just another way to see if our testbench is stable.
We could add some fancy printing as shown in the figure below to make our test environment more friendly.
C:\Download\work>veridos counter.v counter_tb.v VeriWell for Win32 HDL Sat Jan 18 20:10:35 2003 This is a free version of the VeriWell for Win32 Simulator Distribute this freely; call 1-800-VERIWELL for ordering information See the file "!readme.1st" for more information Copyright (c) 1993-97 Wellspring Solutions, Inc. All rights reserved Memory Available: 0 Entering Phase I... Compiling source file : counter.v Compiling source file : counter_tb.v The size of this model is [5%, 6%] of the capacity of the free version Entering Phase II... Entering Phase III... No errors in compilation Top-level modules: counter_tb ############################################ Applying reset Came out of Reset Terminating simulation Simulation Result : PASSED ########################################### Exiting VeriWell for Win32 at time 96 0 Errors, 0 Warnings, Memory Used: 0 Compile time = 0.0, Load time = 0.0, Simulation time = 0.0 Normal exit Thank you for using VeriWell for Win32
I know, you would like to see the test bench code that I used to generate the above output, well you can find it here and counter code here.
There are a lot of things that I have not covered; maybe when I find time, I may add some more details on this subject.
As to books, I am yet to find a good book on writing test benches.
the original above link : http://www.asic-world.com/verilog/art_testbench_writing4.html
- Art of Writing TestBenches(of verilog HDL) Part - IV
- Art of Writing TestBenches (of Verilog HDL) Part - I
- Art of Writing TestBenches (of Verilog HDL) Part - II
- Art of Writing TestBenches (of Verilog HDL)
- Art of Writing TestBenches Part - III
- History of Verilog HDL
- Verilog HDL in one day Part-IV
- Verilog HDL Behavioral Modeling Part-IV
- Gate Level Modeling Part-I (of Verilog HDL)
- Gate Level Modeling Part-II (of Verilog HDL)
- Gate Level Modeling Part-III (of Verilog HDL)
- User Defined Primitives Part-I (of Verilog HDL)
- User Defined Primitives Part-II (of Verilog HDL)
- User Defined Primitives Part-III (of Verilog HDL)
- Procedural Timing Control (of Verilog HDL)
- Design And Tool Flow (of Verilog HDL)
- Gate Level Modeling (of Verilog HDL)
- User Defined Primitives ( of Verilog HDL)
- 无题
- html5(arc()方法)
- ObjC转换为cpp的规则
- 屏蔽js错误
- 数据库系统中事务的ACID原则
- Art of Writing TestBenches(of verilog HDL) Part - IV
- 状态栏彩色渐变进度条实例
- 用数组实现链表一(静态链表)
- [sicily online]1093. Air Express
- 《Inside The C++ Object Model》临时对象
- 分析OpenSurf(1)
- html5标签
- TokuDB6.5与InnoDB(1.1.18)性能对比测试
- 软件计划