VHDL: A Crash Course

Similar documents
Introduction to VHDL. Yvonne Avilés Colaboration: Irvin Ortiz Flores Rapid System Prototyping Laboratory (RASP) University of Puerto Rico at Mayaguez

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Hardware Description Languages. Modeling Complex Systems

Lecture 7. Standard ICs FPGA (Field Programmable Gate Array) VHDL (Very-high-speed integrated circuits. Hardware Description Language)

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

VHDL. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Modeling Complex Behavior

Hardware Description Language VHDL (1) Introduction

COE 405 Design Methodology Based on VHDL

Computer-Aided Digital System Design VHDL

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

ECE 545 Lecture 4. Simple Testbenches. George Mason University

ELCT 501: Digital System Design

VHDL VS VERILOG.

Lecture 12 VHDL Synthesis

Basic Language Concepts

Contents. Appendix D VHDL Summary Page 1 of 23

CprE 583 Reconfigurable Computing

CS211 Digital Systems/Lab. Introduction to VHDL. Hyotaek Shim, Computer Architecture Laboratory

Lecture 4. VHDL Fundamentals. George Mason University

C-Based Hardware Design

What Is VHDL? VHSIC (Very High Speed Integrated Circuit) Hardware Description Language IEEE 1076 standard (1987, 1993)

Lecture 3 Introduction to VHDL

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

Tutorial 4 HDL. Outline VHDL PROCESS. Modeling Combinational Logic. Structural Description Instantiation and Interconnection Hierarchy

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

VHDL 2 Combinational Logic Circuits. Reference: Roth/John Text: Chapter 2

VHDL for FPGA Design. by : Mohamed Samy

ACS College of Engineering. Department of Biomedical Engineering. Logic Design Lab pre lab questions ( ) Cycle-1

EEL 4783: Hardware/Software Co-design with FPGAs

Review of Digital Design with VHDL

JUNE, JULY 2013 Fundamentals of HDL (10EC45) PART A

Digital Systems Design

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

EITF35: Introduction to Structured VLSI Design

Concurrent Signal Assignment Statements (CSAs)

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

CprE 583 Reconfigurable Computing

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

ECE 448 Lecture 3. Combinational-Circuit Building Blocks. Data Flow Modeling of Combinational Logic

CDA 4253 FPGA System Design Introduction to VHDL. Hao Zheng Dept of Comp Sci & Eng USF

Advanced Training Course on FPGA Design and VHDL for Hardware Simulation and Synthesis. 26 October - 20 November, 2009

Mridula Allani Fall Fall

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 4 Introduction to VHDL

310/ ICTP-INFN Advanced Tranining Course on FPGA and VHDL for Hardware Simulation and Synthesis 27 November - 22 December 2006

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

5. VHDL - Introduction - 5. VHDL - Design flow - 5. VHDL - Entities and Architectures (1) - 5. VHDL - Entities and Architectures (2) -

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

Sequential Logic - Module 5

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

Logic and Computer Design Fundamentals VHDL. Part 1 Chapter 4 Basics and Constructs

Introduction to VHDL. Main language concepts

Lattice VHDL Training

Test Benches - Module 8

VHDL. Official Definition: VHSIC Hardware Description Language VHISC Very High Speed Integrated Circuit

Lecture 4. VHDL Fundamentals. Required reading. Example: NAND Gate. Design Entity. Example VHDL Code. Design Entity

INTRODUCTION TO VHDL. Lecture 5 & 6 Dr. Tayab Din Memon Assistant Professor Department of Electronic Engineering, MUET

IT T35 Digital system desigm y - ii /s - iii

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

Introduction to VHDL #3

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

Lecture 1: VHDL Quick Start. Digital Systems Design. Fall 10, Dec 17 Lecture 1 1

Lecture 10 Subprograms & Overloading

VHDL Examples Mohamed Zaky

Digital Systems Design

Control and Datapath 8

[VARIABLE declaration] BEGIN. sequential statements

TKT-1212 Digitaalijärjestelmien toteutus. Lecture 7: VHDL Testbenches Ari Kulmala, Erno Salminen 2008

Writing VHDL for RTL Synthesis

VHDL: RTL Synthesis Basics. 1 of 59

ECE 3401 Lecture 10. More on VHDL

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

CS232 VHDL Lecture. Types

