Programmable Logic/VHDL Operators


 * &lt; Programmable Logic/VHDL

This page is going to discuss VHDL Operators.

Some abbreviations used in this text:
 * int - integer, a data type
 * sl - std_logic, a data type (in most cases replacable with bit)
 * slv - std_logic_vector, a data type (in most cases replacable with bit_vector)
 * slu - std_logic_unsigned - a part of library ieee.
 * sls - std_logic_signed - a part of library ieee.
 * iff - "if and only if"

Logical Operators
This list is far from complete.

Sign Operators
Sign operators are unary operators, i.e. have only one, right operand, which must be of a numeric type. The result of the expression evaluation is of the same type as the operand. There are two sign operators (Table 12).

Table 12 : Sign operators :

When ( + ) sign operator is used, the operand is returned unchanged, but In case of ( - ) sign operator the value of operand with the negated sign is returned. Because of the lower priority, the sign operator in the expression cannot be directly preceded by the multiplication operator, the exponentiation operator (**) or the abs and not operators. When these operators are used then sign operator and its operand should be enclosed in parentheses (Example 7).

Multiplying Operators
The multiplication and division operators are predefined for all integers, floating point numbers. Under certain conditions, they may be used for operations on physical type objects as well. The mod and rem operators, on the other hand, are defined only for the integers. When mod and rem operators are used, then both the operands and the result are of the same integer type. The multiplying operators are shown in the Table 13.

Table 13. Multiplying operators

Miscellaneous operators
The two miscellaneous operators are shown in the Table 14.

Table 14. Miscellaneous operators The abs operator has only one operand. It allows defining the operand's absolute value. The result is of the same type as the operand. The exponentiation operator has two operands. This operator is defined for any integer or floating point number. The right operand (exponent) must be of integer type. When the exponent is the positive integer, then the left operand is repeatedly multiplied by itself. When the exponent is the negative number, then the result is a reverse of exponentiation with the exponent equal to the absolute value of the right operand (Example 9). If the exponent is equal to 0 the result will be 1.

Example 1
The multiplication y*x is carried out first, then a is added to the result of multiplication. This is because the multiplication operator has higher level of priority than the adding operator.

Example 2
For the initial value of the variables We1, We2, We3 equal to '1', the result is assigned to the variable Wy and is equal to '0'.

Example 7
The same expressions without parentheses would be illegal.

Important Notes

 * All predefined operators for standard types are declared in the package STANDARD.
 * The operator not is classified as a miscellaneous operator only for the purpose of defining precedence. Otherwise, it is classified as a logical operator.