Download presentation
Presentation is loading. Please wait.
Published byJessica Turner Modified over 8 years ago
1
13/06/59 1 Copyright 1997, KJH Introduction to VHDL Lecture 2 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University
2
13/06/59 2 Copyright 1997, KJH Outline Objects Object Classes Class Types Operations on Types of Classes
3
13/06/59 3 Copyright 1997, KJH Objects Object: Anything that has a Name and is of a Specified Type Four Classes of Objects Constants Variables Signals (discussion deferred to later) Files (discussion deferred to later) Classes of Objects can be of Different Types
4
13/06/59 4 Copyright 1997, KJH Object Declaration Before an Object can be Used, it must be Declared Declarations Specify a unique identifier Define the type May specify initial (default) value
5
13/06/59 5 Copyright 1997, KJH Constants Initialized to a Value that Cannot Change If not initialized, called a deferred constant May only appear in package declaration Insures a Value has a Type constant_declaration <= constant identifier_list : subtype_indication [ := expression ] ; where identifier_list <= identifier {,... }
6
13/06/59 6 Copyright 1997, KJH Constant Declaration Examples constant PI : real := 3.1415926535897 ; constant BUS_WIDTH : integer := 32 ; constant INTENSITY_DYNAMIC_RANGE : real := 16#FF.F ; constant START_TIME_HOURS : integer := 11 ; constant START_TIME_MINUTES : integer := 00 ;
7
13/06/59 7 Copyright 1997, KJH Variables Variable: an Object Whose Value May be Changed After Creation Initialization Value is Optional, if not Initialized the Default for Scalar Types is the first in the list of an enumeration type the lowest in an ascending range the highest in a descending range Only Declare where it can be Accessed by One Process variable_declaration <= variable identifier_list : subtype_indication [ := expression ] ;
8
13/06/59 8 Copyright 1997, KJH Variable Declaration Examples variable ControlValue : real := 3.68; variable MinTemp, MaxTemp, MeanTemp : real := 0 ; variable ImageWidth, ImageHeight : integer := 256 ; variable DiskSize, MemUsed, MemLeft : integer ; variable MainBus : bit_vector (31 downto 0) ;
9
13/06/59 9 Copyright 1997, KJH Variable Assignment Immediately Overwrites Variable with New Value Unlike the way a Signal := Replacement Operator for Variables <= Replacement Operator for Signals variable_assignment_statement <= [ label : ] name := expression ;
10
13/06/59 10 Copyright 1997, KJH Variable Assignment Examples MinTemp := 0.0 ; ImageWidth := 128 ; MainBus : = 16#ffff_ffff ; MainBus : = x “FFFF_FFFF“ ;
11
13/06/59 11 Copyright 1997, KJH Types The type of a data object Defines the set of values an object can take on Defines operations which can be performed on object Scalar Type Consists of a set of single, indivisible values Composite Type Many Predefined Types
12
13/06/59 12 Copyright 1997, KJH Type Declaration type_declaration <= type identifier is type_definition ; type_definition <=scalar_type_definition | composite_type_definition | access_type_definition | file_type_definition Identical Type Declarations are Distinct type MidTermGrades is range 0 to 100 type FinalGrades is range 0 to 100
13
13/06/59 13 Copyright 1997, KJH Scalar Type Declaration scalar_type_definition <= enumeration_type_definition | integer_type_definition | floating_type_definition | physical_type_definition Scalar Type Number types Enumerated list Physical quantities
14
13/06/59 14 Copyright 1997, KJH Integer Type Definition
15
13/06/59 15 Copyright 1997, KJH Integer Type Definition Examples type StreetNumbers is range 10107 to 12568; type ImagingSensors is range 0 to 5; type Celsius is range 100 downto 0; type PointSpread is range 14 downto 0 ;
16
13/06/59 16 Copyright 1997, KJH Operations on Integer Types *Ashenden, VHDL cookbook
17
13/06/59 17 Copyright 1997, KJH Floating-Point Type Definition
18
13/06/59 18 Copyright 1997, KJH Floating-Point Type Examples type StreetPosition is range 101.07 to 125.68 ; type ImagingSensorSensitivity is range 0.0 to 5.0 ; type Celsius is range 100.0 downto 0.0 ; type PointSpread is range 15.0 downto 0.0 ;
19
13/06/59 19 Copyright 1997, KJH Ops on Floating-Point Types Binary Operators +Add -Subtraction *Multiplication /Division **Exponentiation Unary Operators -Negation +Identity absAbsolute value
20
13/06/59 20 Copyright 1997, KJH Physical Type Definition
21
13/06/59 21 Copyright 1997, KJH Physical Type Definition Time: Predefined Physical Type type time is range implementation defined units fs; ps=1000 fs; ns=1000 ps; us=1000 ns; ms = 1000 us; sec = 1000 ms; min = 60 sec; hr = 60 min; end units; [time]
22
13/06/59 22 Copyright 1997, KJH Simulation Resolution Limit The Resolution Limit Determines the Precision to Which Time Values are Represented. Values of Time Smaller than the Resolution Limit Round Down to Zero. fs is the Normal Resolution Limit During Model Simulation. Larger Values of Time can be used as a Secondary Time Resolution Limit Units of all physical literals involving time must not be smaller than the secondary resolution limit
23
13/06/59 23 Copyright 1997, KJH Physical Type Definition Example type capacitance is range 0 to 1e12 units picofarad; nanofarad = 1000 picofarad ; microfarad = 1000 nanofarad ; farad = 1e6 microfarad ; end units capacitance;
24
13/06/59 24 Copyright 1997, KJH Physical Type Examples 47 picofarad 10.6 nanofarad 4.7 picofarad rounds DOWN to 4 picofarads since pf is smallest unit can only have integer value of base unit
25
13/06/59 25 Copyright 1997, KJH Operations on Physical Types Binary Operators *Multiplication by an integer or float /Division by an integer or float Division by objects of same physical type yield an integer Unary Operators -negation +identity
26
13/06/59 26 Copyright 1997, KJH Operations on Physical Types Multiplication or Division of Two Physical Types not Allowed Convert to integers Perform operation Convert result to correct type
27
13/06/59 27 Copyright 1997, KJH Enumeration Type Definition
28
13/06/59 28 Copyright 1997, KJH Enumeration Type Definition Examples type Buffer_Direction is ( in, out, tri_state ) ; type FFType is ( Toggle, Set_Reset, Data, JK ) ; type MemoryType is ( Read_Only, Write_Only, RW ) ; type GateType is ( AND, OR, INVERT ) ;
29
13/06/59 29 Copyright 1997, KJH Predefined Enumeration Types type severity_level is ( note, warning, error, failure ); type Boolean is ( false, true ); Used to model abstract conditions type bit is ( '0', '1' ); Used to model hardware logic levels type file_open_status is ( open_ok, status_error, name_error, mode_error ); type character is ( NUL, SOH,... ) all characters is ISO 8-bit character set IEEE std_logic_1164 Accounts for Electrical Properties
30
13/06/59 30 Copyright 1997, KJH Subtypes
31
13/06/59 31 Copyright 1997, KJH Subtype Cases A Subtype may Constrain Values from a Scalar Type to be Within a Specified Range subtype Pin_Count is integer range 0 to 400; subtype Octal_Digits is character range '0' to '7'; A Subtype May Constrain an Otherwise Unconstrained Array Type by Specifying Bounds for the Indices subtype id is string (1 to 20); subtype MyBus is bit_vector (8 downto 0);
32
13/06/59 32 Copyright 1997, KJH Subtypes Predefined Numeric Subtypes subtype natural is integer range 0 to highest_integer subtype positive is integer range 1 to highest_integer subtype delay_length is time range 0 fs to highest_time Subtypes Mixed in Expressions Computations done in base type Assignment fails if result is not within range of result variable (sub)type
33
13/06/59 33 Copyright 1997, KJH Type Syntax Type Qualification is Used to Avoid Type Ambiguity in Overloaded Enumeration Literals type_name ‘ ( expression ) Only states type of value Type Conversion can be Used to Perform Mixed Arithmetic New_Type ( Value_of_Old_Type ) real ( 238 ) positive ( My_Integer_Value ) Rounds to nearest integer Changes type of value
34
13/06/59 34 Copyright 1997, KJH Scalar Type Attributes Predefined Attributes Associated with Each Type Type_Name ‘ Attribute_Name Attributes applicable to ALL Scalar Types T’leftleftmost value in T T’rightrightmost value in T T’lowleast value in T T’highgreatest value in T T’ascendingTrue if ascending range, else false T’image(x)a string representing x T’value(s)the value in T that is represented by s
35
13/06/59 35 Copyright 1997, KJH Scalar Attributes Attributes Applicable to Discrete and Physical Types T’pos(x) position number of x in T T’val(n) value in T at position n T’succ(x) value in T at position one greater than that of x T’pred(x) value in T at position one less than that of x T’leftof(x) value in T at position one to the left of x T’rightof(x) value in T at position one to the right of x
36
13/06/59 36 Copyright 1997, KJH Operators “Short-Circuit” Operators Behavior with binary operators Evaluate left operand If value of operand determines the value of expression, set result Else evaluate right operand Left operand can be used to prevent right operand from causing arithmetic error such as divide by zero Reduces computation time by eliminating redundant calculations AND, OR, NAND, NOR
37
13/06/59 37 Copyright 1997, KJH Operators Relational operators =, /=,, >= Operands must be of the same type Yield Boolean results Equality, Inequality operators =, /= Operands of any type. Concatenation operator & Operates on one-dimensional arrays to form a new array
38
13/06/59 38 Copyright 1997, KJH Operators Arithmetic * / Operate on integer, floating point and physical types types. Modulo, Remainder mod rem Operate only on integer types. Absolute value abs Operates on any numeric type
39
13/06/59 39 Copyright 1997, KJH Operators Exponentiation ** Integer or floating point left operand Integer right operand required Negative right operand requires floating point left operand.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.