L7 Sequential Desgin
-
Upload
usitggsipu -
Category
Documents
-
view
217 -
download
0
Transcript of L7 Sequential Desgin
-
8/6/2019 L7 Sequential Desgin
1/15
Sequential Design
-
8/6/2019 L7 Sequential Desgin
2/15
Sequential code Code written within the following
statements execute sequentially.
Process
Functions
Procedures
-
8/6/2019 L7 Sequential Desgin
3/15
Process A process is a sequential section of VHDL
code.
It is characterized by the presence offollowing statements:
IF
Wait Case
Loop
-
8/6/2019 L7 Sequential Desgin
4/15
Process (cont..) A Process must be installed in the main code, and
is executed every time a signal in the sensitivity
list changes (or the condition related to WAIT isfulfilled).
Syntax:
[label:] Process (sensitivity list)
[variable name type [range] [:=initial value;]]Begin
(sequential code)
End Process [label];
-
8/6/2019 L7 Sequential Desgin
5/15
If statementIf condition then
assignments;
elsif condition then
assignments;
..
else assignments;
end if;
-
8/6/2019 L7 Sequential Desgin
6/15
Case statementsThe format of a case statement is
case expression is
when choices => sequential-statements --branch #1
when choices => sequential-statements --branch #2
-- Can have any number of branches.
[ when others => sequential-statements ] -- lastbranch
end case;
-
8/6/2019 L7 Sequential Desgin
7/15
Case (cont.) The case statement is very similar to when
statement.
All the permutation must be tested, so the
keyword OTHERS may be used.
NULL may be used, when no action is
required to take place.
e.g. When OTHERS => NULL;
-
8/6/2019 L7 Sequential Desgin
8/15
entity MUX is
port (A, B, C, D: in BIT; CTRL: in BIT_VECTOR(0 to 1);
Z: out BIT);
end MUX;
architecture MUX_BEHAVIORofMUX is
constant MUX_DELAY: TIME := 10 ns;
begin
PMUX: process (A, B, C, D, CTRL)
variable TEMP: BIT;
begin
case CTRL is
when "00" => TEMP := A:
when "01" => TEMP := B;
when "10" => TEMP := C;
when "11" => TEMP := D;
end case;
Z
-
8/6/2019 L7 Sequential Desgin
9/15
Loop Loop is useful when a piece of code must be
instantiated several times.
Loop is intended exclusively for sequential code.
For/loop : The loop is repeated a fixed number of
times.
[label:] FOR identifier IN range LOOP
(sequential statements)
END LOOP [label];
-
8/6/2019 L7 Sequential Desgin
10/15
Example of For/loopFACTORIAL := 1;
forNUMBERin 2 toN loop
FACTORIAL := FACTORIAL * NUMBER;
end loop;
NOTE: Range must be static.
-
8/6/2019 L7 Sequential Desgin
11/15
Loop (cont.) WHILE/LOOP : The loop is repeated
until a condition no longer holds.
[label:] WHILE condition LOOP
(sequential statements);
end LOOP [label];
-
8/6/2019 L7 Sequential Desgin
12/15
Example WHILE/Loop
While (I
-
8/6/2019 L7 Sequential Desgin
13/15
Other statements EXIT
Used for ending the loop
[label:] EXIT [label] [WHEN condition]
NEXT
Used for skipping loop steps.
[label:] NEXT [loop_label] [WHEN condition]
-
8/6/2019 L7 Sequential Desgin
14/15
Example (exit and Next)SUM := 1; J := 0;
L3: loop
J:=J+21;
SUM := SUM* 10;
if(SUM > 100) then
exit L3; -- "exit;" also would have been sufficient.end if;
end loop L3;
-
8/6/2019 L7 Sequential Desgin
15/15
Example (next)For I in 0 to 15 loop
next when I= skip; -- jump to next iteration