Getting Started with VHDL

Similar documents
Hardware Description Language VHDL (1) Introduction

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

CSCI Lab 3. VHDL Syntax. Due: Tuesday, week6 Submit to: \\fs2\csci250\lab-3\

Review of Digital Design with VHDL

5. 0 VHDL OPERATORS. The above classes are arranged in increasing priority when parentheses are not used.

Contents. Appendix D VHDL Summary Page 1 of 23

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

Building Blocks. Entity Declaration. Entity Declaration with Generics. Architecture Body. entity entity_name is. entity register8 is

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

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

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

COE 405 Design Methodology Based on VHDL

C-Based Hardware Design

Hardware Modeling. VHDL Syntax. Vienna University of Technology Department of Computer Engineering ECS Group

ELCT 501: Digital System Design

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

Computer-Aided Digital System Design VHDL

Very High Speed Integrated Circuit Har dware Description Language

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

VHDL 3 BASIC OPERATORS AND ARCHITECTURE BODY. Design descriptions & design constructions examples are taken from foundation series examples

HDL. Hardware Description Languages extensively used for:

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

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

Design units can NOT be split across different files

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

ECE 3401 Lecture 10. More on VHDL

VHDL BASIC ELEMENTS INTRODUCTION

Introduction to VHDL #3

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

ECOM4311 Digital Systems Design

VHDL Part 2. What is on the agenda? Basic VHDL Constructs. Examples. Data types Objects Packages and libraries Attributes Predefined operators

Lecture 4. VHDL Fundamentals. George Mason University

Modeling Complex Behavior

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

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

A bird s eye view on VHDL!

Performance Engineering of Real-Time and Embedded Systems. Introduction to VHDL

EEL 4783: Hardware/Software Co-design with FPGAs

ECE 545 Lecture 4. Simple Testbenches. George Mason University

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:

CprE 583 Reconfigurable Computing

Outline CPE 626. Advanced VLSI Design. Lecture 4: VHDL Recapitulation (Part 2) Signals. Variables. Constants. Variables vs.

Introduction to VHDL #1

VHDL kod yerleşimi. kütüphaneler. Dış görünüş (entity: varlık) İşleyişi, yapısı (architecture: mimari)

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

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

Basic Language Concepts

Hardware Description Languages. Modeling Complex Systems

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

Lattice VHDL Training

Introduction to the VHDL language. VLSI Digital Design

Declarations. Lexical elements. Type declaration Subtype declaration Constant declaration Signal declaration Variable declaration.

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Control and Datapath 8

Outline CPE 626. Advanced VLSI Design. Lecture 3: VHDL Recapitulation. Intro to VHDL. Intro to VHDL. Entity-Architecture Pair

BASIC VHDL LANGUAGE ELEMENTS AND SEMANTICS. Lecture 7 & 8 Dr. Tayab Din Memon

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

Concurrent Signal Assignment Statements (CSAs)

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

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

In our case Dr. Johnson is setting the best practices

Digital Systems Design

INTRODUCTION TO VHDL ADVANCED COMPUTER ARCHITECTURES. Slides by: Pedro Tomás. Additional reading: - ARQUITECTURAS AVANÇADAS DE COMPUTADORES (AAC)

entity priority is Port ( a,b,c,d : in STD_LOGIC; encoded : out STD_LOGIC_VECTOR(2 downto 0)); end priority;

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

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

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

Summary of basic structures

Quartus Counter Example. Last updated 9/6/18

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

VHDL for FPGA Design. by : Mohamed Samy

CPE/EE 422/522. Chapter 8 - Additional Topics in VHDL. Dr. Rhonda Kay Gaede UAH. 8.1 Attributes - Signal Attributes that return a value

Introduction to VHDL. Main language concepts

Sign here to give permission to return your test in class, where other students might see your score:

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

Lecture 12 VHDL Synthesis

Test Benches - Module 8

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

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

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

Sequential Statement

Department of Electronics & Communication Engineering Lab Manual E-CAD Lab

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2016

VHDL: skaitmeninių įtaisų projektavimo kalba. 2 paskaita Pradmenys

Assignment 01 Computer Architecture Lab ECSE

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

Embedded Systems CS - ES

Inthis lecture we will cover the following material:

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

Lab # 5. Subprograms. Introduction

VHDL Examples Mohamed Zaky

COVER SHEET: Total: Regrade Info: 2 (6 points) 3 (8 points) 4 (10 points) 8 (12 points) 6 (6 points) 7 (6 points) 9 (30 points) 10 (4 points)

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

