Physical Type

LRM §3.1.3.

A physical type represents an integer value together with a physical unit.

Syntax:

type new_name is range left_bound to right_bound 
units 
  primary_unit_name;
  secondary_unit_name = number primary_unit_name;
  ...
end units [ new_name ]; 
type new_name is range left_bound downto right_bound 
units 
  primary_unit_name;
  secondary_unit_name = number primary_unit_name;
  ...
end units [ new_name ];

Description:

A physical type allows to define measurement units for some physical quantity, like length, time, pressure, capacity, etc.

A physical type declaration starts with the definition of a primary unit, which is optionally followed by, one or more secondary units. The primary unit serves as the base unit for representing values of the specified type. The secondary units are defined as multiplicity of primary units or previously specified secondary units. Their declarations may contain only integer literals.

Each value of a physical type has a corresponding position number, which is the number of primary units represented by that unit name. This way values specified in different units of the same type can be compared.

Example:

type Capacity is range 0 to integer'high
units
  pF;               -- picofarad 
  nF = 1000 pF;     -- nanofarad 
  uF = 1000 nF;     -- microfarad 
  mF = 1000 uF;     -- milifarad 
  F  = 1000 mF;     -- farad 
end units; 

Notes:

See also:

Integer, Range, Type