VHDL – Part 2 Some of the slides are taken from

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

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.
Comprehensive VHDL Module 6 Types November Comprehensive VHDL: Types Copyright © 2000 Doulos Types Aim ©To understand the use and synthesis.
VHDL Data Types Module F3.1. VHDL Data Types Scalar Integer Enumerated Real (floating point)* Physical* Composite Array Record Access (pointers)* * Not.
Data Types. Composite Date Types n Arrays –Single and multi-dimensional –Arrays are single Type n Records –Records are mixed types.
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.
EE 524 EDA / ASIC Design Lab Chapter 4 Basic Elements in VHDL Fall 2008 Dr. Ramin Roosta EE 524.
Introduction to VHDL CSCE 496/896: Embedded Systems Witawas Srisa-an.
SubprogramsSubprograms. SubprogramsSubprograms ä Similar to subprograms found in other languages ä Allow repeatedly used code to be referenced multiple.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
VHDL And Synthesis Review. VHDL In Detail Things that we will look at: –Port and Types –Arithmetic Operators –Design styles for Synthesis.
Programming in VHDL Using Processes. How Processes Run A process is either in suspend mode or is running. For a process to run, there has to be a change.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Package with 4-valued logic Signal Attributes Assertion Data Flow description.
ECE 368 Basic VHDL Shantanu Dutt UIC
Introduction to VHDL (part 2)
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.
Basic VHDL RASSP Education & Facilitation Module 10 Version 2.02 Copyright  RASSP E&F All rights reserved. This information is copyrighted by.
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
10/17/2015DSD, USIT, GGSIPU1 Data Types Each data object has a type associated with it. The type defines the set of values that the object can have and.
IAY 0600 Digital Systems Design
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.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Basic VHDL RASSP Education & Facilitation Module 10 Version 2.02 Copyright  RASSP E&F All rights reserved. This information is copyrighted by.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Digital Logic Design.
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.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
L19 – Resolved Signals. Resolved Signals  What are resolved signals In systems In VHDL Resolution – Isn’t that for resolving conflicts?  Ref: text Unit.
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.
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.
IAY 0600 Digital Systems Design Event-Driven Simulation VHDL Discussion Alexander Sudnitson Tallinn University of Technology.
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.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Sequential Logic Design.
VHDL Tutorial.
1 - CPRE 583 (Reconfigurable Computing): VHDL overview 1 Iowa State University (Ames) CPRE 583 Reconfigurable Computing Lecture 2: 8/26/2011 (VHDL Overview.
IAY 0600 Digital Systems Design
Introduction To VHDL 홍 원 의.
Basic Language Concepts
Basic VHDL RASSP Education & Facilitation Module 10 Version 2.02
Design Entry: Schematic Capture and VHDL
Basic VHDL RASSP Education & Facilitation Module 10 Version 2.02
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L08
CHAPTER 10 Introduction to VHDL
Some of the slides are taken from
ECE 434 Advanced Digital System L9
CPE 528: Lecture #4 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
CPE/EE 422/522 Advanced Logic Design L08
CPE/EE 422/522 Advanced Logic Design L11
ECE 434 Advanced Digital System L10
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
VHDL Data Types Module F3.1.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

VHDL – Part 2 Some of the slides are taken from

2 What is on the agenda?  Basic VHDL Constructs  Data types  Objects  Packages and libraries  Attributes  Predefined operators

3 Data Types  All declarations of VHDL ports, signals, and variables must specify their corresponding type or subtype Types Access Scalar Composite ArrayRecord Integer RealEnumerated Physical

4 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; 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;

5 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; 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; 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 :

6 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; 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; VHDL Data Types Scalar Types (Cont.)  Enumerated  User specifies list of possible values  Example declaration and usage of enumerated data type :

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

8 TYPE data_bus IS ARRAY(0 TO 31) OF BIT; VARIABLE X : data_bus; VARIABLE Y : BIT; Y := X(12); -- Y gets value of element at index 12 VARIABLE X : data_bus; VARIABLE Y : BIT; Y := X(12); -- Y gets value of element at index element indices......array values... 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) :

9 VHDL Data Types Composite Types (Cont.)  Example one-dimensional array using DOWNTO :  DOWNTO keyword must be used if leftmost index is greater than rightmost index  e.g. ‘Big-Endian’ bit ordering TYPE reg_type IS ARRAY(15 DOWNTO 0) OF BIT; VARIABLE X : reg_type; VARIABLE Y : BIT; Y := X(4); -- Y gets value of element at index 4 VARIABLE X : reg_type; VARIABLE Y : BIT; Y := X(4); -- Y gets value of element at index element indices......array values...