!"#$%&&"'(')"*+"%,%-".#"'/"'.001$$"

Synthesis from VHDL. Krzysztof Kuchcinski Department of Computer Science Lund Institute of Technology Sweden

Hardware Design Environments. Dr. Mahdi Abbasi Computer Engineering Department Bu-Ali Sina University

Lecture 4. VHDL Basics. Simple Testbenches

CMPT 250: Computer Architecture. Using LogicWorks 5. Tutorial Part 1. Somsubhra Sharangi

ECE 545 Lecture 12. Datapath vs. Controller. Structure of a Typical Digital System Data Inputs. Required reading. Design of Controllers

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Summary of FPGA & VHDL

VHDL Structural Modeling II

Chapter 6 Combinational-Circuit Building Blocks

Digital Systems Design

-- Fill in values for each generic. -- Fill in values for each signal. SIGNAL load_start : std_ulogic := '1'; SIGNAL clock : std_ulogic := '0';

Introduction to VHDL #1

In our case Dr. Johnson is setting the best practices

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. Behavioral Design Style: Registers & Counters.

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

The Optimization of a Design Using VHDL Concepts

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

EECE-4740/5740 Advanced VHDL and FPGA Design. Lecture 3 Concurrent and sequential statements

Transcription:

VHDL: A Crash Course Dr. Manuel Jiménez With contributions by: Irvin Ortiz Flores Electrical and Computer Engineering Department University of Puerto Rico - Mayaguez

Outline Background Program Structure Types, Signals and Variables Description Styles Combinational Logic Design Finite State Machines Testbenches

What is VHDL? VHDL: VHSIC Hardware Description Language VHSIC= Very High Speed Integrated Circuit VHDL was created for modeling digital systems Language subset used in HW synthesis Hierarchical system modeling Top-down and bottom-up design methodologies

VHDL Retrospective VHDL is an IEEE and ANSI standard for describing digital systems Created in 1981 for the DoD VHSIC program First version developed by IBM, TI, and Intermetric First release in 1985 Standardized in 1987 and revised several times thereafter Standard 1076, 1076.1 (VHDL-AMS), 1076.2, 1076.3 Standard 1164, VHDL-2006 Inherits many characteristics of ADA: Strong typed

VHDL Uses Modeling of Digital Systems Looks a High-level Language Synthesis of Digital Systems Language Subset Synthesis Targets FPGAs & FPLDs ASICs Custom ICs

VHDL-based Design Flow Design Specs Architectural Design VHDL Modeling Zero-delay RTL Design Functional RTL Design Backannotated Physical Spec Functional Verification Synthesis Timing Verification Stimulus & Testbench FPGA, Std. Cell, or ASIC Libraries Stimulus & Testbench Verified PPR Implementation

Common VHDL Data Types Integer: Predefined in the range -(2 31 ) through +(2 31-1). Subtypes can be declared Boolean: False, True Bit, std_logic: A single bit Bit_vector, std_logic_vector: Multiple bits Range needs to be specified

Basic VHDL Program Structure Library Inclusion Entity Declaration Architecture Declaration library IEEE; use IEEE.std_logic_1164.all; use IEEE.STD_LOGIC_ARITH.all; Entity Adder is port (A,B : in std_logic_vector(4 downto 0); Cin : in std_logic; Sum : out std_logic_vector(4 downto 0); Cout : out std_logic); End Adder; architecture a_adder of adder is signal AC,BC,SC : std_logic_vector(5 downto 0); AC <='0' & A; BC <='0' & B; SC <= unsigned(ac) + unsigned(bc) + Cin; Cout <= SC(5); Sout <= SC(4 downto 0); end a_adder;

Entity Declaration Specifies interface States port's name, mode, & type Mode can be IN, OUT, or INOUT Port type can be from a single bit to a bit vector Entity name Port length ENTITY Adder IS PORT (A,B : IN STD_LOGIC(4 DOWNTO 0); Cin : IN STD_LOGIC; Sum : OUT STD_LOGIC(4 DOWNTO 0); Cout : OUT STD_LOGIC); END Adder; Port names Port mode Port type

Architecture Declaration Describes the internal operation of an entity Several architectures can be associated to one entity States which components, signals, variables, and constants will be used

