Professional Documents
Culture Documents
2
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Type declaration
12/22/2012
a hardware description language at various level of abstraction should not be limited to Bit or Boolean types VHDL is a highly typed language VHDL allows the use of integers, floating point, and enumerate data types as well as user defined type
It has already arithmetic operators defined for these types
3
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
COMPOSITE
RECORD
VECTOR
4
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Composite Types
12/22/2012
A composite type object is one having multiple elements VHDL composite types consists of arrays and records
5
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type
12/22/2012
Used to collect one or more elements of a similar type in a single construct Elements can be any VHDL data type
6
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type
12/22/2012
Each object of this data type can hold more than one value. Arrays consist of many similar elements of any data type, including arrays.
7
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type
12/22/2012
Simplified Syntax:
type type_name is array (range) of element_type
Or
type type_name is array (type range) of element_type
8
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type
12/22/2012
constrained or unconstrained. constrained if the size of the array is constrained. The size of the array can be constrained using a discrete type mark or a range. In both cases, the number of the elements in the array is known during the compilation. unconstrained if its size is unconstrained Number of elements of unconstrained array type is unknown. The size of a particular object is specified only when it is declared.
9
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type
12/22/2012
Constrained Array
type Real_Matrix is array (1 to 10) of REAL; type BYTE is array (0 to 7) of BIT; type DATA_BUS is array (0 to 7) of BIT;
Unonstrained Array
type Real_Matrix is array (POSITIVE range <>) of Real; variable Real_Matrix_Object : Real_Matrix (1 to 8);
10
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
A vector is a dynamic array (edit the contents) Only 1 dimension A vector will expand its size as necessary to accommodate new elements Can reserve spaces in between Syntax:
Type_Vector(range);
An array is a static array (just to store values) Multiple dimensions An array is fixed
11
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Array Type:
Library IEEE; Use STD_LOGIC_1164.all;
12/22/2012
package arr_pkg is constant N: integer := 4; constant M: integer := 3; subtype wordN is STD_LOGIC_VECTOR (M downto 0);
--building a package for array -- no. of elements of array is N+1 -- no of bits of each element is M+1
12
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY 12/22/2012
Array Type:
Library IEEE; Use STD_LOGIC_1164.all; Use work.arr_pkg.all;
Entity large_array is generic (N: integer :=4; M:integer:=3); Port( a: inout strng; z: out std_logic_vector(M downto 0)); End large_array;
13
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
Array Type:
Begin Process( a) Variable great: wordN; Begin;
a <= (0110, 0111, 0010, 0011, 0001); great := 0000; Loopx : for i in 0 to N loop if (great <= a(i)) then great := a(i); report(great is less than or equal to a); Else report(great is greater than a); end if; end loop loopx; z <= great; End process;
End arry;
14
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Record Type
12/22/2012
The RECORD and END RECORD keywords bracket the field names.
After the RECORD keyword, the record's field names are assigned and their data types are specified.
15
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
Record Type
Used to collect one or more elements of a different types in single construct Elements can be any VHDL data type Elements are accessed through field name There are no predefined records in VHDL, but user-defined records can be very useful. A record holds several units within a group and the code gets easier to read. A record may contain an unlimited amount of elements.
16
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
Record Type
A record element may be of any data type, including another record. The elements need not be of the same type. This construct allows users to create data structures which are useful for the system being represented.
17
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Record Type
12/22/2012
Syntax: type identifier is record element1 : type 1 element2 : type 2 . . . elementN : type N end record [ record-type-identifier ] ;
18
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Record Type:
12/22/2012
examples
-- to declare a date -- with a string for the month -- and an int for the day -- int for year -------------------------------------------- a record for an address -- line for street -- possible PO box -- line for city -- state -- keep zip code as int
19
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Record Type:
examples
12/22/2012
-- declare an employee type -- space for name -- date when hired -- where -- can keep as string or int -- what job is -- comp has 1000 job classes
20
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Access Type
12/22/2012
Only variables can be an access type; that is, it is not permissible for a signal to be utilized as an access type.
If the access type is instantiated in such a way that it is not assigned an initial value, then the initial value is the literal, null.
The access type declaration begins with the keyword "type", followed by an identifier .
The identifier is then followed by the keywords "is access", which is then followed by a subtype indication .
The subtype indication may be as simple as a simple type, or it could be as complex as types can become, including a resolution function and/or index or range constraints.
After the subtype indication the statement is concluded with a semicolon.
21
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Access Type
12/22/2012
Syntax
type DATE is record MONTH : STRING (0 to 20); DAY : INTEGER range 1 to 31; YEAR : INTEGER range 1800 to 2050; end record DATE;
-- main module
22
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
Conclusion
12/22/2012
Arrays contain a number of elements of the same type or subtypes Arrays are Used to collect one or more elements of a similar type in a single construct
Records may contain a number of elements of different types or subtypes Record are used to collect one or more elements of a different types in a single construct
Access types are pointers Access is used for the implementing queues, fifos, etc.
23
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
References
http://www.csee.umbc.edu/portal/help/VHDL/VH DL-Handbook.pdf
http://vhdl.renerta.com/mobile/index.html http://www.ece.unm.edu/faculty/pollard/types.htm l#AccessTypeDec
http://tams-www.informatik.unihamburg.de/vhdl/doc/cookbook/VHDLCookbook.pdf
24
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
12/22/2012
QUESTIONS
25
DEPARTMENT OF INSTRUMENTATION TECHNOLOGY
THANK YOU
12/22/2012