Prévia do material em texto
FUNDAÇÃO CENTRO DE ANÁLISE, PESQUISA E INOVAÇÃO
TECNOLÓGICA
INSTITUTO DE ENSINO SUPERIOR FUCAPI
COORDENAÇÃO DE GRADUAÇÃO EM
ENGENHARIA DA COMPUTAÇÃO
ALAN REIS CHAGAS
AYRTON FUKUNARI SATO
EDUARDA DE PAULA PAIVA PINHEIRO
JOSÉ CARLOS ROCHA COSTA DA ROCHA
RELATÓRIO DE SISTEMAS DIGITAIS
MANAUS
2019
SUMÁRIO
1. LABORATÓRIO I 3 ...................................................................................................
2. LABORÁTORIO II 8 ..................................................................................................
3. LABORÁTORIO III 13 ...............................................................................................
4. LABORATÓRIO IV 20 ..............................................................................................
5. LABORATÓRIO V 26 ...............................................................................................
6. LABORATÓRIO VI 34 ..............................................................................................
7. LABORATÓRIO VII 52 .............................................................................................
CONCLUSÃO 60..........................................................................................................
1. LABORATÓRIO I
1.1 OBJETIVOS
- Verificar através de experimentos a implementação de sistemas digitais em um
dispositivo FPGA, utilizando a linguagem VHDL.
- Testar a Plataforma DE 01 (Altera).
1.2 MATERIAIS
- HW: Plataforma DE 01
- SW: Ide Quartus II Web Edition
1.3 PROCEDIMENTOS
1.3.1 Implementamos a função lógica abaixo em VHDL. Simulamos o resultado para
verificar a funcionalidade:
1.3.2 Utilizando a linguagem VHDL, implementamos e simulamos o circuito lógico
digital correspondente a tabela verdade abaixo:
�3
S =A+(B⊕C )+(A.B .C )+ (A.B +C )
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
�A �S�C�B
1.3.3 Projetamos e simulados em VHDL o circuito decodificador abaixo:
�4
DEC(0)
DEC(1)
DECODIFICADOR
DEC(2)
DEC(3)
A (1)
A (2)
A1 A2 DEC
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
1.4 RESULTADOS
1.4.1 Código e simulação função lógica:
LIBRARY IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
ENTITY logica is
port (a,b,c: in std_logic;
s: out std_logic);
end logica;
ARCHITECTURE funcaoLogica of logica is
signal s1, s2, s3: std_logic;
begin
s1 <= (not (a) and not(c));
s2 <= (not (b) and not (c));
s3 <= (b and c);
s <= s1 or s2 or s3;
end funcaoLogica;
�5
S =A+(B⊕C )+(A.B .C )+ (A.B +C )
1.4.2 Código e simulação do decodificador
ENTITY decoder IS
port (a: IN BIT_VECTOR (1 DOWNTO 0);
S: OUT BIT_VECTOR (3 DOWNTO 0));
END labo3;
ARCHITECTURE decodificador OF decoder is
begin
s <= "0001" when a = "00" else
"0010" when a = "01" else
"0100" when a = "10" else
"1000" when a = "11" else
"1111";
�6
Figura 1: Simulação para A = 0, B = 1 e C
= 1, a saída S é 1
end decodificador;
�7
Figura 2: Simulação para A = 1, B = 1.
2. LABORÁTORIO II
2.1 OBJETIVOS
- Verificar a implementação de um circuito multiplexador e decodificador de 7
segmentos em VHDL.
- Testar a Plataforma DE 01 (Altera).
2.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
2.3 PROCEDIMENTOS
2.3.1 Projetamos e implementamos em VHDL o sistema decodificador da figura
abaixo:
Observamos se o display é acionado com “0” ou “1" para que pudéssemos fazer o
ajuste da tabela abaixo:
�8
DECODIFICADOR
C2
C1
C0
2.3.2 Implementamos em vhdl e prototipamos o circuito multiplexador 4 x 1 abaixo.
Realizamos a simulação antes de fazer a prototipação.
�9
C2 C1 C0 6 5 4 3 2 1 0 Número
0 0 0 0 0 1 1 0 0 1 4
0 0 1 0 1 1 0 0 0 0 3
0 1 0 0 1 0 0 1 0 0 2
0 1 1 1 0 0 0 0 0 0 0
MUX
4x1 y
a
b
c
d
Sel (1:0)
Sel1 Sel2 y
0 0 a
0 1 b
1 0 c
1 1 d
2.4 RESULTADOS
2.4.1 Código e simulação do decodificador de 7 segmentos.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY display_7 is
port (c: in bit_vector(2 downto 0);
s: out bit_vector (6 downto 0));
end display_7;
ARCHITECTURE labo2_display of display_7 is
begin
s<= "0011001" when c = "000" else
"0110000" when c = "001" else
"0100100" when c = "010" else
"1000000" when c = "011" else
"1111111";
end labo2_display;
�10
�11
Figura 3: Simulação número 4 Figura 4: Simulação número 3
Figura 5: Simulação número 2
2.4.2 Código e simulação do multiplexador 4 x 1.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY mux_4 is
port(a,b,c,d: in bit; s0, s1: in bit;
y: out bit);
END mux_4;
architecture labo5 of mux_4 is
signal sel: bit_vector(1 downto 0);
begin
sel<= s0 & s1;
y<= a when sel = "00" else
b when sel = "01" else
c when sel = "10" else
d;
END labo5;
�12
3. LABORÁTORIO III
3.1 OBJETIVOS
- Verificar a implementação de um circuito demultiplexador e um comparador de 4
bits.
- Testar a plataforma DE 01 (Altera).
3.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
3.3 PROCEDIMENTOS
3.3.1 Implementamos em VHDL e prototipamos utilizando a placa DE 01 o circuito
demultiplexador 1x4 abaixo. Utilizamos o circuito multiplexador 4 x 1 do experimento
02 para implantar a letra (b) do exercício.
a)
�13
DEMUX
1x4i
y0
y1
y2
y3
S0 S1
ENTRADA SAÍDA
i S1 S0 y3 y2 y1 y0
x 0 0 0 0 0 x
x 0 1 0 0 x 0
x 1 0 0 x 0 0
x 1 1 x 0 0 0
b)
3.3.2 Implementamos em vhdl e prototipamamos a placa DE 01 um circuito
comparador de 4 bits usando a estrutura with select.
�14
DEMUX
1x4
i
y0
y1
y2
y3
S0 S1
MUX
4x1 i
i0
i1
i2
i3
S0S1
COMPARADOR
4 BITS
A0
A2
A3
A1
A = B
A > B
A < B
3.4 RESULTADOS
3.4.1 Código do demultiplexador 1 x 4.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY demux_4 IS
port(i: IN STD_LOGIC;
s0,s1: IN STD_LOGIC;
y0,y1,y2,y3: OUT STD_LOGIC);
END demux_4;
ARCHITECTURE demux_1x4 OF demux_4 IS
BEGIN
process(i, s0,s1) is
BEGIN
if (s0 = '0' and s1 = '0') then
y0 <= i;
y1 <= '0';
y2 <= '0';
y3 <= '0';
elsif (s0 = '1' and s1 = '0') then
y0 <= '0';
y1 <= i;
y2 <= '0';
y3 <= '0';
elsif (s0 = '0' and s1 = '1') then
y0 <= '0';
y1 <= '0';
y2 <= i;
y3 <= '0';
�15
else
y0 <= '0';
y1 <= '0';
y2 <= '0';
y3 <= i;
end if;
end process;
END demux_1x4;
3.4.2 Código e simulação do multiplexador 4 x1 e demultiplexador 4 x 1.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
entity mux_demux is
port(entradasmux:in bit_vector(0 to 3);
seletormux:in bit_vector(0 to 1);
saidamux: buffer bit;
seletordemux:in bit_vector(0 to 1);
saidasdemux:out bit_vector(0 to 3));
end mux_demux;
architecture circuito of mux_demux is
begin
saidamux<= '1' when seletormux="00" and entradasmux="1000"
else
'1' when seletormux="01" and entradasmux="0100"
else
'1' when seletormux="10" and entradasmux="0010"
else
'1' when seletormux="11" and entradasmux="0001";
�16
saidasdemux<= "1000" when seletordemux="00" and saidamux='1'
else
"0100" when seletordemux="01" and
saidamux='1' else
"0010" when seletordemux="10" and
saidamux='1' else
"0001" when seletordemux="11" and
saidamux='1';
end circuito;
�17
Figura 7
�18
Figura 8
Figura 9
3.4.2 Código e simulação do comparador 4 bits.LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY COMPARADOR IS
PORT(A,B: IN STD_LOGIC_VECTOR (3 DOWNTO 0);
AeqB, AgtB, AltB: OUT STD_LOGIC);
END COMPARADOR;
ARCHITECTURE LABO OF COMPARADOR IS
BEGIN
AeqB <= '1' WHEN A = B ELSE '0';
AgtB <= '1' WHEN A > B ELSE '0';
AltB <= '1' WHEN A < B ELSE '0';
END LABO;
�19
4. LABORATÓRIO IV
4.1 OBJETIVOS
- Verificar a implementação de um circuito somador completo de um 1 bit e de um
somador completo de ( N = 4) bits.
- Testar a plataforma DE 01 (altera).
4.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
4.3 PROCEDIMENTOS
4.3.1 Implementamos em vhdl e prototipamos o circuito somador completo de 1 bit.
Representado pela tabela verdade e circuito abaixo:
�20
S Cout
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
�A �B inC
Circuito somador 1 bit:
�21
Somador Completo
1 bit
A
B
Cin
S
Cout
4.3.2 Implementamos em vhdl e prototipamos o circuito somador completo de 4 bits
do diagrama abaixo:
4.4 RESULTADOS
4.4.1 Código e simulação do somador de 1 bit.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY somador1bit is
port(cin, a, b: in std_logic;
s, cout: out std_logic);
END somador1bit;
ARCHITECTURE soma1bit OF somador1bit IS
BEGIN
s <= a XOR b XOR cin;
cout <= (a AND b) or (cin AND a) or (cin AND b);
END soma1bit;
�22
�23
Figura 10 Figura 11
Figura 12
4.4.1 Código e simulação do somador de 4 bits
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY soma04 is
port(cin: in std_logic;
a,b: in std_logic_vector (3 downto 0);
cout: out std_logic;
s: out std_logic_vector (3 downto 0));
end soma04;
ARCHITECTURE arch_soma04 of soma04 is
BEGIN
process (a,b,cin)
variable soma:std_logic_vector(3 downto 0);
variable c: std_logic;
BEGIN
c:=cin;
for i in 0 to 3 loop
soma(i):=a(i) xor b(i) xor c;
c:= (a(i) and b(i)) or ((a(i) xor b(i)) and c);
end loop;
cout<=c;
s<=soma;
end process;
end arch_soma04;
�24
�25
Figura 13
5. LABORATÓRIO V
5.1 OBJETIVOS
- Verificar a implementação de um circuito gerador de clock de 1 Hz e 10Hz.
- Testar a plataforma DE 01 (altera).
5.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
5.3 PROCEDIMENTOS
5.3.1 Projetamos em vhdl um componente divisor de clock que a partir de um
entrada de 50 MHz possa gerar os sinais de clock de 1Hz e 10Hz.
5.3.2 Projetamos e implementamos em vhdl um circuito contador de realize a
contagem abaixo.
�26
Clock
Divider
50 MHz
10 Hz
1Hz
3 6 9 12
Observação: o circuito deve utilizar o clock de 1 Hz d questão anterior e apresentar o
resultado no display de 7 segmentos.
5.4 RESULTADOS
5.4.1 Código do divisor de clock
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lab05ex01 is
Port (
clk: in STD_LOGIC;
clk_out, clk_out1 : out STD_LOGIC
);
end entity lab05ex01;
architecture arch_lab05ex01 of lab05ex01 is
signal contador : integer range 0 to 50000000:=0;
signal pulso :std_LOGIC;
signal contador1: integer range 0 to 5000000:=0;
signal pulso1: std_LOGIC;
�27
Display 1
Clock 1Hz
50 MHz Contador +
decoder 7
segmentos
1 Hz
Display 2
begin
process(clk)
begin
if(clk'event and clk='1') then
if(contador=50000000/2) then
contador<=0;
pulso<=not(pulso);
else
contador<=contador+1;
end if;
end if;
end process;
process(clk)
begin
if(clk'event and clk='1') then
if(contador1=5000000/2) then
contador1<=0;
pulso1<=not(pulso1);
else
contador1<=contador1+1;
end if;
end if;
end process;
clk_out<=pulso;
clk_out1<=pulso1;
end arch_lab05ex01;
�28
5.4.2 Código e simulação do circuito contador
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity lab05ex02 is
Port (
clk1, reset : in std_logic;
uSegundo : out std_logic_vector(6 downto 0);
clk_out : out STD_LOGIC;
dSegundo : out std_logic_vector(6 downto 0)
);
end lab05ex02;
architecture arch_lab05ex02 of lab05ex02 is
signal dSeg : integer range 0 to 12 :=0;
signal uSeg : integer range 0 to 9:=0;
signal count : integer :=1;
�29
Figura 14
signal clk : std_logic :='0';
begin
process( clk1 )
begin
if(clk1'event and clk1='1') then
count <=count+1;
if( count = 50000000 - 1 ) then
count <=1;
end if;
if count<25000000 then
clk_out <= '1';
clk <= '1';
else
clk_out <= '0';
clk <= '0';
end if;
end if;
end process;
process( clk, reset )
begin
if( clk'event and clk='1' ) then
uSeg <= uSeg+ 2;
if( uSeg = 9 ) then
uSeg <= 0;
dSeg <= 1;
elsif( (dSeg = 1) and (uSeg = 0) ) then
uSeg <= 2;
dSeg <= 0;
end if;
end if;
case uSeg is
when 0 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
�30
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '1';
when 3 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '0';
when 6 =>
uSegundo(0) <= '0';
uSegundo(1) <= '1';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 9 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when others =>
end case;
�31
case dSeg is
when 0 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '0';
dSegundo(6) <= '1';
when 12 =>
dSegundo(0) <= '0';
dSegundo(1) <= '1';
dSegundo(2) <= '1';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '0';
dSegundo(6) <= '1';
when others =>
end case;
end process;
end arch_lab05ex02;
�32
�33
Figura 15 Figura16
Figura 17 Figura 18
6. LABORATÓRIO VI
6.1 OBJETIVOS
- Projetar um cronômetro digital de 2 bits
- Contagem de 00 - 59 s
- Projetar um relógio digital
6.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
6.3 PROCEDIMENTOS
6.3.1 Projetamose implementamos um cronômetro digital que realiza a contagem de
00-59 s utilizando 2 display de 7 segmentos. Cada digito foi apresentado por 1
segundo. O contato foi incrementado pelo sinal de 50 mHz. Simulamos e verificamos
o funcionamento na placa DE 01.
�34
1 Hz
Time
Clock
1Hz
50 MHz
Decoder
BCD 7 seg
Contador
n bits
Leds
6.3.2 Projetamos e implementamos em vhdl o circuito de um relógio digital 24h. O
circuito deverá apresentar os minutos e os segundos nos display de 7 segmentos e
as horas (no formato binário) nos 8 LEDs da placa DE 01 de acordo com o exemplo
abaixo:
Leitura: 14 h 24 min e 05 segundos
�35
2 4 50
1 4
6.4 RESULTADOS
6.4.1 Código e simulação do cronômetro digital 0- 59 s.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity lab06ex01 is
Port (
clk1, reset : in std_logic;
uSegundo : out std_logic_vector(6 downto 0);
clk_out : out STD_LOGIC;
dSegundo : out std_logic_vector(6 downto 0)
);
end lab06ex01;
architecture arch_lab06ex01 of lab06ex01 is
signal uSeg, dSeg : integer range 0 to 60 :=0;
signal count : integer :=1;
signal clk : std_logic :='0';
begin
process( clk1 )
begin
if(clk1'event and clk1='1') then
count <=count+1;
if( count = 50000000 - 1 ) then
count <=1;
end if;
if count<25000000 then
clk_out <= '1';
clk <= '1';
else
clk_out <= '0';
�36
clk <= '0';
end if;
end if;
end process;
process( clk, reset )
begin
if( clk'event and clk='1' ) then
uSeg <= uSeg+ 1;
if( uSeg = 9 ) then
uSeg <= 0;
dSeg <= dSeg + 1;
if ( dSeg = 5 ) then
dSeg <= 0;
end if;
end if;
end if;
case uSeg is
when 0 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '1';
when 1 =>
uSegundo(0) <= '1';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '1';
when 2 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
�37
uSegundo(2) <= '1';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '1';
uSegundo(6) <= '0';
when 3 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '0';
when 4 =>
uSegundo(0) <= '1';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 5 =>
uSegundo(0) <= '0';
uSegundo(1) <= '1';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 6 =>
uSegundo(0) <= '0';
uSegundo(1) <= '1';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 7 =>
uSegundo(0) <= '0';
�38
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '1';
when 8 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 9 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when others =>
end case;
case dSeg is
when 0 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '0';
dSegundo(6) <= '1';
when 1 =>
dSegundo(0) <= '1';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
�39
dSegundo(3) <= '1';
dSegundo(4) <= '1';
dSegundo(5) <= '1';
dSegundo(6) <= '1';
when 2 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '1';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '1';
dSegundo(6) <= '0';
when 3 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '1';
dSegundo(5) <= '1';
dSegundo(6) <= '0';
when 4 =>
dSegundo(0) <= '1';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '1';
dSegundo(4) <= '1';
dSegundo(5) <= '0';
dSegundo(6) <= '0';
when 5 =>
dSegundo(0) <= '0';
dSegundo(1) <= '1';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '1';
dSegundo(5) <= '0';
dSegundo(6) <= '0';
when others =>
end case;
�40
--if ( reset'event and reset='1' ) then
-- uSeg <= 0;
-- dSeg <= 0;
--end if;
end process;
end arch_lab06ex01;
�41
Figura 19
6.4.1 Código e simulação do relógio digital 24h.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity lab06ex02 is
Port (
clk1 : in std_logic;
clk_out : out std_logic;
uSegundo : out std_logic_vector(6 downto 0);
dSegundo : out std_logic_vector(6 downto 0);
uMinuto : out std_logic_vector(6 downto 0);
dMinuto : out std_logic_vector(6 downto 0);
uhora : out std_logic_vector(3 downto 0);
dhora : out std_logic_vector(3 downto 0)
);
end lab06ex02;
architecture arch_lab06ex02 of lab06ex02 is
signal uSeg : integer range 0 to 9 :=0;
signal dSeg : integer range 0 to 5 :=4;
signal uMin : integer range 0 to 9 :=9;
signal dMin : integer range 0 to 5 :=5;
signal dHr : integer range 0 to 2 :=1;
signal uHr : integer range 0 to 9 :=3;
signal count : integer :=1;
signal clk : std_logic :='0';
beginprocess( clk1 )
begin
if(clk1'event and clk1='1') then
count <=count+1;
if( count = 50000000 - 1 ) then
�42
count <=1;
end if;
if count<25000000 then
clk_out <= '1';
clk <= '1';
else
clk_out <= '0';
clk <= '0';
end if;
end if;
end process;
process( clk )
begin
if( clk'event and clk='1' ) then
uSeg <= uSeg+ 1;
if( uSeg = 9 ) then
uSeg <= 0;
dSeg <= dSeg + 1;
if ( dSeg = 5 ) then
dSeg <= 0;
uMin <= uMin + 1;
if ( uMin = 9 ) then
uMin <= 0;
dMin <= dMin + 1;
if ( dMin = 5 ) then
dMin <= 0;
uhr <= uhr + 1;
if ( (uhr = 9) or (uhr = 4) ) then
if ( ((dhr = 0) or (dhr = 1))
and (uHr = 9) ) then
dHr <= dHr + 1;
uHr <= 0;
elsif ( (dhr = 2) and (uHr =
4) ) then
dHr <= 0;
uHr <= 0;
�43
end if;
end if;
end if;
end if;
end if;
end if;
end if;
case uSeg is
when 0 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '1';
when 1 =>
uSegundo(0) <= '1';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '1';
when 2 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '1';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '1';
uSegundo(6) <= '0';
when 3 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
�44
uSegundo(5) <= '1';
uSegundo(6) <= '0';
when 4 =>
uSegundo(0) <= '1';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 5 =>
uSegundo(0) <= '0';
uSegundo(1) <= '1';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 6 =>
uSegundo(0) <= '0';
uSegundo(1) <= '1';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 7 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '1';
uSegundo(4) <= '1';
uSegundo(5) <= '1';
uSegundo(6) <= '1';
when 8 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
�45
uSegundo(4) <= '0';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when 9 =>
uSegundo(0) <= '0';
uSegundo(1) <= '0';
uSegundo(2) <= '0';
uSegundo(3) <= '0';
uSegundo(4) <= '1';
uSegundo(5) <= '0';
uSegundo(6) <= '0';
when others =>
end case;
case dSeg is
when 0 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '0';
dSegundo(6) <= '1';
when 1 =>
dSegundo(0) <= '1';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '1';
dSegundo(4) <= '1';
dSegundo(5) <= '1';
dSegundo(6) <= '1';
when 2 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '1';
dSegundo(3) <= '0';
dSegundo(4) <= '0';
dSegundo(5) <= '1';
�46
dSegundo(6) <= '0';
when 3 =>
dSegundo(0) <= '0';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '1';
dSegundo(5) <= '1';
dSegundo(6) <= '0';
when 4 =>
dSegundo(0) <= '1';
dSegundo(1) <= '0';
dSegundo(2) <= '0';
dSegundo(3) <= '1';
dSegundo(4) <= '1';
dSegundo(5) <= '0';
dSegundo(6) <= '0';
when 5 =>
dSegundo(0) <= '0';
dSegundo(1) <= '1';
dSegundo(2) <= '0';
dSegundo(3) <= '0';
dSegundo(4) <= '1';
dSegundo(5) <= '0';
dSegundo(6) <= '0';
when others =>
end case;
case uMin is
when 0 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '0';
uMinuto(5) <= '0';
uMinuto(6) <= '1';
when 1 =>
�47
uMinuto(0) <= '1';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '1';
uMinuto(4) <= '1';
uMinuto(5) <= '1';
uMinuto(6) <= '1';
when 2 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '1';
uMinuto(3) <= '0';
uMinuto(4) <= '0';
uMinuto(5) <= '1';
uMinuto(6) <= '0';
when 3 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '1';
uMinuto(5) <= '1';
uMinuto(6) <= '0';
when 4 =>
uMinuto(0) <= '1';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '1';
uMinuto(4) <= '1';
uMinuto(5) <= '0';
uMinuto(6) <= '0';
when 5 =>
uMinuto(0) <= '0';
uMinuto(1) <= '1';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '1';uMinuto(5) <= '0';
uMinuto(6) <= '0';
�48
when 6 =>
uMinuto(0) <= '0';
uMinuto(1) <= '1';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '0';
uMinuto(5) <= '0';
uMinuto(6) <= '0';
when 7 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '1';
uMinuto(4) <= '1';
uMinuto(5) <= '1';
uMinuto(6) <= '1';
when 8 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '0';
uMinuto(5) <= '0';
uMinuto(6) <= '0';
when 9 =>
uMinuto(0) <= '0';
uMinuto(1) <= '0';
uMinuto(2) <= '0';
uMinuto(3) <= '0';
uMinuto(4) <= '1';
uMinuto(5) <= '0';
uMinuto(6) <= '0';
when others =>
end case;
case dMin is
when 0 =>
dMinuto(0) <= '0';
�49
dMinuto(1) <= '0';
dMinuto(2) <= '0';
dMinuto(3) <= '0';
dMinuto(4) <= '0';
dMinuto(5) <= '0';
dMinuto(6) <= '1';
when 1 =>
dMinuto(0) <= '1';
dMinuto(1) <= '0';
dMinuto(2) <= '0';
dMinuto(3) <= '1';
dMinuto(4) <= '1';
dMinuto(5) <= '1';
dMinuto(6) <= '1';
when 2 =>
dMinuto(0) <= '0';
dMinuto(1) <= '0';
dMinuto(2) <= '1';
dMinuto(3) <= '0';
dMinuto(4) <= '0';
dMinuto(5) <= '1';
dMinuto(6) <= '0';
when 3 =>
dMinuto(0) <= '0';
dMinuto(1) <= '0';
dMinuto(2) <= '0';
dMinuto(3) <= '0';
dMinuto(4) <= '1';
dMinuto(5) <= '1';
dMinuto(6) <= '0';
when 4 =>
dMinuto(0) <= '1';
dMinuto(1) <= '0';
dMinuto(2) <= '0';
dMinuto(3) <= '1';
dMinuto(4) <= '1';
dMinuto(5) <= '0';
dMinuto(6) <= '0';
when 5 =>
�50
dMinuto(0) <= '0';
dMinuto(1) <= '1';
dMinuto(2) <= '0';
dMinuto(3) <= '0';
dMinuto(4) <= '1';
dMinuto(5) <= '0';
dMinuto(6) <= '0';
when others =>
end case;
uHora <= conv_std_logic_vector(uHr, 4);
dHora <= conv_std_logic_vector(dHr, 4);
end process;
end arch_lab06ex02;
�51
Figura 20 Figura 21
7. LABORATÓRIO VII
7.1 OBJETIVOS
- Projeto de um unidade lógica e aritmética (ULA) de 4 bits.
- Testar a plataforma DE 01 (altera).
7.2 MATERIAIS
- HW: Plataforma DE 01.
- SW: Ide Quartus II Web Edition.
7.3 PROCEDIMENTOS
7.3.1 Projetamos e implementamos em vhdl a unidade lógica e aritmética (ULA) de 4
bits que realiza-se as operações lógicas e aritméticas descrita na tabela verdade
abaixo:
�52
7.4 RESULTADOS
7.4.1 Código e simulação da ULA.
ULA.vhd
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ULA is
port (a, b , sel: in std_logic_vector (0 to 3);
carryIn, M0: in bit;
output: buffer std_logic_vector(0 to 4)
);
end ULA;
architecture arquitetura_componente_ula OF ULA is
component Funcaritimetic1
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: buffer std_logic_vector(0 to 4)
);
end component;
component Funcaritimetic2
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: buffer std_logic_vector(0 to 4)
);
�53
end component;
component Funclogic
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: out std_logic_vector(0 to 4)
);
end component;
SIGNAL S1, S2, S3: std_logic_vector(0 to 4);
begin
G1: Funcaritimetic1 PORT MAP(palavraA => a, palavraB => b,
seletor => sel, cin => carryIn, M => M0, saida_ula => S1);
G2: Funcaritimetic2 PORT MAP(palavraA => a, palavraB => b,
seletor => sel, cin => carryIn, M => M0, saida_ula => S2);
G3: Funclogic PORT MAP(palavraA => a, palavraB => b, seletor
=> sel, cin => carryIn, M => M0, saida_ula => S3);
output <=
S3 when ((M0 = '1') and (carryIn) = '1') else
S1 when ((M0 = '0') and (carryIn) = '1') else
S2 when ((M0 = '0') and (carryIn) = '0');
�54
end arquitetura_componente_ula;
Funclogic
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity Funclogic is
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: buffer std_logic_vector(0 to 4)
);
end Funclogic;
architecture logic of Funclogic is
begin
process (palavraA, palavraB, seletor, saida_ula) begin
case (seletor) is
when "0000" => saida_ula <= ('0' & (not(palavraA)));
when "0001" => saida_ula <= ('0' & (not(palavraA or
palavraB)));
when "0010" => saida_ula <= ('0' & (not(palavraA))and
(palavraB));
when "0011" => saida_ula <= "00000";
when "0100" => saida_ula <= ('0' & (not(palavraA and
palavraB)));
when "0101" => saida_ula <= ('0' & (not(palavraB)));
when "0110" => saida_ula <= ('0' & (not(palavraA)) xor
(palavraB));
when "0111" => saida_ula <= ('0' & (palavraA)and
(not(palavraB)));
when "1000" => saida_ula <= ('0' & (not(palavraA)) or
palavraB);
�55
when "1001" => saida_ula <= ('0' & (not(palavraA xor
palavraB)));
when "1010" => saida_ula <= ('0' & (palavraB));
when "1011" => saida_ula <= ('0' & (palavraA and palavraB));
when "1100" => saida_ula <= "00001";
when "1101" => saida_ula <= ('0' & (palavraA)OR
(not(palavraB)));
when "1110" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraB ));
when "1111" => saida_ula <= ('0' & (palavraA));
end case;
end process;
end logic;
Funcaritimetic1.vhd
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity Funcaritimetic1 is
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: buffer std_logic_vector(0 to 4)
);
end Funcaritimetic1;
architecture aritimetic1 of Funcaritimetic1 is
begin
process (palavraA, palavraB, seletor, saida_ula) begin
�56
-- concatenar funções lógicas: '0' & (FUNÇÃO LÓGICA);
-- concatenar funções aritméticas: ( '0' & (FUNÇÃO
LÓGICA) )maisOUmenos('0' & (FUNÇÃO LÓGICA))
case (seletor) is
when "0000" => saida_ula <= ('0' & (palavraA));
when "0001" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraB ));
when "0010" => saida_ula <= ('0' & (palavraA)) OR ('0' &
(not(palavraB)));
when "0011" => saida_ula <= "01111";
when "0100" => saida_ula <= ('0' & (palavraA)) + ('0' &
(not(palavraA + palavraB )));
when "0101" => saida_ula <= ('0' & (palavraA + palavraB)) +
('0' & (palavraA AND (not(palavraB ))));
when "0110" => saida_ula <= ('0' & (palavraA)) - ('0' &
(palavraB)) - 1;
when "0111" => saida_ula <= ('0' & (palavraA AND palavraB) -
1);
when "1000" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraA AND palavraB ));
when "1001" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraB ));
when "1010" => saida_ula <= ('0' & (palavraA OR
(not(palavraB)))) + ('0' & (palavraA AND palavraB ));
when "1011" => saida_ula <=('0' & (palavraA AND palavraB)) -
1;
when "1100" => saida_ula <= ((palavraA) + (palavraB) & '0');
when "1101" => saida_ula <= ('0' & (palavraA OR palavraB)) +
('0' & (palavraA));
when "1110" => saida_ula <= ('0' & (palavraA OR
(not(palavraB)))) + ('0' & (palavraA ));
when "1111" => saida_ula <= ('0' & (palavraA)) - 1;
end case;
end process;
�57
end aritimetic1;
Funcaritimetic2.vhd
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity Funcaritimetic2 is
port ( palavraA, palavraB, seletor: in std_logic_vector (0 to
3);
cin,M: in bit;
saida_ula: buffer std_logic_vector(0 to 4)
);
end Funcaritimetic2;
architecture aritimetic2 of Funcaritimetic2 is
begin
process (palavraA, palavraB, seletor, saida_ula) begin
case (seletor) is
when "0000" => saida_ula <= ('0' & (palavraA + 1));
when "0001" => saida_ula <= ('0' & (palavraA or palavraB)) +
1;
when "0010" => saida_ula <= ('0' & (palavraA or
(not(palavraB)))) + 1;
when "0011" => saida_ula <= "00000";
when "0100" => saida_ula <= ('0' & (palavraA)) + ('0' &
(not(palavraA AND palavraB ))) + 1;
when "0101" => saida_ula <= ('0' & (palavraA OR palavraB)) +
('0' & (palavraA AND (not(palavraB )))) + 1;
when "0110" => saida_ula <= ('0' & (palavraA)) - ('0' &
(palavraB));
�58
when "0111" => saida_ula <= ('0' & (palavraA AND
(not(palavraB))));
when "1000" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraA AND palavraB )) + 1;
when "1001" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraB )) + 1;
when "1010" => saida_ula <= ('0' & (palavraA +
(not(palavraB)))) + ('0' & (palavraA AND palavraB )) + 1;
when "1011" => saida_ula <= ('0' & (palavraA and palavraB));
when "1100" => saida_ula <= ('0' & (palavraA)) + ('0' &
(palavraA)) + 1;
when "1101" => saida_ula <= ('0' & (palavraA or palavraB)) +
('0' & (palavraA)) + 1;
when "1110" => saida_ula <= ('0' & (palavraA OR
(not(palavraB)))) + ('0' & (palavraA )) + 1;
when "1111" => saida_ula <= ('0' & (palavraA));
end case;
end process;
end aritimetic2;
�59
Figura 22
Figura 23
CONCLUSÃO
Nas práticas de laboratório, aprendemos os principais métodos para criar e
implementar os sistemas digitais usando o software Altera- Quartus tais como:
- Design digital utilizando esquema de blocos;
- Codificação usando o VHDL;
- Atribuição de pinos para implementação na placa;
- Descarregamento de um código VHDL no FPGA.
Sendo assim, mesmo diante das dificuldade encontradas tais como erros de
código, erros de pinagem e entre outros, conseguimos resolver os problemas
práticos com êxito, confirmando assim os principais conceitos de lógica
combinacional aprendidos na sala de aula.
�60
1. LABORATÓRIO I
2. LABORÁTORIO II
3. LABORÁTORIO III
4. LABORATÓRIO IV
5. LABORATÓRIO V
6. LABORATÓRIO VI
7. LABORATÓRIO VII
CONCLUSÃO