An Architecture Example library IEEE; use IEEE.std_logic_1164.all; use IEEE.STD_LOGIC_ARITH.all; Entity Adder is End Adder; port (A,B : in std_logic_vector(4 downto 0); Cin : in std_logic; Sum : out std_logic_vector(4 downto 0); Cout : out std_logic); architecture a_adder of adder is signal AC,BC,SC : std_logic_vector(5 downto 0); AC <='0' & A; BC <='0' & B; SC <= unsigned(ac) + unsigned(bc) + Cin; Cout <= SC(5); Sout <= SC(4 downto 0); end a_adder; Library declaration section Architecture declaration Associated entity Signal declaration. Also can be placed component, constants, types, declarations. Concurrent Statements: Processed at the same time. Also component instantiations, and processes can be placed.

Signals Vs Variables (1/2) Signals Can exist anywhere, like wires Connect components or carry information between processes When inside a process, its value is updated when the process suspends Signal assignment operator: <= Variables Can only exist inside a process Behave like local HLL variables holding temporary values Values updated right after assignment. Sequence matters Variable assignment operator: :=

Concurrent Vs. Sequential Code Concurrent Statements Occur typically outside a process Take place concurrently, i.e. with simulation clock stopped Uses of SIGNALS and processes Sequential Statements Occur only inside a process Are executed sequentially, i.e. one after another Uses VARIABLES and functions

Signals Vs Variables (2/2) Signals Initial values: A=5, B=15, X=10 Final values: A=10, B=5 Sigproc: process(a,x) Begin A <= X; B <= A; End process Sigproc; Variables Initial values: A=5, B= 15, X=10 Final values: A=10, B=10 Sigproc: process(x) Variable A,B : integer; Begin A := X; B := A; End process Sigproc;

Three-Bit Binary Counter entity countl is port( clock, enable: in bit; qa: out integer range 0 to 7); end countl; architecture countarch of countl is process (clock) variable count: integer range 0 to 7; if (clock event and clock ='1') then if enable = '1' then count:=count + 1; end if; end if; qa <= count after 10 ns; end process; end countarch; Sensitivity list. Process is executed each time one of this parameters change. Variable declaration Variable assignment operator Sequential statements. Signal assignment operator

