Download presentation
Presentation is loading. Please wait.
Published byNelson Ross Modified over 9 years ago
1
Basic VHDL RASSP Education & Facilitation Module 10 Version 2.02 Copyright 1995-1998 RASSP E&F All rights reserved. This information is copyrighted by the RASSP E&F Program and may only be used for non-commercial educational purposes. Any other use of this information without the express written permission of the RASSP E&F Program is prohibited. All information contained herein may be duplicated for non- commercial educational use provided this copyright notice is included. No warranty of any kind is provided or implied, nor is any liability accepted regardless of use. FEEDBACK: The RASSP E&F Program welcomes and encourages any feedback that you may have including any changes that you may make to improve or update the material. You can contact us at feedback@rassp.scra.org or http://rassp.scra.org/module-request/FEEDBACK/feedback-on-modules.html
2
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Timing Model l VHDL uses the following simulation cycle to model the stimulus and response nature of digital hardware Start Simulation Update Signals End Simulation Delay
3
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delay Types Input delay Outpu t l All VHDL signal assignment statements prescribe an amount of time that must transpire before the signal assumes its new value l This prescribed delay can be in one of three forms: m Transport -- prescribes propagation delay only m Inertial -- prescribes propagation delay and minimum input pulse width m Delta -- the default if no delay time is explicitly specified
4
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Transport Delay l Transport delay must be explicitly specified m I.e. keyword “TRANSPORT” must be used l Signal will assume its new value after specified delay -- TRANSPORT delay example Output <= TRANSPORT NOT Input AFTER 10 ns; -- TRANSPORT delay example Output <= TRANSPORT NOT Input AFTER 10 ns; InputOutput 0 5 10 15 20 25 30 35 Input Output
5
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Inertial Delay l Provides for specification propagation delay and input pulse width, i.e. ‘inertia’ of output: l Inertial delay is default and REJECT is optional : Output <= NOT Input AFTER 10 ns; -- Propagation delay and minimum pulse width are 10ns Output <= NOT Input AFTER 10 ns; -- Propagation delay and minimum pulse width are 10ns Input Output 0 5 10 15 20 25 30 35 InputOutput target <= [REJECT time_expression] INERTIAL waveform;
6
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Inertial Delay (cont.) l Example of gate with ‘inertia’ smaller than propagation delay m e.g. Inverter with propagation delay of 10ns which suppresses pulses shorter than 5ns l Note: the REJECT feature is new to VHDL 1076-1993 Output <= REJECT 5ns INERTIAL NOT Input AFTER 10ns; Input Output 0 5 10 15 20 25 30 35
7
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F l Default signal assignment propagation delay if no delay is explicitly prescribed m VHDL signal assignments do not take place immediately m Delta is an infinitesimal VHDL time unit so that all signal assignments can result in signals assuming their values at a future time m E.g. l Supports a model of concurrent VHDL process execution m Order in which processes are executed by simulator does not affect simulation output Delta Delay Output <= NOT Input; -- Output assumes new value in one delta cycle Output <= NOT Input; -- Output assumes new value in one delta cycle
8
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1 A: 0 B:1 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0
9
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0 B:1 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 2ns td= 1ns td= 5ns
10
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 2ns td= 1ns td= 5ns
11
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1->0 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 2ns td= 1ns td= 5ns
12
Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1->0 C:0- >0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 2ns td= 1ns td= 5ns
13
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0 B:1 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 5ns td= 1ns td= 2ns
14
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1 C:0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 5ns td= 1ns td= 2ns
15
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1 C:0->1 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 5ns td= 1ns td= 2ns
16
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1->0 C:0->1 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 5ns td= 1ns td= 2ns
17
Delta Delay An Example without Delta Delay l What is the behavior of C? 1 IN: 1->0 A: 0->1 B:1->0 C:0->1->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 NAND gate evaluated first: IN: 1->0 A: 0->1 B: 1->0 C: 0->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 AND gate evaluated first: IN: 1->0 A: 0->1 C: 0->1 B: 1->0 C: 1->0 td= 5ns td= 1ns td= 2ns
18
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example with Delta Delay l What is the behavior of C? IN: 1->0 1 A:0 B:1 C:0 Using delta delay scheduling Time Delta Event 0 ns 1 IN: 1->0 eval INVERTER 2 A: 0->1 eval NAND, AND 3 B: 1->0 C: 0->1 eval AND 4 C: 1->0 1 ns
19
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example with Delta Delay l What is the behavior of C? IN: 1->0 1 A:0->1 B:1 C:0 Using delta delay scheduling Time Delta Event 0 ns 1 IN: 1->0 eval INVERTER 2 A: 0->1 eval NAND, AND 3 B: 1->0 C: 0->1 eval AND 4 C: 1->0 1 ns
20
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example with Delta Delay l What is the behavior of C? IN: 1->0 1 A:0->1 B:1->0 C:0->1 Using delta delay scheduling Time Delta Event 0 ns 1 IN: 1->0 eval INVERTER 2 A: 0->1 eval NAND, AND 3 B: 1->0 C: 0->1 eval AND 4 C: 1->0 1 ns
21
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Delta Delay An Example with Delta Delay l What is the behavior of C? IN: 1->0 1 A:0->1 B:1->0 Using delta delay scheduling Time Delta Event 0 ns 1 IN: 1->0 eval INVERTER 2 A: 0->1 eval NAND, AND 3 B: 1->0 C: 0->1 eval AND 4 C: 1->0 1 ns C:0->1->0
22
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Module Outline l Introduction l VHDL Design Example l VHDL Model Components l Basic VHDL Constructs m Data types m Objects m Sequential and concurrent statements m Packages and libraries m Attributes m Predefined operators l Examples l Summary
23
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Data Types Types Access Scalar Composite ArrayRecord Integer RealEnumerated Physical l All declarations of VHDL ports, signals, and variables must specify their corresponding type or subtype
24
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Data Types Scalar Types l Integer m Minimum range for any implementation as defined by standard: - 2,147,483,647 to 2,147,483,647 m 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;
25
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F 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.) l Real m Minimum range for any implementation as defined by standard: -1.0E38 to 1.0E38 m Example assignments to a variable of type real :
26
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F 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.) l Enumerated m User specifies list of possible values m Example declaration and usage of enumerated data type :
27
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F l Physical m Require associated units m Range must be specified m Example of physical type declaration : m Time is the only physical type predefined in VHDL standard 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; 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; VHDL Data Types Scalar Types (Cont.)
28
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F 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 12 031 01...element indices......array values... VHDL Data Types Composite Types l Array m Used to group elements of the same type into a single VHDL object m Range may be unconstrained in declaration q Range would then be constrained when array is used m Example declaration for one-dimensional array (vector) :
29
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F l Example one-dimensional array using DOWNTO : l DOWNTO keyword must be used if leftmost index is greater than rightmost index m 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 4 150 01...element indices......array values... VHDL Data Types Composite Types (Cont.)
30
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F 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.) l Records m Used to group elements of possibly different types into a single VHDL object m Elements are indexed via field names m Examples of record declaration and usage :
31
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F l Subtype m Allows for user defined constraints on a data type q e.g. a subtype based on an unconstrained VHDL type m May include entire range of base type m Assignments that are out of the subtype range are illegal q Range violation detected at run time rather than compile time because only base type is checked at compile time m Subtype declaration syntax : m Subtype example : SUBTYPE name IS base_type RANGE ; VHDL Data Types Subtypes SUBTYPE first_ten IS INTEGER RANGE 0 TO 9;
32
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Data Types Summary l All declarations of VHDL ports, signals, and variables must include their associated type or subtype l Three forms of VHDL data types are : m Access -- pointers for dynamic storage allocation m Scalar -- includes Integer, Real, Enumerated, and Physical m Composite -- includes Array, and Record l A set of built-in data types are defined in VHDL standard m User can also define own data types and subtypes
33
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Objects l There are four types of objects in VHDL m Constants m Variables m Signals m Files l The scope of an object is as follows : m Objects declared in a package are available to all VHDL descriptions that use that package m Objects declared in an entity are available to all architectures associated with that entity m Objects declared in an architecture are available to all statements in that architecture m Objects declared in a process are available only within that process
34
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Objects Constants l Name assigned to a specific value of a type l Allow for easy update and readability l Declaration of constant may omit value so that the value assignment may be deferred m Facilitates reconfiguration l Declaration syntax : l Declaration examples : CONSTANT constant_name : type_name [:= value]; CONSTANT PI : REAL := 3.14; CONSTANT SPEED : INTEGER; CONSTANT PI : REAL := 3.14; CONSTANT SPEED : INTEGER;
35
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Objects Variables l Provide convenient mechanism for local storage m E.g. loop counters, intermediate values l Scope is process in which they are declared m VHDL ‘93 provides for global variables, to be discussed in the Advanced Concepts in VHDL module l All variable assignments take place immediately m No delta or user specified delay is incurred l Declaration syntax: l 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];
36
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Objects Signals l Used for communication between VHDL components l Real, physical signals in system often mapped to VHDL signals l ALL VHDL signal assignments require either delta cycle or user-specified delay before new value is assumed l Declaration syntax : l 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;
37
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F VHDL Objects Files l Files provide a way for a VHDL design to communicate with the host environment l File declarations make a file available for use to a design l Files can be opened for reading and writing m 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 l The package STANDARD defines basic file I/O routines for VHDL types l The package TEXTIO defines more powerful routines handling I/O of text files
38
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Packages and Libraries l User defined constructs declared inside architectures and entities are not visible to other VHDL components m Scope of subprograms, user defined data types, constants, and signals is limited to the VHDL components in which they are declared l Packages and libraries provide the ability to reuse constructs in multiple entities and architectures m Items declared in packages can be used (i.e. included) in other VHDL components
39
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F l Packages consist of two parts m Package declaration -- contains declarations of objects defined in the package m Package body -- contains necessary definitions for certain objects in package declaration q e.g. subprogram descriptions l Examples of VHDL items included in packages : m Basic declarations q Types, subtypes q Constants q Subprograms q Use clause m Signal declarations m Attribute declarations m Component declarations Packages
40
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Packages Declaration l An example of a package declaration : l Note some items only require declaration while others need further detail provided in subsequent package body m for type and subtype definitions, declaration is sufficient m 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;
41
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Packages Package Body l The package body includes the necessary functional descriptions needed for objects declared in the package declaration m 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;
42
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Packages Use Clause l Packages must be made visible before their contents can be used m 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...
43
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Libraries l Analogous to directories of files m VHDL libraries contain analyzed (i.e. compiled) VHDL entities, architectures, and packages l Facilitate administration of configuration and revision control m E.g. libraries of previous designs l Libraries accessed via an assigned logical name m Current design unit is compiled into the Work library m Both Work and STD libraries are always available m Many other libraries usually supplied by VHDL simulator vendor q E.g. proprietary libraries and IEEE standard libraries
44
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Attributes l Attributes provide information about certain items in VHDL m E.g. types, subtypes, procedures, functions, signals, variables, constants, entities, architectures, configurations, packages, components l General form of attribute use : l VHDL has several predefined, e.g : m X'EVENT -- TRUE when there is an event on signal X m X'LAST_VALUE -- returns the previous value of signal X m Y'HIGH -- returns the highest value in the range of Y m X'STABLE(t) -- TRUE when no event has occurred on signal X in the past ‘t’ time name'attribute_identifier -- read as “tick”
45
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Operators l Operators can be chained to form complex expressions, e.g. : m Can use parentheses for readability and to control the association of operators and operands l Defined precedence levels in decreasing order : m Miscellaneous operators -- **, abs, not m Multiplication operators -- *, /, mod, rem m Sign operator -- +, - m Addition operators -- +, -, & m Shift operators -- sll, srl, sla, sra, rol, ror m Relational operators -- =, /=,, >= m Logical operators -- AND, OR, NAND, NOR, XOR, XNOR res <= a AND NOT(B) OR NOT(a) AND b;
46
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Operators Examples l 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'; 1 123 l The exponentiation operator ** SHIFTIN SHIFTED 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 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 0 001 0010
47
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Module Outline l Introduction l VHDL Design Example l VHDL Model Components l Basic VHDL Constructs l Examples l Summary
48
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Examples l Build a library of logic gates m AND, OR, NAND, NOR, INV, etc. l Include sequential elements m DFF, Register, etc. l Include tri-state devices l Use 4-valued logic m ‘X’, ‘0’, ‘1’, ‘Z’ m Encapsulate global declarations in a package
49
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Global Package PACKAGE resources IS TYPE level IS ('X', '0', '1', 'Z'); -- enumerated type TYPE level_vector IS ARRAY (NATURAL RANGE <>) OF level; -- type for vectors (buses) SUBTYPE delay IS TIME; -- subtype for gate delays -- Function and procedure declarations go here END resources;
50
RASSP E&F SCRA GT UVA Raytheon UCinc EIT ADL Copyright 1995-1998 RASSP E&F Two Input AND Gate Example USE work.resources.all; ENTITY and2 IS GENERIC(trise : delay := 10 ns; tfall : delay := 8 ns); PORT(a, b : IN level; c : OUT level); END and2; ARCHITECTURE behav OF and2 IS BEGIN one : PROCESS (a,b) BEGIN IF (a = '1' AND b = '1') THEN c <= '1' AFTER trise; ELSIF (a = '0' OR b = '0') THEN c <= '0' AFTER tfall; ELSE c<= 'X' AFTER (trise+tfall)/2; END IF; END PROCESS one; END behav;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.