No Slide Title

Download Report

Transcript No Slide Title

Riistvara kirjelduskeel VHDL
 L4, L5. Riistvara kirjelduskeel VHDL
 L6. Mäluga süsteemid VHDL-s
 L7. VHDL ja süntees
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
1
Modelleerimine
 J.F. Wakerly “Digital Design: Principles and Practices” –
7.12, 8.7 - 8.9
 Mäluga süsteemide modelleerimine
 Musta kasti mudel
 Väljundi väärtus
 sõltub sisendi(te) väärtus(t)est
 sõltub signaali (muutuja) eelmisest
väärtusest
 Kuidas kirjeldada osalist sõltuvust sisendi
muutustest?
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
2
Kombinatoorsed ja mäluga skeemid
 Kombinatoorsed skeemid
 skeemi väljund sõltub ainult sisendist
 atsüklilise topoloogiaga skeem on
kombinatoorne
 Mäluga skeemid
 eksisteerivad mäluelemendid
 tagasiside on vajalik
 väljundi väärtus sõltub signaali (muutuja)
eelmisest väärtusest
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
3
VHDL – tundlikkuse nimistu
 Protsess aktiveeritakse
sisendsignaali(de) muutumisel
 Tundlikkuse nimistus võivad olla loetletud
ainult osad sisendsignaalidest
 pole tundlik mitte-loetletud signaalidele
 vihje mäluelemendile (või puhvrile)
 Simuleerimine ja süntees
 erinevused mitte-loetletud signaalide
interpretatsioonil
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
4
VHDL – tundlikkuse nimistu
process (a, b) begin
x1 <= a and b;
end process;
process (a) begin
x2 <= a and b;
end process;
 ehk
 b vajab puhvrit!
x1 <= a and b;
a
b
a
b
x1
D
x2
C
Pole hea… 
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
5
VHDL – tundlikkuse nimistu
process (a, b, c) begin
if a=’1’ and b=’1’ then
else
end if;
end process;
c
x <= c;
x <= ’0’;
x
a
b
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
6
VHDL – tundlikkuse nimistu
process (a, b, c) begin
if a=’1’ and b=’1’ then
end if;
end process;
x <= c;
 else haru katmata → mälu (latch)
c
a
b
D
x
C
latch
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
7
VHDL – tundlikkuse nimistu
process (a, b) begin
if a=’1’ and b=’1’ then
end if;
end process;
x <= c;
 Pole enamasti sünteesitav!
c
a
b
D
x
C
flip-flop
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
8
VHDL – tundlikkuse nimistu
process (a) begin
if a’event and a=’1’ then
end if;
end process;
x <= c;
 Kokkuleppeline interpretatsioon
 et sünteesi tulemus oleks üheselt mõistetav…
c
a
D
x
C
flip-flop
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
9
Atribuudid ‘event’ ja ‘stable’
 Atribuut
 väärtus, funktsioon, tüüp, vahemik, signaal
või konstant, mida võib siduda ühe või
enama märgendiga VHDL kirjelduses
 event
 muutus signaali väärtuses (-tsüklis)
 stable(T)
 signaali väärtus pole muutunud viimase T
ajaühiku jooksul
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
10
Mäluelement – D-flip-flop
P1_FF: process -- behavioral
begin
wait on CLK until CLK=’1’;
Q<=D;
end process P1_FF;
D
CLK
Q
P2_FF: process (CLK) -- ”classical”
begin
if CLK=’1’ and CLK’event then
Q<=D;
end if;
end process P2_FF;
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
11
Mäluelement – D-latch
P1_L: process (CLK, D) -- ”classical”
begin
if CLK=’1’ then
Q<=D;
D
end if;
CLK
end process P1_L;
Q
 D-flip-flop & andmevookäsud
