VHDL for Complex Designs

Similar documents
Introduction to VHDL #1

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

Lecture 4. VHDL Fundamentals. George Mason University

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

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

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

Chapter 6 Combinational-Circuit Building Blocks

Contents. Appendix D VHDL Summary Page 1 of 23

Chapter 2 Basic Logic Circuits and VHDL Description

Introduction to VHDL

Digital Systems Design

1 ST SUMMER SCHOOL: VHDL BOOTCAMP PISA, JULY 2013

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

EEL 4783: Hardware/Software Co-design with FPGAs

Lecture 3 Introduction to VHDL

Basic Language Constructs of VHDL

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

VHDL for FPGA Design. by : Mohamed Samy

Inthis lecture we will cover the following material:

Lattice VHDL Training

INTRODUCTION TO VHDL. Lecture 5 & 6 Dr. Tayab Din Memon Assistant Professor Department of Electronic Engineering, MUET

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

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

Lecture 12 VHDL Synthesis

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

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

Writing VHDL for RTL Synthesis

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

VHDL And Synthesis Review

Control and Datapath 8

Introduction to VHDL. Main language concepts

Very High Speed Integrated Circuit Har dware Description Language

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

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

C-Based Hardware Design

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

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

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

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

CprE 583 Reconfigurable Computing

VHDL Sample Slides Rev Sample Slides from the 2-day and 4-day VHDL Training Courses

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

FPGA Design. Part III - Combinatorial VHDL. Thomas Lenzi

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

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

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

Lecture 5: State Machines, Arrays, Loops. EE 3610 Digital Systems

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

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

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

Hardware Description Language VHDL (1) Introduction

Constructing VHDL Models with CSA

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

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

Design units can NOT be split across different files

Lab # 5. Subprograms. Introduction

Outline. CPE/EE 422/522 Advanced Logic Design L15. Files. Files

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

Lecture 9. VHDL, part IV. Hierarchical and parameterized design. Section 1 HIERARCHICAL DESIGN

VHDL simulation and synthesis

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

VHDL Structural Modeling II

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

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

ENGIN 241 Digital Systems with Lab

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

Lecture 10 Subprograms & Overloading

Contents. Chapter 9 Datapaths Page 1 of 28

FPGAs in a Nutshell - Introduction to Embedded Systems-

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

ECE 545 Lecture 4. Simple Testbenches. George Mason University

ENGG3380: Computer Organization and Design Lab4: Buses and Peripheral Devices

Verilog HDL is one of the two most common Hardware Description Languages (HDL) used by integrated circuit (IC) designers. The other one is VHDL.

HIERARCHICAL DESIGN. RTL Hardware Design by P. Chu. Chapter 13 1

Outline HIERARCHICAL DESIGN. 1. Introduction. Benefits of hierarchical design

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

Subprograms, Packages, and Libraries

In our case Dr. Johnson is setting the best practices

COVER SHEET: Total: Regrade Info: 1 (8 points) 2 ( 8 points) 3 (16 points) 4 (16 points) 5 (16 points) 6 (16 points) 7 (16 points) 8 (8 points)

VHDL Synthesis Reference

Hardware Design Environments. Dr. Mahdi Abbasi Computer Engineering Department Bu-Ali Sina University

Verilog Module 1 Introduction and Combinational Logic

ECOM 4311 Digital Systems Design

Department of Technical Education DIPLOMA COURSE IN ELECTRONICS AND COMMUNICATION ENGINEERING. Fifth Semester. Subject: VHDL Programming

The CPU Bus : Structure 0

VHDL: Code Structure. 1

VHDL: RTL Synthesis Basics. 1 of 59

EE595. Part VIII Overall Concept on VHDL. EE 595 EDA / ASIC Design Lab

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

EECE 353: Digital Systems Design Lecture 10: Datapath Circuits

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

Menu. Introduction to VHDL EEL3701 EEL3701. Intro to VHDL