10 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 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 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 :

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

12 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 example : SUBTYPE name IS base_type RANGE ; SUBTYPE first_ten IS INTEGER RANGE 0 TO 9;

13 Libraries  IEEE Library  Enables usage packages defining all needed in your VHDL design and data types  Always declare all used libraries before entity Library ieee; Use std_logic_1164.all; Library lmp; Use lmp.lmppckg.all;  Library ieee contains standard packages defining commonly used data types and operations  Std_Logic_1164 Multilevel Logic System  Define types and operations to deal with strong, weak and high- impedance strengths, and unknown values Std_ulogic, std_ulogic_vector Std_logic, std_logic_vector  Always include this library in VHDL designs

14 Shortcomings of Bit type  The only elements: ‘0’ and ‘1’  Not sufficient to model behavioral of real hardware  No possibility for indicating:  Uninitialized values  Unknown values (bus driven simultaneously by two sources)  Tri-state or high impedance

15 Std_logic and std_ulogic types  Part of IEEE library (paclage std_logic_1164)  Designed to model electrical signals  Representation of signals driven by active drivers forcing strength), resistive drivers (pull-ups and pull- downs – weak strength) or tri-state drivers including high-impedance state Type std_ulogic is (‘U’; - - uninitialized ‘X’; - - forcing unknown ‘0’; - - forcing zero ‘1’; - - forcing one ‘Z’; - - high impedance ‘W’; - - weak unknown ‘L’; - -- weak zero ‘H; - - weak one ‘-’); - - don’t care

16 Example: Tri-state Buffer  Data_out assigned data_in when enable = ‘1’  For all other 8 values of enable (U, X, Z, W, L, H, -) data_out retains its value.  Insurance that erreneous signals driving enable have no influence on data_out. Library ieee; Use ieee.std_logic_1164; Entity tri_state is Port( data_in, enable: in std_logic; data_out: out std_logic); End tri_state; Architecture example of tri_state is Begin data_out <= data_in when enable = ‘1’ else ‘Z’; End example;

17

18 Resolved types are declared with resolution functions, which define behavior when an object is driven by multiple values simultaneously. In the case of multiple drivers, the nine values of std_logic are resolved to values as indicated in the table above.

19

20

21 Example: Std_ulogic Bus with Multiple Drivers Library ieee; Use ieee.std_logic_1164.all; Entity bad_tristate is port( data_in1, data_in2, en1, en2: in std_ulogic; Data_out: out std_ulogic); End bad_tristate; Architecture example of bad_tristate is Begin data_out <= data_in1 when en1 =‘1’ else ‘Z’; data_out <= data_in2 when en2 =‘1’ else ‘Z’; End example; ** Error Signal (/Bad_tri_state/Data_out) is not a resolve signal and has more than 1 source.

22 Correct use of a bus with multiple drivers Library ieee; Use ieee.std_logic_1164.all; Entity res_tristate is port( din1, din2, en1, en2: in std_logic; D_out: out std_logic); End bad_tristate; Architecture example of res_tristate is Begin d_out <= din1 when en1 =‘1’ else ‘Z’; d_out <= din2 when en2 =‘1’ else ‘Z’; End example; The bus conflict is resolved because of the type std_logic

23 VHDL Data Types Summary  All declarations of VHDL ports, signals, and variables must include 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

24 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

25 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 :  Declaration examples : CONSTANT constant_name : type_name [:= value]; CONSTANT PI : REAL := 3.14; CONSTANT SPEED : INTEGER; CONSTANT PI : REAL := 3.14; CONSTANT SPEED : INTEGER;

26 VHDL Objects Variables  Provide convenient mechanism for local storage  E.g. loop counters, intermediate values  Scope is process in which they are declared  VHDL ‘93 provides for global variables, to be discussed in the Advanced Concepts in VHDL module  All variable assignments take place immediately  No delta or user specified delay is incurred  Declaration syntax:  Declaration examples : VARIABLE opcode : BIT_VECTOR(3 DOWNTO 0) := "0000"; VARIABLE freq : INTEGER; VARIABLE opcode : BIT_VECTOR(3 DOWNTO 0) := "0000"; VARIABLE freq : INTEGER; VARIABLE variable_name : type_name [:= value];

