VHDL/Пакет Standard
Содержание |
VHDL 1992
Файл: Имя файла |
-- This is Package STANDARD as defined in the VHDL 1992 Language Reference Manual. -- -- NOTE: LeonardoSpectrum will not work properly if these declarations -- are modified. -- Version information: @(#)standard.vhd package standard is type boolean is (false,true); type bit is ('0', '1'); 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 character code for 160 is there (NBSP), -- but prints as no char ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ' ); type severity_level is (note, warning, error, failure); type integer is range -2147483648 to 2147483647; type real is range -1.0E308 to 1.0E308; type time is range -2147483647 to 2147483647 units fs; ps = 1000 fs; ns = 1000 ps; us = 1000 ns; ms = 1000 us; sec = 1000 ms; min = 60 sec; hr = 60 min; end units; subtype delay_length is time range 0 fs to time'high; impure function now return delay_length; subtype natural is integer range 0 to integer'high; subtype positive is integer range 1 to integer'high; type string is array (positive range <>) of character; type bit_vector is array (natural range <>) of bit; type file_open_kind is ( read_mode, write_mode, append_mode); type file_open_status is ( open_ok, status_error, name_error, mode_error); attribute foreign : string; -- -- Exemplar specific synthesis directives : Logic type encoding of boolean and bit -- attribute logic_type_encoding : string ; attribute logic_type_encoding of bit:type is ('0','1') ; attribute logic_type_encoding of boolean:type is ('0','1') ; end standard; package body standard is function now return delay_length is begin assert FALSE report "function 'now' returns '0 fs' for synthesis" severity warning; return 0 fs; end now; end standard; |
VHDL-2008
Пакет STANDARD в редакции стандарта VHDL-2008
Левый | Операция | Правый | Результат |
---|---|---|---|
BOOLEAN | and, or, nand, nor, xor, xnor | BOOLEAN | BOOLEAN |
— | not | BOOLEAN | BOOLEAN |
BOOLEAN | =, /=, <, <=, >, >= | BOOLEAN | BOOLEAN |
BOOLEAN | MINIMUM, MAXIMUM | BOOLEAN | BOOLEAN |
— | RISING_EDGE, FALLING_EDGE | BOOLEAN | BOOLEAN |
type BOOLEAN is (FALSE, TRUE); -- The predefined operations for this type are as follows: -- function "and" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "or" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "nand" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "nor" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "xor" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "xnor" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "not" (anonymous: BOOLEAN) return BOOLEAN; -- function "=" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "/=" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "<" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function "<=" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function ">" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function ">=" (anonymous, anonymous: BOOLEAN) return BOOLEAN; -- function MINIMUM (L, R: BOOLEAN) return BOOLEAN; -- function MAXIMUM (L, R: BOOLEAN) return BOOLEAN; -- function RISING_EDGE (signal S: BOOLEAN) return BOOLEAN; -- function FALLING_EDGE (signal S: BOOLEAN) return BOOLEAN;
Левый | Операция | Правый | Результат |
---|---|---|---|
BIT | and, or, nand, nor, xor, xnor | BIT | BIT |
— | not | BIT | BIT |
BIT | =, /=, <, <=, >, >= | BIT | BOOLEAN |
BIT | ?=, ?/=, ?<, ?<=, ?>, ?>= | BIT | BIT |
BIT | MINIMUM, MAXIMUM | BIT | BIT |
— | ?? | BIT | BOOLEAN |
— | RISING_EDGE, FALLING_EDGE | BIT | BOOLEAN |
type BIT is ('0', '1'); -- The predefined operations for this type are as follows: -- function "and" (anonymous, anonymous: BIT) return BIT; -- function "or" (anonymous, anonymous: BIT) return BIT; -- function "nand" (anonymous, anonymous: BIT) return BIT; -- function "nor" (anonymous, anonymous: BIT) return BIT; -- function "xor" (anonymous, anonymous: BIT) return BIT; -- function "xnor" (anonymous, anonymous: BIT) return BIT; -- function "not" (anonymous: BIT) return BIT; -- function "=" (anonymous, anonymous: BIT) return BOOLEAN; -- function "/=" (anonymous, anonymous: BIT) return BOOLEAN; -- function "<" (anonymous, anonymous: BIT) return BOOLEAN; -- function "<=" (anonymous, anonymous: BIT) return BOOLEAN; -- function ">" (anonymous, anonymous: BIT) return BOOLEAN; -- function ">=" (anonymous, anonymous: BIT) return BOOLEAN; -- function "?=" (anonymous, anonymous: BIT) return BIT; -- function "?/=" (anonymous, anonymous: BIT) return BIT; -- function "?<" (anonymous, anonymous: BIT) return BIT; -- function "?<=" (anonymous, anonymous: BIT) return BIT; -- function "?>" (anonymous, anonymous: BIT) return BIT; -- function "?>=" (anonymous, anonymous: BIT) return BIT; -- function MINIMUM (L, R: BIT) return BIT; -- function MAXIMUM (L, R: BIT) return BIT; -- function "??" (anonymous: BIT) return BOOLEAN; -- function RISING_EDGE (signal S: BIT) return BOOLEAN; -- function FALLING_EDGE (signal S: BIT) return BOOLEAN;
Левый | Операция | Правый | Результат |
---|---|---|---|
CHARACTER | =, /=, <, <=, >, >= | CHARACTER | BOOLEAN |
CHARACTER | MINIMUM, MAXIMUM | CHARACTER | CHARACTER |
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, ' ',⁹ '¡', '¢', '£', '¤', '¥', '¦', '§', ' ̈', '©', 'a', '«', '¬', '-',¹⁰ '®', ' ̄', '°', '±', '2', '3', ' ́', 'μ', '¶', '·', ' ̧', '1', 'o', '»', '1⁄4', '1⁄2', '3⁄4', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ'); -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function "/=" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function "<" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function "<=" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function ">" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function ">=" (anonymous, anonymous: CHARACTER) -- return BOOLEAN; -- function MINIMUM (L, R: CHARACTER) return CHARACTER; -- function MAXIMUM (L, R: CHARACTER) return CHARACTER;
9 - The nonbreaking space character. 10 - The soft hyphen character.
Левый | Операция | Правый | Результат |
---|---|---|---|
SEVERITY_LEVEL | =, /=, <, <=, >, >= | SEVERITY_LEVEL | BOOLEAN |
SEVERITY_LEVEL | MINIMUM, MAXIMUM | SEVERITY_LEVEL | SEVERITY_LEVEL |
type SEVERITY_LEVEL is (NOTE, WARNING, ERROR, FAILURE); -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function "/=" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function "<" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function "<=" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function ">" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function ">=" (anonymous, anonymous: SEVERITY_LEVEL) -- return BOOLEAN; -- function MINIMUM (L, R: SEVERITY_LEVEL) return SEVERITY_LEVEL; -- function MAXIMUM (L, R: SEVERITY_LEVEL) return SEVERITY_LEVEL;
-- type universal_integer is range implementation_defined; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function "/=" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function "<" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function "<=" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function ">" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function ">=" (anonymous, anonymous: universal_integer) -- return BOOLEAN; -- function "+" (anonymous: universal_integer) -- return universal_integer; -- function "-" (anonymous: universal_integer) -- return universal_integer; -- function "abs" (anonymous: universal_integer) -- return universal_integer; -- function "+" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function "-" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function "*" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function "/" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function "mod" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function "rem" (anonymous, anonymous: universal_integer) -- return universal_integer; -- function MINIMUM (L, R: universal_integer) -- return universal_integer; -- function MAXIMUM (L, R: universal_integer) -- return universal_integer; -- type universal_real is range implementation_defined; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function "/=" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function "<" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function "<=" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function ">" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function ">=" (anonymous, anonymous: universal_real) -- return BOOLEAN; -- function "+" (anonymous: universal_real) -- return universal_real; -- function "-" (anonymous: universal_real) -- return universal_real; -- function "abs" (anonymous: universal_real) -- return universal_real; -- function "+" (anonymous, anonymous: universal_real) return universal_real; -- function "-" (anonymous, anonymous: universal_real) return universal_real; -- function "*" (anonymous, anonymous: universal_real) return universal_real; -- function "/" (anonymous, anonymous: universal_real) return universal_real; -- function "*" (anonymous: universal_real; anonymous: universal_integer) return universal_real; -- function "*" (anonymous: universal_integer; anonymous: universal_real) return universal_real; -- function "/" (anonymous: universal_real; anonymous: universal_integer) return universal_real; -- function MINIMUM (L, R: universal_real) return universal_real; -- function MAXIMUM (L, R: universal_real) return universal_real;
Левый | Операция | Правый | Результат |
---|---|---|---|
universal_integer | ** | INTEGER | universal_integer |
universal_real | INTEGER | universal_real | |
INTEGER | =, /=, <, <=, >, >= | INTEGER | BOOLEAN |
— | +, –, abs | INTEGER | INTEGER |
INTEGER | +, –, *, /, mod, rem, ** | INTEGER | INTEGER |
INTEGER | MINIMUM, MAXIMUM | INTEGER | INTEGER |
-- Predefined numeric types: type INTEGER is range implementation_defined; -- The predefined operations for this type are as follows: -- function "**" (anonymous: universal_integer; -- anonymous: INTEGER) return universal_integer; -- function "**" (anonymous: universal_real; -- anonymous: INTEGER) return universal_real; -- function "=" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function "/=" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function "<" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function "<=" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function ">" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function ">=" (anonymous, anonymous: INTEGER) return BOOLEAN; -- function "+" (anonymous: INTEGER) return INTEGER; -- function "-" (anonymous: INTEGER) return INTEGER; -- function "abs" (anonymous: INTEGER) return INTEGER; -- function "+" (anonymous, anonymous: INTEGER) return INTEGER; -- function "-" (anonymous, anonymous: INTEGER) return INTEGER; -- function "*" (anonymous, anonymous: INTEGER) return INTEGER; -- function "/" (anonymous, anonymous: INTEGER) return INTEGER; -- function "mod" (anonymous, anonymous: INTEGER) return INTEGER; -- function "rem" (anonymous, anonymous: INTEGER) return INTEGER; -- function "**" (anonymous: INTEGER; anonymous: INTEGER) return INTEGER; -- function MINIMUM (L, R: INTEGER) return INTEGER; -- function MAXIMUM (L, R: INTEGER) return INTEGER;
Левый | Операция | Правый | Результат |
---|---|---|---|
REAL | =, /=, <, <=, >, >= | REAL | BOOLEAN |
— | +, –, abs | REAL | REAL |
REAL | +, –, *, / | REAL | REAL |
REAL | ** | INTEGER | REAL |
REAL | MINIMUM, MAXIMUM | REAL | REAL |
type REAL is range implementation_defined; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: REAL) return BOOLEAN; -- function "/=" (anonymous, anonymous: REAL) return BOOLEAN; -- function "<" (anonymous, anonymous: REAL) return BOOLEAN; -- function "<=" (anonymous, anonymous: REAL) return BOOLEAN; -- function ">" (anonymous, anonymous: REAL) return BOOLEAN; -- function ">=" (anonymous, anonymous: REAL) return BOOLEAN; -- function "+" (anonymous: REAL) return REAL; -- function "-" (anonymous: REAL) return REAL; -- function "abs" (anonymous: REAL) return REAL; -- function "+" (anonymous, anonymous: REAL) return REAL; -- function "-" (anonymous, anonymous: REAL) return REAL; -- function "*" (anonymous, anonymous: REAL) return REAL; -- function "/" (anonymous, anonymous: REAL) return REAL; -- function "**" (anonymous: REAL; anonymous: INTEGER) return REAL; -- function MINIMUM (L, R: REAL) return REAL; -- function MAXIMUM (L, R: REAL) return REAL;
Левый | Операция | Правый | Результат |
---|---|---|---|
TIME | =, /=, <, <=, >, >= | TIME | BOOLEAN |
— | +, –, abs | TIME | TIME |
TIME | +, –, mod, rem | TIME | TIME |
TIME | * | INTEGER | TIME |
INTEGER | TIME | TIME | |
TIME | REAL | TIME | |
REAL | TIME | TIME | |
TIME | / | INTEGER | TIME |
TIME | REAL | TIME | |
TIME | TIME | universal_integer | |
TIME | MINIMUM, MAXIMUM | TIME | TIME |
-- Predefined type TIME: type TIME is range implementation_defined units fs; -- femtosecond ps = 1000 fs; -- picosecond ns = 1000 ps; -- nanosecond us = 1000 ns; -- microsecond ms = 1000 us; -- millisecond sec = 1000 ms; -- second min = 60 sec; -- minute hr = 60 min; -- hour end units; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: TIME) return BOOLEAN; -- function "/=" (anonymous, anonymous: TIME) return BOOLEAN; -- function "<" (anonymous, anonymous: TIME) return BOOLEAN; -- function "<=" (anonymous, anonymous: TIME) return BOOLEAN; -- function ">" (anonymous, anonymous: TIME) return BOOLEAN; -- function ">=" (anonymous, anonymous: TIME) return BOOLEAN; -- function "+" (anonymous: TIME) return TIME; -- function "-" (anonymous: TIME) return TIME; -- function "abs" (anonymous: TIME) return TIME; -- function "+" (anonymous, anonymous: TIME) return TIME; -- function "-" (anonymous, anonymous: TIME) return TIME; -- function "*" (anonymous: TIME; anonymous: INTEGER) return TIME; -- function "*" (anonymous: TIME; anonymous: REAL) return TIME; -- function "*" (anonymous: INTEGER; anonymous: TIME) return TIME; -- function "*" (anonymous: REAL; anonymous: TIME) return TIME; -- function "/" (anonymous: TIME; anonymous: INTEGER) return TIME; -- function "/" (anonymous: TIME; anonymous: REAL) return TIME; -- function "/" (anonymous, anonymous: TIME) return universal_integer; -- function "mod" (anonymous, anonymous: TIME) return TIME; -- function "rem" (anonymous, anonymous: TIME) return TIME; -- function MINIMUM (L, R: TIME) return TIME; -- function MAXIMUM (L, R: TIME) return TIME; subtype DELAY_LENGTH is TIME range 0 fs to TIME'HIGH; -- A function that returns the current simulation time, Tc, -- (see 14.7.5.1): impure function NOW return DELAY_LENGTH;
Левый | Операция | Правый | Результат |
---|---|---|---|
STRING | =, /=, <, <=, >, >= | STRING | BOOLEAN |
STRING | & | STRING | STRING |
STRING | CHARACTER | STRING | |
CHARACTER | STRING | STRING | |
CHARACTER | CHARACTER | STRING | |
STRING | MINIMUM, MAXIMUM | STRING | STRING |
— | STRING | CHARACTER |
-- Predefined array types: type STRING is array (POSITIVE range <>) of CHARACTER; -- The predefined operations for these types are as follows: -- function "=" (anonymous, anonymous: STRING) return BOOLEAN; -- function "/=" (anonymous, anonymous: STRING) return BOOLEAN; -- function "<" (anonymous, anonymous: STRING) return BOOLEAN; -- function "<=" (anonymous, anonymous: STRING) return BOOLEAN; -- function ">" (anonymous, anonymous: STRING) return BOOLEAN; -- function ">=" (anonymous, anonymous: STRING) return BOOLEAN; -- function "&" (anonymous: STRING; anonymous: STRING) return STRING; -- function "&" (anonymous: STRING; anonymous: CHARACTER) return STRING; -- function "&" (anonymous: CHARACTER; anonymous: STRING) return STRING; -- function "&" (anonymous: CHARACTER; anonymous: CHARACTER) return STRING; -- function MINIMUM (L, R: STRING) return STRING; -- function MAXIMUM (L, R: STRING) return STRING; -- function MINIMUM (L: STRING) return CHARACTER; -- function MAXIMUM (L: STRING) return CHARACTER;
Левый | Операция | Правый | Результат |
---|---|---|---|
FILE_OPEN_KIND | =, /=, <, <=, >, >= | FILE_OPEN_KIND | BOOLEAN |
FILE_OPEN_KIND | MINIMUM, MAXIMUM | FILE_OPEN_KIND | FILE_OPEN_KIND |
type FILE_OPEN_KIND is ( READ_MODE, WRITE_MODE, APPEND_MODE); -- Resulting access mode is read-only. -- Resulting access mode is write-only. -- Resulting access mode is write-only; -- information is appended to the end -- of the existing file. -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function "/=" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function "<" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function "<=" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function ">" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function ">=" (anonymous, anonymous: FILE_OPEN_KIND) return BOOLEAN; -- function MINIMUM (L, R: FILE_OPEN_KIND) return FILE_OPEN_KIND; -- function MAXIMUM (L, R: FILE_OPEN_KIND) return FILE_OPEN_KIND;
Левый | Операция | Правый | Результат |
---|---|---|---|
FILE_OPEN_STATUS | =, /=, <, <=, >, >= | FILE_OPEN_STATUS | BOOLEAN |
FILE_OPEN_STATUS | MINIMUM, MAXIMUM | FILE_OPEN_STATUS | FILE_OPEN_STATUS |
type FILE_OPEN_STATUS is ( OPEN_OK, -- File open was successful. STATUS_ERROR, -- File object was already open. NAME_ERROR, -- External file not found -- or inaccessible. MODE_ERROR); -- Could not open file with requested -- access mode. -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function "/=" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function "<" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function "<=" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function ">" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function ">=" (anonymous, anonymous: FILE_OPEN_STATUS) return BOOLEAN; -- function MINIMUM (L, R: FILE_OPEN_STATUS) return FILE_OPEN_STATUS; -- function MAXIMUM (L, R: FILE_OPEN_STATUS) return FILE_OPEN_STATUS;
Новое в VHDL-2008
В пакете STD.STANDARD определены четыре новых типа данных:
- REAL_VECTOR — массив элементов типа real;
- TIME_VECTOR — массив элементов типа time;
- INTEGER_VECTOR — массив элементов типа integer;
- BOOLEAN_VECTOR — массив элементов типа boolean.
type BOOLEAN_VECTOR is array (NATURAL range <>) of BOOLEAN; type INTEGER_VECTOR is array (NATURAL range <>) of INTEGER; type REAL_VECTOR is array (NATURAL range <>) of REAL; type TIME_VECTOR is array (NATURAL range <>) of TIME;
Стр. 191-192 (vhdl-2008 book)
- The types boolean_vector, integer_vector, real_vector, and time_vector are now predefined.
- Для типа BOOLEAN_VECTOR предопределены такие же операторы (операции) как и для типа BIT_VECTOR (and, or, nand, nor, xor, xnor, not, [and, or, nand, nor, xor, xnor], sll, srl, sla, sra, rol, ror, =, /=, <, <=, >, >=, ?=, ?/=, &, MINIMUM, MAXIMUM).
- Предопределённые операции для типа integer_vector включают операторы отношения (relational) (“=”, “/=”, “<”, “>”, “<=”, and “>=”) и оператор конкатенации (“&”).
- Предопределённые операции для типа real_vector и time_vector включают операторы равенства и неравенства (“=” and “/=”) и оператор конкатенации (“&”).
- Логические операции над массивами/скалярными типами и логическое сокрощение (logical reduction operation) (see Sections 4.1 and 4.3) определены для типов bit_vector и boolean_vector, так как ония являются массивами с элементами типа bit и boolean соответственно.
In earlier versions of VHDL, the logical operators and, or, nand, nor, xor, and xnor were defined only as binary operators; that is, they each operated on two operands. The operands could be bit or boolean values, or they could be arrays of bit or boolean ele- ments. In the case of array operands, the logical operator is applied to corresponding array elements to produce an array result. In some models, we need to apply a logical operator to all of the elements of an array to produce a single scalar result. To do this in earlier versions of VHDL, we had to write a loop to apply the operator to the elements.
VHDL-2008 extends the definition of logical operators to allow them to be used as unary operators. Each such logical reduction operator is applied to a single operand that is an array of bit or boolean elements and produces a bit or boolean result, respectively. The std_logic_1164 package also defines overloaded logical reduction operators for std_ulogic_vector operands. Thus, the signature of each logical reduction operator is:
[ArrayType return ArrayElementType]
The reduction and, or, and xor operators form the logical AND, OR, and exclusive OR, respectively of the array elements. Thus:
and "0110" = '0' and '1' and '1' and '0' = '0' or "0110" = '0' or '1' or '1' or '0' = '1' xor "0110" = '0' xor '1' xor '1' xor '0' = '0'
In each case, if the array has only one element, the result is the value of that ele- ment. If the array is a null array (that is, it has no elements), the result of the and opera- tor is '1', and the result of the or and xor operators is '0'. The reduction nand, nor, and xnor operators are the negation of the reduction and, or, and xor operators, respectively. Thus:
nand "0110" = not ('0' and '1' and '1' and '0') = not '0' = '1' nor "0110" = not ('0' or '1' or '1' or '0') = not '1' = '0' xnor "0110" = not ('0' xor '1' xor '1' xor '0') = not '0' = '1'
In each case, application to a single-element array produces the negation of the ele- ment value. Application of nand to a null array produces '0', and application of nor or xnor to a null array produces '1'.
The logical reduction operators have the same precedence as the unary not and abs operators. In the absence of parentheses, they are evaluated before binary operators. So the expression:
and A or B
involves applying the reduction and operator to A, then applying the binary or operator to the result and B. In some cases, we need to include parentheses to make an expres- sion legal. For example, the expression:
and not X
is not legal without parentheses, since we cannot chain unary operators. Instead, we must write the expression as:
and (not X)
EXAMPLE 4.3 Parity of a vector value
Without reduction operators, calculating parity requires the following:
parity <= data(7) xor data(6) xor data(5) xor data(4) xor data(3) xor data(2) xor data(1) xor data(0);With reduction operators, calculating parity becomes
parity <= xor Data;Since reduction operators have higher precedence than binary logical operators, the following two asignments produce the same value:
parity_error1 <= (xor data) and received_parity; parity_error2 <= xor data and received_parity;However, for readability, parentheses are recommended.
- Операции соотношений (matching relational operators) “?=”, “?/=”, “?>”, “?>=”, “?<”, и “?<=” определены для типов bit и boolean. Кроме того, операторы “?=” и “?/=” определены для типов bit_vector и boolean_vector. (See Section 4.5.)
- Оператор состояния “??” (condition operator) определён для типа BIT (see Section 4.4).
VHDL-2008 provides two new language features that allow us to treat an expression producing a bit or std_ulogic value as a condition. The first of these features is a condi- tion operator, “??”, that converts from a bit or std_ulogic value to a boolean value. For bit, “??” converts '1' to true and '0' to false. For std_ulogic, “??” converts both '1' and 'H' to true and all other values to false. (We can also overload the operator for other user- defined types.) Thus, we could rewrite the if-statement condition shown above as:
if ?? control_sig then ...
эквивалентно записи
if control_sig = '1' then ...
- Операторы mod и rem определены для типа TIME, так как это физический тип (see Section 4.7).
- Операции maximum и minimum определены для всех предопределённых типов (see Section 4.6).
- Функции rising_edge и falling_edge определены для типов bit и boolean. До стандарта VHDL-2008, версия этой функции для типа bit была определена в пакете numeric_bit. Однако, то это было сделано для обеспечения совместимости с типом std_logic, определённым в пакете std_logic_1164. В стандарт VHDL-2008 включено определение этих функций в пакете standard. В версии стандарта VHDL-2008 в пакете numeric_bit переопределено определение этих функций, как ссылок (aliases) на предопределённые функции в пакете standard.
- Функция to_string определена для всех скалярных типов и для bit_vector (see Section 7.1). Кроме того функции to_bstring, to_ostring, и to_hstring и связанные ссылки (associated aliase) определены для типа bit_vector.
Левый | Операция | Правый | Результат |
---|---|---|---|
BOOLEAN_VECTOR | and, or, nand, nor, xor, xnor | BOOLEAN_VECTOR | BOOLEAN_VECTOR |
BOOLEAN_VECTOR | BOOLEAN | BOOLEAN_VECTOR | |
BOOLEAN | BOOLEAN_VECTOR | BOOLEAN_VECTOR | |
— | not | BOOLEAN_VECTOR | BOOLEAN_VECTOR |
— | and, or, nand, nor, xor, xnor | BOOLEAN_VECTOR | BOOLEAN |
BOOLEAN_VECTOR | sll, srl, sla, sra, rol, ror | INTEGER | BOOLEAN_VECTOR |
BOOLEAN_VECTOR | =, /=, <, <=, >, >=, ?=, ?/= | BOOLEAN_VECTOR | BOOLEAN |
BOOLEAN_VECTOR | & | BOOLEAN_VECTOR | BOOLEAN_VECTOR |
BOOLEAN_VECTOR | BOOLEAN | BOOLEAN_VECTOR | |
BOOLEAN | BOOLEAN_VECTOR | BOOLEAN_VECTOR | |
BOOLEAN | BOOLEAN | BOOLEAN_VECTOR | |
BOOLEAN_VECTOR | MINIMUM, MAXIMUM | BOOLEAN_VECTOR | BOOLEAN_VECTOR |
— | BOOLEAN_VECTOR | BOOLEAN |
type BOOLEAN_VECTOR is array (NATURAL range <>) of BOOLEAN; -- The predefined operations for this type are as follows: -- function "and" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "or" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "nand" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "nor" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "xor" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "xnor" (anonymous, anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "not" (anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "and" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "and" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "or" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "or" (anonymous: BOOLEAN; anonymous : BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "nand" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "nand" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "nor" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "nor" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "xor" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "xor" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "xnor" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) -- return BOOLEAN_VECTOR; -- function "xnor" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR; -- function "and" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "or" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "nand" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "nor" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "xor" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "xnor" (anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "sll" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "srl" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "sla" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "sra" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "rol" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "ror" (anonymous: BOOLEAN_VECTOR; anonymous: INTEGER) -- return BOOLEAN_VECTOR; -- function "=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "/=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "<" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "<=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function ">" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function ">=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "?=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "?/=" (anonymous, anonymous: BOOLEAN_VECTOR) return BOOLEAN; -- function "&" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN_VECTOR) return BOOLEAN_VECTOR; -- function "&" (anonymous: BOOLEAN_VECTOR; anonymous: BOOLEAN) return BOOLEAN_VECTOR; -- function "&" (anonymous: BOOLEAN; anonymous: BOOLEAN_VECTOR) return BOOLEAN_VECTOR; -- function "&" (anonymous: BOOLEAN; anonymous: BOOLEAN) return BOOLEAN_VECTOR; -- function MINIMUM (L, R: BOOLEAN_VECTOR) return BOOLEAN_VECTOR; -- function MAXIMUM (L, R: BOOLEAN_VECTOR) return BOOLEAN_VECTOR; -- function MINIMUM (L: BOOLEAN_VECTOR) return BOOLEAN; -- function MAXIMUM (L: BOOLEAN_VECTOR) return BOOLEAN;
Левый | Операция | Правый | Результат |
---|---|---|---|
BIT_VECTOR | and, or, nand, nor, xor, xnor | BIT_VECTOR | BIT_VECTOR |
BIT_VECTOR | BIT | BIT_VECTOR | |
BIT | BIT_VECTOR | BIT_VECTOR | |
— | not | BIT_VECTOR | BIT_VECTOR |
— | and, or, nand, nor, xor, xnor | BIT_VECTOR | BIT |
BIT_VECTOR | sll, srl, sla, sra, rol, ror | INTEGER | BIT_VECTOR |
BIT_VECTOR | =, /=, <, <=, >, >= | BIT_VECTOR | BOOLEAN |
BIT_VECTOR | ?=, ?/= | BIT_VECTOR | BIT |
BIT_VECTOR | & | BIT_VECTOR | BIT_VECTOR |
BIT_VECTOR | BIT | BIT_VECTOR | |
BIT | BIT_VECTOR | BIT_VECTOR | |
BIT | BIT | BIT_VECTOR | |
BIT_VECTOR | MINIMUM, MAXIMUM | BIT_VECTOR | BIT_VECTOR |
— | BIT_VECTOR | BIT | |
BIT_VECTOR | TO_STRING (alias: TO_BSTRING, TO_BINARY_STRING) | STRING | |
BIT_VECTOR | TO_OSTRING (alias: TO_OCTAL_STRING) | STRING | |
BIT_VECTOR | TO_HSTRING (alias: TO_HEX_STRING) | STRING |
type BIT_VECTOR is array (NATURAL range <>) of BIT; -- The predefined operations for this type are as follows: -- function "and" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "or" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "nand" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "nor" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "xor" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "xnor" (anonymous, anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "not" (anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "and" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "and" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "or" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "or" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "nand" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "nand" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "nor" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "nor" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "xor" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "xor" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "xnor" (anonymous: BIT_VECTOR; anonymous : BIT) return BIT_VECTOR; -- function "xnor" (anonymous: BIT; anonymous : BIT_VECTOR) return BIT_VECTOR; -- function "and" (anonymous: BIT_VECTOR) return BIT; -- function "or" (anonymous: BIT_VECTOR) return BIT; -- function "nand" (anonymous: BIT_VECTOR) return BIT; -- function "nor" (anonymous: BIT_VECTOR) return BIT; -- function "xor" (anonymous: BIT_VECTOR) return BIT; -- function "xnor" (anonymous: BIT_VECTOR) return BIT; -- function "sll" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "srl" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "sla" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "sra" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "rol" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "ror" (anonymous: BIT_VECTOR; anonymous: INTEGER) return BIT_VECTOR; -- function "=" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function "/=" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function "<" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function "<=" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function ">" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function ">=" (anonymous, anonymous: BIT_VECTOR) return BOOLEAN; -- function "?=" (anonymous, anonymous: BIT_VECTOR) return BIT; -- function "?/=" (anonymous, anonymous: BIT_VECTOR) return BIT; -- function "&" (anonymous: BIT_VECTOR; anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "&" (anonymous: BIT_VECTOR; anonymous: BIT) return BIT_VECTOR; -- function "&" (anonymous: BIT; anonymous: BIT_VECTOR) return BIT_VECTOR; -- function "&" (anonymous: BIT; anonymous: BIT) return BIT_VECTOR; -- function MINIMUM (L, R: BIT_VECTOR) return BIT_VECTOR; -- function MAXIMUM (L, R: BIT_VECTOR) return BIT_VECTOR; -- function MINIMUM (L: BIT_VECTOR) return BIT; -- function MAXIMUM (L: BIT_VECTOR) return BIT; -- function TO_STRING (VALUE: BIT_VECTOR) return STRING; -- alias TO_BSTRING is TO_STRING -- [BIT_VECTOR return STRING]; -- alias TO_BINARY_STRING is TO_STRING -- [BIT_VECTOR return STRING]; -- function TO_OSTRING (VALUE: BIT_VECTOR) return STRING; -- alias TO_OCTAL_STRING is TO_OSTRING -- [BIT_VECTOR return STRING]; -- function TO_HSTRING (VALUE: BIT_VECTOR) return STRING; -- alias TO_HEX_STRING is TO_HSTRING -- [BIT_VECTOR return STRING];
Левый | Операция | Правый | Результат |
---|---|---|---|
INTEGER_VECTOR | =, /=, <, <=, >, >= | INTEGER_VECTOR | BOOLEAN |
INTEGER_VECTOR | & | INTEGER_VECTOR | INTEGER_VECTOR |
INTEGER_VECTOR | INTEGER | INTEGER_VECTOR | |
INTEGER | INTEGER_VECTOR | INTEGER_VECTOR | |
INTEGER | INTEGER | INTEGER_VECTOR | |
INTEGER_VECTOR | MINIMUM, MAXIMUM | INTEGER_VECTOR | INTEGER_VECTOR |
— | INTEGER_VECTOR | INTEGER |
type INTEGER_VECTOR is array (NATURAL range <>) of INTEGER; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function "/=" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function "<" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function "<=" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function ">" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function ">=" (anonymous, anonymous: INTEGER_VECTOR) return BOOLEAN; -- function "&" (anonymous: INTEGER_VECTOR; -- anonymous: INTEGER_VECTOR) return INTEGER_VECTOR; -- function "&" (anonymous: INTEGER_VECTOR; -- anonymous: INTEGER) return INTEGER_VECTOR; -- function "&" (anonymous: INTEGER; -- anonymous: INTEGER_VECTOR) return INTEGER_VECTOR; -- function "&" (anonymous: INTEGER; -- anonymous: INTEGER) return INTEGER_VECTOR; -- function MINIMUM (L, R: INTEGER_VECTOR) return INTEGER_VECTOR; -- function MAXIMUM (L, R: INTEGER_VECTOR) return INTEGER_VECTOR; -- function MINIMUM (L: INTEGER_VECTOR) return INTEGER; -- function MAXIMUM (L: INTEGER_VECTOR) return INTEGER;
Левый | Операция | Правый | Результат |
---|---|---|---|
REAL_VECTOR | =, /= | REAL_VECTOR | BOOLEAN |
REAL_VECTOR | & | REAL_VECTOR | REAL_VECTOR |
REAL_VECTOR | REAL | REAL_VECTOR | |
REAL | REAL_VECTOR | REAL_VECTOR | |
REAL | REAL | REAL_VECTOR | |
— | MINIMUM, MAXIMUM | REAL_VECTOR | REAL |
type REAL_VECTOR is array (NATURAL range <>) of REAL; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: REAL_VECTOR) return BOOLEAN; -- function "/=" (anonymous, anonymous: REAL_VECTOR) return BOOLEAN; -- function "&" (anonymous: REAL_VECTOR; anonymous: REAL_VECTOR) return REAL_VECTOR; -- function "&" (anonymous: REAL_VECTOR; anonymous: REAL) return REAL_VECTOR; -- function "&" (anonymous: REAL; anonymous: REAL_VECTOR) return REAL_VECTOR; -- function "&" (anonymous: REAL; anonymous: REAL) return REAL_VECTOR; -- function MINIMUM (L: REAL_VECTOR) return REAL; -- function MAXIMUM (L: REAL_VECTOR) return REAL;
Левый | Операция | Правый | Результат |
---|---|---|---|
TIME_VECTOR | =, /= | TIME_VECTOR | BOOLEAN |
TIME_VECTOR | & | TIME_VECTOR | TIME_VECTOR |
TIME_VECTOR | TIME | TIME_VECTOR | |
TIME | TIME_VECTOR | TIME_VECTOR | |
TIME | TIME | TIME_VECTOR | |
— | MINIMUM, MAXIMUM | TIME_VECTOR | TIME |
type TIME_VECTOR is array (NATURAL range <>) of TIME; -- The predefined operations for this type are as follows: -- function "=" (anonymous, anonymous: TIME_VECTOR) return BOOLEAN; -- function "/=" (anonymous, anonymous: TIME_VECTOR) return BOOLEAN; -- function "&" (anonymous: TIME_VECTOR; anonymous: TIME_VECTOR) return TIME_VECTOR; -- function "&" (anonymous: TIME_VECTOR; anonymous: TIME) return TIME_VECTOR; -- function "&" (anonymous: TIME; anonymous: TIME_VECTOR) return TIME_VECTOR; -- function "&" (anonymous: TIME; anonymous: TIME) return TIME_VECTOR; -- function MINIMUM (L: TIME_VECTOR) return TIME; -- function MAXIMUM (L: TIME_VECTOR) return TIME;
Левый | Операция | Правый | Результат |
---|---|---|---|
— | TO_STRING | BIT | STRING |
BOOLEAN | |||
CHARACTER | |||
SEVERITY_LEVEL | |||
universal_integer | |||
universal_real | |||
INTEGER | |||
REAL | |||
TIME | |||
FILE_OPEN_KIND | |||
FILE_OPEN_STATUS | |||
VALUE: REAL | DIGITS: NATURAL | ||
VALUE: REAL | FORMAT: STRING | ||
VALUE: TIME | UNIT: TIME |
-- Predefined TO_STRING operations on scalar types -- function TO_STRING (VALUE: BOOLEAN) return STRING; -- function TO_STRING (VALUE: BIT) return STRING; -- function TO_STRING (VALUE: CHARACTER) return STRING; -- function TO_STRING (VALUE: SEVERITY_LEVEL) return STRING; -- function TO_STRING (VALUE: universal_integer) return STRING; -- function TO_STRING (VALUE: universal_real) return STRING; -- function TO_STRING (VALUE: INTEGER) return STRING; -- function TO_STRING (VALUE: REAL) return STRING; -- function TO_STRING (VALUE: TIME) return STRING; -- function TO_STRING (VALUE: FILE_OPEN_KIND) return STRING; -- function TO_STRING (VALUE: FILE_OPEN_STATUS) return STRING; -- Predefined overloaded TO_STRING operations -- function TO_STRING (VALUE: REAL; DIGITS: NATURAL) return STRING; -- function TO_STRING (VALUE: REAL; FORMAT: STRING) return STRING; -- function TO_STRING (VALUE: TIME; UNIT: TIME) return STRING;
Пакет STD.ENV
Добавлен новый пакет STD.ENV, в котором вводятся несколько функций:
- STOP — процедура остановки моделирования
- FINISH — процедура остановки моделирования с выходом из симулятора (modelsim/qustasim)
- resolution_limit — функция возвращает значения точности моделирования (тип DELAY_LENGTH)
procedure stop (STATUS : INTEGER := 0); procedure finish (STATUS : INTEGER := 0); function resolution_limit return DELAY_LENGTH;
В зависимости от значения параметра STATUS, передаваемого процедурам STOP и FINISH предусмотрен разный вывод в лог (консоль):
- 0 — ничего не выводит;
- 1 — выводит время моделирование и путь к entity в котором выполнена процедура;
- 2 — выводит время, расположение и статистику о задейсвованной памяти и ресурсу CPU при моделировании;
- другие значения STATUS интерпретируются как 0.
Пример
Файл: std_sim.vhd |
library std; use std.env.all; entity std_sim is end entity std_sim; architecture beh of std_sim is signal clk : bit := '0'; -- signal resolution : DELAY_LENGTH := resolution_limit; signal resolution : DELAY_LENGTH ; begin -- architecture beh p1: process is begin -- process p1 while (now <= 100 ns) loop wait for 10 ns; clk <= not clk; end loop; -- finish; -- finish(0); -- finish(1); finish(2); -- finish(3); -- stop(3); -- stop(2); -- stop(1); -- stop(0); -- stop; end process p1; end architecture beh; |
- Вызов функции
stop;
илиstop(0);
илиstop(3);
(или с любым другим числом >2):
# Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 25
- stop(1);
# ** Note: stop # Time: 110 ns Iteration: 0 Instance: /std_sim # Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 25
- stop(2);
# ** Note: Data structure takes 16558720 bytes of memory # Process time 0.00 seconds # stop # Time: 110 ns Iteration: 0 Instance: /std_sim # Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 25
- finish;
# 1 # Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 27
- finish(1);
# ** Note: finish # Time: 110 ns Iteration: 0 Instance: /std_sim # 1 # Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 29
- finish(2);
# ** Note: Data structure takes 16558720 bytes of memory # Process time 0.00 seconds # finish # Time: 110 ns Iteration: 0 Instance: /std_sim # 1 # Break in Process p1 at /home/kola/docs/osvvm.org/docs/sim/vhd/std_sim.vhd line 30
![]() |
В отличии от пакета STD.STANDARD декларацию пакета STD.ENV необходимо включать в VHDL-файл, чтобы его функции стали доступны: library std; use std.env.all; |
New types defined in this package: REAL_VECTOR - A vector of type real TIME_VECTOR - A vector of type time INTEGER_VECTOR - A vector of type integer BOOLEAN_VECTOR - a vector of type boolean New constants defined in this package: SIM_RESOLUTION : TIME - returns the simulator's resolution (1 ns default) New funcitons defined in this package: "maximum" and "minimum" are defined for all default datatypes _reduce functions (and_reduce, nand_reduce, or_reduce ...) are defined These functions reduce a bit_vector to a single bit. Example: or_reduce ("0101") = '1' In VHDL-2008 syntax these will be "or". "vector" and "bit" operations are defined. These will perform a boolean operation of a vector. Example: "1" xor "1010" = "0101"; /??/ function is defined for "bit" ("??" operator is release) if (/??/('1')) then -- will return a "true". rising_edge and falling_edge functions are defined (see Notes). to_string function - Converts any of the base types into a string. Example: assert (bv = "101") report "result was " & to_string(bv) severity note; to_hstring and to_ostring function (bit_vector to hex or octal string)
- tee - Echos the string to BOTH the file and the screen
- SREAD and SWRITE - String read and write routines
(so you no longer need to do write (L, string'("ABCEDFG"));
- HREAD and HWRITE (Hex read and write) for bit_vector
- OREAD and OWRITE (octal read and write) for bit_vector
- BREAD and BWRITE (binary read and write, same as "READ" and "WRITE" for bit_vector
- justify - Justify a string left or right with a width.
Example:
justify ("ABCD", left, 6); will result in "ABCD "
Листинги пакетов
Файл: standard.vhd |
-- This is Package STANDARD as defined in the VHDL 2008 Language Reference Manual. -- -- NOTE: VCOM and VSIM will not work properly if these declarations -- are modified. -- Version information: @(#)standard.vhd package STANDARD is type BOOLEAN is (FALSE,TRUE); type BIT is ('0', '1'); 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 character code for 160 is there (NBSP), -- but prints as no char ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ' ); type SEVERITY_LEVEL is (NOTE, WARNING, ERROR, FAILURE); type INTEGER is range -2147483648 to 2147483647; type REAL is range -1.0E308 to 1.0E308; type TIME is range -2147483647 to 2147483647 units fs; ps = 1000 fs; ns = 1000 ps; us = 1000 ns; ms = 1000 us; sec = 1000 ms; min = 60 sec; hr = 60 min; end units; subtype DELAY_LENGTH is TIME range 0 fs to TIME'HIGH; impure function NOW return DELAY_LENGTH; subtype NATURAL is INTEGER range 0 to INTEGER'HIGH; subtype POSITIVE is INTEGER range 1 to INTEGER'HIGH; type STRING is array (POSITIVE range <>) of CHARACTER; type BOOLEAN_VECTOR is array (NATURAL range <>) of BOOLEAN; type BIT_VECTOR is array (NATURAL range <>) of BIT; type INTEGER_VECTOR is array (NATURAL range <>) of INTEGER; type REAL_VECTOR is array (NATURAL range <>) of REAL; type TIME_VECTOR is array (NATURAL range <>) of TIME; type FILE_OPEN_KIND is ( READ_MODE, WRITE_MODE, APPEND_MODE); type FILE_OPEN_STATUS is ( OPEN_OK, STATUS_ERROR, NAME_ERROR, MODE_ERROR); attribute FOREIGN : STRING; end STANDARD; |
Файл: env.vhd |
package ENV is procedure stop (STATUS : INTEGER := 0); procedure finish (STATUS : INTEGER := 0); function resolution_limit return DELAY_LENGTH; end ENV; package body env is -- For both STOP and FINISH the STATUS values are those used -- in the Verilog $finish task -- 0 prints nothing -- 1 prints simulation time and location -- 2 prints simulation time, location, and statistics about -- the memory and CPU times used in simulation -- Other STATUS values are interpreted as 0. procedure stop (STATUS : INTEGER :=0 ) is begin assert false report "ERROR: builtin subprogram STOP not called" severity note; end; procedure finish (STATUS : INTEGER := 0 ) is begin assert false report "ERROR: builtin subprogram FINISH not called" severity note; end; function resolution_limit return delay_length is begin assert false report "ERROR: builtin function RESOLUTION_LIMIT not called" severity note; return 0 hr; end; end env; |
Файл: textio.vhd |
--------------------------------------------------------------------------- -- Package TEXTIO as defined in Chapter 14 of the IEEE Standard VHDL -- Language Reference Manual (IEEE Std. 1076-1987), as modified -- by the Issues Screening and Analysis Committee (ISAC), a subcommittee -- of the VHDL Analysis and Standardization Group (VASG) on -- 10 November, 1988. See "The Sense of the VASG", October, 1989. -- VHDL2008 features added. --------------------------------------------------------------------------- -- Version information: %W% %G% --------------------------------------------------------------------------- -- Note: Some of the procedures are not yet accelerated. Many of these implementations -- were written by Dave Bishop of Kodak and are not normative. -- There are questions whether some -- corner cases and error cases are handled correctly. When these issues are resolved -- implementations will be updated, possible in ways not compatible with these -- current implementations. -- Also some routines dont accept underlines when they should. package TEXTIO is type LINE is access string; -- procedure DEALLOCATE (P : inout LINE); type TEXT is file of string; -- procedure FLUSH (file F : TEXT); type SIDE is (right, left); -- function MINIMUM (L, R : SIDE) return SIDE; -- function MAXIMUM (L, R : SIDE) return SIDE; -- function TO_STRING (VALUE : SIDE) return STRING; subtype WIDTH is natural; function JUSTIFY (VALUE : STRING; JUSTIFIED : SIDE := right; FIELD : WIDTH := 0) return STRING; -- changed for vhdl92 syntax: file input : TEXT open read_mode is "STD_INPUT"; file output : TEXT open write_mode is "STD_OUTPUT"; -- changed for vhdl92 syntax (and now a built-in): procedure READLINE(file f: TEXT; L: out LINE); procedure READ(L:inout LINE; VALUE: out bit; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out bit); procedure READ(L:inout LINE; VALUE: out bit_vector; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out bit_vector); procedure READ(L:inout LINE; VALUE: out BOOLEAN; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out BOOLEAN); procedure READ(L:inout LINE; VALUE: out character; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out character); procedure READ(L:inout LINE; VALUE: out integer; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out integer); procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out real); procedure READ(L:inout LINE; VALUE: out string; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out string); procedure READ(L:inout LINE; VALUE: out time; GOOD : out BOOLEAN); procedure READ(L:inout LINE; VALUE: out time); procedure SREAD (L : inout LINE; VALUE : out STRING; STRLEN : out NATURAL); alias STRING_READ is SREAD [LINE, STRING, NATURAL]; alias BREAD is READ [LINE, BIT_VECTOR, BOOLEAN]; alias BREAD is READ [LINE, BIT_VECTOR]; alias BINARY_READ is READ [LINE, BIT_VECTOR, BOOLEAN]; alias BINARY_READ is READ [LINE, BIT_VECTOR]; procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN); procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR); alias OCTAL_READ is OREAD [LINE, BIT_VECTOR, BOOLEAN]; alias OCTAL_READ is OREAD [LINE, BIT_VECTOR]; procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN); procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR); alias HEX_READ is HREAD [LINE, BIT_VECTOR, BOOLEAN]; alias HEX_READ is HREAD [LINE, BIT_VECTOR]; -- changed for vhdl92 syntax (and now a built-in): procedure WRITELINE(file f : TEXT; L : inout LINE); procedure TEE (file F : TEXT; L : inout LINE); procedure WRITE(L : inout LINE; VALUE : in bit; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in bit_vector; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in BOOLEAN; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in character; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in integer; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in real; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0; DIGITS: in NATURAL := 0); procedure WRITE (L : inout LINE; VALUE : in REAL; FORMAT : in STRING); procedure WRITE(L : inout LINE; VALUE : in string; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0); procedure WRITE(L : inout LINE; VALUE : in time; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0; UNIT: in TIME := ns); alias SWRITE is WRITE [LINE, STRING, SIDE, WIDTH]; alias STRING_WRITE is WRITE [LINE, STRING, SIDE, WIDTH]; alias BWRITE is WRITE [LINE, BIT_VECTOR, SIDE, WIDTH]; alias BINARY_WRITE is WRITE [LINE, BIT_VECTOR, SIDE, WIDTH]; procedure OWRITE (L : inout LINE; VALUE : in BIT_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0); alias OCTAL_WRITE is OWRITE [LINE, BIT_VECTOR, SIDE, WIDTH]; procedure HWRITE (L : inout LINE; VALUE : in BIT_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0); alias HEX_WRITE is HWRITE [LINE, BIT_VECTOR, SIDE, WIDTH]; -- is implicit built-in: -- function ENDFILE(file F : TEXT) return boolean; -- function ENDLINE(variable L : in LINE) return BOOLEAN; -- -- Function ENDLINE as declared cannot be legal VHDL, and -- the entire function was deleted from the definition -- by the Issues Screening and Analysis Committee (ISAC), -- a subcommittee of the VHDL Analysis and Standardization -- Group (VASG) on 10 November, 1988. See "The Sense of -- the VASG", October, 1989, VHDL Issue Number 0032. end; --******************************************************* --** ** --** Copyright 1991-2011 Mentor Graphics Corporation ** --** ** --** All Rights Reserved ** --** ** --** THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY ** --** INFORMATION WHICH IS THE PROPERTY OF MENTOR ** --** GRAPHICS CORPORATION OR ITS LICENSORS AND IS ** --** SUBJECT TO LICENSE TERMS. ** --** ** --******************************************************* -- There is no true source-code package body for textio -- since the code is all accellerated package body TEXTIO is constant NBSP : CHARACTER := CHARACTER'val(160); -- space character function JUSTIFY (VALUE : STRING; JUSTIFIED : SIDE := right; FIELD : WIDTH := 0) return STRING is begin assert false report "ERROR: builtin subprogram JUSTIFY not called" severity note; return value; end; procedure READLINE(file f: TEXT; L: out LINE) is begin assert false report "ERROR: builtin subprogram READLINE not called" severity note; end; procedure READ(L:inout LINE; VALUE: out bit; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram RAD(line,bit.boolead) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out bit) is begin assert false report "ERROR: builtin subprogram read(line,bit) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out bit_vector; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram read(line,bit_vector,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out bit_vector) is begin assert false report "ERROR: builtin subprogram read(line,bit_vector) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out BOOLEAN; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram read(line,boolean,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out BOOLEAN) is begin assert false report "ERROR: builtin subprogram READ(line,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out character; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram read(line,character,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out character) is begin assert false report "ERROR: builtin subprogram read(line,character) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out integer; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram READ(line,integer,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out integer) is begin assert false report "ERROR: builtin subprogram READ(line,integer) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out real; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram READ(line,read,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out real) is begin assert false report "ERROR: builtin subprogram READ(line,real) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out string; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram READ(line,string,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out string) is begin assert false report "ERROR: builtin subprogram READ(Line,string) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out time; GOOD : out BOOLEAN) is begin assert false report "ERROR: builtin subprogram READ(line,string,boolean) not called" severity note; end; procedure READ(L:inout LINE; VALUE: out time) is begin assert false report "ERROR: builtin subprogram READ(line,time) not called" severity note; end; procedure SREAD (L : inout LINE; VALUE : out STRING; STRLEN : out NATURAL) is begin assert false report "ERROR: builtin subprogram SREAD not called" severity note; end; -- Procedure only visible internally. procedure Char2TriBits (C : CHARACTER; RESULT : out BIT_VECTOR(2 downto 0); GOOD : out BOOLEAN; ISSUE_ERROR : in BOOLEAN) is begin case c is when '0' => result := o"0"; good := true; when '1' => result := o"1"; good := true; when '2' => result := o"2"; good := true; when '3' => result := o"3"; good := true; when '4' => result := o"4"; good := true; when '5' => result := o"5"; good := true; when '6' => result := o"6"; good := true; when '7' => result := o"7"; good := true; when others => assert not ISSUE_ERROR report "TEXTIO.OREAD Error: Read a '" & c & "', expected an Octal character (0-7)." severity error; GOOD := false; end case; end procedure Char2TriBits; procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN) is variable ok : BOOLEAN; variable c : CHARACTER; constant ne : INTEGER := (VALUE'length+2)/3; constant pad : INTEGER := ne*3 - VALUE'length; variable sv : BIT_VECTOR(0 to ne*3 - 1) := (others => '0'); variable s : STRING(1 to ne-1); begin VALUE (VALUE'range) := (others => '0'); loop -- skip white space read(l, c, ok); exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT)); end loop; -- Bail out if there was a bad read if not ok then GOOD := false; return; end if; Char2TriBits(c, sv(0 to 2), ok, false); if not ok then GOOD := false; return; end if; read(L, s, ok); if not ok then GOOD := false; return; end if; for i in 1 to ne-1 loop Char2TriBits(s(i), sv(3*i to 3*i+2), ok, false); if not ok then GOOD := false; return; end if; end loop; if (or(sv (0 to pad-1))) = '1' then GOOD := false; -- vector was truncated. else GOOD := true; VALUE := sv (pad to sv'high); end if; end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR) is variable c : CHARACTER; variable ok : BOOLEAN; constant ne : INTEGER := (VALUE'length+2)/3; constant pad : INTEGER := ne*3 - VALUE'length; variable sv : BIT_VECTOR(0 to ne*3 - 1) := (others => '0'); variable s : STRING(1 to ne-1); begin VALUE (VALUE'range) := (others => '0'); loop -- skip white space read(l, c, ok); exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT)); end loop; -- Bail out if there was a bad read if not ok then report "TEXTIO.OREAD Error: Failed skipping white space" severity error; return; end if; Char2TriBits(c, sv(0 to 2), ok, true); if not ok then return; end if; read(L, s, ok); if not ok then report "TEXTIO.OREAD Error: Failed to read the STRING" severity error; return; end if; for i in 1 to ne-1 loop Char2TriBits(s(i), sv(3*i to 3*i+2), ok, true); if not ok then return; end if; end loop; if (or(sv (0 to pad-1))) = '1' then report "TEXTIO.OREAD Error: Vector truncated" severity error; else VALUE := sv (pad to sv'high); end if; end procedure OREAD; -- Hex Read and Write procedures for bit_vector. -- Procedure only visible internally. procedure Char2QuadBits (C : CHARACTER; RESULT : out BIT_VECTOR(3 downto 0); GOOD : out BOOLEAN; ISSUE_ERROR : in BOOLEAN) is begin case c is when '0' => result := x"0"; good := true; when '1' => result := x"1"; good := true; when '2' => result := x"2"; good := true; when '3' => result := x"3"; good := true; when '4' => result := x"4"; good := true; when '5' => result := x"5"; good := true; when '6' => result := x"6"; good := true; when '7' => result := x"7"; good := true; when '8' => result := x"8"; good := true; when '9' => result := x"9"; good := true; when 'A' | 'a' => result := x"A"; good := true; when 'B' | 'b' => result := x"B"; good := true; when 'C' | 'c' => result := x"C"; good := true; when 'D' | 'd' => result := x"D"; good := true; when 'E' | 'e' => result := x"E"; good := true; when 'F' | 'f' => result := x"F"; good := true; when others => assert not ISSUE_ERROR report "TEXTIO.HREAD Error: Read a '" & c & "', expected a Hex character (0-F)." severity error; GOOD := false; end case; end procedure Char2QuadBits; procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN) is variable ok : BOOLEAN; variable c : CHARACTER; constant ne : INTEGER := (VALUE'length+3)/4; constant pad : INTEGER := ne*4 - VALUE'length; variable sv : BIT_VECTOR (0 to ne*4 - 1) := (others => '0'); variable s : STRING(1 to ne-1); begin VALUE (VALUE'range) := (others => '0'); loop -- skip white space read(l, c, ok); exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT)); end loop; -- Bail out if there was a bad read if not ok then GOOD := false; return; end if; Char2QuadBits(c, sv(0 to 3), ok, false); if not ok then GOOD := false; return; end if; read(L, s, ok); if not ok then GOOD := false; return; end if; for i in 1 to ne-1 loop Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, false); if not ok then GOOD := false; return; end if; end loop; if (or(sv (0 to pad-1))) = '1' then GOOD := false; -- vector was truncated. else GOOD := true; VALUE := sv (pad to sv'high); end if; end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR) is variable ok : BOOLEAN; variable c : CHARACTER; constant ne : INTEGER := (VALUE'length+3)/4; constant pad : INTEGER := ne*4 - VALUE'length; variable sv : BIT_VECTOR(0 to ne*4 - 1) := (others => '0'); variable s : STRING(1 to ne-1); begin VALUE (VALUE'range) := (others => '0'); loop -- skip white space read(l, c, ok); exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT)); end loop; -- Bail out if there was a bad read if not ok then report "TEXTIO.HREAD Error: Failed skipping white space" severity error; return; end if; Char2QuadBits(c, sv(0 to 3), ok, true); if not ok then return; end if; read(L, s, ok); if not ok then report "TEXTIO.HREAD Error: Failed to read the STRING" severity error; return; end if; for i in 1 to ne-1 loop Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, true); if not ok then return; end if; end loop; if (or (sv (0 to pad-1))) = '1' then report "TEXTIO.HREAD Error: Vector truncated" severity error; else VALUE := sv (pad to sv'high); end if; end procedure HREAD; procedure WRITELINE(file f : TEXT; L : inout LINE) is begin assert false report "ERROR: builtin subprogram WRITELINE not called" severity note; end; -- Writes L to a file without modifying the contents of the line procedure tee (file F : TEXT; variable L : inout LINE) is begin write (OUTPUT, L.all & LF); writeline(F, L); end procedure tee; procedure WRITE(L : inout LINE; VALUE : in bit; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,bit,side,width) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in bit_vector; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,bit_vector) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in BOOLEAN; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,boolean) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in character; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,character) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in integer; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,integer) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in real; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0; DIGITS: in NATURAL := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,real) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in STRING; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0) is begin assert false report "ERROR: builtin subprogram WRITE(line,string) not called" severity note; end; procedure WRITE(L : inout LINE; VALUE : in TIME; JUSTIFIED: in SIDE := right; FIELD: in WIDTH := 0; UNIT: in TIME := ns) is begin assert false report "ERROR: builtin subprogram WRITE(line,time) not called" severity note; end; procedure OWRITE (L : inout LINE; VALUE : in BIT_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is begin write (L => L, VALUE => to_ostring(VALUE), JUSTIFIED => JUSTIFIED, FIELD => FIELD); end procedure OWRITE; procedure HWRITE (L : inout LINE; VALUE : in BIT_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is begin write (L => L, VALUE => to_hstring(VALUE), JUSTIFIED => JUSTIFIED, FIELD => FIELD); end procedure HWRITE; procedure WRITE (L: inout LINE; VALUE: in REAL; FORMAT: in STRING) is begin swrite ( L => L, VALUE => to_string (VALUE, FORMAT)); end procedure WRITE; end textio; |