ECOM 4311 Digital System Design using VHDL. Chapter 7

Constructing VHDL Models with CSA

VHDL in 1h. Martin Schöberl

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. 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 :

Lecture 4. VHDL Basics. Simple Testbenches

Transcription:

Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component Entities can be primitive objects or complex objects Architectures are associated with each entity Architectures describe: Behavior Structure copyright(c) 1996 W. B. Ligon III 1

VHDL Entities A B XOR_GATE ports F ENTITY xor_gate IS GENERIC (prop_delay:time := 10ns); PORT( a : IN std_logic; b : IN std_logic; f : OUT std_logic); END xor_gate; copyright(c) 1996 W. B. Ligon III 2

Entity Syntax entity <name> is [generic( <gen_name> : <type * >[:=<init>];... )] port ( <port_name> : <dir ** > <type>;... ); end <name>; * <type> is any VHDL type ** <dir> is a direction of the port: IN, OUT, or INOUT copyright(c) 1996 W. B. Ligon III 3

VHDL Architectures Describe the implementation of entities Can be behavioral, data flow, structural, or a combination ARCHITECTURE behavior OF xor_gate IS BEGIN new_input : PROCESS(a,b) BEGIN IF (a = b) f <= 0 AFTER prop_delay; ELSE f <= 1 AFTER prop_delay; END PROCESS; END behavior; copyright(c) 1996 W. B. Ligon III 4

Data flow Architecture Consists entirely of boolean equations References only port signals ARCHITECTURE dataflow OF xor_gate IS BEGIN f <= (a AND NOT b) OR (NOT a AND b) AFTER prop_delay; END dataflow; copyright(c) 1996 W. B. Ligon III 5

Structural Architecture Defines an entity using components Defines internal signals to connect components ARCHITECTURE structure OF xor_gate IS COMPONENT nor_gate PORT (x, y: IN std_logic; z: OUT std_logic); END COMPONENT; COMPONENT and_gate PORT (x, y: IN std_logic; z: OUT std_logic); END COMPONENT; SIGNAL s1, s2: BIT; BEGIN nor1: nor_gate PORT MAP (s1, s2, f); and1: and_gate PORT MAP (a, b, s1); nor2: nor_gate PORT MAP (a, b, s2); END structure ; copyright(c) 1996 W. B. Ligon III 6

Syntax of an Architecture Architecture <name> of <entity> is <declarations> begin <statements> end <name>; copyright(c) 1996 W. B. Ligon III 7

Data Types Many data types in VHDL, but we will use a small subset: STD_LOGIC A single bit STD_LOGIC_VECTOR A bit vector, often used for a bus INTEGER Standard integer type that will often be used for generic parameters copyright(c) 1996 W. B. Ligon III 8

Declarations Signals CONSTANT bus_width : INTEGER := 32; CONSTANT rise_delay : TIME := 20ns; VARIABLE data_val :STD_LOGIC_VECTOR (7 DOWNTO 0); VARIABLE sum : INTEGER RANGE 0 TO 100; VARIABLE done : BOOLEAN; SIGNAL clock : STD_LOGIC; SIGNAL addr_bus : STD_LOGIC_VECTOR (31 DOWNTO 0); Implicit declaration FOR count IN 1 TO 10 LOOP declares count sum := sum + count; END LOOP; copyright(c) 1996 W. B. Ligon III 9

Declarations Components component fill_reg port( clk :in std_logic; rst :in std_logic; write :in std_logic; read :in std_logic; data_in :in std_logic_vector(3 downto 0); FFout :out std_logic; data_out:out std_logic_vector(31 downto 0)); end component; copyright(c) 1996 W. B. Ligon III 10

Architecture Body Concurrent Signal Assignment statements (CSAs) a <= b + c; Component Instantiations Processes with behavioral descriptions copyright(c) 1996 W. B. Ligon III 11

Component Instantiations reg5 : fill_reg port map ( clk => clk, rst => rst, write => write_comp, read => readout, data_in => dataout_comp, FFout => FFout, data_out => datareg5_out); reg5 : fill_reg port map (clk, rst, write_comp, readout, dataout_comp, FFout, datareg5_out); copyright(c) 1996 W. B. Ligon III 12

Processes Process Statement <label> PROCESS ( <sensitivity> ) < process declarations > BEGIN < statements > END PROCESS <label> ; Process executes whenever an event occurs on a signal in the sensitivity list Multiple processes can execute concurrently copyright(c) 1996 W. B. Ligon III 13

