VHDL OPERATORS
The predefined operators in the VHDL language are classified into
the following five categories:
1. Logical
operators
2. Relational
operators
3. Adding operators
4. Multiplying
operators
5. Miscellaneous
operators
·
The operators have increasing precedence going from category (1)
to (5).
·
Operators in the same category have the same precedence and
evaluation is done left to right.
·
Parentheses may be used to override the left to right evaluation.
1. Logical Operators
The six logical operators
are
and or nand nor xor not
These operators are defined
for (one-dimensional arrays) the predefined types BIT and BOOLEAN.
During evaluation, bit
values '0' and 1' are treated as FALSE and TRUE values of the BOOLEAN type,
respectively. The result of a logical operation has the same type as its operands.
The not operator is a unary
logical operator which has the same precedence as that of miscellaneous
operators.
2. Relational Operators
These are
= /= < <= > >=
The result types for all
relational operations is always BOOLEAN.
The = (equality) and the /=
(inequality) operators are permitted on any type except file types.
The remaining four
relational operators are permitted on any scalar type (e.g., integer or
enumerated types) or discrete array type (i.e., arrays in which element values
belong to a discrete type).
When operands are discrete
array types, comparison is performed one element at a time from left to right.
Eg.,
BIT_VECTOR'('0', '1', '1') <
BIT_VECTOR'('1', '0', '1')
is true, since the first
element in the first array aggregate is less than the first element in the
second aggregate.
Also, if
type MVL is ('U', '0', '1', 'Z' );
then,
MVL'( 'U' ) < MVL'( 'Z'
)
is true since 'U' occurs to
the left of 'Z'.
3. Adding Operators
These are
+
- &
The operands for the +
(addition) and - (subtraction) operators must be of the same numeric type with
the result being of the same numeric type.
The addition and subtraction
operators may also be used as unary operators then the operand and the result
type must be the same.
The operands for the &
(concatenation) operator can be either a I-dirnensional array type or an
element type. The result is always an array type.
Eg.,
'0' & '1'
results in an array of
characters "01".
'C' & 'A' & 'T'
results in the value
"CAT".
"BA" & "LL"
creates an array of
characters "BALL".
4. Multiplying Operators
These are
* / mod rem
The * (multiplication) and
/ (division) operators are predefined for both operands being of the same
integer or floating point type. The result is also of the same type.
The multiplication operator
is also defined for the case when one of the operands is of a physical type and
the second operand is of integer or real type. The result is of physical type.
For the division operator, division of an object of a physical
type by either an integer or a real type object is allowed and the result type
is of the physical type.
Division of an object of a physical type by another object of the same
physical type is also defined and it yields an integer value as a result.
The rem (remainder) and mod (modulus) operators operate on
operands of integer types and the result is also of the same type.
The result of a rem operation has the sign of its first operand
and is defined as
A rem B = A - ( A / B ) * B
The result of a mod operator has the sign of the second operand
and is defined as
A mod B = A – B * N -For some integer N.
5. Miscellaneous Operators
The miscellaneous operators are
abs **
The abs (absolute) operator is defined for any numeric
type.
The ** (exponentiation) operator is defined for the left
operand to be of integer or floating point type and the right operand (i.e.,
the exponent) to be of integer type only.
The not logical operator
has the same precedence as the above two operators.
No comments:
Post a Comment