A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.

Slides:



Advertisements
Similar presentations
1 Introduction to VHDL (Continued) EE19D. 2 Basic elements of a VHDL Model Package Declaration ENTITY (interface description) ARCHITECTURE (functionality)
Advertisements

Verilog Intro: Part 1.
Digital Design with VHDL Presented by: Amir Masoud Gharehbaghi
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
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.
History TTL-logic PAL (Programmable Array Logic)
Mridula Allani Fall 2010 (Refer to the comments if required) ELEC Fall 2010, Nov 21(Adopted from Profs. Nelson and Stroud)
VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
Comprehensive VHDL Module 6 Types November Comprehensive VHDL: Types Copyright © 2000 Doulos Types Aim ©To understand the use and synthesis.
Introduction to VHDL Multiplexers. Introduction to VHDL VHDL is an acronym for VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
VHDL Intro What does VHDL stand for? VHSIC Hardware Description Language VHSIC = Very High Speed Integrated Circuit Developed in 1982 by Govt. to standardize.
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.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Behavioral & Structural.
1 H ardware D escription L anguages Basic Language Concepts.
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
A.7 Concurrent Assignment Statements Used to assign a value to a signal in an architecture body. Four types of concurrent assignment statements –Simple.
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
VHDL – Dataflow and Structural Modeling and Testbenches ENGIN 341 – Advanced Digital Design University of Massachusetts Boston Department of Engineering.
ENG6090 RCS1 ENG6090 Reconfigurable Computing Systems Hardware Description Languages Part 5: Modeling Structure.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
RTL Hardware Design by P. Chu Chapter Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.
陳慶瀚 機器智慧與自動化技術 (MIAT) 實驗室 國立中央大學資工系 2009 年 10 月 8 日 ESD-04 VHDL 硬體描述語言概論 VHDL Hardware Description Language.
1 Introduction to VHDL Spring What is VHDL? VHDL can be uses to model and synthesise digital systems. VHDL = VHSIC Hardware Description Language.
Introducing the Nexys 2 Board CS 332 – Operating Systems 12/04/2011 by Otto Castell-R.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
1 Introduction to VHDL part 1 Fall Preliminary Class web page egre365/index.html Syllabus Grades: –Quizzes.
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
1 component OR_3 port (A,B,C: in bit; Z: out bit); end component ; Reserved Words  Declarations of Components and Entities are similar  Components are.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
VHDL Basics. VHDL BASICS 2 OUTLINE –Component model –Code model –Entity –Architecture –Identifiers and objects –Operations for relations VHDL ET062G &
Hardware Description Languages Digital Logic Design Instructor: Kasım Sinan YILDIRIM.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
VHDL ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
VHDL Tutorial.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
1 - CPRE 583 (Reconfigurable Computing): VHDL overview 1 Iowa State University (Ames) CPRE 583 Reconfigurable Computing Lecture 2: 8/26/2011 (VHDL Overview.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Combinational logic circuit
Basic Language Concepts
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Design Entry: Schematic Capture and VHDL
VHDL Basics.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
CHAPTER 10 Introduction to VHDL
VHDL VHSIC Hardware Description Language VHSIC
VHDL (VHSIC Hardware Description Language)
VHDL Structural Architecture
Chapter 5 – Number Representation and Arithmetic Circuits
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
4-Input Gates VHDL for Loops
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

A VHDL Tutorial ENG2410

ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe your design using VHDL. –Why use VHDL as an alternative to schematic capture. –Syntax of VHDL. –Hierarchical Design.

ENG241/VHDL Tutorial3 VHDL VHDL stands for VHSIC (Very High Speed Integrated Circuit) HDL (Hardware Description Language). HDLs are used to model hardware VHDL is used to describe digital systems. Initially was intented for documentation, and simulation. Now used for synthesis.

ENG241/VHDL Tutorial4 VHDL program components Library Declaration. Entity Declaration. Architecture Body.

ENG241/VHDL Tutorial5 Library Declaration This declare standard data types and some procedures used in modelling the design. Library IEEE; -- Declare the IEEE library Use IEEE.STD_LOGIC.1164.all; --Use package 1164 Packages are containers for related functional units. Library contains declaration of different packages and components.

ENG241/VHDL Tutorial6 Entity describes the input/output configuration for the modelled system. entity and2 is port ( a,b in : std_logic; f out : std_logic); end and2; Entity Declaration Port Name Data Type Direction Entity Name

ENG241/VHDL Tutorial7 Architecture Body Architecture body is used to describe the internal structure of the modelled system. architecture dataflow of and2 is --signal and component declaration here begin f <= a and b; end dataflow; Architecture Name Entity Concurrent Statements

ENG241/VHDL Tutorial8 Library IEEE; Use IEEE.STD_LOGIC.1164.all; entity and2 is port ( a,b in : std_logic; f out : std_logic); end and2; architecture dataflow of and2 is begin f <= a and b;--Data flow model end dataflow; Complete Model

ENG241/VHDL Tutorial9 entity and2 is--Three Model Styles port ( a,b in : std_logic;--1. Data Flow f out : std_logic);--2. Structured end and2;--3. Behavioural Complete Model architecture dataflow of and2 is begin f <= a and b; end dataflow; architecture behaviour of and2 is begin and_proc: process (a,b) begin if a = b then f <= ‘ 1 ’ ; else f <= ‘ 0 ’ ; end if; end behaviour; architecture structured of and2 is begin u1 : oldand2 port map (a,b,f); end structured;

ENG241/VHDL Tutorial10 Data Types Every data object in VHDL can hold a value that belongs to a set of values. This set of values is specified using a type declaration. –Predefined types. –User defined types

ENG241/VHDL Tutorial11 Predefined Data Types Boolean “False, True” Bit (0,1) –Bit_Vector -array of bits (100011) Character ‘a’,”ASCII” INTEGER (3, 12) REAL (1.5, 0.23)

ENG241/VHDL Tutorial12 STD_LOGIC Data Type This data type is used to define signals that could be found in standard digital system. This data type is defined in the IEEE library Package IEEE.STD_LOGIC It could have the following values: –‘1’ => Forcing Logic 1 –‘0’ => Forcing Logic 0 –‘Z’ => High Impedance –‘U’ => Un-initialized –‘X’ => Forcing Unknown –‘-’ => Don’t care –‘W’=> Weak Unknown –‘L’ => Weak 0 –‘H’ => Weak 1

ENG241/VHDL Tutorial13 STD_LOGIC_VECTOR Data Type Array of STD_LOGIC. It could be used to represent a bus in digital systems. --MSB in the left and LSB in the right signal data_bus : std_logic_vector (7 downto 0); --LSB in the left and MSB in the right signal data_bus : std_logic_vector (0 to 7);

ENG241/VHDL Tutorial14 STD_LOGIC_VECTOR Data Type Signals or Variables of this data type could be accessed completely, partially, or bit by bit. --MSB in the left and LSB in the right signal data_bus : std_logic_vector (7 downto 0); signal data_bus_nipple : std_logic_vector (3 downto 0); --Inside the architecture data_bus_nipple <= “ 0101 ” ; --load data in 4 bit signal data_bus (3 downto 0) <= data_bus_nipple; --connect it to the first 4 data_bus (6 downto 4) <= “ 100 ” ; --assign the other 3 bits data_bus (7) <= not data_bus_nipple (3); --and the final bit

ENG241/VHDL Tutorial15 Concurrent Statements Inside the architecture body we use concurrent statements. –Signal assignment f <= a and b; –Processes and_proc : process (a,b) begin. --sequential statements. end process; –Component instantiation u1 : and2 port map (as,bs,fs);

ENG241/VHDL Tutorial16 Concurrent Statements The concurrent statements are executed without any specific order. The architecture body could contain any combination of the 3 types of concurrent statements.

ENG241/VHDL Tutorial17 Concurrent Statements This circuit could be modelled as following: f<= z or w; z<= x and y; x<= not a; w<= a and b; y<= not b;

ENG241/VHDL Tutorial18 Generate Statement Used to generate multiple concurrent statements with the same pattern. signal x : std_logic_vector (3 downto 0); signal y,z : std_logic_vector (3 downto 0); for i in 0 to 2 generate x(i) <= (y (i) and y (i+1) ) or z (i); end generate;

ENG241/VHDL Tutorial19 Process Block proc_name : process (x,y) variable z: std_logic; begin z:= x or y; if z= ‘ 0 ’ and y= ‘ 1 ’ then m<= z; else m<= not x; end if; end process; Note: The process block is considered a single concurrent statement. Process name Sensitivity List Variable Deceleration Sequential Statements

ENG241/VHDL Tutorial20 Component Instantiation It has two parts: –Component Declaration in arch. Body before the begin line: component and2--like entity declaration port (a,b : in STD_LOGIC; f : out STD_LOGIC); end component; –Component Instantiation inside the arch. Body: u1: and2 port map (a=>x,f=>z,b=>y); --No order required or simply u1: and2 port map (x,y,z);--Has to be in order Component port Arch. Signal

ENG241/VHDL Tutorial21 Sequential Statements Sequential Statements are used inside the process, function or procedure blocks. This may be regarded as normal programming language (The order of the statements affect the result of execution). Can make use and change the values of signals and variables

ENG241/VHDL Tutorial22 Sequential Statements If statement if x = y then z<= ‘ 1 ’ ;--if true else z<= ‘ 0 ’ ;--if false end if; Case statement signal y : std_logic_vector (1 downto 0); signal m : std_logic_vector (3 downto 0); case (y) is when "00" => m <= “ 1001 ” ; when "01" => m<= “ 0101 ” ; when "10" => m<= “ 1100 ” ; when "11" => m<= “ 0001 ” ; when others => m<= “ 0000 ” ; end case;

ENG241/VHDL Tutorial23 Sequential Statements Other statements like for and while are also existing but requires attention. signal v: std_logic_vector (3 downto 0); for i in 0 to 2 loop--shifting right using for loop v(i) <= v(i+1); end loop; v(3) <= ‘ 0 ’ ; Note: In this example the signal is regarded as a register.

ENG241/VHDL Tutorial24 Object Types Signals –Ports. port ( a: in std_logic; …… –Internal Signals. signal x : std_logic; Variable variable x : integer; x:= 5; Constants constant gnd : bit := 0;

ENG241/VHDL Tutorial25 Signals Declared as ports or inside the architecture body. –Ports. port ( a: in std_logic; …… –Internal Signals. signal x : std_logic; Signals are regarded is wires in some models and as memory storage (register) in other models. signals

ENG241/VHDL Tutorial26 Signals The order of signal assignments in the same block is not important. f<= z or w; z<= x and y; x<= not a; w<= a and b; y<= not b;

ENG241/VHDL Tutorial27 Signals Signals can’t have two drivers. Note: In this example the process is considered a single driver signal x,y,x : std_logic; --signal declaration. x<= y or z; -- first driver uproc : process (y,z) -- second driver Begin if y = z then x <= ‘1’; else x <= ‘0’; end if; end process;

ENG241/VHDL Tutorial28 Conditional Signal Assignment Signal Assignment could be conditional. signal x : STD_LOGIC; signal y : STD_LOGIC_VECTOR (2 downto 0); with y select x<= ‘0’ when “00”, ‘0’ when “01”, ‘0’ when “10”, ‘1’ when “11”, ‘0’ when others;

ENG241/VHDL Tutorial29 Conditional Signal Assignment Signal Assignment could be conditional. signal x : STD_LOGIC; signal y : STD_LOGIC_VECTOR (2 downto 0); x<= ‘0’ when y = “00” else ‘0’ when y = “01” else ‘0’ when y = “10” else ‘1’ when y = “11” else ‘0’;

ENG241/VHDL Tutorial30 Variables Same variable concept as computer programming languages. Declared inside a process block,function or procedure. uproc: process (x,y) variable z : std_logic; begin z := ‘ 0 ’ ;--variable could have different values z := x or y; end process;

ENG241/VHDL Tutorial31 Variables The scope of the variable is inside the unit it declared in (process, function or procedure). uproc: process (x,y) variable z : std_logic; begin z := ‘ 0 ’ ; --variable could have different values z := x or y; end process; z:= ‘ 1 ’ ;-- This variable is out of scope

ENG241/VHDL Tutorial32 Logic operators: They are bit-wise operators ( and, or, xor, xnor, nand, nor, not) x<= y and z; a<= (b and c) or (d and e); j <= (h and i and k) Note: Parenthesis are used to group terms. m<= (n not k);m<= (n and (not k)); g<= f and h or p;g<= (f and h) or p; Operators

ENG241/VHDL Tutorial33 Operators Arithmetic operators: Defined for predefined data types. For user defined data types they should be defined. - + Add, - Subtract, * multiply, / divide. Division is not always defined signal v,w,x : integer; w <= 5; v <= 3; x <= w + v; -- x = 8

ENG241/VHDL Tutorial34 Operators for STD_LOGIC Although STD_LOGIC type is defined in VHDL libraries. It is considered a user defined data type. Some extra package declaration are required. library IEEE; use IEEE.STD_LOGIC.1164; use IEEE.STD_LOGIC.ARITH.all; use IEEE.STD_LOGIC.UNSIGNED.all;--unsigned operations or use IEEE.STD_LOGIC.SIGNED.all;--signed operations

ENG241/VHDL Tutorial35 Operators for STD_LOGIC; use IEEE.STD_LOGIC.unsigned.all; signal x,y : std_logic_vector (3 downto 0); signal za :std_logic_vector (3 downto 0); signal zm :std_logic_vector (7 downto 0); x<= “ 0101 ” ;--5 y<= “ 1101 ” ;--13 za<= x + y;-- za = “ 0010 ” ;= 2; wrong answer Zm<= x * y;-- zm = “ ” ; 65; right answer

ENG241/VHDL Tutorial36 Operators for STD_LOGIC; use IEEE.STD_LOGIC.unsigned.all; signal x,y : std_logic_vector (3 downto 0); signal za :std_logic_vector (4 downto 0); signal zm :std_logic_vector (7 downto 0); x<= “ 0101 ” ;--5 y<= “ 1101 ” ;--13 za<= x + y;-- za = “ 0010 ” ;= 2; wrong answer Zm<= x * y;-- zm = “ ” ; 65; right answer

ENG241/VHDL Tutorial37 Operators for STD_LOGIC; use IEEE.STD_LOGIC.unsigned.all; signal x,y : std_logic_vector (3 downto 0); signal za :std_logic_vector (3 downto 0); signal zm :std_logic_vector (7 downto 0); x<= “ 0101 ” ;--5 y<= “ 1101 ” ;--13 za<= ‘ 0 ’ &x + ‘ 0 ’ &y;-- za = “ ” ;= 18; right answer Zm<= x * y;-- zm = “ ” ; 65; right answer concatenation

ENG241/VHDL Tutorial38 Operators for STD_LOGIC; use IEEE.STD_LOGIC.signed.all; signal x,y : std_logic_vector (3 downto 0); signal za :std_logic_vector (3 downto 0); signal zm :std_logic_vector (7 downto 0); x<= “ 0101 ” ;--5 y<= “ 1101 ” ;--(-3) za<= ‘ 0 ’ &x + ’ 0 ’ &y;-- za = “ ” ;= 2 (; wrong answer Zm<= x * y;-- zm = “ ” ; -15; right answer

ENG241/VHDL Tutorial39 Example This Figure Shows a Full Adder Circuit

ENG241/VHDL Tutorial40 Example First declare Xor2,And2 and Or3 entities and architectures entity and2 is port ( a,b : in std_logic; c : out std_logic ); end and2; architecture dataflow of and2 is begin c<= a and b; end dataflow; entity or3 is port ( a, b,c : in std_logic; d : out std_logic ); end and2; architecture behavior of or3 is begin and3_proc : process is begin if a = ‘0’ and b = ‘0’ and c=‘0’ then d <= ‘0’; else d <= ‘1’; end if; end process; end behavior; entity xo2 is port ( a,b : in std_logic; c : out std_logic ); end xor2; architecture dataflow of and2 is begin c<= a xor b; end dataflow;

ENG241/VHDL Tutorial41 Example Now use them to implement a register entity full_adder is port (a, b, ci: in std_logic; s,co: out std_logic); end full_adder; architecture struct of full_adder is --Internal signals signal w,x,y,z : std_logic; --component declaration component and2 port ( a,b : in bit; c : out bit ); end component; component xo2 port ( a,b : in bit; c : out bit ); end component; component or3 is port ( a, b,c : in bit; d : out bit ); end component; begin u0 : xor2 port map ( a, b, w); u1 : xor2 port map ( w, ci, s ); u2 : and2 port map ( a, b, x); u3 : and2 port map ( a, ci, y ); u4 : and2 port map ( b, ci, z ); u5 : or2 port map (x,y,z, co); end struct;