Processes Sensitivity list tell simulator when to evaluate process No sensitivity list is required, BUT if not, wait statements must be used in the process copyright(c) 1996 W. B. Ligon III 14

Processes Example process begin wait for 15 ns; clkx2 <= not(clkx2); end process; process(clk, rst) begin if rst = 1 then readout <= 0 ; elsif (clk event and clk= 1 ) then if (Ffout = 1 ) then readout <= 1 ; else readout <= 0 ; end if; end if; end process; copyright(c) 1996 W. B. Ligon III 15

Architecture Example Library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; use IEEE.STD_LOGIC_UNSIGNED.all; entity count_example is port( clk : in std_logic; rst : in std_logic; enable : in std_logic; load : in std_logic; data_in : in std_logic_vector(4 downto 0); data_out: out std_logic_vector(4 downto 0)); end count_example; copyright(c) 1996 W. B. Ligon III 16

Architecture Example architecture version1 of count_example is component adder generic ( WIDTH : INTEGER := 8) port ( in1 :in std_logic_vector(width 1 downto 0); in2 :in std_logic_vector(width 1 downto 0); out :out std_logic_vector(width 1 downto 0) ); signal CNT :std_logic_vector(4 downto 0); signal result :std_logic_vector(4 downto 0); CONSTANT ONE : std_logic_vector(4 downto 0) := "00001"; copyright(c) 1996 W. B. Ligon III 17

Architecture Example begin data_out <= CNT; adder1 : adder generic map ( WIDTH => 5) port map ( in1 => CNT, in2 => ONE, out => result ); process (clk, rst) begin if rst = 1 then CNT <= "00000"; elsif (clk event and clk = 1 ) then if (load = 1 ) then CNT <= data_in; elsif (enable = 1 ) then CNT <= result; else CNT <= CNT; end if; end if; end process; end version1; copyright(c) 1996 W. B. Ligon III 18

Operators Logical and or nand nor xor xnor not NOTE: nand and nor not associative Relational = /= < <= > >= Shift sll srl sla sra rol ror Adding + & Multiplying * / mod rem a rem b = a (a/b) * b a mod b = a b * n (for some n) Other abs ** copyright(c) 1996 W. B. Ligon III 19

Behavioral Statements Wait Statement WAIT ON <sensitivity> UNTIL <expression> FOR <time> Examples: WAIT ON A, B, C; WAIT UNTIL A > 10; WAIT FOR 30ns; WAIT ON A FOR 100ns; WAIT UNTIL C < 4 FOR 50ms; WAIT ON B UNTIL A > 4; WAIT ON C UNTIL B > 5 FOR 30us; WAIT; suspends forever copyright(c) 1996 W. B. Ligon III 20

Control Flow Statements LOOP Statement <label> : FOR <identifier> IN <range> LOOP <statments> END LOOP; <label> : WHILE <expression> LOOP <statments> END LOOP; <label> : LOOP <statements> END LOOP; copyright(c) 1996 W. B. Ligon III 21

Control Flow Statements IF Statement IF <expression> THEN <statements> ELSIF <expression> <statements> ELSE <statements> END IF; CASE Statement CASE <expression> IS WHEN <choice> => <statements> WHEN <choice> => <statements> WHEN OTHERS => <statements> END CASE; copyright(c) 1996 W. B. Ligon III 22

Sub Programs Functions FUNCTION <designator> ( < args> ) RETURN <return type> IS <declarations> BEGIN <statements> END; Procedures PROCEDURE <identifier> ( < args> ) IS <declarations> BEGIN <statements> END; copyright(c) 1996 W. B. Ligon III 23

VHDL Literals Numbers 14364 14_364 16#FF03# 16.3 13_634.34 1.293E 23 16#3A.B2#E3A Characters A _ "This is a string" Bits X"FF_AA" B"1101_1010" O"037" copyright(c) 1996 W. B. Ligon III 24

Architectures and Entities At least one architecture must be available for each entity ENTITY xor_gate IS GENERIC (prop_delay:time := 10ns); PORT( a : IN STD_LOGIC; b : IN STD_LOGIC; f : OUT STD_LOGIC); END xor_gate; ARCHITECTURE behavior OF xor_gate IS BEGIN new_input : PROCESS(a,b) BEGIN IF (a = b) f <= 0 AFTER prop_delay; ELSE f <= 1 AFTER prop_delay; END PROCESS; END behavior; copyright(c) 1996 W. B. Ligon III 25

