Embedded Systems CS - ES

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

A bird s eye view on VHDL!

Generatore di parità. LIBRARY ieee; USE ieee.std_logic_1164.all ; ENTITY xor2 IS PORT( A, B : in std_logic ; Y : out std_logic ) ; END xor2 ;

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

VHDL Objects. Lecture 8: VHDL (2) Variables. VHDL Objects - Constant. Files. EE3109 Gopi K. Manne Fall 2007

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

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

Hardware Description Language VHDL (1) Introduction

Outline. CPE/EE 422/522 Advanced Logic Design L07. Review: JK Flip-Flop Model. Review: VHDL Program Structure. Review: VHDL Models for a MUX

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

EEL 4783: Hardware/Software Co-design with FPGAs

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

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

EE 595. Part IV Basic Elements in VHDL. EE 595 EDA / ASIC Design Lab

C-Based Hardware Design

Review of Digital Design with VHDL

Contents. Appendix D VHDL Summary Page 1 of 23

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

VHDL BASIC ELEMENTS INTRODUCTION

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

ECE 3401 Lecture 10. More on VHDL

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

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

Design units can NOT be split across different files

Concurrent Signal Assignment Statements (CSAs)

ECOM4311 Digital Systems Design

IT T35 Digital system desigm y - ii /s - iii

VHDL Structural Modeling II

ECE4401 / CSE3350 ECE280 / CSE280 Digital Design Laboratory

COE 405 Design Methodology Based on VHDL

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

Introduction to VHDL #1

Basic Language Concepts

Digital Systems Design

Hardware Description Languages. Modeling Complex Systems

Performance Engineering of Real-Time and Embedded Systems. Introduction to VHDL

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

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

ENGIN 241 Digital Systems with Lab

Introduction to the VHDL language. VLSI Digital Design

VHDL 3 BASIC OPERATORS AND ARCHITECTURE BODY. Design descriptions & design constructions examples are taken from foundation series examples

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

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

Introduction to VHDL. Main language concepts

VHDL for FPGA Design. by : Mohamed Samy

Introduction to VHDL Lecture D

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

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

Computer-Aided Digital System Design VHDL

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

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

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

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

Chapter 6 Combinational-Circuit Building Blocks

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

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

ELCT 501: Digital System Design

Modeling Complex Behavior

ECOM 4311 Digital System Design using VHDL. Chapter 7

Lecture 3 Introduction to VHDL

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification

Outline. CPE/EE 422/522 Advanced Logic Design L05. Review: General Model of Moore Sequential Machine. Review: Mealy Sequential Networks.

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

Entity, Architecture and Process

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

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

Introduction to Verilog

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

Digital Systems Design

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

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

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

Hardware Modeling. VHDL Basics. ECS Group, TU Wien

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification Part II

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

EITF35: Introduction to Structured VLSI Design

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

Digital Systems Design

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

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Mridula Allani Fall Fall

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

VHDL: skaitmeninių įtaisų projektavimo kalba. 2 paskaita Pradmenys

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

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

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

Sequential VHDL. Katarzyna Radecka. DSD COEN 313

VHDL: A Crash Course

VHDL Examples Mohamed Zaky

Specifications Part 3

VHDL Synthesis Reference

0. Overview of this standard Design entities and configurations... 5

SECTION 1 FAMILIARIZATION WITH VHDL

Tutorial on VHDL and Verilog Applications

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

[1] Douglas L. Perry, VHDL, third edition, ISBN , McRaw- Hill Series on Computer Engineering.

1. Using the for-generahon scheme, concurrent statements can be replicated a predetermined number of times.

SRI SUKHMANI INSTITUTE OF ENGINEERING AND TECHNOLOGY, DERA BASSI (MOHALI)

Lecture 4. VHDL Fundamentals. George Mason University

Inthis lecture we will cover the following material:

Transcription:

Embedded Systems - 1 -

REVIEW Hardware/System description languages VDHL VHDL-AMS SystemC TLM - 2 -

VHDL REVIEW Main goal was modeling of digital circuits Modelling at various levels of abstraction Technology-independent Re-Usability of specifications - 3 -

Abstraction Levels REVIEW - 4 -

