• No se han encontrado resultados

RESOLUCIÓN GMC Nº 31/2006

INFORMACIÓN NUTRICIONAL

Types used for ports must be declared in a package, so that the type is visible to entity declarations. A package must be compiled before any entity declaration that uses a type declared in that package is compiled.

Predefined Types Predefined (built-in) types are those defined in packages STANDARD and TEXTIO in the library STD. This library is provided with all VHDL compilers. Package TEXTIO is provided to support formatted human-readable I/O.

FIGURE 3.3.1

Predefined scalar types.

Scalar Types Enumeration Types Integer Types integer Physical Types time Floating Types real discrete numeric predefined bit

(chap. 3) (chap. 3) (chap. 7) boolean (chap. 4) character (chap. 3) severity_level (chap. 7) file_open_kind file_open_status type_declaration ::=

type identifier is type_definition ; FIGURE 3.3.2

The predefined scalar types in Figure 3.3.1 are defined in package STANDARD. Of these, only bit, boolean, character, and integer are synthesizable. Types character, bit, and integer are discussed in this chapter. The other predefined scaler types are discussed in later chapters.

To use a type that is declared in a package, we must precede each entity decla- ration that uses that type with an appropriate context clause. Because every design unit in a description is automatically preceded by the implicit context clause:

library std, work;

use std.standard.all;

the predefined types in package STANDARD are directly visible in a design without explicitly using any library or use clauses.

Enumeration Types An enumeration type is declared by simply listing (enumerating) all possible values for the type. There must be at least one value in the list. The syntax for declaring an enumeration type is given in Figure 3.3.3.

Identifier is the name given to the type. The type definition portion of an enumer- ation type declaration consists of the list of enumeration literals (values) for the type. An enumeration literal can be an identifier or a character literal.

Like all other VHDL identifiers, an identifier used as an enumeration literal is not case sensitive. In contrast, character literals are case sensitive. A character literal is a single character enclosed in single quotes. For example, the single characters 'a'

and 'A' are distinct. An enumeration type is said to be a character type if at least one of its enumeration literals is a character literal.

Each enumeration literal must be unique within the type being declared. However, different enumeration types may use the same literal. In such cases, the literal is said to be overloaded.

All scalar types are ordered. All relational operators (>, <, =, and so on) are predefined for their values. Enumeration literals are ordered, in ascending order, by their textual position in the list of literals defining the type.

Type Character Type character is an enumeration type, predefined in package STANDARD, that corresponds to the International Organization for Standardization (ISO) 8-bit encoded character set ISO 8859-1:1987. This character set includes graphic characters and format effectors. The definition of type character contains a mixture of character literals and identifiers as elements:

enumeration_type_declaration ::=

type identifier is ( enumeration_literal { , enumeraton_literal } )

enumeration_literal ::= identifier | character_literal

FIGURE 3.3.3

Section 3.3 Scalar Types 91 type character is (NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL,

BS, HT, LF, VT, FF, CR, SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FSP, GSP, RSP, USP, ' ', '!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', DEL, C128, C129, C130, C131, C132, C133, C134, C135, C136, C137, C138, C139, C140, C141, C142, C143, C144, C145, C146, C147, C148, C149, C150, C151, C152, C153, C154, C155, C156, C157, C158, C159, ' ', '¡', '¢', '£', '‡', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '-', '®', '¯', '°', '±', '²', '³', '´', 'μ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ');

The first 128 characters in this enumeration are the ASCII characters. The identifiers from NUL to USP and DLE are the nonprintable ASCII control characters. Characters

C128 to C159 in the ISO character set do not have names. In VHDL, these characters are given names based on their positions in the enumeration.

The character in position 160 is the nonbreaking space character, in contrast to the ordinary space character in position 32. The character at position 173 is the soft hyphen, in contrast to the ordinary hyphen in position 45. The soft hyphen is used to represent a line break within a word.

Type Bit Type bit is an enumeration type used as a simple representation for a logic signal. The type declaration for bit appears in package STANDARD as:

Here character literals '0' and '1' are used to represent logic 0 and logic 1. Hence, type bit is also a character type. Because of their order in the enumeration list, '0' is less than '1'.

Subtype Declarations

A type derived from another type is a subtype. The type from which the subtype is derived is its base type. Creating and using a subtype allows us to make it clear which values from the base type are valid for an object.

The simplified syntax for a subtype declaration is given in Figure 3.3.4. From the syntax, we see that a subtype is simply a type together with either a resolution function or a constraint, or both.

Inclusion in a Subtype

A value belongs to a subtype of a given type if it belongs to the base type and satisfies the constraint, if any, of the subtype declaration. A constraint is a restriction on the set of possible values for the subtype from the values allowed for the base type. A type is a subtype of itself. Such a subtype is unconstrained because it corre- sponds to a situation that imposes no restrictions.

A subtype declaration does not define a new type. The type of a subtype is the same as its base type. Accordingly, the set of operations allowed on a subtype is the same as the set allowed on its base type.

An example of a subtype declaration using a resolution function is given in the next section. Examples of subtype declarations using constraints are given in Section 3.10.

Type Compatibility in Assignments

When a signal assignment is made, the objects on both sides of the assignment symbol must be of the same type. Otherwise, the compiler gives a type conflict error. This ensures that an object is only assigned values of its own type and avoids mixing values that represent different things.

Since a subtype declaration does not define a new type, a value of a subtype can be assigned to an object of its base type.

Conversely, a value of a base type can also be assigned to an object of its subtype without producing a syntax error. However, if, during simulation, an assignment of a value of a given type is made to an object of its subtype and the value assigned does not meet the subtype constraint, a dynamic semantic error occurs.

subtype_declaration ::=

subtype identifier is [ resolution_function_name ] type_mark [ constraint ] ;

type_mark ::= type_name | subtype_name constraint ::= range_constraint | index_constraint range_constraint ::= range range

index_constraint ::= ( discrete_range { , discrete_range } )

FIGURE 3.3.4

Section 3.4 Type Std_Logic 93

Documento similar