Operators and Statements in VHDL
Operators and Statements in VHDL
2.Relational operator
= /= <= > >=
3.Adding operators
+ - &
4.Multiplying operators
* / mod rem
5. Miscellaneous operator
abc **
Operator overloading
• When a standard operator symbol is made to behave
differently based on the type of its operands, the operator is
said to be overloaded.
• The need for operator overloading arises from the fact that the
predefined operators in the language are defined only for
operands of certain predefined types.
Example of operator overloading:
signal A,B,C:MVL;
signal A,B,C:BIT;
A<= ‘Z’ or ‘1’; -- #1 standard operator notation.
B<= “or” (‘0’, ‘Z’) -- #2 function operator notation.
Statements in VHDL
• Variable assignment statement
• Signal assignment statement
• Process statement
• If statement
• Wait statement
• Null statement
• Loop statement
• Exit statement
Variable Assignment Statement
• Variables can be declared and used inside a process
statement.
process (A)
variable EVENTS_ON_A: INTEGER := 0;
begin
EVENTS_ON_A := EVENTS_ON_A+1;
end process;
Signal assignment statement
• Signals are assigned values using a signal assignment
statement .
• The simplest form of a signal assignment statement is
signal-object <= expression [ after delay-value ];
• A signal assignment statement can appear within a
process or outside of a process.
• If it occurs outside of a process, it is considered to be a
concurrent signal assignment statement.
• Example of signal assignment statement:
COUNTER <= COUNTER+ "0010"; - Assign after a
delta delay
PAR <= PAR xor DIN after 2 ns;
Z <=(AO and A1) Or (BO and B1)Or (CO and C1) after 6 ns;
Process statement
FACTORIAL := 1;
for NUMBER in 2 to N loop
FACTORIAL := FACTORIAL * NUMBER;
end loop;
While loop
J:=0;SUM:=10;
WH-LOOP: while J < 20 loop - This loop has a label, WH_LOOP
SUM := SUM * 2;
J:=J+3;
end loop;
Exit statement
SUM:=1;J:=0;
L2: loop --This loop also has a label
J:=J+21;
SUM := SUM* 10;
exit when SUM > 100;
end loop L2; -- This loop label, if present, must be the
-- same as the initial loop label
Wait statement
• when a process has a sensitivity list, it always suspends
after executing the last sequential statement in the
process.
• The wait statement provides an alternate way to suspend
the execution of process.
• There are three basic forms of the wait statement:
Wait on sensitivity list;
Wait until Boolean expression;
Wait for time-expression;
• Example of wait statement: