Test Bench Un test bench es una entidad que no tiene declaraciones de puertos. Consiste en una arquitectura que contiene una instancia del componente a.

Slides:



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

© 1998, Peter J. AshendenVHDL Quick Start1 Basic VHDL Concepts Interfaces Behavior Structure Test Benches Analysis, elaboration, simulation Synthesis.
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.
1 H ardware D escription L anguages Basic Input/Output.
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
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.
Sistemas Digitais I LESI - 2º ano Lesson 5 - VHDL U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes Dept.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
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.
Binary-to-BCD Converter
1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
(1) Basic Input and Output © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
CMPUT Computer Organization and Architecture II 1 CMPUT329 - Fall 2003 Topic 6: Testbenches Paras Mehta and José Nelson Amaral.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Binary-to-BCD Converter
Design Verification VHDL ET062G & ET063G Lecture 5 Najeem Lawal 2012.
10/17/2015DSD, USIT, GGSIPU1 Data Types Each data object has a type associated with it. The type defines the set of values that the object can have and.
VHDL Project I: Introduction to Testbench Design Matthew Murach Slides Available at:
Digital System Verification. VERIFICATION OUTLINE Purpose of Verification –Verification effort and cost Verification Tools –Linting tools –Code Coverage.
ECE 368 CAD-Based Logic Design Shantanu Dutt Lecture 11 File I/O and Textio in VHDL (courtesy of Karam Chatha, ASU)
VHDL Files & Text IO ECE4623/5623 Computer Hardware Design.
1 Introduction to VHDL Spring What is VHDL? VHDL can be uses to model and synthesise digital systems. VHDL = VHSIC Hardware Description Language.
George Mason University ECE 545 Lecture 7 Advanced Testbenches.
George Mason University ECE 545 – Introduction to VHDL Variables, Functions, Memory, File I/O ECE 545 Lecture 7.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
IAY 0600 Digital Systems Design VHDL discussion Verification: Testbenches Alexander Sudnitson Tallinn University of Technology.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
1 VLSI Design & Reconfigurable Computing ENG*6090(3) Advanced Topics in VHDL Stephen Coe Guangfa Lu Friday, March 07, 2003.
EE694v-Verification-Lect6-1- Lecture 6 - Writing Tests A difference if treating the design as a black box or if you have access to internal signals EE762.
Lecture #7 Page 1 Lecture #7 Agenda 1.VHDL Data Types Announcements 1.n/a ECE 4110– Digital Logic Design.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
Introduction to VHDL. VHDL DARPA, VHSIC (Very High Speed Integrated Circuits) program Different manufacturers Standard language to describe –Structure.
George Mason University Simple Testbenches ECE 545 Lecture 4.
1 Introduction to VHDL Part 2 Fall We will use Std_logic And, Or have same precedence See slide 8 of part 1.
Assignment write a short notes on 1.Manufacturing Testing. 2.Functional Testing. 3.Files and Text I/O. 4.Differentiate the cpld and fpga architecture.
16/11/2006DSD,USIT,GGSIPU1 Packages The primary purpose of a package is to encapsulate elements that can be shared (globally) among two or more design.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
EE694v-Verification-Lect6-1- Lecture 6 - Writing Tests A difference if treating the design as a black box or if you have access to internal signals EE762.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Lecture 8 Review Combinational Devices –Decoder –Multiplexor (Bhasker p-81) –Shifter –Barrel Shifter (Bhasker p-303)
Modern Digital System Design Using VHDL: A Practical Introduction Subprograms & Packages Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
CWRU EECS 318 EECS 318 CAD Computer Aided Design LECTURE Simulator 2: Textio, Wait, Clocks, and Test Benches Instructor: Francis G. Wolff
George Mason University Advanced Testbenches Lecture 4.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Part III: SYSTEM DESIGN
ECE 4110–5110 Digital System Design
ECE 545 Lecture 10 Advanced Testbenches.
CPE 528: Session #7 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
ECE 448 Lab 1a Developing Effective Testbenches
ECE 434 Advanced Digital System L17
CHAPTER 10 Introduction to VHDL
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
Modeling of Circuits with a Regular Structure
ECE 331 – Digital System Design
ECE 545 Lecture 5 Simple Testbenches.
High-Low Guessing Game
Data Types Each data object has a type associated with it.
4-Input Gates VHDL for Loops
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
(Simple Testbenches & Arithmetic Operations)
Presentation transcript:

Test Bench Un test bench es una entidad que no tiene declaraciones de puertos. Consiste en una arquitectura que contiene una instancia del componente a ser testeado y procesos que general los valores sobre las señales conectadas al mismo. Tambien puede contener procesos que chequeen que las salidas del sistema son las esperadas. La arquitectura de un test bench normalmente consiste en una parte estructural (instanciacion del componente a testear) y uno o varios procesos que generan los datos a testear.

Estructura ENTITY test_bench IS END test_bench; ARCHITECTURE s OF test_bench IS COMPONENT clock PORT( clk: OUT std_logic ); END COMPONENT; COMPONENT wm PORT( clk, start, lid, pause: IN std_logic; ……); END COMPONENT; SIGNAL clk, start, lid, pause : std_logic_vector; BEGIN c : clock PORT MAP( clk => clk ); f : wm PORT MAP( clk => clk, start => start, lid => lid, … ); p : PROCESS BEGIN … END PROCESS; END ARCHITECTURE s;

Ejemplo de Test Bench entity reg4 is port ( d0, d1, d2, d3, en, clk : in bit; q0, q1, q2, q3 : out bit ); end entity reg4; architecture behav of reg4 is begin storage : process is variable stored_d0, stored_d1, stored_d2, stored_d3 : bit; begin wait until clk; if en then stored_d0 := d0; stored_d1 := d1; stored_d2 := d2; stored_d3 := d3; end if; q0 <= stored_d0; q1 <= stored_d1; q2 <= stored_d2; q3 <= stored_d3; end process storage; end architecture behav;

Ejemplo de Test Bench entity test_bench is end entity test_bench; architecture test_reg4 of test_bench is signal d0, d1, d2, d3, en, clk, q0, q1, q2, q3 : bit; begin dut : entity work.reg4(behav) port map ( d0, d1, d2, d3, en, clk, q0, q1, q2, q3 ); stimulus : process is begin d0 <= '1'; d1 <= '1'; d2 <= '1'; d3 <= '1'; en <= '0'; clk <= '0'; wait for 20 ns; en <= '1'; wait for 20 ns; clk <= '1'; wait for 20 ns; d0 <= '0'; d1 <= '0'; d2 <= '0'; d3 <= '0'; wait for 20 ns; en <= '0'; wait for 20 ns;... wait; end process stimulus; end architecture test_reg4;

Driving signals al testbench Waveform assignament: start <= ‘0’, ‘1’ after 1 sec, ‘0’ after 50 ms Loops dentro de procesos: process begin for j in 0 to 9 loop start<='0'; WAIT for 1 sec; start<=s(j); --tenemos una tabla con los valores cargados WAIT for 1 sec; --chequeo los resultados end loop; end process; Generacion de clock

Escribiendo a archivos El tipo file en VHDL se utiliza para representar archivos. file nombre logico : nombre tipo [ open modo ] is ”archivo.ext” el modo puede ser write mode, read mode o append mode. Se utilizan las siguientes librerias: Textio: es una libreria para manejar textos. La entrada/salida de texto se realiza a traves de una variable tipo line. txt_util

TextIO PreDefined Files Input : Text is in "Std_Input"; -- usually mapped to keyboard Output : Text is out "Std_Output"; --usually mapped to console Type Text is file of String; Type Line is access String; Type Side is ( Right, Left ); Subtype Width is Natural;

Read Procedures procedure ReadLine ( F : in Text; L : out Line ); procedure Read ( L : inout; Value : out; |Good : out Boolean| ); Read is an Overloaded Procedure Where Value May be of Type: + Bit, Bit_Vector + Boolean + Character + Integer + Real + String + Time