27 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 user-specified delay before new value is assumed  Declaration syntax :  Declaration and assignment examples : SIGNAL signal_name : type_name [:= value]; SIGNAL brdy : BIT; brdy <= ‘0’ AFTER 5ns, ‘1’ AFTER 10ns; SIGNAL brdy : BIT; brdy <= ‘0’ AFTER 5ns, ‘1’ AFTER 10ns;

28 VHDL Objects Signals vs Variables  A key difference between variables and signals is the assignment delay ARCHITECTURE sig_ex OF test IS PROCESS (a, b, c, out_1) BEGIN out_1 <= a NAND b; out_2 <= out_1 XOR c; END PROCESS; END sig_ex; ARCHITECTURE sig_ex OF test IS 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_ d d

29 Time a b c out_3 out_ d VHDL Objects Signals vs Variables (Cont.) ARCHITECTURE var_ex OF test IS 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; ARCHITECTURE var_ex OF test IS 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;

30 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  In VHDL87, files are opened and closed when their associated objects come into and out of scope  In VHDL93 explicit FILE_OPEN() and FILE_CLOSE() procedures were added  The package STANDARD defines basic file I/O routines for VHDL types  The package TEXTIO defines more powerful routines handling I/O of text files

31 Simulation Cycle Revisited Sequential vs Concurrent Statements  VHDL is inherently a concurrent language  All VHDL processes execute concurrently  Concurrent signal assignment statements are actually one-line processes  VHDL statements execute sequentially within a process  Concurrent processes with sequential execution within a process offers maximum flexibility  Supports various levels of abstraction  Supports modeling of concurrent and sequential events as observed in real systems

32 Concurrent Statements  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  Concurrent VHDL statements include :  Block, process, assert, signal assignment, procedure call, component instantiation

33 Sequential Statements  Statements inside a process execute sequentially ARCHITECTURE sequential OF test_mux IS BEGIN select_proc : PROCESS (x,y) BEGIN IF (select_sig = '0') THEN z <= x; ELSIF (select_sig = '1') THEN z <= y; ELSE z <= "XXXX"; END IF; END PROCESS select_proc; END sequential; ARCHITECTURE sequential OF test_mux IS BEGIN select_proc : PROCESS (x,y) BEGIN IF (select_sig = '0') THEN z <= x; ELSIF (select_sig = '1') THEN z <= y; ELSE z <= "XXXX"; END IF; END PROCESS select_proc; END sequential;

34 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

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

36 Packages Declaration  An example of a package declaration :  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 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; 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;

37 Packages Package Body  The package body includes the necessary functional descriptions needed 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; 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;

38 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...

39 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

40 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 :  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 name'attribute_identifier -- read as “tick”

41 Attributes Register Example  The following example shows how attributes can be used to make an 8-bit register  Specifications :  Triggers on rising clock edge  Latches only on enable high  Has a data setup time of x_setup  Has propagation delay of prop_delay ENTITY 8_bit_reg IS GENERIC (x_setup, prop_delay : TIME); PORT(enable, clk : IN qsim_state; a : IN qsim_state_vector(7 DOWNTO 0); b : OUT qsim_state_vector(7 DOWNTO 0)); END 8_bit_reg; l qsim_state type is being used - includes logic values 0, 1, X, and Z

42 Attributes Register Example (Cont.) l The following architecture is a first attempt at the register l The use of 'STABLE is to used to detect setup violations in the data input l What happens if a does not satisfy its setup time requirement of x_setup? ARCHITECTURE first_attempt OF 8_bit_reg IS BEGIN PROCESS (clk) BEGIN IF (enable = '1') AND a'STABLE(x_setup) AND (clk = '1') THEN b <= a AFTER prop_delay; END IF; END PROCESS; END first_attempt;

43 Attributes Register Example (Cont.) l The following architecture is a second and more robust attempt l The use of 'LAST_VALUE ensures the clock is rising from a value of ‘0’ l An ELSE clause could be added to define the behavior when the requirements are not satisfied ARCHITECTURE behavior OF 8_bit_reg IS BEGIN PROCESS (clk) BEGIN IF (enable = '1') AND a'STABLE(x_setup) AND (clk = '1') AND (clk'LAST_VALUE = '0') THEN b <= a AFTER delay; END IF; END PROCESS; END behavior;

44 Operators  Operators can be chained to form complex expressions, e.g. :  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 res <= a AND NOT(B) OR NOT(a) AND b;

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

46 Putting It All Together GenericsPorts Entity Architecture Concurrent Statements Process Sequential Statements Concurrent Statements Package