A D Flip-Flop entity dff is port ( d,clock : in bit; q: out bit); end dff; architecture arch of dff is process (clock) if(clock'event and clock=1) then if(d= 1 ) then q <= 1 ; else q <= 0 ; end if; end if; end process; end arch; Refers to the rising edge of the clock Explicit comparisons and assignments to port and signals uses for one bit and for multiple bits

D-type flip-flop with active low preset and clear inputs -- The pm and din signals are asynchronous entity dffpc is port(d,clrn,prn,clock: in bit; q out bit); end dffpc; architecture arch of dffpc is process (clock) if(clock'event and clock = '1') then if(d='l' and prn='l' and clrn='l') then q <= '1'; elsif(d='0' and prn='l' and clrn ='1') then q <='0'. end if; --handle active low preset if(prn='0' and clrn='l') then q <= '1'; end if; --handle active low clear if(clrn='0' and prn='l') then q <= '0'; end if; end if; end process; end arch; Coments with -- Logical operators and, or, not, nand, xor are defined in the language elsif is used instead of the else if of C language.

D Flip-Flop with Asynchronous Preset and Clear entity dffapc is port(clock, d, prn, clrn : in bit; q : out bit); end dffapc; architecture archl of dffapc is process(clock, clrn, prn) variable reset, set: integer range 0 to 1; if(prn= 0 ) then q <= 1 ; elsif (clrn= 0 ) then q <= 0 ; elsif (clock event and clock= 1 ) then q <= d; end if; end process; end archl; Integer range definition. Range 0 to 1 defines one bit.

Full Adder library ieee; use ieee.std_logic 1164.all; entity fulladd is port( al,a2,cin: in std_logic; sum,cout: out std_logic); end fulladd; architecture fulladd of fulladd is process(al,a2,cin) sum <= cm xor al xor a2; cout <= (al and a2) or (cin and (al xor a2)); end process; end fulladd;

Four Bit Adder --A VHDL 4 bit adder entity fourbadd is port ( cin: in integer range 0 to 1; addendl:in integer range 0 to 15; addend2:in integer range 0 to 15; sum: out integer range 0 to 31); end fourbadd; architecture a4bitadd of fourbadd is sum <= addendl + addend2 + cin; end a4bitadd; Integer type allows addition, subtraction and multiplication. Need the following statement at the library declaration section: use IEEE.STD_LOGIC_ARITH.all

VHDL Description Styles Dataflow: Uses concurrent signal assignments Behavioral: Relies on process to implement sequential statements Structural: Describes the interconnections among components of a system. Requires hierarchical constructs. Mixed Method: Combines the three styles.

D Flip-Flop Dataflow --D flip-flop dataflow --Includes preset and clear entity dff_flow is port ( d, prn, clrn: in bit; q,qbar: out bit); end dff_flow; architecture archl of dff_flow is q <= not prn or (clrn and d); qbar <= prn and (not clrn or not d); end archl;

Behavioral D Flip-Flop --Active low preset and clear inputs entity dffpc2 is port(d,clock,clrn,prn:in bit; q,qbar:out bit; end dffpc2; architecture arch of dffpc2 is process(clock,clrn,prn) if(clock event and clock = 1 ) then q <= not prn or (clrn and d); qbar <= prn and (not clrn or not d); end if; end process; end arch;

D Flip-Flop Structural entity dff_str is port (d :in bit; q,qbar:out bit); end dff_str; architecture adff_str of dff_str is component nandtwo port(x, y: in bit; z:out bit); end component; signal qbarinside, qinside, dbar: bit; nandq:nandtwo port map(qinside, d,qbarinside); nandqbar:nandtwo port map(qbarinside,dbar, qinside); dbar <= not d; q <= qinside; qbar <= qbarinside; end adff_str; Component instantiation. Connections are made by correspondence Component declaration. Port appears exactly as in the entity declaration. Entity name Component instantiation label d dbar nandq:nandtwo qbarinside qinside nandqbar:nandtwo qbar q --A two input nand gate entity nandtwo is port(x, y:in bit; z :out bit); end nandtwo; architecture anandtwo of nandtwo is z <= not(x and y); end anandtwo;

A Sequence Detector entity simple is port ( clock, resetn, w: in stdlogic; z:out std logic); end simple; Type declaration Signal definition using a defined type architecture behavior of simple is type state_type is (a, b, c); signal y: state_type ; process (resetn, clock) if resetn = 0 then y <= a; elsif (clock event and clock = l ) then case y is when a => if w= 0 then y <= a; else y <= b; end if; Case statement declaration Item under test w=0 w=1 A/z=0 w=0 w=0 C/z=1 B/z=0 w=1 Clock Cycle t 0 t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 t 9 t 10 W: 0 1 0 1 1 0 1 1 1 0 1 Z: 0 0 0 0 0 1 0 0 1 1 0 w=1

A Secuence Detector (continued) when b => if w= 0 then Case statement declaration y <= a; else y <= c; end if; when c => if w= 0 then Conditional signal assignment y <= a; else y <= c; end if; end case: end if; end process; z <= l when y=c else 0 ; w=0 w=1 end behavior; A/z=0 B/z=0 w=0 w=0 C/z=1 w=1 Clock Cycle t 0 t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 t 9 t 10 W: 0 1 0 1 1 0 1 1 1 0 1 Z: 0 0 0 0 0 1 0 0 1 1 0 w=1

Testbenches Stimuli transmitter to DUT (testvectors) Needs not to be synthesizable No ports to the outside Environment for DUT Verification and validation of the design Several output methods Several input methods

Example Testbench entity TB_TEST is end TB_TEST; architecture BEH of TB_TEST is -- component declaration of the DUT -- internal signal definition -- component instantiation of the DUT -- clock generation -- stimuli generation end BEH;

Example Testbench entity TB_TEST is end TB_TEST; architecture BEH of TB_TEST is component TEST port(clk : in std_logic; RESET : in std_logic; A : in integer range 0 to 15; B : in std_logic; C : out integer range 0 to 15); end component; constant PERIOD : time := 10 ns; signal W_CLK : std_logic := '0'; signal W_A, W_C : integer range 0 to 15; signal W_B : std_logic; signal W_RESET : std_logic; DUT : TEST port map(clk => W_CLK, RESET => W_RESET, A => W_A, B => W_B, C => W_C);

Questions?