1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.

Slides:



Advertisements
Similar presentations
VHDL in digital circuit synthesis (tutorial) dr inż. Miron Kłosowski EA 309
Advertisements

Digital Design with VHDL Presented by: Amir Masoud Gharehbaghi
Sequential Statements
Lecture 6 Chap 8: Sequential VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Quad 2-to-1 and Quad 4-to-1 Multiplexers Discussion D2.4 Example 7.
History TTL-logic PAL (Programmable Array Logic)
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL ECE 448 Lecture 10 Advanced Testbenches.
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
4-to-1 Multiplexer: case Statement Discussion D2.3 Example 6.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
Resolved Signals Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
Reconfigurable Computing - VHDL - Types John Morris Chung-Ang University The University of Auckland.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Hardware Design Environment Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Graduate Computer Architecture I VHDL Structure and Testing Michael Sorensen.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
VHDL Project I: Introduction to Testbench Design Matthew Murach Slides Available at:
EE3A1 Computer Hardware and Digital Design Lecture 5 Testbenches and Memories in VHDL.
George Mason University ECE 545 Lecture 7 Advanced Testbenches.
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
Lecture 5 Chap 6 Package std_logic_arith Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
Generate Statements Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Design Methodology Based on VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
ECE 331 – Digital System Design Multiplexers and Demultiplexers (Lecture #13)
Reconfigurable Computing - VHDL - Types John Morris Chung-Ang University The University of Auckland.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Hardware Description Languages Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
Lecture 7 Chap 9: Registers Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
George Mason University Simple Testbenches ECE 545 Lecture 4.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
ECOM 4311—Digital System Design with VHDL
Data Flow Modeling in VHDL
Apr. 3, 2000Systems Architecture I1 Introduction to VHDL (CS 570) Jeremy R. Johnson Wed. Nov. 8, 2000.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
May 9, 2001Systems Architecture I1 Systems Architecture I (CS ) Lab 5: Introduction to VHDL Jeremy R. Johnson May 9, 2001.
Signals & Data-typesVer 1.1, Copyright 1997, TS, Inc. VHDL S i g n a l s & D a t a T y p e s Page 1.
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
George Mason University Advanced Testbenches Lecture 4.
ECE 448 Lab 1 Developing Effective Testbenches
ECE 448 – FPGA and ASIC Design with VHDL George Mason University ECE 448 Lab 2 Implementing Combinational Logic in VHDL.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
IAY 0600 Digital Systems Design
Systems Architecture Lab: Introduction to VHDL
Verification: Testbenches in Combinational Design
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
ECE 545 Lecture 10 Advanced Testbenches.
CPE 528: Session #7 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
ECE 331 – Digital System Design
Figure 8.1. The general form of a sequential circuit.
Developing Effective Testbenches
ECE 545 Lecture 5 Simple Testbenches.
Sequntial-Circuit Building Blocks
EEL4712 Digital Design (VHDL Tutorial).
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University

2 Test Benches Most hardware description languages: Circuit description and test waveforms are described in different ways. VHDL: the language itself can be used to express the testing waveforms. (called test benches.) Test benches: a VHDL model that generates waveforms with which to test a circuit (VHDL) model. Test benches is used only in simulation, not for synthesized.

3 Test Benches A synthesizable model should be extensively tested in simulation before synthesis to ensure correctness. WYSISYG: what you simulate is what you get. Any errors in the design will be faithfully synthesized as errors in the final circuit. (Testing is very important…) Diagnosing errors in synthesizer-generated netlists is almost impossible. Because test benches are not synthesized, the full scope of VHDL language is available for writing them.

4 Combinational Test Benches How to write a test bench for combinational circuits. (use testing a MUX (2x1 multiplexer) as an example) 1. Define an empty entity: entity mux_test is end; 2. Create an architecture with the under-test component instance. 3. Produce test patterns: 4. Write a process to test the circuit by applying the test patterns: mux Gen inputs

5 Combinational Test Benches 2. Create an architecture with the under-test component instance. library ieee; use ieee.std_logic_1164.all; architecture test_bench of mux_test is component mux; port (in0,in1,sel:in std_logic; z: out std_logic; end component; for all: mux use work.mux; signal in0, in1, sel, z:std_logic; begin CUT: mux port map(in0,in1,sel,z); end;

6 Combinational Test Benches 3. Produce test patterns: type sample is record in0: std_logic; in1: std_logic; sel: std_logic; end; type sample_array is array (natural range <>) of sample; constant test_data: sample_array := ( (‘0’,’0’,’0’), (‘0’,’0’,’1’), (‘0’,’1’,’0’), (‘0’,’1’,’1’), (‘1’,’0’,’0’), (‘1’,’0’,’1’), (‘1’,’1’,’0’), (‘1’,’1’,’1’) );

7 Combinational Test Benches 4. Write a process to test the circuit by applying the test patterns: process begin for i in test_data’range loop in0 <=test_data(i).in0; in1 <=test_data(i).in1; sel <=test_data(i).sel; wait for 10ns; end loop; wait; end process;

8 entity mux_test is end; library ieee; use ieee.std_logic_1164.all; architecture test_bench of mux_test is type sample is record in0: std_logic; in1: std_logic; sel: std_logic; end; type sample_array is array (natural range <>) of sample; constant test_data: sample_array := ( (‘0’,’0’,’0’), (‘0’,’0’,’1’), (‘0’,’1’,’0’), (‘0’,’1’,’1’), (‘1’,’0’,’0’), (‘1’,’0’,’1’), (‘1’,’1’,’0’), (‘1’,’1’,’1’) );

9 component mux; port (in0,in1,sel:in std_logic; z: out std_logic; end component; for all: mux use work.mux; signal in0, in1, sel, z:std_logic; begin process for i in test_data’range loop in0 <=test_data(i).in0; in1 <=test_data(i).in1; sel <=test_data(i).sel; wait for 10 ns; end loop; wait; end process; CUT: mux port map(in0,in1,sel,z); end;

10 Combinational Test Benches: verifying responses Check the correctness through outputs Response data: type sample is record in0: std_logic; in1: std_logic; sel: std_logic; z: std_logic; end; constant test_data: sample_array := ( (‘0’,’0’,’0’,’0’), (‘0’,’0’,’1’,’0’), (‘0’,’1’,’0’,’0’), (‘0’,’1’,’1’,’1’), (‘1’,’0’,’0’,’1’), (‘1’,’0’,’1’,’0’), (‘1’,’1’,’0’,’1’), (‘1’,’1’,’1’,’1’) );

11 Combinational Test Benches: verifying responses Check the correctness through outputs Response data: type sample is record in0: std_logic; in1: std_logic; sel: std_logic; z: std_logic; end; constant test_data: sample_array := ( (‘0’,’0’,’0’,’0’), (‘0’,’0’,’1’,’0’), (‘0’,’1’,’0’,’0’), (‘0’,’1’,’1’,’1’), (‘1’,’0’,’0’,’1’), (‘1’,’0’,’1’,’0’), (‘1’,’1’,’0’,’1’), (‘1’,’1’,’1’,’1’) );

12 Combinational Test Benches: verifying responses Check the response process for i in test_data’range loop in0 <=test_data(i).in0; in1 <=test_data(i).in1; sel <=test_data(i).sel; wait for 10ns; assert z = test_data(i).z report “output z is wrong!” severity error; end loop; wait; end process;

13 Test Benches: Clock & Reset A simple clocked circuit:

14 Test Benches: Clock & Reset under-test component instance: library ieee; use ieee.std_logic_1164.all; architecture test_bench of Dmux_test is component Dmux; port (in0,in1,sel,ck:in std_logic; z: out std_logic; end component; for all: Dmux use work.Dmux; signal in0, in1, sel, ck, z:std_logic; begin CUT: Dmux port map(in0,in1,sel, ck, z); end;

15 Test Benches: Clock & Reset Check the response process for i in test_data’range loop in0 <=test_data(i).in0; in1 <=test_data(i).in1; sel <=test_data(i).sel; ck <=‘0’; wait for 5 ns; ck <=‘1’; wait for 5 ns; assert z = test_data(i).z report “output z is wrong!” severity error; end loop; wait; end process;

16 Test Bench: count_ones architecture behavior of count_ones is process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); for i in vec’range loop next when vec(i) = ‘0’; result = result +1; end loop count <= result; end process; end;

17 Test Bench: count_ones input and output of count_ones is vectors: Vec: std_logic_vector(15 downto 0); count: std_logic_vector(4 downto 0);

18 Test Bench: count_ones under-test component instance: library ieee; use ieee.std_logic_1164.all; architecture test_bench of count_ones_test is component count_ones port (vec:in std_logic_vector(15 downto 0); count: out std_logic_vector(4 downto 0); end component; for all: count_ones use work.count_ones; signal vec: std_logic_vector(15 downto 0); signal count: std_logic_vector(4 downto 0); begin CUT: count_ones port map(vec, count); end;

19 Test Bench: count_ones Check the correctness through outputs Response data: type sample is record vec:in std_logic_vector(15 downto 0); count: out std_logic_vector(4 downto 0); end; type sample_array is array (natural range <>) of sample; constant test_data: sample_array := ( (“ ”, “00000”), (“ ”, “00100”), …. );

20 Test Bench: count_ones Response data with Hexadecimal: type sample is record vec:in std_logic_vector(15 downto 0); count: out std_logic_vector(4 downto 0); end; type sample_array is array (natural range <>) of sample; constant test_data: sample_array := ( (X“0000”, “00000”), (X“000F”, “00100”), …. );

21 Test Bench: count_ones Response data with Hexadecimal input, integer output: type sample is record vec:in std_logic_vector(15 downto 0); count: out integer; end; type sample_array is array (natural range <>) of sample; constant test_data: sample_array := ( (X“0000”, 0), (X“000F”, 4), …. );

22 Test Bench: count_ones Check the response process for i in test_data’range loop vec <=test_data(i).vec; wait for 10ns; assert count = to_unsigned(test_data(i).count, count’length) report “output count is wrong!” severity error; end loop; wait; end process;

23 Test Bench: Don’t care Many circuits do not generate valid outputs on very clock cycle. Example: pipeline Test benches need to ignore the invalid outputs and check only valid outputs. 1. Use extra field to indicates an valid or invalid output the field’s type is boolean. 2. Use don’t care.

24 Test Bench: invalid output Circuit to be tested: 1-bit register in the 3rd pipeline stage library ieee; use ieee.std_logic_1164.all; entity delay3 is port (d, ck: in std_logic, q: out std_logic); end; Sample record: type sample is record d: std_logic; q: std_logic; valid: boolean; end record;

25 Test Bench: invalid output Test patten: constant test_data: sample_array:= ( (‘1’,’0’,false), (‘0’,’0’,false), (‘1’,’1’,true), … ); test statement: if test_data(i).valid then assert test_data(i).q = q report “q is wrong”; severity error; end if;

26 Test Bench: don’t care output Test patten: constant test_data: sample_array:= ( (‘1’,’-’), (‘0’,’-’), (‘1’,’1’), … ); test statement: assert std_match(test_data(i).q, q) report “q is wrong”; severity error;

27 Print Response values It is useful to print out the expected and actual values. A function converting std_logic to string: function toString(arg:std_logic) return string is begin case arg is when ‘U’ return “U”;when ‘X’ return “X”; when ‘0’ return “0”;when ‘1’ return “1”; when ‘W’ return “W”;when ‘L’ return “L”; when ‘H’ return “H”;when ‘Z’ return “Z”; when ‘-’ return “-”; end case; end;

28 Print Response values The assertion statement: assert test_data(i).q = q; report “q:expected =“ & toString(test_data(i).q) & “, actural =“ & toString(q) severity error; See page for predefined conversion functions.