RTL Hardware Design by P. Chu Chapter 31. 1. Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.

Slides:



Advertisements
Similar presentations
VHDL in digital circuit synthesis (tutorial) dr inż. Miron Kłosowski EA 309
Advertisements

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.
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
Comprehensive VHDL Module 6 Types November Comprehensive VHDL: Types Copyright © 2000 Doulos Types Aim ©To understand the use and synthesis.
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.
Sistemas Digitais I LESI - 2º ano Lesson 5 - VHDL U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes Dept.
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.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
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.
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.
George Mason University Modeling of Arithmetic Circuits ECE 545 Lecture 7.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
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
CSET 4650 Field Programmable Logic Devices Dan Solarek Introduction to VHDL An Overview / Review.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Capt Michael Tanner Room 2F46A
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.
IAY 0600 Digital Systems Design VHDL discussion Dataflow&Behavioral Styles Combinational Design Alexander Sudnitson Tallinn University of Technology.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
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.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
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.
IAY 0600 Digital Systems Design
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.
8-Jan-16EE5141 Chapter 6 Subprograms & Packages Subprogram declaration Subprogram body Package declaration Package body Resolution function Subprogram.
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
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
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.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
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
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Dataflow Style Combinational Design with VHDL
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L17
Data Flow Modeling of Combinational Logic
IAS 0600 Digital Systems Design
CPE 528: Lecture #3 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.
Data Flow Description of Combinational-Circuit Building Blocks
IAS 0600 Digital Systems Design
Chapter 2: Introduction to C++.
Data Flow Description of Combinational-Circuit Building Blocks
VHDL Data Types Module F3.1.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

RTL Hardware Design by P. Chu Chapter 31

1. Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware Design by P. Chu Chapter 32

RTL Hardware Design by P. Chu Chapter 33

 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 RTL Hardware Design by P. Chu Chapter 34

 Simplified syntax RTL Hardware Design by P. ChuChapter 35

 mode: ◦ in: flow into the circuit ◦ out: flow out of the circuit ◦ inout: bi-directional  E.g. RTL Hardware Design by P. ChuChapter 36

 A common mistake with mode RTL Hardware Design by P. ChuChapter 37

 Fix: use an internal signal RTL Hardware Design by P. ChuChapter 38

 Simplified syntax RTL Hardware Design by P. ChuChapter 39 An entity declaration can be associated with multiple architecture bodies

E.g. RTL Hardware Design by P. ChuChapter 310

 Package declaration/body: ◦ collection of commonly used items, such as data types, subprograms and components  Configuration: ◦ specify which architecture body is to be bound with the entity declaration RTL Hardware Design by P. Chu Chapter 311

 A place to store the analyzed design units  Normally mapped to a directory in host computer  Software define the mapping between the symbolic library and physical location  Default library: “work”  Library “ieee” is used for many ieee packages RTL Hardware Design by P. Chu Chapter 312

 E.g.  Line 1: invoke a library named ieee  Line 2: makes std_logic_1164 package visible to the subsequent design units  The package is normally needed for the std_logic/std_logic_vector data type RTL Hardware Design by P. ChuChapter 313

 Analysis ◦ Performed on “design unit” basis ◦ Check the syntax and translate the unit into an intermediate form ◦ Store it in a library  Elaboration ◦ Bind architecture body with entity ◦ Substitute the instantiated components with architecture description ◦ Create a “flattened”' description  Execution ◦ Simulation or synthesis RTL Hardware Design by P. Chu Chapter 314

RTL Hardware Design by P. Chu Chapter 315

 Lexical element: ◦ Basic syntactical units in a VHDL program  Types of Lexical elements: ◦ Comments ◦ Identifiers ◦ Reserved words ◦ Numbers ◦ Characters ◦ Strings RTL Hardware Design by P. Chu Chapter 316

 Starts with - -  Just for clarity  e.g., RTL Hardware Design by P. ChuChapter 317

 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 RTL Hardware Design by P. Chu Chapter 318

 Valid examples: A10, next_state, NextState, mem_addr_enable  Invalid examples: sig#3, _X10, 7segment, X10_, hi_ _there  VHDL is case insensitive: ◦ Following identifiers are the same: nextstate, NextState, NEXTSTATE, nEXTsTATE RTL Hardware Design by P. Chu Chapter 319

RTL Hardware Design by P. ChuChapter 320

 Number: ◦ Integer: 0, 1234, 98E7 ◦ Real: 0.0, 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 RTL Hardware Design by P. Chu Chapter 321

 VHDL is “free-format”: blank space, tab, new-line can be freely inserted  e.g., the following are the same RTL Hardware Design by P. ChuChapter 322

RTL Hardware Design by P. Chu Chapter 323

 A good “header” RTL Hardware Design by P. ChuChapter 324

