# Programmable Logic/VHDL Operators

    < 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.
| operator | examples | description |
| sl and sl | a_sl <= b_sl and c_sl a_sl <= ieee.std_logic_1164."and"(b_sl, c_sl); | a_sl will be '1' iff both b_sl and c_sl is '1' |
| slv and slv | a_slv <= b_slv and c_slv a_slv <= ieee.std_logic_1164."and"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |
| sl or sl | a_sl <= b_sl or c_sl a_sl <= ieee.std_logic_1164."or"(b_sl, c_sl); | a_sl will be '1' iff at least one of b_sl and c_sl is '1'. |
| slv or slv | a_slv <= b_slv or c_slv a_slv <= ieee.std_logic_1164."or"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |
| sl xor sl | a_sl <= b_sl xor c_sl a_sl <= ieee.std_logic_1164."xor"(b_sl, c_sl); | a_sl will be '1' iff exactly one of b_sl and c_sl is '1'. |
| slv xor slv | a_slv <= b_slv xor c_slv a_slv <= ieee.std_logic_1164."xor"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |
| not sl | a_sl <= not b_sl a_sl <= ieee.std_logic_1164."not"(b_sl); | a_sl will be inverse of b_sl, that is '1' iff b_sl = '0'. |
| not slv | a_slv <= not b_slv a_slv <= ieee.std_logic_1164."not"(b_slv); | Applied to each respectively bits in a_slv, b_slv. a_slv, b_slv must have equal length (e.g. 8 bits) |
| sl nand sl | a_sl <= b_sl nand c_sl a_sl <= ieee.std_logic_1164."nand"(b_sl, c_sl); | a_sl will be '1' iff at least one of b_sl and c_sl is '0'. Equivalent to not (sl and sl) |
| slv nand slv | a_slv <= b_slv nand c_slv a_slv <= ieee.std_logic_1164."nand"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |
| sl nor sl | a_sl <= b_sl nor c_sl a_sl <= ieee.std_logic_1164."nor"(b_sl, c_sl); | a_sl will be '1' iff both b_sl and c_sl is '0'. Equivalent to not (sl or sl) |
| slv nor slv | a_slv <= b_slv nor c_slv a_slv <= ieee.std_logic_1164."nor"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |
| sl xnor sl | a_sl <= b_sl xnor c_sl a_sl <= ieee.std_logic_1164."xnor"(b_sl, c_sl); | a_sl will be '1' iff both b_sl and c_sl is either '1' or '0'. Equivalent to not (sl xor sl) |
| slv xnor slv | a_slv <= b_slv xnor c_slv a_slv <= ieee.std_logic_1164."xnor"(b_slv, c_slv); | Applied to each respectively bits in a_slv, b_slv, c_slv. a_slv, b_slv, c_slv must have equal length (e.g. 8 bits) |

## Operators
### 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 :
| + | Identity |
| - | Negation |
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
| * | Multiplication |
| / | Division |
| mod | Modulus |
| rem | Remainder |

### Miscellaneous operators

The two miscellaneous operators are shown in the Table 14. Table 14. Miscellaneous operators
| ** | Exponentiation |
| abs | Absolute value |
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.

### Examples
#### 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.

#### Example 9
### 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.