Sequential
Statements
Sequential Statements
–
–
–
–
–
–
–
–
Il VHDL simula lo svolgersi in parallelo di varie operazioni
L’oggetto fondamentale e’ il PROCESS
Un PROCESS contiene una serie di operazioni sequenziali
Al suo interno la metodologia di programmazione e’ di tipo
sequenziale e pertanto familiare ai programmatori
Tutte le operazioni racchiuse in un PROCESS avvengono in
un tempo (tempo di simulazione) NULLO
I PROCESS sono tra loro concorrenti (operano in parallelo)
Un PROCESS e’ un loop infinito e non esce mai
Un PROCESS deve contenere un’istruzione WAIT o una
SENSITIVITY LIST (per la sincronizzazione)
Sequential Statements
(es.)
Entity LOW_HIGH is
port (a,b,c in integer);
end;
architecture BEHAV of LOW_HIGH is
begin
L: Process
variable low: integer :=0;
begin
wait on a,b,c;
if a < b then low:=a; else low:=b; end if;
if c < low then low :=c; end if;
end process;
H: Process
variable high integer :=0;
begin
wait on a,b,c;
if a > b then high:=a; else high:=b; end if;
if c > high then high :=c; end if;
end process;
end BEHAV;
Sequential Statements
• Le espressioni tipiche di operazioni sequenziali sono:
–
–
–
–
–
–
–
–
–
–
PROCESS Statement
Variable Assignement
IF Statement
CASE Statement
LOOP Statement
WAIT Statement
NEXT Statement
EXIT Statement
Subprograms
ASSERT
PROCESS Statements
• Sintassi
[label:] process [(sensitivity list)]
[subprograms]
[type]
[constant]
[variable]
[other declaration]
begin
sequential statements
end process [label];
VARIABLE Assignment
• Sintassi
target := expression;
• La variabile deve essere dichiarata a priori
• Deve essere dello stesso tipo dell’assegnamento
• Le variabili sono LOCALI all’interno del PROCESS
a
b
c
z
:=
:=
:=
:=
‘a’;
123.0;
“010010”;
x + y ;
SIGNAL Assignment
• Sintassi
target <= expression [after delay];
• L’assegnazione di un segnale deve essere sincronizzata
o tramite un WAIT o con la “sensitivity list”
c <= ‘1’ after 1ns;
b <= a ;
z <= x + y ;
IF Assignment
• Sintassi
if condition then seq_statement1;
{elsif condition then seq_statement2;}
[else seq_statement3;]
end if;
• Esempio:
if (Z) then T:=D;
elsif (Y) then T:=C;
elsif (X) then T:=B;
else T:=A;
end if;
CASE Assignment
• Sintassi
case expression is
when choise_1 => seq_of_assign_1;
. . .
when choise_n => seq_of_assign_n;
end case;
• Esempio:
case BCD is
when “0000” => LED := “1111110”;
when “0001” => LED := “1100000”;
. . .
when others => LED := “-------”;
end case;
CASE Assignment
• Casi particolari
case expression is
when c1 => assign_1;
when c2 | c3 => assign_2;
when c4 to c9 => assign_3;
when others => assign_4;
end case;
• Certi sistemi richiedono esplicito il when others! Anche
se fisicamente la condizione non sara’ mai raggiunta.
LOOP Statement
• E’ il modo classico per descrivere cicli
• Si possono usare sia FOR, WHILE o cicli infiniti
• I LOOPs possono essere “nidificati” uno nell’altro
Label1: FOR i in 1 to 10 LOOP
s1; s2; ... sn;
END LOOP;
i:=1;
Label2: WHILE (i < 11) LOOP
s1; s2; ... sn;
i:= i+1;
END LOOP
LOOP Statement
• Sebbene il PROCESS sia un LOOP infinito si puo’
evidenziare il loop (per motivi di stile)
process
begin
initial_statements
loop
sequential_statement
end loop;
end process;
NEXT Statement
• Serve per “bypassare” una parte di un LOOP
• Le “LABEL” servono per identificare univocamente il loop
in caso di loop annidati
L2: WHILE j < 20 LOOP
L1: FOR i in 1 to 10 LOOP
IF (a(i) = 0) THEN NEXT L1;
END IF;
q(i) := a(i);
END LOOP L1;
END LOOP L2;
EXIT Statement
• Serve per “uscire” da un LOOP prima che questo abbia
raggiunto la sua logica fine
L1: FOR i in 1 to 10 LOOP
IF (a(i) = 0) THEN EXIT;
END IF;
q(i) := a(i);
END LOOP L1;
WAIT Statement
• Serve per sincronizzare un processo su opportuni eventi
• Ve ne sono 4 tipi:
– WAIT FOR, WAIT UNTIL, WAIT ON e WAIT
• Sintassi:
wait [on signal]
[until condition]
[for time]
• Esempi:
wait on a,b;
wait until x > 10;
wait for 10 ns;
wait;
ASSERT/REPORT Statement
• Da usarsi SOLO IN SIMULAZIONE
• Serve al “debugging” di un sistema
• 4 gradi di severity: FAILURE, ERROR, WARNING,
NOTE
• Sintassi:
assert condition [report string]
[severity expression];
• Esempio:
assert (x > 3)
report “troppo basso”
severity WARNING
assert (false) report “starting sim.”
PROCEDURE e FUNCTIONS
• Vengono impiegate per “documentare” operazioni usate
frequentemente
• Si rimanda il lettore a testi specifici
Scarica

VHDL2