RTL Hardware Design by P. Chu Chapter 325

 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 RTL Hardware Design by P. Chu Chapter 326

 Declared in the architecture body's declaration section  Signal declaration: signal signal_name, signal_name,... : 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” (i.e., FFs, latches etc.) RTL Hardware Design by P. ChuChapter 327

 Declared and used inside a process  Variable declaration: variable variable_name,... : 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 RTL Hardware Design by P. ChuChapter 328

 Value cannot be changed  Constant declaration: constant const_name,... : data_type := value_expression  Used to enhance readability ◦ E.g., RTL Hardware Design by P. ChuChapter 329

 It is a good idea to avoid “hard literals” RTL Hardware Design by P. ChuChapter 330

 Not a object  Alternative name for an object  Used to enhance readability ◦ E.g., RTL Hardware Design by P. ChuChapter 331

 Standard VHDL  IEEE1164_std_logic package  IEEE numeric_std package RTL Hardware Design by P. Chu Chapter 332

 Definition of data type ◦ 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 ◦ only the operations defined with the data type can be performed on the object RTL Hardware Design by P. Chu Chapter 333

 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 RTL Hardware Design by P. Chu Chapter 334

RTL Hardware Design by P. Chu Chapter 335

RTL Hardware Design by P. Chu Chapter 336

 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. RTL Hardware Design by P. Chu Chapter 337

 std_logic_vector ◦ an array of elements with std_logic data type ◦ Imply a bus ◦ E.g., signal a: std_logic_vector(7 downto 0); ◦ Another form (less desired) signal a: std_logic_vector(0 to 7);  Need to invoke package to use the data type: library ieee; use ieee.std_logic_1164.all; RTL Hardware Design by P. Chu Chapter 338

 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 RTL Hardware Design by P. ChuChapter 339

 Type conversion function in std_logic_1164 package: RTL Hardware Design by P. ChuChapter 340

 E.g., RTL Hardware Design by P. ChuChapter 341

 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" RTL Hardware Design by P. Chu Chapter 342

 Concatenation operator (&)  e.g., y <= "00" & a(7 downto 2); y <= a(7) & a(7) & a(7 downto 2); y <= a(1 downto 0) & a(7 downto 2); RTL Hardware Design by P. Chu Chapter 343

 Aggregate is a VHDL construct to assign a value to an array-typed object  E.g., a <= " "; a '1', 6=>'0', 0=>'0', 1=>'0', 5=>'1', 4=>'0', 3=>'0', 2=>'1'); a '1', 6|4|3|2|1|0=>'0'); a '1', others=>'0');  E.g., a <= " " a '0'); RTL Hardware Design by P. Chu Chapter 344

 How to infer arithmetic operators?  In standard VHDL: signal a, b, sum: integer;... sum <= a + b;  What’s wrong with integer data type? RTL Hardware Design by P. Chu Chapter 345

 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  E.g., 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; RTL Hardware Design by P. Chu Chapter 346

RTL Hardware Design by P. Chu Chapter 347

 E.g., RTL Hardware Design by P. ChuChapter 348

RTL Hardware Design by P. Chu Chapter 349

 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) RTL Hardware Design by P. Chu Chapter 350

RTL Hardware Design by P. Chu Chapter 351

 E.g. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;... signal s1, s2, s3, s4, s5, s6: std_logic_vector(3 downto 0); signal u1, u2, u3, u4, u6, u7: unsigned(3 downto 0); signal sg: signed(3 downto 0); RTL Hardware Design by P. Chu Chapter 352

 E.g. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;... signal s1, s2, s3, s4, s5, s6: std_logic_vector(3 downto 0); signal u1, u2, u3, u4, u6, u7: unsigned(3 downto 0); signal sg: signed(3 downto 0); RTL Hardware Design by P. Chu Chapter 353

◦ Ok u3 <= u2 + u1; --- ok, both operands unsigned u4 <= u2 + 1; --- ok, operands unsigned and natural ◦ Wrong u5 <= sg; -- type mismatch u6 <= 5; -- type mismatch ◦ Fix u5 <= unsigned(sg); -- type casting u6 <= to_unsigned(5,4); -- conversion function RTL Hardware Design by P. Chu Chapter 354

◦ Wrong u7 <= sg + u1; -- + undefined over the types ◦ Fix u7 <= unsigned(sg) + u1; -- ok, but be careful ◦ Wrong s3 <= u3; -- type mismatch s4 <= 5; -- type mismatch ◦ Fix s3 <= std_logic_vector(u3); -- type casting s4 <= std_logic_vector(to_unsigned(5,4)); RTL Hardware Design by P. Chu Chapter 355

◦ Wrong s5 <= s2 + s1; + undefined over std_logic_vector s6 <= s2 + 1; + undefined ◦ Fix s5 <= std_logic_vector(unsigned(s2) + unsigned(s1)); s6 <= std_logic_vector(unsigned(s2) + 1); RTL Hardware Design by P. Chu Chapter 356

 Packagea 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 ◦ i.e., overload std_logic_vector with arith operations RTL Hardware Design by P. Chu Chapter 357

 Software vendors frequently store them in ieee library:  E.g., library ieee; use ieee.std_logic_1164.all; use ieee.std_arith_unsigned.all;... signal s1, s2, s3, s4, s5, s6: std_logic_vector(3 downto 0);... s5 <= s2 + s1; -- ok, + overloaded with std_logic_vector s6 <= s2 + 1; -- ok, + overloaded with std_logic_vector RTL Hardware Design by P. Chu Chapter 358

 Only one of the std_logic_unsigned and std_logic_signed packages can be used  The std_logic_unsigned/std_logic_signed packages beat the motivation behind a strongly-typed language  Numeric_std is preferred RTL Hardware Design by P. Chu Chapter 359