Capt Michael Tanner Room 2F46A

Slides:



Advertisements
Similar presentations
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.
Advertisements

Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
02/02/20091 Logic devices can be classified into two broad categories Fixed Programmable Programmable Logic Device Introduction Lecture Notes – Lab 2.
VHDL Data Types Module F3.1. VHDL Data Types Scalar Integer Enumerated Real (floating point)* Physical* Composite Array Record Access (pointers)* * Not.
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
1/31/20081 Logic devices can be classified into two broad categories Fixed Programmable Programmable Logic Device Introduction Lecture Notes – Lab 2.
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.
Data types and variables
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
ECE 331 – Digital System Design Course Introduction and VHDL Fundamentals (Lecture #1)
Chapter 2 Data Types, Declarations, and Displays
Chapter 2: Introduction to C++.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Lecture #6 Page 1 Lecture #6 Agenda 1.VHDL - Architecture 2.VHDL - Packages Announcements 1.HW #3 assigned ECE 4110– Sequential Logic Design.
1 Data Object Object Types A VHDL object consists of one of the following: –Signal, Which represents interconnection wires that connect component instantiation.
1 H ardware D escription L anguages Basic Language Concepts.
1 Data Object Object Types A VHDL object consists of one of the following: –Signal, Which represents interconnection wires that connect component instantiation.
Objectives You should be able to describe: Data Types
George Mason University Modeling of Arithmetic Circuits ECE 545 Lecture 7.
Reconfigurable Computing - VHDL - Types John Morris Chung-Ang University The University of Auckland.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
IAY 0600 Digital Systems Design
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
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.
IAY 0600 Digital Systems Design VHDL discussion Dataflow&Behavioral Styles Combinational Design Alexander Sudnitson Tallinn University of Technology.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
(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 &
EE3A1 Computer Hardware and Digital Design Lecture 2 Introduction to VHDL.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
IAY 0600 Digital Systems Design VHDL discussion Dataflow Style Combinational Design Alexander Sudnitson Tallinn University of Technology.
L19 – Resolved Signals. Resolved Signals  What are resolved signals In systems In VHDL Resolution – Isn’t that for resolving conflicts?  Ref: text Unit.
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.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
ECOM 4311—Digital System Design with VHDL
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
ECOM 4311—Digital System Design with VHDL
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Advanced FPGA Based System Design Lecture-6 & 7 VHDL Data Types By: Dr Imtiaz Hussain 1.
Signals & Data-typesVer 1.1, Copyright 1997, TS, Inc. VHDL S i g n a l s & D a t a T y p e s Page 1.
Slide 1 3.VHDL/Verilog Description Elements. Slide 2 To create a digital component, we start with…? The component’s interface signals Defined in MODULE.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
IAY 0600 Digital Systems Design
Basic Language Concepts
Dataflow Style Combinational Design with VHDL
IAS 0600 Digital Systems Design
2.1 Parts of a C++ Program.
IAS 0600 Digital Systems Design
CPE 528: Lecture #3 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
IAS 0600 Digital Systems Design
Chapter 2: Introduction to C++.
Data Object By E. Thirumeni Department of Electronics
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Capt Michael Tanner Room 2F46A 333-6766 HQ U.S. Air Force Academy I n t e g r i t y - S e r v i c e - E x c e l l e n c e ECE 484 - Advanced Digital Systems Design Lecture 3 – Basic Language Constructs of VHDL Capt Michael Tanner Room 2F46A 333-6766 Write on board: ECE 315 Day 1 – Admin Section Marcher Introductions Syllabus

Lesson Outline Basic VHDL Program Lexical Elements and Program Format VHDL Objects Data Types and Operators Synthesis Guidelines

Basic VHDL Program

Design Unit Building blocks in a VHDL program Each design unit is analyzed and stored independently Types of design unit: entity declaration architecture body package declaration package body configuration

Entity Declaration Simplified syntax Mode: in: flow into the circuit out: flow out of the circuit inout: bi-directional flow entity entity_name is port( port_names : mode data_type; ... port_names : mode data_type ); end entity_name; entity even_detector is port( a : in std_logic_vector(2 downto 0); even : out std_logic; ); end even_detector;

Common Mistake with Mode entity mode_demo is port( a, b: in std_logic; x, y : out std_logic; ); end mode_demo; architecture wrong of mode_demo is begin x <= a and b; y <= not x; end wrong; ... architecture correct of entity_name is signal x_i : std_logic; begin x_i <= a and b; x <= x_i; y <= not x_i; end correct;

Architecture Body Simplified syntax An entity declaration can be associated with multiple architecture bodies architecture arch_name of entity_name is declarations; begin concurrent statement; ... end arch_name; architecture sop_arch of even_detector is signal p1, p2, p3, p4 : std_logic; begin even <= (p1 or p2) or (p3 or p4); p1 <= (not a(2)) and (not a(1)) and (not a(0)); p2 <= (not a(2)) and a(1) and a(0); p3 <= a(2) and (not a(1)) and a(0); p4 <= a(2) and a(1) and (not a(0)); end sop_arch;

Other Design Units Package declaration/body - collection of commonly used items: Data Types Subprograms Components Configuration – specify which architecture body is to be bound with the entity declaration VHDL Library – A place to store the analyzed design units Normally mapped to a folder on host computer Default library: “work” Library “IEEE” is used for many IEEE packages 1 library ieee; 2 use ieee.std_logic_1164.all; Invoke library named IEEE Make std_logic_1164 visible to all design units in current file

Processing of VHDL Code Analysis Performed on “design unit” basis Check the syntax and translate the unit into an intermediate form Store design unit in a library Elaboration Bind architecture body with entity Substitute the instantiated components with architecture description Create a “flattened”' description Execution Simulation or synthesis

Lexical Elements and Program Format

Lexical Elements Basic syntactical units in a VHDL program Types of elements: Comments Identifiers Reserved words Numbers Characters Strings

Comments Starts with -- Comments for the remainder of the line Added for program clarity and documentation VHDL 2008 supports C-style block commenting /* ... */ --******************************************* -- Example to show the caveot of the out mode architecture correct of entity_name is signal x_i : std_logic; -- Internal signal begin x_i <= a and b; x <= x_i; -- Connect the internal signal to the output y <= not x_i; end correct;

Identifier Identifier is the name of an object Basic rules: Can only contain alphabetic letters, decimal digits and underscore The first character must be a letter The last character cannot be an underscore Two successive underscores are not allowed Valid: A10, next_state, NextState Invalid: sig#3, _X10, 7segment, X10_, hi_ _there VHDL is case insensitive: {nextstate, NextState, NEXTSTATE, nEXTsTATE} are all the same

Reserved Words

Numbers, Characters, and Strings Integer: 0, 1234, 98E7 Real: 0.0, 1.23456 or 9.87E6 Base 2: 2#101101# Character: ‘A’, ‘Z’, ‘1’ Strings “Hello”, “101101” Note: 0 and ‘0’ are different 2#101101# and “101101” are different

Program Format VHDL is “free-format”: blank space, tab, new-line (i.e., “white space”) can be freely inserted The following are the same: architecture correct of entity_name is signal x_i : std_logic; begin x_i <= a and b; x <= x_i; y <= not x_i; end correct; architecture correct of entity_name is signal x_i : std_logic; begin x_i <= a and b; x <= x_i; y <= not x_i; end correct;

VHDL Objects

Objects A named item that hold a value of specific data type Four kinds of objects Signal Variable Constant File (cannot be synthesized) Related construct Alias

Signal Declared in the architecture body's declaration section Signal declaration: signal sig1, sig2, ... : data_type; Signal assignment: signal_name <= projected_waveform; Ports in entity declaration are considered as signals Can be interpreted as wires or “wires with memory” (e.g., FFs, latches etc.)

Variable Declared and used inside a process Variable declaration: variable var1, var2, ... : data_type; Variable assignment: variable_name := value_expression; Contains no “timing info” (immediate assignment) Used as in traditional PL: a “symbolic memory location” where a value can be stored and modified No direct hardware counterpart

Constant Value cannot be changed Constant declaration: constant const_name, ... : data_type := value_expression; Used to enhance readability constant BUS_WIDTH : integer := 32; constant BUS_BYTDL : integer := BUS_WIDTH / 8;

Constant Example: Avoid Hard Literals architecture beh1_arch of even_detector is signal odd : std_logic; begin ... tmp := '0'; for i in 2 downto 0 loop tmp := tmp xor a(i); end loop; Versus architecture beh1_arch of even_detector is signal odd : std_logic; constant BUS_WIDTH : integer := 3; begin ... tmp := '0'; for i in (BUS_WIDTH-1) downto 0 loop tmp := tmp xor a(i); end loop;

Alias Not an object Alternative name for an object Used to enhance readability signal word : std_logic_vector(15 downto 0); alias op : std_logic_vector(6 downto 0) is word(15 downto 9); alias reg1 : std_logic_vector(2 downto 0) is word(8 downto 6); alias reg2 : std_logic_vector(2 downto 0) is word(5 downto 3); alias reg3 : std_logic_vector(2 downto 0) is word(2 downto 0);

Data Types and Operators

Data Types and Operators Standard VHDL IEEE1164_std_logic package IEEE numeric_std package

Data Type Definition of data type VHDL is a strongly-typed language A set of values that an object can assume. A set of operations that can be performed on objects of this data type. VHDL is a strongly-typed language an object can only be assigned with a value of its type Error: int_var := char_var; Correct: int_var := to_integer(char_var); only the operations defined with the data type can be performed on the object

Data Types in Standard VHDL integer: Minimal range: -(2^31-1) to 2^31-1 Two subtypes: natural, positive boolean: (false, true) bit: ('0', '1') Not capable enough bit_vector: a one-dimensional array of bit

Operators in Standard VHDL

Operators in Standard VHDL

IEEE std_logic_1164 package What’s wrong with bit? New data type: std_logic, std_logic_vector std_logic: 9 values: ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-') '0', '1': forcing logic 0' and forcing logic 1 'Z': high-impedance, as in a tri-state buffer. 'L' , 'H': weak logic 0 and weak logic 1, as in wired logic 'X', 'W': “unknown” and “weak unknown” 'U': for uninitialized '-': don't-care.

IEEE std_logic_1164 package std_logic_vector an array of elements with std_logic data type Implies a bus Example declaration signal a: in std_logic_vector(7 downto 0); Another form (less desired) signal a: in std_logic_vector(0 to 7); Need to invoke package to use the data type: library ieee; use ieee.std_logic_1164.all;

IEEE std_logic_1164 package: Overloaded Operators Which standard VHDL operators can be applied to std_logic and std_logic_vector? Overloading: same operator of different data types Overloaded operators in std_logic_1164 package

IEEE std_logic_1164 package: Conversion Functions Provides functions to convert between data types signal s1, s2, s3 : std_logic_vector(7 downto 0); signal b1, b2: bit_vector(7 downto 0); s1 <= to_stdlogicvector(b1); b2 <= to_bitvector(s1 and s2); s3 <= to_stdlogicvector(b1) or s2; s3 <= to_stdlogicvector(b1 or to_bitvector(s2));

Array Data Type Operators Relational operators for array operands must have the same element type but their lengths may differ Two arrays are compared element by element, form the left most element All following returns true "011"="011", "011">"010", "011">"00010", "0110">"011“ Concatenation operator (&) y <= "00" & a(7 downto 2); y <= a(7) & a(7) & a(7 downto 2); y <= a(1 downto 0) & a(7 downto 2);

Array Aggregate Aggregate is a VHDL construct to assign a value to an array-typed object a <= "10100000"; a <= (7 => '1', 6 => '0', 0 => '0', 1 => '0', 5 => '1', 4 => '0', 3 => '0', 2 =>'1'); a <= (7|5 => '1', 6|4|3|2|1|0 => '0'); a <= (7|5 => '1', others => '0'); a <= "00000000" a <= (others => '0');

IEEE numeric_std package How to infer arithmetic operators? In standard VHDL: signal a, b, sum: integer; . . . sum <= a + b; What’s wrong with integer data type?

IEEE numeric_std package IEEE numeric_std package: define integer as a an array of elements of std_logic Two new data types: unsigned, signed The array interpreted as an unsigned or signed binary number signal x, y: signed(15 downto 0); Need invoke package to use the data type library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;

IEEE numeric_std package: Overloaded Operators

IEEE numeric_std package: New Functions

IEEE numeric_std package: Type Conversion std_logic_vector, unsigned, signed are defined as an array of element of std_logic They considered as three different data types in VHDL Type conversion between data types: type conversion function Type casting (for “closely related” data types)

Casting vs. Conversion Type casting (language primitive) is available between related types bit, std_logic bit_vector, std_logic_vector, unsigned, signed integer, natural, positive Conversion functions (library add-ons) must be used when type casting is not available. Best Reference: C:\Xilinx\xx.x\ISE_DS\ISE\vhdl\src.

Non-IEEE Package Packages by Synopsys std_logic_arith Similar to numeric_std New data types: unsigned, signed Details are different std_logic_unsigned/std_logic_signed Treat std_logic_vector as unsigned and signed numbers Overload std_logic_vector with arith operations Vendors typically store these packages in the IEEE library Only one type (unsigned/signed) can be used per VHDL file unsigned/signed defeat the motivation behind strong typing Inconsistent implementation between vendors numeric_std is preferred (required in this class)

Synthesis Guidelines

Guidelines for General VHDL Use the std_logic_vector and std_logic instead of bit_vector and bit data types Use the numeric_std package and the unsigned and signed data types for synthensizing arithmetic operations Only use downto in array specification (e.g., unsigned, signed, std_logic_vector) Use parentheses to clarify the intended order of operations Don’t use user-defined types unless there is a compelling reason Don’t use immediate assignment (i.e., :=) to assign an initial value to a signal Use operands with identical lengths for the relational operators

Guidelines for VHDL Formatting Include an information header for each file Be consistent with the use of case Use proper spaces, blank lines, and indentations to make the code clear Add necessary comments Use symbolic constant names to replace hard literals in VHDL code Use meaningful names for the identifiers Use a suffix to indicate a signal’s special property: _n for active low signals _i for internal signals (tied to an output signal to make it readable) Keep the line width within 72 characters so code can be displayed and printed properly by various editors and printers without wrapping

Lesson Outline Basic VHDL Program Lexical Elements and Program Format VHDL Objects Data Types and Operators Synthesis Guidelines