VHDL Data Types & Declarations: Types, Enums, Integers, Floats, Slides of Verilog and VHDL
An overview of data types and declarations in vhdl, including types, enumerations, integers, floating point, physical types, and user-defined types. It covers predefined types, user-defined examples, and the use of strings and records. The document also explains the concepts of subtypes, arrays, unconstrained arrays, and composite types.
Download VHDL Data Types & Declarations: Types, Enums, Integers, Floats and more Slides Verilog and VHDL in PDF only on Docsity!
Language Overview I
The start of a grand tour of the
language.
Elements Covered in I
Language overview lectures(I,II,III) do not cover
all aspects of the language, however, they do
cover a large portion of it.
This Lecture:
TYPES
DECLARATIONS
OPERATORS
CONCURRENT STATEMENT
Component Instantiation
Generate Statement
DATA TYPES
Integer Types
INTEGER
Predefined type
Integer type with range of at least -2147483647 to + ( a 2 complement range for a 32 bit integer)
TYPE word_index IS RANGE 31 DOWNTO 0;
And integer with values >= 0 and <= 31
TYPE two_complement_integer IS RANGE -32768 TO 32767;
use VARIABLE myintvar : INTEGER;
SIGNAL my_word :word_index;
DATA TYPES
Floating Point Type
REAL
Predefined type with range >= -1E38 to +1E
Character Type
CHARACTER - a single alphanumeric character
DATA TYPES
PHYSICAL TYPE
TYPE time IS RANGE 0 to 1E18 -- Predefined
UNITS
FS; -- femtosecond
PS = 1000 FS; -- picosecond
NS = 1000 PS; -- nanosecond
US = 1000 NS; -- microsecond
MS = 1000 US; --millisecond
SEC = 1000 MS; -- second
MIN = 60 SEC; -- minute
END UNITS;
DATA TYPES
User defined physical type
TYPE distance IS RANGE 0 TO 1E
UNITS
A; -- angstrom, base unit
NM = 10A; -- nanometer
MIL = 254000A; -- mil
INCH = 1000 mil; -- inch
END UNITS;
Usage
VARIABLE X : distance; VARIABLE Y : time;
X := 5 A + 14 inch – 45 mil;
Y := 3 ns + 5 min;
Any implementation allows for declaration of physical types with a range of -2147483647 to +
Composite types
ARRAYS
TYPE my_word IS ARRAY (0 to 31) of BIT;
TYPE regs IS ARRAY (7 downto 0) of my_word;
Unconstrained ARRAYS
TYPE memory IS ARRAY (INTEGER range <>) of my- word;
USE:
VARIABLE my_mem : MEMORY (0 to 65536);
Predefined Arrays
SUBTYPE positive IS INTEGER range 1 to ITEGER’HIGH; - INTEGER’HIGH is the largest integer for this installation
TYPE string IS ARRAY (POSITIVE RANGE <>) of CHARACTER;
SUBTYPE natural IS INTEGER range 0 to ITEGER’HIGH;
TYPE bit_vector IS ARRAY (NATURAL range <>) of BIT;
An interjected comment
From prior years
Comments on HW1 and PS
BE SURE TO SUBMIT TO RIGHT DROPBOX
BE SURE FILES ARE THE RIGHT ONES AND ARE READABLE
For submission convert .ps files to .pdf
DATA TYPES
COMPOSITE TYPES
RECORDS
TYPE month_name IS (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
TYPE date IS
RECORD
DAY : INTEGER range 1 to 31;
MONTH : month_name;
YEAR : INTEGER range 0 to 4000;
END RECORD;
DECLARATIONS
• VARIABLES
For use in processes, procedures and functions
Scope limited to the process, procedure, or function in which declared.
Cannot be declared in the declarative region of architectures!!!!
Have no time component
Any assignment takes place immediately upon assignment.
VARIABLE my_var : BIT;
DECLARATIONS
• SIGNALS
For use in entities, architectures, procedures, functions, and process.
Scope depends upon where declared – can be sort of global (scope of architecture)
Have a value and time component
Assignments do-not take place immediately – assignment of new values are scheduled
Delaration in Entities, Architectures, Concurrent Procedures - SIGNAL my_sig : BIT :=‘1’; - SIGNAL my_int : INTEGER := 45;
DECLARATIONS
CONSTANTS
CONSTANT pi : REAL := 3.141592;
CONSTANT cycle_time : TIME := 75 ns;
Can be declared and used but cannot be assigned to
COMPONENT
Declaration needed for hierarchical models
COMPONENT local_component_name
PORT(port declarations from component’s entity)
END COMPONENT;
The easy way to do a component declaration is to copy theENTITY Declaration, change ENTITY TO COMPONENT, delete theIS and change END xxx to END COMPONENT.
OPERATORS
LOGICAL OPERATORS::
AND | OR | NAND | NOR | XOR | XNOR | NOT
APPLY TO TYPES BIT AND BOOLEAN
RELATIONAL OPERATORS::
= | /= | < | <= | > | >=
Result of comparison with relational operators is BOOLEAN