Verilog Design Principles

OUTLINE SYSTEM-ON-CHIP DESIGN. GETTING STARTED WITH VHDL September 3, 2018 GAJSKI S Y-CHART (1983) TOP-DOWN DESIGN (1)

Review of Digital Design with VHDL

APPLICATION NOTE. A CPLD VHDL Introduction. Introduction. Overview. Entity. XAPP 105 January12, 1998 (Version 1.0) 0 4* Application Note

Designing Procedural-Based Behavioral Bus Functional Models for High Performance Verification

Introduction to VHDL #3

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

Transcription:

ELEC 379 : DESIGN OF DIGITAL AND MICROCOMPUTER SYSTEMS 1998/99 WINTER SESSION, TERM 2 VHDL for Complex Designs This lecture covers VHDL features that are useful when designing complex logic circuits. After this lecture you should be able to: make library packages visible declare s and save them in packages instantiate s into an architecture declare std logic, std logic vector, signed and unsigned signals declare enumerated types and subtypes of array types and save them in packages use conditional signal assignments convert between std logic vector, unsigned and integer types instantiate tri-state outputs model RAM using arrays Libraries, Packages and Components As in the design of any complex system, in the design of complex logic circuits it s often a good idea to decompose a design into simpler parts. Each of these parts can be written and tested separately, perhaps by different people. If the parts are sufficiently general then it s often possible to re-use them in future projects. A similar principle holds for software. We break down complex programs into smaller subroutines or functions, each of which is easier to write, test, and re-use. In VHDL, we can re-use an entity in another entity s architecture by declaring the first entity as a. A declaration is very similar to its corresponding entity declaration it only declares the input and output signals. In order to avoid declaring each in every architecture where it is used, we typically place declarations in packages. A package typically contains a set of declarations for a particular application. Packages are themselves stored in libraries : Package Library Package To make the s in a package available ( visible ) in another design, we use library statements to specify the libraries to be searched and a use statement for each package we wish to use. The two most commonly used libraries are called IEEE and WORK. In the Synopsys Design Compiler 1 and Max PlusII VHDL implementations a library is a directory and each package is a file in that directory. The package file is a database containing information about the s in the package (the inputs, outputs, types, etc). The WORK library is always available without having to use a library statement. In Design Compiler the WORK library is a subdirectory of the current directory called WORK while in Max PlusII it is the current project directory. library and use statements must be used before each design unit (entity or architecture) that makes use of s found in those packages 2. For example, if you wanted to use the numeric_bit package in the ieee library you would use: use ieee.numeric_bit.all ; and if you wanted to use the dsp package in the WORK library you would use: 1 The logic synthesizer used to create the schematics in these lecture notes. 2 An exception: when an architecture immediately follows its entity you need not repeat the library and use statements. lec7.tex 1

