intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Chapter9: Testbench and Verification

Chia sẻ: Lê Văn | Ngày: | Loại File: PDF | Số trang:73

61
lượt xem
9
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

A testbench is used to verify that the logic is correct. The testbench instantiates the logic under test. It reads a file of inputs and expected outputs called test -vectors, applies them to the module under test, and logs mismatches.

Chủ đề:
Lưu

Nội dung Text: Chapter9: Testbench and Verification

  1. NATIONAL UNIVERSITY OF HO CHI MINH CITY UNIVERSITY OF INFORMATION TECHNOLOGY FACULTY OF COMPUTER ENGINEERING LECTURE VERILOG Subject: Hardware Design Language Chapter9: Testbench and Verification Lecturer: Lam Duc Khai 1
  2. Agenda 1. Chapter 1: Introduction ( Week1) 2. Chapter 2: Fundamental concepts (Week1) 3. Chapter 3: Modules and hierarchical structure (Week2) 4. Chapter 4: Primitive Gates – Switches – User defined primitives (Week2) 5. Chapter 5: Structural model (Week3) 6. Chapter 6: Behavioral model – Combination circuit & Sequential circuit (Week4 & Week5) 7. Chapter 7: Tasks and Functions (Week6) 8. Chapter 8: State machines (Week6) 9. Chaper 9: Testbench and verification (Week7) 2
  3. Agenda 3
  4. CAD flow reminder Pre-synthesis Design Specification verification: Behavior Description Pre-synthesis verification + Check design function flaws that may cause by ambiguous problem specification, Compilation and Synthesis designer errors, or incorrect use of parts in the design. + Done by simulation (presynthesis simulation), and Placement Routing assertion verification with testbench definition or input waveform. Timing analyis Post-synthesis verification Physical layout Chip 4
  5. CAD flow reminder (Cont’d) Function verification with input waveform: Define input waveform manually 5
  6. CAD flow reminder (Cont’d) Function verification with testbench: • A testbench is used to verify that the logic is correct. The testbench instantiates the logic under test. It reads a file of inputs and expected outputs called test -vectors, applies them to the module under test, and logs mismatches. • Testbench is a code for test, not a part of final design. 6
  7. CAD flow reminder (Cont’d) Function verification with testbench: 7
  8. Structure of a testbench •Structure1 8
  9. Structure of a testbench (Cont’d) •Structure1 (Cont’d) 9
  10. Structure of a testbench (Cont’d) •Structure1 (Cont’d) 10
  11. Structure of a testbench (Cont’d) •Structure1 (Cont’d) 11
  12. Structure of a testbench (Cont’d) •Structure2 module testbench; This part is same to Verilog parameter declaration RTL programming in the declaration such as the signal previous pages (reg [7:0] dat, … and so on) design module instances Used for generating clock always sentence signals and other signals initial sentence definition of function Used to give initial value to definition of task the signals and to create endmodule signals in time sequence 12
  13. Structure of a testbench (Cont’d) •Structure2 (Cont’d) D_FF example: module dff (d ,clk, q ); input d, clk; output q; reg q; always @(posedge clk) q
  14. Structure of a testbench (Cont’d) •Structure2 (Cont’d) `timescale 1ns/1ps module stimulus; reg din, clock; reg exp; wire dout; parameter clk_cycle = 20; // Instance DFF dff instance_1 (.d(din), .clk(clock), .q(dout)); // Clock generator always begin #(clk_cycle/2) clock = ~clock; $display( "Time at %5f. DIN: [%b] DO=[%b]", $realtime, din, dout); end 14
  15. Structure of a testbench (Cont’d) •Structure2 (Cont’d) // Input waveform and Expected output initial begin clock = 1'b0; //Compare output din = 1'b0; always @(negedge clock) fork begin #6 din = 1'b1; if (dout !== exp) #11 exp = 1'b1; $display( "FAIL: %5f - #26 din = 1'b0; output=[%b] Exp=[%b]", $realtime, dout, exp); #31 exp = 1'b0; else #46 din = 1'b1; $display( "PASS: %5f - #51 exp = 1'b1; output=[%b] Exp=[%b]", $realtime, dout, exp); #66 din = 1'b0; end #71 exp = 1'b0; endmodule #100 $finish; join end 15
  16. Test vectors definition While programming RTL code, it is important to assume various data as input and make your code prepared for such data. Your code will not work properly for data which you did not expected to come. This means your imaginative power decide the quality of your program. To verify design function correctly but less time comsuming, it is very important for an engineer to be able to select or determine proper data to test a module he/she designed. Test data shall be selected so that all the possible paths of your code are covered. Typical cases Use data which will be applied most usually. Test data All possible state change Use data which will be applied most usually. Corner cases Use data which will be applied most usually. 16
  17. Test vectors definition (Cont’d) To do test, you must have the state transition matrix of your logic. You have to apply data which causes all the possible transition of the state. state …. INTL ST1 ST2 input in1 no- ST2 ST3 …. op If you have not prepared a in2 ST1 ST3 state transition matrix, write it. in3 ST2 …. …. Without a state transition matrix, we can not verify our logic. 17
  18. Test vectors definition (Cont’d) How to select typical and corner cases. What data can check corner cases depend on the logic to handle them. However, we have to have a good sensitivity to tell what kind of data may be critical for various logic. Example For 8-bit numerical input data, 8’h25, 8’h74, 8’h09, etc. may be typical input 8’h00, 8’hFF may be corner case input For 1-bit control input data which is supposed to be 1 several times for certain period of time, Input sequence: 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, … may be typical input, 1, 1, 1, 1, 1, 1, 1, 1, … may be corner case input. 18
  19. Test vectors definition (Cont’d) Suppose testing logic which calculate average of four 4-bit positive integers. 4-bit output average must be rounded. If we prepare the following data for testing, is it effective for finding bugs? Prepared data: 4’b0010, 4’b0101, 4’b0100, and 4’b0001, add result 12 is still 4-bit integer data, a1 no carry produced, no round up operation needed + a2 There are several ways divide + to implement the logic. A average a3 by 4 rounding diagram shown on the + left may be one possible a4 implementation Where bugs possibly sneak in? Your imaginative power is needed!! 19
  20. Test vectors definition (Cont’d) Where bugs possibly sneak in? a1 error in dividing by 4 This can be checked reslt_sum by typical data + a2 divide + average a3 by 4 rounding + a4 reslt_num error in round operation use another error in but than bit 1 11_1101 handling possible of reslt_sum carry bugs bit 1 of reslt_num 00_0010 reslt_sum is not used carry is round up 11_1101 01_1110 neglected miss possible bugs a1, a2, a3 and a4 shall be fraudulent 00_0010 determined so that those carry is reslt_sum are to be created.0 2 created
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2