Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ЛО САПР / VHDL.PDF
Скачиваний:
43
Добавлен:
17.04.2013
Размер:
5.27 Mб
Скачать
-- Ambiguous; could be of -- type ARR_1 or ARR_2

Expressions

You can separate the digits in a bit-string literal value with underscores (_ ) for readability. The following example shows three bit string literals that represent the value AAA.

X"AAA"

B"1010_1010_1010"

O"5252”

Qualified Expressions

Qualified expressions state the type of an ambiguous operand. You cannot use qualified expressions for type conversion. (See the “Type Conversions” section of this chapter.)

The syntax of a qualified expression follows.

type_name’(expression)

type_name is the name of a defined type. The expression must evaluate to a value of an appropriate type.

Note: Foundation Express requires a single quotation mark (tick) between type_name and (expression). If the single quotation mark is omitted, the construction is interpreted as a type conversion (described in the next section).

The following example shows a qualified expression that resolves an overloaded function by qualifying the type of a decimal literal parameter.

type R_1 is range 0 to 10;

-- Integer 0 to 10

type R_2 is range 0 to 20;

-- Integer 0 to 20

function FUNC(A: R_1)

return BIT;

function FUNC(A: R_2)

return BIT;

FUNC(5)

-- Ambiguous; could be of type R_1,

 

--

R_2, or INTEGER

FUNC(R_1’(5))

-- Unambiguous

The following example shows how qualified expressions resolve ambiguities in aggregates and enumeration literals.

type ARR_1 is array(0 to 10) of BIT; type ARR_2 is array(0 to 20) of BIT;

. . .

(others => ’0’)

VHDL Reference Guide

4-25

VHDL Reference Guide

ARR_1’(others => ’0’) -- Qualified; unambiguous

-----------------------------------------------------

type ENUM_1 is (A, B);

type ENUM_2 is (B, C);

 

 

 

. . .

 

 

 

B

-- Ambiguous;

could be of

 

--

type ENUM_1 or ENUM_2

ENUM_1’(B)

--

Qualified;

unambiguous

Records and Fields

Records are composed of named fields of any type. For more information, see the “Record Types” section of the “Data Types” chapter.

In an expression, you can refer to a whole record or to a single field. The syntax of field names follows.

record_name.field_name

record_name is the name of the record variable or signal. A record_ name is different for each variable or signal of that record type.

field_name is the name of a field in that record type. A field_name is separated from the record_name by a period (.). A field_name is the field name defined for that record type.

The example below shows a record type definition and record and field access.

type BYTE_AND_IX is record

BYTE: BIT_VECTOR(7 downto 0); IX: INTEGER range 0 to 7;

end record;

signal X: BYTE_AND_IX;

. . .

X

-- record

 

X.BYTE

--

field:

8-bit array

X.IX

--

field:

integer

A field can be any type, including an array, record, or aggregate type. Refer to a field element by using that type’s notation as in the following example.

4-26

Xilinx Development System

Соседние файлы в папке ЛО САПР