spraw.pdf

(459 KB) Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
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
835539716.051.png 835539716.062.png 835539716.073.png 835539716.083.png 835539716.001.png 835539716.002.png 835539716.003.png 835539716.004.png 835539716.005.png 835539716.006.png 835539716.007.png 835539716.008.png 835539716.009.png 835539716.010.png 835539716.011.png 835539716.012.png 835539716.013.png 835539716.014.png 835539716.015.png 835539716.016.png 835539716.017.png 835539716.018.png 835539716.019.png 835539716.020.png 835539716.021.png 835539716.022.png 835539716.023.png 835539716.024.png 835539716.025.png 835539716.026.png 835539716.027.png 835539716.028.png 835539716.029.png 835539716.030.png 835539716.031.png 835539716.032.png 835539716.033.png 835539716.034.png 835539716.035.png 835539716.036.png 835539716.037.png 835539716.038.png 835539716.039.png 835539716.040.png 835539716.041.png 835539716.042.png 835539716.043.png 835539716.044.png 835539716.045.png 835539716.046.png 835539716.047.png 835539716.048.png 835539716.049.png 835539716.050.png 835539716.052.png 835539716.053.png 835539716.054.png 835539716.055.png 835539716.056.png 835539716.057.png 835539716.058.png 835539716.059.png 835539716.060.png 835539716.061.png 835539716.063.png 835539716.064.png 835539716.065.png 835539716.066.png 835539716.067.png 835539716.068.png
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.
835539716.069.png
Rys. 1. Schemat blokowy w Multisimie.
Rys. 2. Schemat bloku w Quartusie.
835539716.070.png
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 
835539716.071.png 835539716.072.png 835539716.074.png 835539716.075.png
 
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; 
835539716.076.png 835539716.077.png 835539716.078.png 835539716.079.png 835539716.080.png 835539716.081.png 835539716.082.png 835539716.084.png
Zgłoś jeśli naruszono regulamin