Understanding VHDL Operators
The following charts summarize the operators available in VHDL. As indicated, not all operators can be used for all data types, and the data type that results from an operation may differ from the type of the object on which the operation is performed.
Note: Operations defined for types Bit are also valid for type std_ulogic and std_logic.
Logical operators
The logical operators and, or, nand, nor, xor and xnor are used to describe Boolean logic operations, or perform bit-wise operations, on bits or arrays of bits.
Operator |
Description |
Operand Types |
Result Types |
and |
And |
Any Bit or Boolean type |
Same Type |
or |
Or |
Any Bit or Boolean type |
Same Type |
nand |
Not And |
Any Bit or Boolean type |
Same Type |
nor |
Not Or |
Any Bit or Boolean type |
Same Type |
xor |
Exclusive OR |
Any Bit or Boolean type |
Same Type |
xnor |
Exclusive NOR |
Any Bit or Boolean type |
Same Type |
Relational operators
Relational operators are used to test the relative values of two scalar types. The result of a relational operation is always a Boolean true or false value.
Operator |
Description |
Operand Types |
Result Type |
= |
Equality |
Any type |
Boolean |
/= |
Inequality |
Any type |
Boolean |
< |
Less than |
Any scalar type or discrete array |
Boolean |
<= |
Less than or equal |
Any scalar type or discrete array |
Boolean |
> |
Greater than |
Any scalar type or discrete array |
Boolean |
>= |
Greater than or equal |
Any scalar type or discrete array |
Boolean |
Adding operators
The adding operators can be used to describe arithmetic functions or, in the case of array types, concatenation operations.
Operator |
Description |
Operand Types |
Result Type |
+ |
Addition |
Any numeric type |
Same type |
- |
Subtraction |
Any numeric type |
Same type |
& |
Concatenation |
Any numeric type |
Same type |
& |
Concatenation |
Any array or element type |
Same array type |
Multiplying operators
The multiplying operators can be used to describe mathematical functions on numeric types.
Note: Synthesis tools vary in their support for multiplying operators.
Operator |
Description |
Operand Types |
Result Type |
* |
Multiplication |
Left: any integer or floating point type. |
Same as left |
* |
Multiplication |
Left: any physical type. |
Same as left |
* |
Multiplication |
Left: integer or real type. |
Same as right |
/ |
Division |
Left: any integer or floating point type. |
Same as left |
/ |
Division |
Left: any integer or floating point type. |
Same as left |
/ |
Division |
Left: integer or real type. |
Same as right |
mod |
Modulus |
Any integer type |
Same type |
rem |
Remainder |
Any integer type |
Same type |
Sign operators
Sign operators can be used to specify the sign (either postive or negative) of a numeric object or literal.
Operator |
Description |
Operand Types |
Result Type |
+ |
Identity |
Any numeric type |
Same type |
- |
Negation |
Any numeric type |
Same type |
Miscellaneous operators
The exponentiation and absolute value operators can be applied to numeric types, in which case they result in the same numeric type. The logical negation operator results in the same type (bit or Boolean), but with the reverse logical polarity. The shift operators provide bit-wise shift and rotate operatons for arrays of type bit or Boolean.
Operator |
Description |
Operand Types |
Result Type |
** |
Exponentiation |
Left: any integer type |
Same as left |
** |
Exponentiation |
Left: any floating point type |
Same as left |
abs |
Absolute value |
Any numeric type |
Same as left type |
not |
Logical negation |
Any Bit or Boolean type |
Same as left type |
sll |
Shift left logical |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
srl |
Shift right logical |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
sla |
Shift left arithmetic |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
sra |
Shift right arithmetic |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
rol |
Rotate left |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
ror |
Rotate right |
Left: Any one-dimensinal arrayof Bit or Boolean |
Same as left type |
See also