Simulation speed Relative speeds of different types of simulation/emulation 1 hour actual execution of SOC = 1.2 years instruction-set simulation = 10,000,000 hours gate-level simulation 1 IC 1 hour 1000 100 10 FPGA hardware emulation throughput model 1 day 4 days 1.4 months 10000 100,000 1,000,000 10,000,000 instruction-set simulation cycle-accurate simulation register-transfer-level HDL simulation gate-level HDL simulation 1.2 years 12 years >1 lifetime 1 millennium - 5 -

Entity/Architectures Architecture body E1_A3 is bound to entity E1 Architecture body E2_A1 is bound to entity E2 Component M1 in the AB E2_A1 is bound to entity E3 Component CX in the AB E1_A3 is bound to entity E2-6 -

Definitions of the Description Methods Structural Description Method: expresses the design as an arrangement of interconnected components It is basically schematic Behavioral Description Method: describes the functional behavior of a hardware design in terms of circuits and signal responses to various stimuli The hardware behavior is described algorithmically Data-Flow Description Method: is similar to a registertransfer language This method describes the function of a design by defining the flow of information from one input or register to another register or output - 7 -

Design Description Methods Structural Description Method Behavioral Description Method Data-Flow Description Method Schematic These two are similar in that both use a process to describe the functionality of a circuit - 8 -

VHDL Mixed Modeling The three types of modeling can be combined within an architecture body component instantiation structural concurrent signal assignments dataflow process statements behavior This is called the mixed style of modeling - 9 -

VHDL Mixed Modeling - 10 -

Putting It All Together REVIEW The entity represents the interface specification (I/O) of the component. It defines the components external view, sometimes referred to as its "pins". Generics Package Entity Ports Architecture Architecture Architecture Concurrent Statements Concurrent Statements Process Sequential Statements - 11 -

Putting It All Together generics provide a method to communicate static information to a architecture from the external environment - are passed through the entity construct Generics Package Entity packages are used to provide a collection of common declarations, constants, and/or subprograms to entities and architectures Ports REVIEW ports provide the mechanism for a device to communication with its environment Architecture Architecture Architecture Concurrent Statements Concurrent Statements Process Sequential Statements - 12 -

Putting It All Together REVIEW architecture, containing only concurrent statements, is commonly referred to as a dataflow description -. concurrent statements execute when data is available on their inputs. Generics Entity Ports Architecture Architecture Architecture Concurrent Statements Concurrent Statements Package architecture is the behavioral description in which the functional and possibly timing characteristics are described using VHDL concurrent statements and processes. The process is a concurrent statement of an architecture Process Sequential Statements architecture describes the structure of the design in terms of its sub-components and their interconnections - 13 -

Concurrent Statements REVIEW Basic granularity of concurrency is the process Processes are executed concurrently Concurrent signal assignment statements are one-line processes Mechanism for achieving concurrency : Processes communicate with each other via signals Signal assignments require delay before new value is assumed Simulation time advances when all active processes complete Effect is concurrent processing I.e. order in which processes are actually executed by simulator does not affect behavior - 14 -

Delta Delay REVIEW 1) all active processes can execute in the same simulation cycle e.g., t n 2) each active process will suspend at wait statement (sensitive list process finish) 3) when all processes are suspended simulation is advanced the minimum time necessary (one delta delay) so that some signals can take on their new values 4) processes then determine if the new signal values satisfy the conditions to proceed from the wait statement at which they are suspended 5) all processes are suspended and no signal update: t n t n+1 (new entries in the event queue) - 15 -

A B C in Sum C out The Full Adder 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0 1 1 + 0 + 1 + 0 + 1 0 1 1 10 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Carry-in Truth Table 1 1 1 1 0 0 1 1 + 0 + 1 + 0 + 1 1 10 10 11 Carry-out Sum - 16 -

The Full Adder Half Adder Cin B A Sum Cout Half Adder - 17 -

The Full Adder in VHDL - 18 -

The Full Adder in VHDL Construct Full Adder from two Half Adders Use Structural VHDL Realize using hierarchical design Design half adder Interconnect half adders Include any additional logic - 19 -

The Full Adder in VHDL (Using the structural model) signals Architecture Half Adder (ha2) input ports Entity Cin B A Half Adder (ha1) s1 c1 c2 Sum Cout output ports 20-20 -

The Full Adder in VHDL (The Package File) LIBRARY ieee ; USE ieee.std_logic_1164.all ; PACKAGE halfadd_package IS COMPONENT halfadd PORT ( A, B: IN STD_LOGIC ; Sum, Cout: OUT STD_LOGIC ) ; END COMPONENT ; END halfadd_package ; - 21 -

