Você está na página 1de 2

 

Sistemas Digitais 
Engenharia Electrotécnica ‐ Engenharia Informática 
EXAME A 

Nome __________________________________________________________________________________ 

Número _____________________ Curso__________________________ Classificação ________________ 

1‐ Escreva um módulo em VHDL que implemente o seguinte codificador digital com prioridades: [12] 

(se já não se recordar do modo de operação de um codificador pode ler as páginas 50 e 51 da sebenta 
“Pneumática e Automatismos” que pode encontrar em www.ipb.pt/~jpcoelho/Misc/PeA_.pdf) 

Sugestão: Utilize vectores para representar os sinais de entrada e os sinais de saída 

A preencher pelo professor. 
 
 
 

2‐ Escreva um “testbench” para o circuito anterior com os seguintes estímulos: [8] 
I3 constante e igual a 1 
I2 constante e igual a 0 
I1 e I0 devem possuir o seguinte comportamento temporal: 

A preencher pelo professor. 
 
 

 

 
SUGESTÃO DE RESOLUÇÃO 

 
-- MODULO
-- TESTBENCH
library IEEE;
LIBRARY ieee;
use IEEE.STD_LOGIC_1164.ALL;
USE ieee.std_logic_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
USE ieee.std_logic_unsigned.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
USE ieee.numeric_std.ALL;
entity codificador is
ENTITY tb IS
Port ( I0,I1,I2,I3 : in STD_LOGIC;
END tb;
Saidas : out integer range 0
to 3);
ARCHITECTURE behavior OF tb IS
end codificador;
COMPONENT codificador
architecture Behavioral of codificador is
PORT(
I0 : IN std_logic;
begin
I1 : IN std_logic;
I2 : IN std_logic;
process(I0,I1,I2,I3)
I3 : IN std_logic;
variable tmp:integer range 0 to 3;
Saidas : OUT integer range 0 to
begin
3
if I0='1' then tmp:=0;
);
elsif I1='1' then
END COMPONENT;
tmp:=1;
signal I0 : std_logic := '0';
elsif I2='1' then
signal I1 : std_logic := '0';
tmp:=2;
signal I2 : std_logic := '0';
else tmp:=3;
signal I3 : std_logic := '0';
end if;
signal Saidas : integer range 0 to 3;
Saidas<=tmp;
end process;
BEGIN
end Behavioral;
uut: codificador PORT MAP (
I0 => I0,  
I1 => I1,
I2 => I2,
I3 => I3,
Saidas => Saidas
);

I3<='1';
I2<='0';
I1<='1','0' after 100 ns, '1' after 300
ns;
I0<='0','1' after 200 ns, '0' after 400
ns;

END;

 

Você também pode gostar