Q <= D when CLK’event and CLK = ’1’
else Q’DRIVING_VALUE;
Q <= D when CLK’event and CLK = ’1’
else unaffected;
Q <= D when CLK’event and CLK = ’1’;
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
12
flip-flop – reset & enable
P4_FF: process (CLK) begin
if CLK=’1’ and CLK’event then
if
RES=’1’ then
Q<=(others=>’0’);
elsif ENA=’1’ then
Q<=D;
end if;
end if;
end process P4_FF;
 Sünkroonne nullimine
 “clk’event” ja selle järel “res”
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
13
flip-flop – asynchronous reset
P5_FF: process (RESET,CLK) begin
if RESET=’1’ then
-- asynchronous reset
Q<=(others=>’0’);
elsif CLK=’1’ and CLK’EVENT then
if ENA=’1’ then
Q<=D;
end if;
end if;
end process P5_FF;
 Asünkroonne nullimine
 “reset” esimesena ja
“clk’event” elsif-harus takti tunnusena
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
14
Taktsignaali stiilid
 Frondi tunnus ja signaali uus väärtus
 järjekord pole oluline
 if CLK=’1’ and CLK’event then ...
 if CLK=’1’ and not CLK’stable then ...
 wait on CLK until CLK=’1’;
 wait until CLK=’1’ and CLK’event;
 wait until CLK=’1’ and not CLK’stable;
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
15
VHDL ja digitaalsüsteem
process (a, b, c)
begin
x <= f (a, b);
y <= g (b, c);
end process;
process (clk)
begin
if clk’event and
clk=’1’ then
q <= d;
end if;
end process;
© Peeter Ellervee
Funktsionaalsed sõlmed
+/-
</>
RG
RG
Mäluelemendid
I207 - Digitaalloogika ja -süsteemid - L6
16
Näide - loendur
4 bitti:
algus (strt)
lõpp (stp)
1-suunaline
2-suunaline
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
17
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
18
käitumine
library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all;
entity agener is
generic ( bitwidth: positive );
port ( clock: in bit;
reset, enable: in std_logic;
start_address, stop_address: in unsigned(bitwidth-1 downto 0);
address: out unsigned(bitwidth-1 downto 0) );
end agener;
library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all;
architecture one_process of agener is
signal count: unsigned(bitwidth-1 downto 0);
begin
process begin
wait on clock until clock='1';
if reset='1' then count<=start_address;
elsif enable='1' and count/=stop_address then count<=count+'1';
end if;
end process;
address<=count;
end one_process;
liides
Loendur – üks protsess
Loendur – kaks protsessi
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
register
kombinatsioonskeem
architecture two_process of agener is
signal count, new_count: unsigned(bitwidth-1 downto 0);
begin
process (reset, enable, start_address, stop_address, count) begin
new_count<=count;
if reset='1' then new_count<=start_address;
elsif enable='1' then
if start_address<=stop_address then
if count<stop_address then new_count<=count+'1'; end if;
else if count>stop_address then new_count<=count-'1'; end if;
end if;
end if;
end process;
process begin
wait on clock until clock='1';
count<=new_count;
end process;
address<=count;
end two_process;
19
VHDL & valgusfoor
 Kogutsükkel 30 sek., andurid puuduvad
 roheline
 kollane
 punane
 kollane+punane
12 sek.
3 sek.
12 sek.
3 sek.
punane
kollane+punane
roheline
kollane
 Käitumuslik kood
 ajakontrolli-käsud – eeldab sisemist taimerit
 for-tsükkel ja 1 sek. timer – samm loenduri poole
 Sünteesitav kood
 eraldi loendur (andmeosa) ja kontroller (automaat)
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
20
VHDL & valgusfoor
 Ajakontrolli-käsud
 Test-pink