Architectures and Entities More than one architecture may be available for each entity ENTITY xor_gate IS... END xor_gate; ARCHITECTURE behavior OF xor_gate IS BEGIN... END behavior; ARCHITECTURE structure OF xor_gate IS BEGIN... END structure; copyright(c) 1996 W. B. Ligon III 26

Configuration Can appear in a structural architecture ARCHITECTURE foo OF bar IS COMPONENT cmp1 PORT (a: IN std_logic); COMPONENT cmp2 PORT (b: IN std_logic); FOR ALL: cmp1 USE ENTITY c1(c1_arch1); FOR c2_1, c2_2: cmp2 USE ENTITY c2(c2_arch1); FOR C2_3 : cmp2 USE ENTITY c2(c2_arch2); FOR OTHERS : cmp2 USE ENTITY c3(c3_arch1); BEGIN c1_1 : cmp1 PORT MAP (a_1); copyright(c) 1996 W. B. Ligon III 27

Configuration Declaration Used as a separate design unit CONFIGURATION c1 OF an_entity IS FOR c1_architecture FOR ALL: cmp1 USE ENTITY c1(c1_arch1); END FOR; FOR c2_1, c2_2: cmp2 USE ENTITY c2(c_2arch1); FOR c2_arch1 FOR ALL xor: USE ENTITY x(xa); END FOR; END FOR; FOR C2_3 : cmp2 USE CONFIGURATION foobar; END FOR; FOR OTHERS : cmp2 USE OPEN; END FOR; END FOR; END CONFIGURATION; copyright(c) 1996 W. B. Ligon III 28

Configuration Defaults For each unbound component instance: An entity that is visible and has the same name is bound The most recently analyzed architecture is used For each port or generic must correspond by name, type, and mode copyright(c) 1996 W. B. Ligon III 29

Direct Instantiation Can bind an instance directly to an entity or configuration ARCHITECTURE foo OF bar IS SIGNAL a, b, c; BEGIN a1: ENTITY a_ent1(a_arch1) PORT MAP (a, b); a2: ENTITY a_ent1(a_arch2) PORT MAP (b, c); a3: ENTITY a_ent2(a_arch3) PORT MAP (c, a); b1: CONFIGURATION b_conf PORT MAP (a, b, c); END foo; copyright(c) 1996 W. B. Ligon III 30

Packages Package Declaration PACKAGE <identifier> IS <declarations> END; No function or procedure bodies Package Body Declaration PACKAGE BODY <identifier> IS <declarations> END; Required for each package declaration Body for each function or procedure in package declaration or body declaration Use Clause USE <library>.<package>.all USE <library>.<package>.<item> copyright(c) 1996 W. B. Ligon III 31

Designs Consist of an entity and an architecture describing it Architecture is synthesizable May have sub components copyright(c) 1996 W. B. Ligon III 32

Testbenches Used to test a design Entity is empty Generates all external stimulus, including clock and reset copyright(c) 1996 W. B. Ligon III 33

Testbench Example Library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; use IEEE.std_logic_unsigned.all; Library WORK; use WORK.all; entity testbench is end testbench; architecture test of testbench is signal clk : std_logic:= 0 ; signal rst : std_logic:= 0 ; signal data_in1:std_logic_vector(4 downto 0); signal data_in2:std_logic_vector(4 downto 0); signal data_out:std_logic_vector(4 downto 0); copyright(c) 1996 W. B. Ligon III 34

Testbench Example component adder port( in1 : in std_logic_vector(4 downto 0); in2 : in std_logic_vector(4 downto 0); out : out std_logic_vector(4 downto 0)); end component; signal a : std_logic_vector(4 downto 0); signal b : std_logic_vector(4 downto 0); signal c : std_logic_vector(4 downto 0); begin add1 : adder port map( in1 => a, in2 => b, out => c ); copyright(c) 1996 W. B. Ligon III 35

Testbench Example ********************************* process for simulating the clock process begin clk <= not(clk); wait for 20 ns; end process; ********************************* This process does the RESET process begin rst <= 1 ; wait for 53 ns; rst <= 0 ; wait until(rst event and rst = 1 ); stops this process (this is an initial ) end process; copyright(c) 1996 W. B. Ligon III 36

Testbench Example process variable i : integer; variable j : integer; begin for i in 1 to 16 loop for j in 1 to 16 loop a <= CONV_STD_LOGIC_VECTOR(i, 5); b <= CONV_STD_LOGIC_VECTOR(j, 5); wait until (clk event and clk= 1 ); end loop; end loop; end process; ****************************************** end test; configuration c_testbench of testbench is for test end for; end c_testbench; copyright(c) 1996 W. B. Ligon III 37