use work.dsp.all ; example? Why is there no library statement in the second Creating Components To create s, we usually put declarations within a package declaration. When we compile (or analyze ) the file that contains the package and declarations the information about the s in the package will be saved in a file with the name of the package (and, in Max PlusII, the extension.vhdlview) in the WORK library. The s in the package can then be used in other designs by making them visible with a use statement. A declaration is similar to an entity declaration and simply defines the input and output signals. Note that a declaration does not create hardware only when the is used in an architecture is the hardware generated ( instantiated ). For example, the following code declares a package called flipflops. This package contains only one, rs, with inputs r and s and an output q when it is compiled: package flipflops is rs port ( r, s : in bit ; q : out bit ) ; end ; end flipflops ; The following example shows how 2-input exclusive-or gates can be used to built a 4-input parity-check circuit using instantiation. This type of description is called structural VHDL because we are defining the structure rather than the behaviour of the circuit. There are two files: the first file, mypackage.vhd, describes the xor2 (although a typical package defines more than one ): -- define an xor2 in a package package xor_pkg is xor2 port ( a, b : in bit ; x : out bit ) ; end ; end xor_pkg ; the second file, parity.vhd, describes the parity entity that uses the xor2 : -- parity function built from xor gates use work.xor_pkg.all ; entity parity is port ( a, b, c, d : in bit ; p : out bit ) ; end parity ; architecture rtl of parity is -- internal signals signal x, y : bit ; x1: xor2 port map ( a, b, x ) ; x2: xor2 port map ( c, x, y ) ; x3: xor2 port map ( d, y, p ) ; The resulting top-level schematic for the parity entity is: If you this code was stored in a file called ff.vhd, what file would be created? Where would it be placed? Component Instantiation Once a has been placed in a package, it can be used ( instantiated ) in an architecture. A instantiation simply describes how the is hooked up to the other signals in the architecture. It is thus a concurrent statement like the process statement rather than a sequential statement and a instantiation cannot be put inside a process. Label the connections within the parity generator schematic with the signal names used in the architecture. When the parity.vhd file is compiled, the compiler will search the (WORK) directory for the xor_pkg package. Although s don t necessarily have to be created using VHDL descriptions (they may have been created using design methods other than VHDL), we could have done so by using the following entity/architecture pair in file called xor2.vhd: 2

-- xor gate entity xor2 is port ( a, b : in bit ; x : out bit ) ; end xor2 ; architecture rtl of xor2 is x <= a xor b ; Type Declarations It s often useful to make up new types of signals for a project. We can do this in VHDL by including type declarations in packages. The most common uses for defining new types are to create signals of of a given width (i.e. a bus) and to declare types that can only have one of a set of possible values (called enumeration types). The following example shows how a package called dsp_types that declares three new types is created: package dsp_types is type mode is (slow, medium, fast) ; subtype word is bit_vector (15 downto 0) ; end dsp_types ; Note that we need to use a subtype declaration in the second example because the bit_vector type is already defined. Type declarations are often placed in packages to make them available to multiple design units. Write a declaration for a signal that controls whether the value in a register should be loaded, incremented, decremented, or held. Write the declaration for an 8-bit signal type called byte. std logic Packages In the IEEE library there are two packages that are often used. These packages define alternatives to the bit and bit_vector types for logic design. The first package, std_logic_1164, defines the types std_logic (similar to bit) and std_logic_vector (similar to bit_vector). The advantage of the std_logic types is that they can have values other than 0 and 1. For example, an std_logic signal can also have a high-impedance value ( Z ). The std_logic_1164 package also redefines ( overloads ) the standard boolean operators so that they also work with std_logic signals. The second package is called std_logic_arith 3 and defines the types signed and unsigned. These are subtypes of std_logic_vector with overloaded operators that allow them to be used as both vectors of logic values and as a binary values (in two s complement or unsigned representations). The hierarchy of these logic types could be drawn as follows: std_logic signed declared in std_logic_1164 std_logic_vector declared in std_logic_arith unsigned Although the standard arithmetic operators (+, -, *, /, **) can be applied to signals of type signed or unsigned, it may not be practical or possible to synthesize complex operators such as multiplication, division or exponentiation. For example, we could generate the combinational logic to build a 4-bit adder using the following architecture: use ieee.std_logic_arith.all ; entity adder4 is port ( a, b : in unsigned (3 downto 0) ; c : out unsigned (3 downto 0) ) ; end adder4 ; architecture rtl of adder4 is c <= a + b ; The resulting (rather messy) schematic is: 3 The IEEE standard is really numeric std but it s not widely used yet. 3