entity TLC is
port ( R1, Y1, G1,
R2, Y2, G2: out bit );
end entity TLC;
entity test_tlc is
end entity test_tlc;
architecture behave of TLC is
begin
process begin
R1 <= '0'; Y1 <= '0'; G1
R2 <= '1'; Y2 <= '0'; G2
wait for 12 sec;
R1 <= '0'; Y1 <= '1'; G1
R2 <= '1'; Y2 <= '1'; G2
wait for 3 sec;
R1 <= '1'; Y1 <= '0'; G1
R2 <= '0'; Y2 <= '0'; G2
wait for 12 sec;
R1 <= '1'; Y1 <= '1'; G1
R2 <= '0'; Y2 <= '1'; G2
wait for 3 sec;
end process;
end architecture behave;
© Peeter Ellervee
architecture bench of test_tlc is
signal road1, road2:
bit_vector (1 to 3);
<= '1';
<= '0';
<= '0';
<= '0';
<= '0';
<= '1';
<= '0';
<= '0';
component TLC
port ( R1, Y1, G1,
R2, Y2, G2: out bit );
end component;
begin
U1: TLC port map
(road1(1),road1(2),road1(3),
road2(1),road2(2),road2(3));
end architecture bench;
I207 - Digitaalloogika ja -süsteemid - L6
21
VHDL & valgusfoor
 for-tsükkel
 Test-pink
entity TLC2 is
port ( timer: in bit;
R1, Y1, G1,
R2, Y2, G2: out bit );
end entity TLC2;
architecture behave of TLC2 is
begin
process begin
R1 <= '0'; Y1 <= '0'; G1 <= '1';
R2 <= '1'; Y2 <= '0'; G2 <= '0';
for i in 1 to 12 loop
wait on timer until timer='1';
end loop;
R1 <= '0'; Y1 <= '1'; G1 <= '0';
R2 <= '1'; Y2 <= '1'; G2 <= '0';
for i in 1 to 3 loop
wait on timer until timer='1';
end loop;
R1 <= '1'; Y1 <= '0'; G1 <= '0';
R2 <= '0'; Y2 <= '0'; G2 <= '1';
for i in 1 to 12 loop
wait on timer until timer='1';
end loop;
R1 <= '1'; Y1 <= '1'; G1 <= '0';
R2 <= '0'; Y2 <= '1'; G2 <= '0';
for i in 1 to 3 loop
wait on timer until timer='1';
end loop;
end process;
end architecture behave;
© Peeter Ellervee
entity test_tlc2 is
end entity test_tlc2;
architecture bench of test_tlc2 is
signal road1, road2:
bit_vector (1 to 3);
signal timer: bit := '1';
component TLC2
port ( timer: in bit;
R1, Y1, G1,
R2, Y2, G2: out bit );
end component;
begin
timer <= not timer after 500 ms;
U1: TLC2 port map (timer,
road1(1),road1(2),road1(3),
road2(1),road2(2),road2(3));
end architecture bench;
I207 - Digitaalloogika ja -süsteemid - L6
22
VHDL & valgusfoor
 Simulatsioonide tulemused
TLC
TLC2
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
23
Konfigureerimine

Komponendid
entity AD2 is port (A1, A2: in
architecture B of AD2 is begin
entity XR2 is port (X1, X2: in
architecture B of XR2 is begin

BIT;
Y <=
BIT;
Y <=
Y:
A1
Y:
X1
out
and
out
xor
BIT); end;
A2; end;
BIT); end;
X2; end;
Komponentide deklaratsioonid ja konfiguratsiooni spetsifikatsioon
entity Half_Adder is port (X, Y: BIT; Sum, Cout: out BIT); end;
architecture Netlist of Half_Adder is use work.all;
component MX port (A, B: BIT; Z:out BIT); end component;
component MA port (A, B: BIT; Z:out BIT); end component;
for G1:MX use entity XR2(B) port map(X1 => A,X2 => B,Y => Z);
begin
G1:MX port map (X, Y, Sum); G2:MA port map (X, Y, Cout);
end;

Konfiguratsiooni deklaratsioon, ploki konfiguratsioon, komponendi konfiguratsioon
configuration C1 of Half_Adder is
use work.all;
for Netlist
for G2:MA use entity AD2(B) port map(A1 => A,A2 => B,Y => Z); end for;
end for;
end;

Allikas – http://www10.edacafe.com/book/ASIC/ASICs.php
© Peeter Ellervee
I207 - Digitaalloogika ja -süsteemid - L6
24