The Full Adder in VHDL (The Design File) LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE work.halfadd_package.all ; ENTITY fulladd IS PORT ( Cin, A, B : IN STD_LOGIC ; Sum, Cout : OUT STD_LOGIC ) ; END fulladd ; ARCHITECTURE Structure OF fulladd IS SIGNAL s1, c1, c2: STD_LOGIC ; BEGIN ha1 : halfadd PORT MAP ( A => A, B => B, Sum => s1, Cout => c1 ) ; ha2 : halfadd PORT MAP ( s1, Cin, Sum, c2 ); Cout <= c1 OR c2 ; END Structure ; - 22 -

Module Outline Introduction VHDL Design Example VHDL Model Components Entity Declarations Architecture Descriptions Basic VHDL Constructs Summary - 23 -

VHDL Model Components A complete VHDL component description requires a VHDL entity and a VHDL architecture The entity defines a component s interface The architecture defines a component s function Several alternative architectures may be developed for use with the same entity - 24 -

VHDL Model Components (cont.) Fundamental unit for component behavior description is the process Processes may be explicitly or implicitly defined and are packaged in architectures Primary communication mechanism is the signal Process executions result in new values being assigned to signals which are then accessible to other processes Similarly, a signal may be accessed by a process in another architecture by connecting the signal to ports in the the entities associated with the two architectures Example signal assignment statement : Output <= My_id + 10; - 25 -

Entity Declarations The primary purpose of the entity is to declare the signals in the component s interface The interface signals are listed in the PORT clause In this respect, the entity is akin to the schematic symbol for the component x y enable Half Adder carry result ENTITY half_adder IS GENERIC(prop_delay : TIME := 10 ns); PORT( x, y, enable : IN BIT; carry, result : OUT BIT); END half_adder; - 26 -

Entity Declarations Port Clause PORT clause declares the interface signals of the object to the outside world Three parts of the PORT clause Name Mode PORT (signal_name : mode data_type); Data type Example PORT clause: PORT ( input : IN BIT_VECTOR(3 DOWNTO 0); ready, output : OUT BIT ); Note port signals (i.e. ports ) of the same mode and type or subtype may be declared on the same line - 27 -

Entity Declarations Port Clause (cont.) The port mode of the interface describes the direction in which data travels with respect to the component The five available port modes are: In - data comes in this port and can only be read Out - data travels out this port Buffer - data may travel in either direction, but only one signal driver may be on at any one time Inout - data may travel in either direction with any number of active drivers allowed; requires a Bus Resolution Function - 28 -

Entity Declarations Generic Clause Generics may be used for readability, maintenance and configuration Generic clause syntax : GENERIC (generic_name : type [:= default_value]); Generic clause example : GENERIC (My_ID : INTEGER := 37); The generic My_ID, with a default value of 37, can be referenced by any architecture of the entity with this generic clause The default can be overridden at component instantiation - 29 -

Architecture Bodies Describe the operation of the component Consist of two parts : Declarative part -- includes necessary declarations, e.g. : type declarations, signal declarations, component declarations, subprogram declarations Statement part -- includes statements that describe organization and/or functional operation of component, e.g. : concurrent signal assignment statements, process statements, component instantiation statements ARCHITECTURE half_adder_d OF half_adder IS SIGNAL xor_res : BIT; -- architecture declarative part BEGIN -- begins architecture statement part carry <= enable AND (x AND y); result <= enable AND xor_res; xor_res <= x XOR y; END half_adder_d; - 30 -

Structural Descriptions Pre-defined VHDL components are instantiated and connected together Structural descriptions may connect simple gates or complex, abstract components Mechanisms for supporting hierarchical description Mechanisms for describing highly repetitive structures easily Input Behavioral Entity Output - 31 -

Behavioral Descriptions VHDL provides two styles of describing component behavior Data Flow: concurrent signal assignment statements Behavioral: processes used to describe complex behavior by means of high-level language constructs variables, loops, if-then-else statements, etc. Input Behavioral Description Output - 32 -

Module Outline Introduction VHDL Design Example VHDL Model Components Basic VHDL Constructs Data types Objects Packages and libraries Attributes Predefined operators Summary - 33 -