Write Procedures procedure WriteLine ( F : out Text; L : out Line ); procedure Write ( L : inout;.. Write is an Overloaded Procedure Where Value May be of Type: + Bit, Bit_Vector + Boolean + Character + Integer + Real + String + Time

File I/O Status procedure file_open ( status : out file_open_status, file f : file_type, external_name : in string, open_kind : in file_open_kind := read_mode ) ; type file_open_status is ( open_ok, status_error, name_error, mode_error ) ; file_open_status open_ok File Opened Successfully status_error File Previously Opened name_error read_mode, append_mode - File Does Not Exist write_mode - Can Not Create File file_name mode_error File Exists But Can NotOpened in Specific Mode

Ejemplo de lectura file p_file : text open read_mode is "C:\CLASS\ALU.PAT" ; Begin Process Variable l : Line; Variable b : Bit;... Begin While Not Endfile( f ) Loop Readline ( p_file, l ); Read ( l, b );... End Loop; End Process; End Arc;

Ejemplo de Escritura file p_file : text open write_mode is "C:\CLASS\ALU.PAT" ; Begin Process Variable l : Line; Variable r : Bit_vector ( 31 downto 0 ) ;... Begin For i in r'range Loop Write ( l, r ( i ) );... Writeline ( p_file, l ). ; End Loop; End Process; End Arc;

ejemplo use textio.all; architecture behavior of check is begin process (x) variable s : line; variable cnt : integer:=0; begin if (x='1' and x'last_value='0') then cnt:=cnt+1; if (cnt>MAX_COUNT) then write(s,"Counter overflow - "); write(s,cnt); writeline(output,s); end if; end process; end behavior;

Escribiendo a archivos library ieee; use ieee.std_logic_1164.all; use std.textio.all; use work.txt_util.all; entity FILE_LOG is generic ( log_file: string := "res.log" ); port( CLK : in std_logic; RST : in std_logic; x1 : in std_logic; x2 : in std_logic_vector(7 downto 0) ); end FILE_LOG;

Escribiendo a archivos architecture log_to_file of FILE_LOG is file l_file: TEXT open write_mode is log_file; Begin while true loop write(l, str(x1)&" "& hstr(x2)& "h"); writeline(l_file, l); end loop;

Libreria TXT_UTIL library ieee; use ieee.std_logic_1164.all; use std.textio.all; package txt_util is -- prints a message to the screen procedure print(text: string); -- prints the message when active -- useful for debug switches procedure print(active: boolean; text: string); -- converts std_logic into a character function chr(sl: std_logic) return character; -- converts std_logic into a string (1 to 1) function str(sl: std_logic) return string;

-- converts std_logic_vector into a string (binary base) function str(slv: std_logic_vector) return string; -- converts boolean into a string function str(b: boolean) return string; -- converts an integer into a single character -- (can also be used for hex conversion and other bases) function chr(int: integer) return character; -- converts integer into string using specified base function str(int: integer; base: integer) return string; -- converts integer to string, using base 10 function str(int: integer) return string; -- convert std_logic_vector into a string in hex format function hstr(slv: std_logic_vector) return string;

-- functions to manipulate strings convert a character to upper case function to_upper(c: character) return character; -- convert a character to lower case function to_lower(c: character) return character; -- convert a string to upper case function to_upper(s: string) return string; -- convert a string to lower case function to_lower(s: string) return string;

-- functions to convert strings into other formats converts a character into std_logic function to_std_logic(c: character) return std_logic; -- converts a string into std_logic_vector function to_std_logic_vector(s: string) return std_logic_vector; -- file I/O read variable length string from input file procedure str_read(file in_file: TEXT; res_string: out string); -- print string to a file and start new line procedure print(file out_file: TEXT; new_string: in string); -- print character to a file and start new line procedure print(file out_file: TEXT; char: in character); end txt_util;