Objects Object Classes Class Types Operations On Types of Classes
Objects Object Classes Class Types Operations On Types of Classes
Objects
Object Classes
Class Types
3
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
4
Constants
Initialized to a Value That Cannot Change
– If not initialized, called a deferred constant
– May only appear in package declaration
5
Constant Syntax
where
identifier_list <= identifier { , ... }
6
Constant Declaration, e.g.,
constant PI : real := 3.1415926535897 ;
constant BUS_WIDTH : integer := 32 ;
constant
INTENSITY_DYNAMIC_RANGE :
real := 16 # FF . F ;
constant START_TIME_MINUTES :
integer := 00 ;
7
Variables
Variable: an Object Whose Value May be
Changed After Creation
variable identifier_list :
subtype_indication [ := expression ] ;
9
Variable Declaration, e.g.,
10
Variable Declaration, e.g.,
variable ImageWidth, ImageHeight :
integer := 256 ;
11
Variable Assignment Syntax
Immediately Overwrites Variable with New
Value Unlike the way a Signal Does
12
Variable Assignment, e.g.,
MinTemp := 0 . 0 ;
ImageWidth := 128 ;
MainBus : = 16 # ffff_ffff ;
MainBus : = x “ FFFF_FFFF “ ;
13
Types
Scalar Type
– Consists of a set of single, indivisible values
14
Types
Composite Type
15
Type Syntax
16
Type Syntax
Type Conversion Can Be Used to Perform
Mixed Arithmetic
New_Type ( Value_of_Old_Type )
e.g.,
real ( 238 )
positive ( My_Integer_Value )
– Rounds to nearest integer
– Changes type of value
17
Type Declaration Syntax
type identifier is type_definition ;
type_definition <=
scalar_type_definition
| composite_type_definition
| access_type_definition
| file_type_definition
18
Type Declaration, e.g.
19
Scalar Type Declaration
Scalar Type
– Number types
– Enumerated list
– Physical quantities
20
Scalar Type Declaration Syntax
scalar_type_definition <=
enumeration_type_definition
| integer_type_definition
| floating_type_definition
| physical_type_definition
21
Predefined Integer Type
Integer Type
– A range of integer values within a specified
range including the endpoints
22
Operations on Integer Types
23
Integer Type Definition Syntax
24
Integer Type Definition , e.g.,
type StreetNumbers is range 10107 to 12568 ;
25
Pre-defined Floating-Point Type
Definition
Floating-Point Type
– A range of real values within a specified range
including the endpoints
Real
– Minimum range ( -1.0E+38 ) to ( +1.0E+38 )
– 6-digits minimum precision
– Corresponds to IEEE 32-bit representation
– Floating-point type
26
Ops on Floating-Point Types
Binary Operators
+ Add
- Subtraction
* Multiplication
/ Division
** Exponentiation
27
Ops on Floating-Point Types
Unary Operators
- Negation
+ Identity
abs Absolute value
28
Floating-Point Type Syntax
29
Floating-Point Type, e.g.,
type StreetPosition is range
101 . 07 to 125 . 68 ;
30
Floating-Point Type, e.g.,
31
Physical Type Definition
32
Operations on Physical Types
Binary Operators
* Multiplication by an integer or float
33
Operations on Physical Types
Unary Operators
- negation
+ identity
34
Physical Type Definition Syntax
range simple_expression ( to | downto )
simple_expression
units
identifier ;
{ identifier-n = physical_literal ; }
end units [ identifier ] ;
35
Operations on Physical Types
If Required,
– Convert to integers
– Perform operation
– Convert result to correct type
36
Predefined Physical Type, e.g.,
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 ]
37
Simulation Time Resolution
Limit
38
Simulation Time Resolution
Limit
39
Physical Type Definition, e.g.,
type capacitance is range 0 to 1e12
units
picofarad ;
nanofarad = 1000 picofarad
;
microfarad = 1000 nanofarad ;
farad = 1e6 microfarad ;
end units capacitance ;
40
Physical Type Resolution
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
41
Enumeration Type Definition
Enumeration Type
– An ordered set of identifiers or characters
– The identifiers and characters within a single
enumeration type must be unique.
– Identifiers and characters may be reused in
different enumeration types.
42
Enumeration Type, e.g.,
type Buffer_Direction is ( in , out ,
tri_state ) ;
type FF_Type is
( Toggle , Set_Reset , Data , JK ) ;
43
Enumeration Type, e.g.,
type MemoryType is ( Read_Only ,
Write_Only ,
RW ) ;
44
Predefined Enumeration Types
type severity_level is ( note , warning ,
error , failure ) ;
45
Predefined Enumeration Types
type file_open_status is
( open_ok , status_error , name_error ,
mode_error ) ;
Subtype
– Values which may be taken on by an object and
– are a subset of some base type, and,
– may include all values.
47
Subtypes
48
Subtype Syntax
subtype_indication <=
identifier [ range simple_expression ( to |
downto ) simple_expression ]
49
Subtype Cases
50
Subtype Cases
subtype id is string ( 1 to 20 ) ;
51
Predefined Numeric Subtypes
subtype natural is integer range 0 to
highest_integer ;
52
Scalar Type Attributes
Type_Name ‘ Attribute_Name
53
All Scalar Type Attributes
54
Discrete and Physical Scalar
Type Attributes
“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
56
Operators
57
Operators
Relational Operators
= , /= , < , <= , > , >=
– Operands must be of the same type
– Yield Boolean results
Equality, Inequality Operators
= , /=
– Operands of any type
58
Operators
Concatenation Operator
&
– Operates on one-dimensional arrays to form a
new array
Arithmetic
* , /
– Operate on integer, floating point and physical
types types.
59
Operators
Modulo, Remainder
mod , rem
– Operate only on integer types.
Absolute Value
abs
– Operates on any numeric type
60
Operators
Exponentiation
**
– Integer or floating point left operand
– Integer right operand required
– Negative right operand requires floating point
left operand
61
End of Leture
The End
62