Data Types All declarations VHDL ports, signals, and variables must specify their corresponding type or subtype Types Access Composite Scalar Array Record Integer Real Enumerated Physical - 34 -

VHDL Data Types Scalar Types Integer Minimum range for any implementation as defined by standard: - 2,147,483,647 to 2,147,483,647 Example assignments to a variable of type integer : ARCHITECTURE test_int OF test IS BEGIN PROCESS (X) VARIABLE a: INTEGER; BEGIN a := 1; -- OK a := -1; -- OK a := 1.0; -- illegal END PROCESS; END test_int; - 35 -

VHDL Data Types Scalar Types (Cont.) Real Minimum range for any implementation as defined by standard: -1.0E38 to 1.0E38 Example assignments to a variable of type real : ARCHITECTURE test_real OF test IS BEGIN PROCESS (X) VARIABLE a: REAL; BEGIN a := 1.3; -- OK a := -7.5; -- OK a := 1; -- illegal a := 1.7E13; -- OK a := 5.3 ns; -- illegal END PROCESS; END test_real; - 36 -

VHDL Data Types Scalar Types (Cont.) Enumerated User specifies list of possible values Example declaration and usage of enumerated data type : TYPE binary IS ( ON, OFF );... some statements... ARCHITECTURE test_enum OF test IS BEGIN PROCESS (X) VARIABLE a: binary; BEGIN a := ON; -- OK... more statements... a := OFF; -- OK... more statements... END PROCESS; END test_enum; - 37 -

VHDL Data Types Scalar Types (Cont.) Physical Require associated units Range must be specified Example of physical type declaration : TYPE resistance IS RANGE 0 TO 10000000 UNITS ohm; -- ohm Kohm = 1000 ohm; -- i.e. 1 K Mohm = 1000 kohm; -- i.e. 1 M END UNITS; Time is the only physical type predefined in VHDL standard - 38 -

VHDL Data Types Composite Types Array Used to group elements of the same type into a single VHDL object Range may be unconstrained in declaration Range would then be constrained when array is used Example declaration for one-dimensional array (vector) : TYPE data_bus IS ARRAY(0 TO 31) OF BIT; VARIABLE X : data_bus; VARIABLE Y : BIT; 0...element indices... 31 0 1...array values... Y := X(12); -- Y gets value of element at index 12-39 -

VHDL Data Types Composite Types (Cont.) Example one-dimensional array using DOWNTO : TYPE reg_type IS ARRAY(15 DOWNTO 0) OF BIT; 15...element indices... 0 0 1...array values... DOWNTO keyword must be used if leftmost index is greater than rightmost index Big-endian bit ordering, for example VARIABLE X : reg_type; VARIABLE Y : BIT; Y := X(4); -- Y gets value of element at index 4-40 -

VHDL Data Types Composite Types (Cont.) Records Used to group elements of possibly different types into a single VHDL object Elements are indexed via field names Examples of record declaration and usage : TYPE binary IS ( ON, OFF ); TYPE switch_info IS RECORD status : BINARY; IDnumber : INTEGER; END RECORD; VARIABLE switch : switch_info; switch.status := ON; -- status of the switch switch.idnumber := 30; -- e.g. number of the switch - 41 -

VHDL Data Types Access Type Access Analogous to pointers in other languages Allows for dynamic allocation of storage Useful for implementing queues, fifos, etc. - 42 -

VHDL Data Types Subtypes Subtype Allows for user defined constraints on a data type e.g. a subtype based on an unconstrained VHDL type May include entire range of base type Assignments that are out of the subtype range are illegal Range violation detected at run time rather than compile time because only base type is checked at compile time Subtype declaration syntax : SUBTYPE name IS base_type RANGE <user range>; Subtype example : SUBTYPE first_ten IS INTEGER RANGE 0 TO 9; - 43 -

VHDL Data Types Summary All declarations of VHDL ports, signals, and variables must included their associated type or subtype Three forms of VHDL data types are : Access -- pointers for dynamic storage allocation Scalar -- includes Integer, Real, Enumerated, and Physical Composite -- includes Array, and Record A set of built-in data types are defined in VHDL standard User can also define own data types and subtypes - 44 -

VHDL Objects There are four types of objects in VHDL Constants Variables Signals Files The scope of an object is as follows : Objects declared in a package are available to all VHDL descriptions that use that package Objects declared in an entity are available to all architectures associated with that entity Objects declared in an architecture are available to all statements in that architecture Objects declared in a process are available only within that process - 45 -

