Constant

LRM §4.3.1.1.

A constant is an object whose value cannot be changed once defined for the design. Constants may be explicitly declared or they may be sub-elements of explicitly declared constants, or interface constants. Constants declared in packages may also be deferred constants.

Syntax:

constant constant_name: data_type [ := expression ]; 

Description:

A constant is used to give a name to a value, this makes it easier to read and maintain the code.

The data type in the constant declaration can be of scalar or composite type and it can be constrained. A constant cannot be of the file or access type. If a constant is an array or a record then none of its elements can be of the file or access type.

The visibility of constants depends on the place of their declaration. The constants defined in the package can be used by several design units. The constant declaration in the design entity is seen by all the statements of the architecture bodies of this entity. The constants defined in the declaration part of the design unit is seen in all bodies related to this design, including the process statement. The constant defined in the process can only be used in this process.

Example:

constant Size: Positive := 8; 
constant MaxSimTime: Time := 200 * ClkPeriod;

Notes:

See also:

Alias, Package, Variable