






Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!







Lista 1
(a) 𝐹 = 𝑥̅ ∙ 𝑧 + 𝑥 ∙ 𝑦 + 𝑥 ∙ 𝑦̅ ∙ 𝑧; (b) 𝐺 = 𝑎̅ ∙ 𝑐̅ ∙ 𝑑 + 𝑏̅ ∙ 𝑐 ∙ 𝑑 + 𝑎 ∙ 𝑐̅ ∙ 𝑑 + 𝑏 ∙ 𝑐 ∙ 𝑑.
Entity 4to1_mux port ( Signal a, b, c, d: std_logic_vectors (3 downto 0); Select: in std_logic_vector(1 downto 0); X : out bit_vector(3 downto 0); End;
Architecture of 4to1_mux Begin P1: process begin If select = ‘00’ then X <= a; Elsif select = ‘10’ X <= b; Elsif select = ‘11’ X <= c; Else X <= d End if; End process; End 4to1_mux;
library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all;
entity P1_1_001 is port( a,b,c,d: in std_logic_vector(5 downto 0); reset,clock, ch1, pm: in std_logic; s: out std_logic_vector(5 downto 0)); end P1_1_001;
architecture P1_1_001 of P1_1_001 is signal pm1,pm2,res : std_logic_vector(5 downto 0);
begin process (clock, reset) begin if reset='1' then s <= (others=>'0'); elsif clock'event and clock='1' then s <= res; end if; end process;
res <= pm1+pm2 when pm='1' else pm1-pm2; pm1 <= a when ch1='0' else b; pm2 <= c when ch1='0' else d;
end P1_1_001;
else Z <= ’0’; snext <= S1; end if; when S2 => if X = '0' then Z <= ’1’; snext <= S2; else Z <= ’0’; snext <= S3; end if; when S3 => if X = '0' then Z <= ’0’; snext <= S0; else Z <= ’0’; snext <= S1; end if;
end case; end process combinacional; end A;
Respostas
Os códigos em VHDL apresentados são apenas sugestões.
Existem várias formas de codificar cada um dos problemas propostos e não necessariamente o código mostrado é a melhor solução.
Exercício 1:
library ieee; use ieee.std_logic_1164.all;
entity exerc_1 is port ( a, b : in std_logic_vector(3 downto 0); z : out integer ); end exerc_1;
architecture logica of exerc_1 is
begin z <= 1 when a > b else 0 when a = b else
end logica;
Exercício 2:
library ieee; use ieee.std_logic_1164.all;
entity exerc_2 is port ( x, y, z, a, b, c, d: in std_logic; F, G : out std_logic ); end exerc_2;
architecture logic_comb of exerc_2 is
begin F <= (not x and z) or (x and y) or (x and not y and z); G <= (not a and not c and d) or (not b and c and d) or (a and not c and d) or (b and c and d);
end logic_comb;
Exercício 4:
Código corrigido.
library ieee; use ieee.std_logic_1164.all;
entity mux_4to1 is port ( sel: in std_logic_vector(1 downto 0); x : out bit_vector(3 downto 0) ); end mux_4to1;
architecture my_mux of mux_4to1 is signal a, b, c, d: std_logic_vector(3 downto 0);
begin P1: process (sel) begin if sel = "00" then x <= to_bitvector(a); elsif sel = "10" then x <= to_bitvector(b); elsif sel = "11" then x <= to_bitvector(c); else x <= to_bitvector(d); end if; end process P1; end my_mux;
Exercício 5:
MUX
MUX
c
d
a
b
SOMA
SUB
ch1^ MUX
pm
pm
pm
res
FF D clock
reset
s
Exercício 6:
library ieee; use ieee.std_logic_1164.all;
entity codec is port ( enable, reset, clk : in bit; toggle : buffer bit ); end codec;
architecture ckt of codec is signal ff_in : bit;
begin ff_in <= toggle xor enable;
FFD: process (clk, reset) begin if reset = '1' then toggle <= '0'; elsif (clk'event and clk = '1') then toggle <= ff_in; end if;
end process FFD; end ckt;
Exercício 8:
library ieee; use ieee.std_logic_1164.all;
entity detector is port ( en, clk : in bit; s_input : in bit; z : out std_logic ); end detector;
architecture sniffer of detector is signal cont_code : integer range 0 to 4 := 0;
begin conta: process (clk, en) begin if (clk'event and clk = '1') and en = '1' then case cont_code is when 0 => if s_input = '1' and cont_code = 0 then cont_code <= cont_code + 1; elsif s_input = '1' and cont_code = 1 then cont_code <= 1; end if; when 1 => if s_input = '0' then cont_code <= cont_code + 1; else cont_code <= 1; end if; when 2 => if s_input = '1' then cont_code <= cont_code + 1; else cont_code <= 0; end if; when 3 => if s_input = '1' then cont_code <= cont_code + 1; else cont_code <= 0; end if; when others => if s_input = '1' then cont_code <= 1; else cont_code <= 0; end if; end case; end if;
end process conta;
z <= '1' when cont_code = 4 else '0';
end sniffer;
Exercício 9:
library ieee; use ieee.std_logic_1164.all;
entity exerc_3a is port ( w, clk : in std_logic; z : out std_logic ); end exerc_3a;
architecture fsm of exerc_3a is type estado is (A, B, C, F); signal atual_estado: estado := A; signal prox_estado: estado;
begin
process (clk) begin if (clk'event and clk = '1') then atual_estado <= prox_estado; end if; end process;
prox_estado <= C when (atual_estado = A and w = '1') else F when (atual_estado = B and w = '1') else C when (atual_estado = C and w = '1') else A when (atual_estado = F and w = '1') else B when (atual_estado = A and w = '0') else A when (atual_estado = B and w = '0') else F when (atual_estado = C and w = '0') else C when (atual_estado = F and w = '0');
with atual_estado select z <= '1' when A, '1' when B, '0' when C, '0' when F; end fsm;