VHDL Objects Constants Name assigned to a specific value of a type Allow for easy update and readability Declaration of constant may omit value so that the value assignment may be deferred Facilitates reconfiguration Declaration syntax : CONSTANT constant_name : type_name [:= value]; Declaration examples : CONSTANT PI : REAL := 3.14; CONSTANT SPEED : INTEGER; - 46 -

VHDL Objects Variables Provide convenient mechanism for local storage E.g. loop counters, intermediate values, etc. Scope is process in which they are declared All variable assignments take place immediately No delta or user specified delay is incurred Declaration syntax: Declaration VARIABLE examples variable_name : : type_name [:= value]; VARIABLE opcode : BIT_VECTOR(3 DOWNTO 0) := "0000"; VARIABLE freq : INTEGER; - 47 -

VHDL Objects Signals Used for communication between VHDL components Real, physical signals in system often mapped to VHDL signals ALL VHDL signal assignments require either delta cycle or userspecified delay before new value is assumed Declaration syntax : SIGNAL signal_name : type_name [:= value]; Declaration and assignment examples : SIGNAL sig_a : BIT; event queue for sig_a - 48 -

Variables vs. Signal - 49 -

Signals and Variables This example highlights the difference between signals and variables ARCHITECTURE test1 OF mux IS SIGNAL x : BIT := '1'; SIGNAL y : BIT := '0'; BEGIN PROCESS (in_sig, x, y) BEGIN x <= in_sig XOR y; y <= in_sig XOR x; END PROCESS; END test1; ARCHITECTURE test2 OF mux IS SIGNAL y : BIT := '0'; BEGIN PROCESS (in_sig, y) VARIABLE x : BIT := '1'; BEGIN x := in_sig XOR y; y <= in_sig XOR x; END PROCESS; END test2; Assuming a 1 to 0 transition on in_sig, what are the resulting values for y in the both cases? - 50 -

VHDL Objects Signals vs Variables A key difference between variables and signals is the assignment delay ARCHITECTURE sig_ex OF test IS SIGNAL a, b, c, out_1, out_2 : BIT; BEGIN PROCESS (a, b, c, out_1) BEGIN out_1 <= a NAND b; out_2 <= out_1 XOR c; END PROCESS; END sig_ex; Time a b c out_1 out_2 0 0 1 1 1 0 1 1 1 1 1 0 1+d 1 1 1 0 0 1+2d 1 1 1 0 1-51 -

VHDL Objects Signals vs Variables (Cont.) ARCHITECTURE var_ex OF test IS SIGNAL a,b,c,out_4 : BIT; BEGIN PROCESS (a, b, c) VARIABLE out_3 : BIT; BEGIN out_3 := a NAND b; out_4 <= out_3 XOR c; END PROCESS; END var_ex; Time a b c out_3 out_4 0 0 1 1 1 0 1 1 1 1 0 0 1+d 1 1 1 0 1-52 -

VHDL Objects Files Files provide a way for a VHDL design to communicate with the host environment File declarations make a file available for use to a design Files can be opened for reading and writing The package STANDARD defines basic file IO routines for VHDL types The package TEXTIO defines more powerful routines handling IO of text files - 53 -

Packages and Libraries User defined constructs declared inside architectures and entities are not visible to other VHDL components Scope of subprograms, user defined data types, constants, and signals is limited to the VHDL components in which they are declared Packages and libraries provide the ability to reuse constructs in multiple entities and architectures Items declared in packages can be used (i.e. included) in other VHDL components - 54 -

Packages Packages consist of two parts Package declaration -- contains declarations of objects defined in the package Package body -- contains necessary definitions for objects in package declaration e.g. subprogram descriptions Examples of VHDL items included in packages : - Basic declarations Types, subtypes Constants Subprograms Use clause - Signal declarations - Attribute declarations - Component declarations - 55 -

Packages Declaration An example of a package declaration : PACKAGE my_stuff IS TYPE binary IS ( ON, OFF ); CONSTANT PI : REAL := 3.14; CONSTANT My_ID : INTEGER; PROCEDURE add_bits3(signal a, b, en : IN BIT; SIGNAL temp_result, temp_carry : OUT BIT); END my_stuff; Note some items only require declaration while others need further detail provided in subsequent package body for type and subtype definitions, declaration is sufficient subprograms require declarations and descriptions - 56 -

