Skip to content

Vhdl Assignment Operators Php

< Programmable Logic/VHDL

Programmable Logic

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[edit]

This list is far from complete.

operatorexamplesdescription
sl and sla_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 slva_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 sla_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 slva_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 sla_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 slva_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 sla_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 slva_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 sla_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 slva_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 sla_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 slva_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 sla_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 slva_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)

Arithmetic Operators[edit]

Relational Operators[edit]

Shift and Rotate[edit]

This page or section is an undeveloped draft or outline.
You can help to develop the work, or you can ask for assistance in the project room.

Operators[edit]

Sign Operators[edit]

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[edit]

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
modModulus
remRemainder

Miscellaneous operators[edit]

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

**Exponentiation
absAbsolute 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[edit]

Example 1[edit]

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[edit]

variableWe1,We2,We3,Wy:BIT:='1';Wy:=We1andWe2xnorWe1norWe3;

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 3[edit]

variableZm1:REAL:=100.0;variableZm2:BIT_VECTOR(7downto0):=('0','0','0','0','0','0','0','0');variableZm3,Zm4:BIT_VECTOR(1to0);Zm1/=342.54-- TrueZm1=100.0-- TrueZm2/=('1','0','0','0','0','0','0','0')-- TrueZm3=Zm4-- TrueExample4Zm1>42.54-- TrueZm1>=100.0-- TrueZm2<('1','0','0','0','0','0','0','0')-- TrueZm3<=Zm2-- True

Example 5[edit]

variableZm5:BIT_VECTOR(3downto0):=('1','0','1','1');Zm5sll1-- ('0', '1', '1', '0')Zm5sll3-- ('1', '0', '0', '0')Zm5sll-3-- Zm5 srl 3Zm5srl1-- ('0', '1', '0', '1')Zm5srl3-- ('0', '0', '0', '1')Zm5srl-3-- Zm5 sll 3Zm5sla1-- ('0', '1', '1', '1')Zm5sla3-- ('1', '1', '1', '1')Zm5sla-3-- Zm5 sra 3Zm5sra1-- ('1', '1', '0', '1')Zm5sra3-- ('1', '1', '1', '1')Zm5sra-3-- Zm5 sla 3Zm5rol1-- ('0', '1', '1', '1')Zm5rol3-- ('1', '1', '0', '1')Zm5rol-3-- Zm5 ror 3Zm5ror1-- ('1', '1', '0', '1')Zm5ror3-- ('0', '1', '1', '1')Zm5ror-3-- Zm5 rol 3

Example 6[edit]

constantB1:BIT_VECTOR:="0000";-- four element arrayconstantB2:BIT_VECTOR:="1111";-- four element arrayconstantB3:BIT_VECTOR:=B1&B2;-- eight element array, ascending-- direction, value "00001111"subtypeBIT_VECTOR_TABisBIT_VECTOR(1downto0);constantB4:BIT_VECTOR_TAB:="01";constantB5:BIT_VECTOR:=B4&B2;-- six element array, descending-- direction, value "011111"constantB6:BIT:='0';constantB7:BIT_VECTOR:=B2&B6;-- five element array, ascending-- direction, value "11110"constantB8:BIT:='1';constantB9:BIT_VECTOR:=B6&B8;-- two element array, ascending-- direction value "01"

Example 7[edit]

z:=x*(-y)-- A legal expressionz:=x/(noty)-- A legal expression

The same expressions without parentheses would be illegal.

Example 8[edit]

variableA,B:Integer;variableC:Real;C:=12.34*(234.4/43.89);A:=Bmod2;

Example 9[edit]

2**8=2563.8**3=54.8724**(-2)=1/(4**2)=0.0625

Important Notes[edit]

  • 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.

PHP Assignment Operators

Description

Assignment operators allow writing a value to a variable. The first operand must be a variable and the basic assignment operator is "=". The value of an assignment expression is the final value assigned to the variable. In addition to the regular assignment operator "=", several other assignment operators are composites of an operator followed by an equal sign.

Interestingly all five arithmetic operators have corresponding assignment operators, Here is the list.

The following table discussed more details of the said assignment operators.

ShorthandExpressionDescription
$a+= $b$a = $a + $bAdds 2 numbers and assigns the result to the first.
$a-= $b$a = $a -$bSubtracts 2 numbers and assigns the result to the first.
$a*= $b$a = $a*$bMultiplies 2 numbers and assigns the result to the first.
$a/= $b$a = $a/$bDivides 2 numbers and assigns the result to the first.
$a%= $b $a = $a%$bComputes the modulus of 2 numbers and assigns the result to the first.

Example:

Output:

200 0 90000 1 0 Value of x & y is : 20 11

View the example in the browser