sumator(2)

sumator(2), WAT, SEMESTR I, PKC

[ Pobierz całość w formacie PDF ]
Technika cyfrowa – projekt:
Sumator 4­bitowy r
ó
wnoległy
Autorzy: Paweł Bara
Robert Boczek
Przebieg prac projektowych:
Zadany układ dostaje na wejściu dwie czterobitowe liczby naturalne, sumuje je, 
po   czym   co   najwyżej   pięciobitowy   wynik   wyprowadza   na   siedmiosegmentowy 
wyświetlacz. Całość oparta jest o półsumator i trzy sumatory pełne:
a) półsumator:
A
B
S
P
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
A i B – dwa bity
S – wynik (A xor B)
P – bit przeniesienia (A and B)
W ten sposób otrzymujemy najmłodszy bit wyniku i pierwszy bit przeniesienia. 
b) sumator pełny:
A
i
B
i
P
i­1
S
i
P
i
0
0
0
0
0
0
0
1
1
0
0
1
0
1
0
0
1
1
0
1
1
0
0
1
0
1
0
1
0
1
1
1
0
0
1
1
1
1
1
1
i = 2, 3, 4
Wejście:

A
i
 – i­ty bit liczby a

B
i
 – i­ty bit liczby b

P
i­1
 – poprzedni  bit przeniesienia
Wyjście

S
i
 – i­ty bit sumy (A
i
 xor B
i
 xor P
i­1
)

P
i
 – kolejny bit przeniesienia (A
i
 * B
i
 + (A
i
 xor  B
i
) * P
i­1
)
Cała operacja przebiega następująco:
P
4
P
3
P
2
P
1
A
4
A
3
A
2
A
1
+
B
4
B
3
B
2
B
1
S
5
S
4
S
3
S
2
S
1
Korzystając   z  narzędzia   Quartus  przenosimy  złożony   układ  na   płytkę  UP2.   Osiem 
przełączników   FLEX_SWITCH   reprezentuje   bity   liczb   wejściowych.   Wynik 
przekazujemy   na   wyświetlacz   siedmiosegmentowy   FLEX_DIGIT   zaprogramowany 
odpowiednią funkcją w języku VHDL przekształcającą cztery pierwsze bity wyniku 
na   czytelną  postać  szesnastkową.   Najstarszy   bit   wyniku   reprezentujemy   kropką 
dziesiętną, oznaczającą zwiększenie wyświetlanej liczby o 16.
Rys. 1. Schemat blokowy w Multisimie.
Rys. 2. Schemat bloku w Quartusie.
W programie Quartus wykonaliśmy dwie wersje układu ­ jedną w całości w języku 
VHDL, drugą z wykorzystaniem bloczka I/O, kodu VHDL i zestawu bramek.
Kod wyświetlający liczby szesnastkowe na wyświetlaczu:
ARCHITECTURE mojBolok_architecture OF mojBolok IS 
SIGNAL LED: std_logic_vector(6 downto 0); 
BEGIN 
process(c1,c2,c3,c4) 
begin 
             if (not c1 and not c2 and not c3 and c4)='1' then 
                                     LED <= "1111001"; ­­1 
 elsif (not c1 and not c2 and c3 and not c4)='1' then 
  LED <= "0100100";  ­­2 
 elsif ( not c1 and not c2 and c3 and c4 )='1' then ­­3 
  LED <= "0110000";  ­­3 
elsif ( not c1 and c2 and not c3 and not c4 )='1' then ­­4 
  LED <= "0011001";  ­­4 
elsif ( not c1 and c2 and not c3 and c4 )='1' then ­­5 
  LED <= "0010010";  ­­5 
elsif ( not c1 and c2 and c3 and not c4 )='1' then ­­6 
  LED <= "0000010";  ­­6 
elsif ( not c1 and c2 and c3 and c4 )='1' then ­­7 
  LED <= "1111000";  ­­7 
elsif ( c1 and not c2 and not c3 and not c4 )='1' then ­­8 
  LED <= "0000000";  ­­8 
elsif ( c1 and not c2 and not c3 and c4 )='1' then ­­9 
  LED <= "0010000";  ­­9 
elsif ( c1 and not c2 and c3 and not c4 )='1' then ­­A 
  LED <= "0001000";  ­­A 
elsif ( c1 and not c2 and c3 and c4 )='1' then ­­b 
  LED <= "0000011";  ­­b 
elsif ( c1 and c2 and not c3 and not c4 )='1' then ­­C 
  LED <= "1000110";  ­­C 
elsif ( c1 and c2 and not c3 and c4 )='1' then ­­d 
  LED <= "0100001";  ­­d 
elsif ( c1 and c2 and c3 and not c4 )='1' then ­­E 
  LED <= "0000110";  ­­E 
elsif ( c1 and c2 and c3 and c4 )='1' then ­­F 
  LED <= "0001110";  ­­F 
else ­­0 
  LED <= "1000000"; 
end if; 
end process; 
 
process (LED) 
begin 
 a<=LED(0); 
b<=LED(1); 
c<=LED(2); 
d<=LED(3); 
e<=LED(4); 
f<=LED(5); 
g<=LED(6); 
end process; 
 
END mojBolok_architecture;
Wersja napisana wyłącznie w języku VHDL ma postać:
LIBRARY ieee; 
USE ieee.std_logic_1164.all; 
ENTITY robercik IS 
PORT( a1, a2, a3, a4, b1, b2, b3, b4 : IN STD_LOGIC; 
a,b,c,d,e,f,g, p : OUT STD_LOGIC ); 
END robercik; 
ARCHITECTURE sumator of robercik IS 
signal c1, c2, c3, c4, c5: STD_LOGIC; 
signal tmp: STD_LOGIC_VECTOR ( 2 downto 0); 
signal LED : STD_LOGIC_VECTOR ( 6 downto 0); 
 
BEGIN 
 
tmp(0) <= ( not a4 and not b4 ); 
tmp(1) <= (((not a3 xor not b3) and (tmp(0))) or (not a3 and not b3)); 
tmp(2) <= (((not a2 xor not b2) and (tmp(1))) or (not a2 and not b2)); 
process (tmp) 
begin 
 
­­bit przeniesienia 
p <= not (((not a1 xor not b1) and (tmp(2))) or (not a1 and not b1)); 
 
c4 <= (not b4 xor not a4); 
c1 <= ((not a1 xor not b1) xor tmp(2)); 
c2 <= ((not a2 xor not b2) xor tmp(1)); 
c3 <= ((not a3 xor not b3) xor tmp(0)); 
 
end process; 
[ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • jutuu.keep.pl