Packages Package Body The package body includes the necessary functional descriptions for objects declared in the package declaration e.g. subprogram descriptions, assignments to constants PACKAGE BODY my_stuff IS CONSTANT My_ID : INTEGER := 2; PROCEDURE add_bits3(signal a, b, en : IN BIT; SIGNAL temp_result, temp_carry : OUT BIT) IS BEGIN -- this function can return a carry temp_result <= (a XOR b) AND en; temp_carry <= a AND b AND en; END add_bits3; END my_stuff; - 57 -

Packages Use Clause Packages must be made visible before their contents can be used The USE clause makes packages visible to entities, architectures, and other packages -- use only the binary and add_bits3 declarations USE my_stuff.binary, my_stuff.add_bits3;... ENTITY declaration...... ARCHITECTURE declaration... -- use all of the declarations in package my_stuff USE my_stuff.all;... ENTITY declaration...... ARCHITECTURE declaration... - 58 -

Libraries Analogous to directories of files VHDL libraries contain analyzed (i.e. compiled) VHDL entities, architectures, and packages Facilitate administration of configuration and revision control E.g. libraries of previous designs Libraries accessed via an assigned logical name Current design unit is compiled into the Work library Both Work and STD libraries are always available Many other libraries usually supplied by VHDL simulator vendor E.g. proprietary libraries and IEEE standard libraries - 59 -

Attributes Attributes provide information about certain items in VHDL, e.g : Types, subtypes, procedures, functions, signals, variables, constants, entities, architectures, configurations, packages, components General form of attribute use : name'attribute_identifier -- read as tick VHDL has several predefined, e.g : X'EVENT -- TRUE when there is an event on signal X X'LAST_VALUE -- returns the previous value of signal X Y'HIGH -- returns the highest value in the range of Y X'STABLE(t) -- TRUE when no event has occurred on signal X in the past t time - 60 -

Operators Operators can be chained to form complex expressions, e.g. : res <= a AND NOT(B) OR NOT(a) AND b; Can use parentheses for readability and to control the association of operators and operands Defined precedence levels in decreasing order : Miscellaneous operators -- **, abs, not Multiplication operators -- *, /, mod, rem Sign operator -- +, - Addition operators -- +, -, & Shift operators -- sll, srl, sla, sra, rol, ror Relational operators -- =, /=, <, <=, >, >= Logical operators -- AND, OR, NAND, NOR, XOR, XNOR - 61 -

Operators Examples The concatenation operator & VARIABLE shifted, shiftin : BIT_VECTOR(0 TO 3);... shifted := shiftin(1 TO 3) & '0'; SHIFTIN 0 1 1 2 3 0 0 1 SHIFTED 0 0 1 0 The exponentiation operator ** x := 5**5 -- 5^5, OK y := 0.5**3 -- 0.5^3, OK x := 4**0.5 -- 4^0.5, Illegal y := 0.5**(-2) -- 0.5^(-2), OK - 62 -

Module Outline Introduction VHDL Design Example VHDL Model Components Basic VHDL Constructs Summary - 63 -

Summary VHDL is a worldwide standard for the description and modeling of digital hardware VHDL gives the designer many different ways to describe hardware Familiar programming tools are available for complex and simple problems Sequential and concurrent modes of execution meet a large variety of design needs Packages and libraries support design management and component reuse - 64 -

Delay models and VHDL semantics - 65 -

1. Transport delay signal <= transport expression after delay; This corresponds to models for simple wires Pulses will be propagated, no matter how short they are - idealized wire. c <= transport a or b after 10 ns; Pulse of 5 ns a b 1 OR gate c a b c 20 40 60 80 ns - 66 -

1. Transport delay (2) All old transactions that are projected to occur at or after the time at which the earliest of the new transactions is projected to occur are deleted from the projected output waveform [VHDL LRM, chap. 8.4] - 67 -

2. Inertial delay By default, inertial delay is assumed. Suppression of all spikes shorter than the delay, resp. shorter than the indicated suppression threshold. Inertial delay models the behavior of gates. Example: c <= a or b after 10 ns; a b 1 OR gate c a b c No pulse of 5 ns 20 40 60 80 ns Tricky rules for removing events from projected waveform ( ) - 68 -