"000" "001" b(0)= 1 "010" b(1)= 1 "011" b(2)= 1 "100" b(3)= 1 Synthesizing the above description results in: n Conditional Assignment In the same way that a selected assignment statement models a case statement in a sequential programming language, a conditional assignment statement models an if/else statement. Like the selected assignment statement, it is also a concurrent statement. For example, the following circuit outputs the position of the left-most 1 bit in the input: entity nbits is port ( b : in std_logic_vector (3 downto 0) ; n : out std_logic_vector (2 downto 0) ) ; end nbits ; architecture rtl of nbits is n <= "100" when b(3) = 1 else "011" when b(2) = 1 else "010" when b(1) = 1 else "001" when b(0) = 1 else "000" ; Note that the conditions are tested in the order that they appear in the statement and only the first value whose controlling expression is true is assigned. In the same was that we can view a selected assignment statement as the VHDL model for a ROM or lookup table, a conditional assignment statement can be viewed the VHDL description of one or more multiplexers. For example, the structure of the example above could be drawn as: Write a conditional assignment that models a 2- to-1 multiplexer. Use an array x as the input, a signal sel to select the input and a signal y as the output. Repeat for a 4-to-1 multiplexer (sel is now an array). Type Conversion Functions VHDL is a strongly-typed language each function or operator must be supplied arguments of exactly the right type or the compiler will give an error message. Although many functions/operators (e.g. and) are overloaded so that you can use the same function/operator with more than one type, in many cases you will need to use type conversion functions. The following table shows the type conversion functions found in the the std_logic_arith package in the ieee library. The abbreviations lv, un and in are used for std_logic_vector, unsigned and integer respectively. from to function lv un unsigned(x) lv in conv integer(x) un lv std logic vector(x) un in conv integer(x) in un conv unsigned(x,len) in lv conv std logic vector(x,len) Note that when converting an integer you must explicitly specify the number of bits in the result (len). 4

Tri-State Buses A tri-state output can be set to the normal high and low logic levels as well as to a third state: highimpedance. This type of output is often used where different devices drive the same bus at different times (e.g. a data bus). The most common way to specify that an output should be set to the high-impedance state is to use a signal of type std_logic and assign it a value of Z. The following example shows an implementation of a 4-bit buffer with an enable output. When the enable is not asserted the output is in high-impedance mode : entity tbuf is port ( d : in std_logic_vector (3 downto 0) ; q : out std_logic_vector (3 downto 0) ; en : in std_logic ) ; end tbuf ; architecture rtl of tbuf is q <= d when en = 1 else "ZZZZ" ; The resulting schematic for the tbuf is: Tri-state outputs are used primarily to implement bidirectional bus signals. Such signals are declared of type inout rather than in or out and their values can be used within the architecture (unlike signals of type out). When the bus is to act as an input, the bidirectional bus signals are driven to the high-impedance state and in this case it s the value of signals outside the entity that determine the signal s value. RAM Models VHDL also allows the use of arrays with signal indices to model random-access memory (RAM). The following example demonstrates the use of VHDL arrays as well as bi-directional buses. We must use the type-conversion function conv_integer because the address input, a, is of type unsigned while the array index must be of type integer. use ieee.std_logic_arith.all ; entity ram is port ( -- bi-directional data signal d : inout std_logic_vector (7 downto 0) ; -- address input a : in unsigned (1 downto 0) ; -- output enable and write strobe (clock) oe, wr : in std_logic ) ; end ram ; architecture rtl of ram is subtype byte is std_logic_vector (7 downto 0) ; type byte_array is array (0 to 3) of byte ; signal ram : byte_array ; -- output value is the indexed array element d <= ram(conv_integer(a)) when oe = 1 else "ZZZZZZZZ" ; -- register the indexed array element process(wr) if wr event and wr = 1 then ram(conv_integer(a)) <= d ; end if ; end process ; Modify the design above to create a 16-element, 4-bit wide RAM with separate input and output signals. The result of synthesizing this description is: 5

For many implementation technologies (FPGAs, gate arrays, or standard-cell ASICs) there are usually vendor-specific ways of implementing memory arrays that give better results. However, using a VHDL-only model with random logic as shown above is more portable. Why is portability desirable? 6