Documente Academic
Documente Profesional
Documente Cultură
- COMPORTAMENTAL
Tipuri de descriere :
- FLUX DE DATE
- STRUCTURAL
DESCRIEREA COMPORTAMENTAL
nume_proces :
Lista senzitivitilor
process (
semnal 1 , semnal 2
, )
begin
instruciuni care definesc
algoritmul comportamental
end process
nume_proces
Lista senzitivitilor :
conine semnalele care declaneaz procesu
b
a
b
c
d
e
c
Proces
a, d
- Structurile COMBINAIONALE :
sunt senzitive la toate semnalele de intrare.
- Structurile
SECVENIALE :
-intrarea de sincronozare (clk)
- sunt senzitive la :
- intrrile asincrone.
- NU sunt senzitive la intrrile sincrone.
clk
D
Q
reset
clk
reset
D
reset
- Indic modul n care datele sunt transferate de la intrri spre ieiri (fluxu
f`r a acorda importan ordinii n timp a acestor transferuri.
- Se recomand descrierea prin instruciuni concurente.
( Se pot folosi i instruciuni secveniale. In acest caz descrierea se face
cadrul unui proces, sezitiv la toate mrimile de intrare ).
Descrieri :
A1
A0
B1
B0
COMP
2x2
library ieee;
use ieee.std_logic_1164.all;
A1
A0
B1
B0
--semnale interne
u
Y
v
library ieee;
use ieee.std_logic_1164.all;
A1
A0
B1
B0
COMP
2x2
library ieee;
use ieee.std_logic_1164.all;
A1
A0
B1
B0
process(A , B)
begin
if A = B then Y <= 1 ;
else Y <= 0 ;
end if ;
end process;
end arch_COMP_2;
COMP
2x2
Exemplu :
A0
u0
xnor2
A1
X0
and2
Y
X1
B0
B1
xnor2
u1
u2
library ieee;
use ieee.std_logic_1164.all;
use work.gates_pkg.all ;
entity COMP is port
(A , B : in std_logic_vector (0 to 1);
Y : out std_logic);
end COMP;
architecture arch_COMP of COMP is
signal X : std_logic_vector(0 to 1);
begin
DESCRIEREA STRUCTURILOR
COMBINAIONALE
-comportamentale
descrieri :
Se folosesc :
-flux de date
-structurale
instruciuni :
-concurente
- secveniale
recomandate
1.
- bit
Pot opera cu semnale de tip -: bit_vector
- std_logic
- std_logic vector
a OR b AND c
a+bc
se va evalua ca :
(a + b)c
paranteze.
se codeaz :
00
b3
b2
b1
b0
01
Reprezentare simplificat :
MUX 4:1
c3
c2
c1
c0
10
d3
d2
d1
d0
11
y3
y2
y1
y0
a [3:0]
00
b [3:0]
01
c [3:0]
10
d [3:0]
11
y [3:0]
s [1:0]
s 1 s0
library ieee;
use ieee.std_logic_1164.all
entity MUX is
port ( a , b , c , d : in std_logic_vector(3 downto 0) ;
s : in std_logic_vector(1 downto 0) ;
y : out std_logic_vector(3 downto 0) ) ;
end MUX;
architecture arch_MUX of MUX is
begin
y(3) <= (a(3) and not (s(1)) and not (s(0))) or (b(3) and not (s(1)) and not (s(0)))
or (c(3) and not (s(1)) and not (s(0))) or (d(3) and not (s(1)) and not (s(0)));
y(2) <= (a(2) and not (s(1)) and s(0)) or (b(2) and not (s(1)) and s(0))
or (c(2) and not (s(1)) and s(0)) or (d(2) and not (s(1)) and s(0));
y(1) <= (a(1) and s(1) and not (s(0))) or (b(1) and s(1) and not (s(0)))
or (c(1) and s(1) and not (s(0))) or (d(1) and s(1) and not (s(0)));
y(0) <= (a(0) and s(1) and s(0)) or (b(0) and s(1) and s(0))
or (c(0) and s(1) and s(0)) or (d(0) and s(1) and s(0));
end arch_MUX;
2. INSTRUCIUNEA DE SELECIE
with-select-when
flux de date.
with
semnal_selecie
semnal_ieire
<=
selecto
select
valoare_1
valoare_2
when
when
valoare_1_semnal_selecie
valoare_2_semnal_selecie
valoare_n-1
valoare_n
Cuvntul rezervat
Se folosete
others
obligatoriu
when valoare_n-1_semnal_seleci
when others ;
a [3:0]
00
b
[3:0]
01
library ieee;
use ieee.std_logic_1164.all
y [3:0]
10
c [3:0]
d
[3:0]
11
s [1:0]
selectorul
s = "00"
DA
y <= a
s = "01"
DA
s = 10"
DA
y <= b
ieirea
y <= c
s = alte
valori
DA
y <= d
-Ordinea n timp
de testare
a valorilor
selectorului s
nu are importan.
000
001
010
011
100
Semnal selecie
s
s2 s1 s0
s [2:0]
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
alte valori
y=a
y=b
y=c
y=d
y=e
y=0
..
with s select
y <= a when "000",
b when "001",
c when "010",
d when "011",
e when "100",
'0' when others ;
..
a 1 a2 a 3 y
Circuit combinaional :
a1
a2
CLC
a3
0
0
0
0
0
1
1
1
1
0
0
1
1
0
0
0
1
1
0
1
0
1
1
0
1
0
1
1
0
0
1
0
0
1
0
0
library ieee;
use ieee.std_logic_1164.all
entity CLC is port
( a : in std_logic_vector(1 to 3);
y : out std_logic ) ;
end CLC;
architecture arch_CLC of CLC is
begin
with a select
y <= 1 when "000" | "011 | "101" ,
0 when others ;
end arch_MUX;
are semnificaia
operatorului SAU
3. INSTRUCIUNEA CONDIIONAL
when-else
nume_semnal
<=
condiii
flux de date.
valoare_1
when
condiie_1
valoare_2
when
condiie_2
else
else
...
valoare_n-1
valoare_n
when
condiie_n-1
else
a [3:0]
b
[3:0]
00
01
y [3:0]
10
c [3:0]
d
[3:0]
library ieee;
use ieee.std_logic_1164.all
11
s [1:0]
end arch_MUX;
-- y=d pentru s =
Comp.
b [3:0]
oe
relaia a,b
ab
y
0
a=b
ab
a=b
a egal cu b
a diferit de b
a mai mic ca b
a mai mic sau egal cu b
a mai mare ca b
a mai mare sau egal cu b
operatorul relaional
a = b
a /= b
a < b
a <= b
a > b
a >= b
!!
= i /=
Exemplu :
Exemplu :
biblioteca work.std_arith extinde utilizarea operatorilor relaionali
i aritmetici la semnalele de tip std_logic i std_logic_vector.
Detector de 9 :
Exemplu :
a3
a
a 3 a2 a1 a 0
a1
1 0
a0
alte valori
a2
Detect 9
0 1
library ieee;
use ieee.std_logic_1164.all ;
use work.std_arith.all;
entity DETECT9 is port
( a : in std_logic_vector(3 downto 0);
y : out std_logic );
end DETECT9;
architecture arch_DETECT9 of DETECT9 is
begin
y <= '1' when (a = 9) else '0' ;
end arch_DETECT9;
Exemplu :
a [3:0]
Comp.
b [3:0]
aINFb
aSUPb
library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
semnale
entity COMP is
port (a , b : in std_logic_vector(3 downto 0);
aEGALb, aINFb, aSUPb : out std_logic);
end COMP;
architecture arch_COMP of COMP is
begin
aEGALb <= '1' when a = b else
'0 ;
aINFb <= '1' when a < b else
else
'0 ;
aSUPb <= '1' when a > b else
'0';
end arch_COMP;
3 instruciuni when-
Sumator de 2 x 16 bii :
Exemplu :
a
b
16
16
16
suma
library ieee;
use ieee.std_logic_1164.all;
use work.std_arith.all;
-- extinde operatorul + la
semnale
entity SUM is
port (a , b : in std_logic_vector(15 downto 0);
suma : out std_logic_vector(15 downto 0) );
end SUM;
architecture arch_SUM of SUM is
begin
suma <= a + b ;
end arch_SUM;
Obs. : - din bibliotec se apeleaz schema unui sumator cu schem predefinit ;
- sumatorul predefinit este omogen (operanzii i suma au acelai numr de bii ;
- biblioteca conine dispozitive aritmetice pentru toate operaiile uzuale (+ , - , * , / ).
INSTRUCIUNEA SECVENIAL
if - then - else
if
then
condiie
else
aciune_1
aciune_2 ;
end if ;
if
condiie
else
da
then
nu
aciune_2
aciune_1
if
condiie_1
then
aciune_1 ;
elsif
condiie_2
then
aciune_2 ;
elsif
condiie_3
then
aciune_3 ;
else
end if ;
aciune_4 ;
if
condiie_1
elsif
then
aciune_1
nu
condiie_2
elsif
da
da
then
aciune_2
nu
condiie_3
nu
else
aciune_4
da
then
aciune_3
Exemplu
a [3:0]
b [3:0]
c [3:0]
d [3:0]
e [3:0]
f [3:0]
g [3:0]
h [3:0]
s [2:0]
y [3:0]
library ieee;
use ieee.std_logic_1164.all
entity MUX is port
( a, b, c, d, e, f, g, h : in std_logic_vector(3 downto 0);
s : in std_logic_vector(2 downto 0);
y : out std_logic_vector(3 downto 0) );
end MUX;
architecture arch_MUX of MUX is
begin
process ( a , b , c , d , e, f , g , h , s )
begin
if
s = "000" then y <= a ;
elsif s = "001" then y <= b ;
elsif s = "010" then y <= c ;
elsif s = "011" then y <= d ;
elsif s = "100" then y <= e ;
elsif s = "101" then y <= f ;
elsif s = "110" then y <= g ;
else y <= h ;
--pentru s = "111"
end if ;
end process ;
end arch_MUX;
INSTRUCIUNEA SECVENIAL
case - when
case
nume_selector
is
when
valoare_selector_1
=>
aciune_1
when
valoare_selector_2
=>
aciune_2
valoare_selector_n-1
=>
aciune_n-1
.
.
.
when
when others
end case ;
=>
aciune_n
Obs. :
a)
when
da
valoare_1
nu
aciune_1
when
da
valoare_2
nu
aciune_2
when
da
valoare_3
nu
aciune_3
when others
- instruciunea descrie un
algoritm comportamental
al entitii logice,
deci se cere ncadrat
ntr-un P R O C E S .
aciune_4
Obs. :
instruciunile case-when i if-then-else pot fi folosite n
cadrul aceluiai proces.
10
B1
Z1
Z2
Z3
B0
2
intrare zecimal
Z0 Z 1 Z 2 Z 3
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
library ieee ;
use ieee.std_logic_1164.all ;
entity CODIF is port
( z : in std_logic_vector (0 to 3) ;
b : out std_logic_vector (1 downto 0)) ;
end CODIF ;
architecture arch_CODIF of CODIF is
begin
process (z)
case z is
when "1000" => b<="00" ;
when "0100" => b<="01" ;
when "0010" => b<="10" ;
when others => b<="11" ;
end case ;
end process ;
ieire binar
B1
B0
0
0
1
1
0
1
0
1
Atenie
la ordonarea
vectorilor
logici !
others este
obligatoriu pt. c
nu sunt folosite
toate combinaiile
posibile de 4 bii
Instruciuni
de selecie
Instruciuni
concurentewith - select - when
Instruciuni
condiionale
- Descriu structuri logice prin relaiide tip
intrare - ieire.
when - else
i f - then - else
Instruciuni
secveniale case - when
i
if - elsif - else
Execut aciuni
n funcie de
valoarea unii
selector.