Scalar types
Definitions
scalar_type_definition
Examples
Different types are declared.
- Types Bit and switch_level are declared as enumeration types through characters and can only have the values ' 0' or ' 1' and 'X '. One has to distinguish between these values '0 ' and '1' and the integer values 0 and 1 . Both characters are overloaded.
- Types states and colours are declared as enumeration types by self-explanatory element names.
TYPE Bit IS ( '0', '1' ) ; TYPE switch_level IS ( '0', '1', 'X' ) ; TYPE states IS (out, sleeping, working); TYPE colors IS ( red, green, blue );
- Integer types are generated by stating integral numbers in the range declaration (RANGE).
- The range can be declared rising (TO) or falling (DOWNTO).
- Real types are created through realistic range declarations.
- Subtypes can be declared by stating the base type and the selected range.
TYPE byte_length_integer IS RANGE 0 TO 255 ; TYPE word_index IS RANGE 31 DOWNTO 0 ; TYPE my_real IS RANGE 0.0 TO 9.99 ; SUBTYPE high_bit_low IS byte_length_integer RANGE 0 TO 127 ;
With physical types a real-type is defined first. Afterwards the basic unit and its derivative units are declared.
As examples the definitions of the units of length (distance) and the units of time (time) are shown here.
The physical unit time is a predefined type.
TYPE distance IS RANGE 0 TO 1E16 UNITS -- Basiseinheit : A -- Angström -- Metrische Einheiten : nm = 10 A ; -- Nanometer um = 1000 nm ; -- Mikrometer mm = 1000 um ; -- Millimeter cm = 10 mm ; -- Centimeter m = 1000 mm ; -- Meter km = 1000 m ; -- Kilometer END UNITS ; TYPE time IS RANGE -1E18 TO 1E18 UNITS fs ; --Femtosekunde 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