VHDL for FPGA Design. by : Mohamed Samy

Similar documents
Basic Language Concepts

Multi-valued Logic. Standard Logic IEEE 1164 Type std_ulogic is ( U, uninitialized

Lattice VHDL Training

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

Digital Systems Design

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

Introduction to VHDL

Introduction to VHDL #1

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

VHDL And Synthesis Review

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

Digital Systems Design

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

Hardware Description Language VHDL (1) Introduction

Lecture 4. VHDL Fundamentals. George Mason University

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

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

Menu. Introduction to VHDL EEL3701 EEL3701. Intro to VHDL

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

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

Hardware Description Languages. Modeling Complex Systems

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

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

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

Subprograms, Packages, and Libraries

Modeling Complex Behavior

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

Review of Digital Design with VHDL

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

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

Computer-Aided Digital System Design VHDL

Digital Systems Design

Mridula Allani Fall Fall

Combinational Logic COMB. LOGIC BLOCK. A Combinational Logic Block is one where the outputs depend only on the current inputs

EEL 4783: Hardware/Software Co-design with FPGAs

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

Lecture 10 Subprograms & Overloading

Design units can NOT be split across different files

Very High Speed Integrated Circuit Har dware Description Language

Concurrent Signal Assignment Statements (CSAs)

Introduction to VHDL. Main language concepts

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

Lecture 12 VHDL Synthesis

VHDL Examples Mohamed Zaky

VHDL: Code Structure. 1

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

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

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

In our case Dr. Johnson is setting the best practices

1. Defining and capturing the design of a system. 2. Cost Limitations (low profit margin must sell millions)

Chapter 6 Combinational-Circuit Building Blocks

ENGIN 241 Digital Systems with Lab

Contents. Appendix D VHDL Summary Page 1 of 23

FPGA BASED SYSTEM DESIGN. Dr. Tayab Din Memon Lecture 9 & 10 : Combinational and Sequential Logic

VHDL in 1h. Martin Schöberl

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

VHDL for Complex Designs

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

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

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

Inthis lecture we will cover the following material:

Review. LIBRARY list of library names; USE library.package.object; ENTITY entity_name IS generic declarations PORT ( signal_name(s): mode signal_type;

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

VHDL Synthesis Reference

Lecture 4: Modeling in VHDL (Continued ) EE 3610 Digital Systems

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

SEQUENTIAL STATEMENTS

Lecture 3. VHDL Design Units and Methods. Entity, Architecture, and Components Examples of Combinational Logic Hands-on in the Laboratory

EEL 4712 Digital Design Test 1 Spring Semester 2008

Introduction to VHDL #3

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

Sequential Statement

EE 595. Part II Design Units in VHDL. EE 595 EDA / ASIC Design Lab

Assignment. Last time. Last time. ECE 4514 Digital Design II. Back to the big picture. Back to the big picture

VHDL: A Crash Course

Basic Language Constructs of VHDL

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

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

PROGRAMMABLE LOGIC DESIGN WITH VHDL

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

Embedded Systems CS - ES

C-Based Hardware Design

VHDL Basics. Mehdi Modarressi. Department of Electrical and Computer Engineering, University of Tehran. ECE381(CAD), Lecture 4:

Lecture 3. VHDL Design Units and Methods. Notes. Notes. Notes

VHDL Packages for Synthesis Base Types Standard bit types may be used Typically IEEE 1164 Std. types are used. CPE 528: Session #9

Introduction to VHDL. Copyright 2005 Altera Corporation

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

A bird s eye view on VHDL!

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

Lecture 3 Introduction to VHDL

CprE 583 Reconfigurable Computing

VHDL is a hardware description language. The code describes the behavior or structure of an electronic circuit.

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 3

VHDL VS VERILOG.

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

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

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

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

Sequential Logic - Module 5

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

Transcription:

VHDL for FPGA Design by : Mohamed Samy

VHDL Vhdl is Case insensitive myvar = myvar = MYVAR IF = if = if Comments start with -- Comments can exist anywhere in the line Semi colon indicates the end of statements Vhdl Design Units Packages Library Entity Architecture

Library All VHDL objects ultimately reside in libraries By definition, a library is a collection of analyzed design units Work and std are the two libraries available to every design unit Libraries and Packages comprise the VHDL Design Management structure This is somehow analogous to directories and subdirectories

Library & Packages A library can be considered as a place where the compiler stores information about a design project. A VHDL package is a file or module that contains declarations of commonly used objects, data type, component declarations, signal, procedures and functions. To specify the library and package, use the library and the use keywords. For example to include the std_logic_1164 package that exists in the library ieee Library ieee; use ieee.std_logic_1164.all; The.all extension indicates to use all of the ieee.std_logic_1164 package.

Multiple Architecture Multiple architectures can exist for each entity These may represent different stages of the design process or different approaches to the same functionality (optimization for speed verus area, etc.)

How to identify any hardware? A B DU1 and DU3 F B A C DU2 and F A B or F For a given interface we can have many functionalities To identify a given design unit: Interface (input/output ports) Input-output relation (the DU functionality)

VHDL Design Unit Entity Describes the external interface of a hardware module Black Box entity <entity_name> is port ( <port_name> : <mode> <type>; <other ports>... ); End entity;

VHDL Design Unit Architecture An architecture describes the internal operation of its associated (primary) entity A given architecture represents one possible implementation for its associated entity, multiple architectures can exist for each entity Half Adder architecture <arch_name> of <entity_name> is -- architecture body end <arch_name>; Full Adder

Entity: entity <entity_name> is port ( <port_name> : <mode> <type>; <other ports>... ); End entity; Modes : In : input to this device Out : output from this device Inout : input to or output from this device Buffer : output from device and can be read inside the device

Illegal Port Usage Signal Defined As Out Cannot Be Used As Signal Connected to Internal Device. entity (W,X,Y: in bit; A,B: out bit);

Entity: Data types : wire : bit ---- 0 or 1 std_logic ------------------- std_ulogic ------------------- entity <entity_name> is port ( <port_name> : <mode> <type>; <other ports>... ); End entity; U -- Uninitialized X -- Forcing Unknown 0 -- Forcing Zero 1 -- Forcing One Z -- High Impedance W -- Weak Unknown L -- Weak Zero H -- Weak One - -- Don t Care bus : bit_vector ( range ) -> 001 std_logic_vector ( range ) -> 001 range: 0 to 7 3 downto 0 Note: std_logic and std_ulogic are defined in IEEE.STD_LOGIC_1164

Entity: (cont.) Example: full adder Entity fulladder is port ( x : in bit ; y : in bit ; z : in bit ; c : out bit ; o : out bit ) ; End fulladder; x y z fulladder c o Direction Data type

Architecture: A design unit associated with an entity which describes its internal operation or organization. Multiple architectures may be defined for a single entity Example: Architecture arch of fulladder is declarative area Begin concurrent statements are written here End arch; Declarative area: to declare signals, components and data types

Architecture: (cont.) Statement types: 1 2 A C Concurrent: Boolean equation. when else. With select. Process Generate Instances B Sequential: Boolean equation. If else. case when loops. wait.

Don t forget Concurrent statements (Default) Executed in parallel With select When else Process statements Generate statements Sequential statements (within Process) Executed in sequence If statement Case statement loop statement Wait statement Note : Sequential statements must be used within process

Architecture Concurrent statements Boolean When-else With-select Process

Concurrent statements: 1. Boolean equation: s <= a xor b and c; Note: Use of parentheses is absolutely essential to specify operator precedence. Only the not operator has inherently higher precedence among logical operators.

Architecture: (cont.) Example: Example: full adder Architecture arch of fulladder is Begin o <= x xor y xor z; c <= (x and y) or (z and (x xor y)); End arch; x y z fulladder c o

Concurrent statements: 2. When. Else: <sig1> <= value1 when condition1 else value2 when condition2 else. valuen; a Architecture behave of mux is Begin F <= a when sel = 00 else b when sel = 01 else c; End behave ; b c Sel(1:0) F What is the result if the last else statement doesn t exist?

Concurrent statements: 3. With. select: With < signal1> select Signal2 <= value1 when choice1, value2 when choice2,. valuen when others ; Architecture behave of mux is Begin With sel select F <= a when 00, b when 01, c when others; End behave; b c a Sel(1:0) F What is the result if there is no when others?

Skills check Try the following: Bus Mux Modified Bus Mux A(7:0) B(7:0) C(7:0) D(7:0) F(7:0) Ssel(2:0) G Bsel(1:0)

Concurrent statements: A process contains statements that are executed sequentially The order of the statements impacts the final result Process (sensitivity_list) list of sequential statements end process ; List of signals, any change in any of them causes the process statement to be executed.

Language Structure architecture RTL of ENTITY_1 is concurrent statements ; process sequential statements ; end process ; concurrent statements ; process sequential statements ; end process ; end architecture RTL ;

Signal assignment inside process The signal assignment statement Z <= A causes a transaction to be scheduled This means; the current value of A is read and scheduled to be driven onto Z when the process suspends process (...) Z <= A ; F <= G ; X <= F;... end process ;

Architecture Sequential statements Boolean Case If Loops Wait

Sequential statements: 1. Boolean equation: s <= a xor b xor c; Architecture behave of fulladder is Begin process (?) (x,y,z) o <= x xor y xor z; c <= (x and y) or (z and (x xor y)); end process; End behave ; Signals in sensitivity list create implied wait condition x y z fulladder c o

Sequential statements: 2. Case when: case <signal_name> is when value => list of sequential statements; when value => list of sequential statements; when others => list of sequential statements; end case; ENTITY mux IS PORT( a, b, c, d: in bit; sel: IN bit_vector(1 downto 0); F: OUT bit); END ENTITY mux; ARCHITECTURE rtl OF mux IS process (a,b,c,d,sel) (?) is is CASE sel IS WHEN "00" => F <= a; WHEN "01" => F <= b; WHEN "10" => F <= c; WHEN "11" => F <= d; END CASE; END PROCESS ; END ARCHITECTURE rtl; a b c d Sel(1:0) What about when others? F

Sequential statements: Case when: case <signal_name> is when value =>list of sequential statements; when value =>list of sequential statements; when others =>list of sequential statements; end case; ENTITY mux IS PORT( a, b, c, d: IN bit; s: IN bit_vector(1 downto 0); x: OUT bit); END ENTITY mux; ARCHITECTURE rtl OF mux IS BEGIN sl: PROCESS (a,b,c,d,sel) IS BEGIN CASE s IS WHEN "00" => x <= a; WHEN "01" => x <= b; WHEN "10" => x <= c; WHEN "11" => x <= d; END CASE; END PROCESS sl; END ARCHITECTURE rtl; ENTITY mux IS PORT( a, b, c, d: IN bit_vector (3 DOWNTO 0); s: IN bit_vector (1 DOWNTO 0); x: OUT bit_vector (3 DOWNTO 0)); END ENTITY mux; ARCHITECTURE rtl OF mux IS BEGIN sl: PROCESS (a,b,c,d,s) IS BEGIN CASE s IS WHEN "00" => x <= a; WHEN "01" => x <= b; WHEN "10" => x <= c; WHEN "11" => x <= d; END CASE; END PROCESS sl; END ARCHITECTURE rtl;

Two-input Exclusive OR function A process example for a 2-input exclusive-or function is illustrated below. For this function, there are two input signals, in1 and in2, and one output signal. x_or : sig1 <= in1 xor in2; Concurrent signal assignment: output is updated when signals on the right change x_or : process (in1, in2) is sigl <= in1 xor in2; end process x_or; Signal assignment in process: output is updated when process suspends

Sequential statements: 3. if. Else: If <condition> then list of sequential statements; Elsif <condition> then list of sequential statements; Elsif <condition> then list of sequential statements;.. End if;

Sequential statements: ENTITY latch IS PORT( d, clk: IN bit; q, nq: OUT bit); END ENTITY latch; ARCHITECTURE behav OF latch is BEGIN p1: PROCESS (d, clk) BEGIN IF clk = '1' THEN q <= d; nq <= NOT(d); END IF; END PROCESS p1; END behav; if <condition> then list of sequential statements Elsif <condition> then list of sequential statements End if; Library ieee; use ieee.std_logic_1164.all; ENTITY D_FF IS PORT( d, clk: IN std_logic; q, nq: OUT std_logic); END ENTITY D_FF; ARCHITECTURE behav OF D_FF is BEGIN p1: PROCESS (d, clk) BEGIN IF rising_edge(clk) THEN q <= d; nq <= NOT(d); END IF; END PROCESS p1; END behav; Is d required in sensitivity list?

Sequential statements: Library ieee; use ieee.std_logic_1164.all; entity D_FF_Asynch_rst is port( d, clk: in std_logic; q: out std_logic); end entity; architecture behav of D_FF_Asynch_rst is process (clk, rst) If rst = 0 then q <= 1 ; Else if falling_edge (clk) then q <= d; end if; End if; end process; end behav; Library ieee; use ieee.std_logic_1164.all; entity D_FF_Synch_rst is port( d, clk: in std_logic; q, nq: out std_logic); end entity ; architecture behav of D_FF_Synch_rst is process (clk) if falling_edge (clk) then if (rst = 1 ) q <= 0 ; nq <= 1 ; else q <= d; nq <= not(d); end if; End if; end process; end behav;

Sequential statements: entity latch_asynch_rst is port (d, clk: in bit; q: out bit); end entity; architecture behav of latch_asynch_rst is process (d, clk, rst) if rst = 1 then q <= 0 ; else if clk = '1' then q <= d; end if; end if; end process; end behav; entity latch_synch_rst is port (d, clk: in bit; q: out bit); end entity; architecture behav of latch_synch_rst is process (d, clk, rst) if clk = '1' then if rst = 1 then q <= 0 ; else q <= d; end if; end if; end process; end behav;

Sequential statements: q doesn t change architecture behav of D_FF_Asynch_rst_clkEnable is PROCESS (clk, rst) BEGIN If rst = 0 then q <= 1 ; Else IF rising_edge (clk) THEN if en = 1 then q <= d; end if; END IF; End if; END PROCESS; END behav; q is high impedance architecture behav of D_FF_Asynch_rst_clkEnable is PROCESS (clk, rst) BEGIN If rst = 0 then q <= 1 ; Else IF rising_edge (clk) THEN if en = 1 then q <= d; else q <= Z ; end if; END IF; End if; END PROCESS; END behav;

Sequential statements: ARCHITECTURE behav OF D_FF_gated_Clk IS BEGIN PROCESS (en, clk, rst) BEGIN If rst = 0 then q <= 1 ; Else if en = 1 then IF rising_edge (clk) then q <= d; end if; END IF; End if; END PROCESS; END behav;

Concurrent vs. Sequential Statements Concurrent Sequential entity XNOR2 is port (A, B: in std_logic; Z: out std_logic); end XNOR2; architecture concurrent of XNOR2 is -- signal declaration (of internal signals X, Y) signal X, Y: std_logic; X <= A and B; Y <= (not A) and (not B); Z <= X or Y; End concurrent; entity XNOR2 is port (A, B: in std_logic; Z: out std_logic); end XNOR2; architecture sequential of XNOR2 is XNOR2 : Process (A,B) if ((A = 0 and B = 0 ) (A = 1 and B = 1 )) then Z <= 1 ; else Z <= 0 ; end if; end process XNOR2; end sequential;

Skills check Out1? architecture... process ( ) OUT1 <= A ; OUT1 <= B ;... end process ; end architecture ; The last assignment takes effect architecture... OUT1 <= A ; OUT1 <= B ;... end architecture ; Some form of resolution is required for the output signal OUT1

Don t forget Concurrent statements (Default) Executed in parallel With select When else Process statements Generate statements Sequential statements (within Process) Executed in sequence If statement Case statement loop statement Wait statement Note : Sequential statements must be used within process

Assignment Write VHDL code for 3X8 Decoder? Write VHDL code for 3X8 Encoder? What is the difference between std_logic and std_ulogic data types? Prepare yourself for a quick test?

Q&A