You are on page 1of 3

Problema 1.

1
process(Q)
begin
a <= '0';
b <= '0';
c <= '0';
d <= '0';
e <= '0';
f <= '0';
case Q is
when "000" =>
a <= '1';
when "001" =>
f <= '1';
when "010" =>
e <= '1';
when "011" =>
d <= '1';
when "100" =>
c <= '1';
when "101" =>
b <= '1';
when others =>
end case;
end process;

Problema 1.2
120 = 01111000
119 = 01110111
-119 = 10001001

signal a,b,s: signed(7 downto 0);

-- Opción 1
a <= to_signed( 120,8); -- a <= "01111000"
b <= to_signed(-119,8); -- b <= "10001001"
s <= a+b;

-- Opción 2
a <= to_signed(120,8); -- a <= "01111000"
b <= to_signed(119,8); -- b <= "01110111"
s <= a-b;
Problema 1.3
1/0

0/0 Init

S0
0/1 1/0
0/0
0/0
S00
0/0 1/0

1/0
S0X1
S01
1/0

library ieee;
use ieee.std_logic_1164.all;

entity maquina is
port ( Clk: in std_logic;
Reset: in std_logic;
A: in std_logic;
S: out std_logic );
end maquina;

architecture funcional of maquina is


type EstadoT is (Init,S0,S01,S00,S0X1);
signal estado,siguiente: EstadoT;
begin

process(Clk,Reset)
begin
if Reset='1' then
estado <= Init;
elsif rising_edge(Clk) then
estado <= siguiente;
end if;
end process;

process(estado,A)
begin
S <= '0';
case estado is
when Init =>
if A='0' then
siguiente <= S0;
else
siguiente <= Init;
end if;
when S0 =>
if A='0' then
siguiente <= S00;
else
siguiente <= S01;
end if;
when S00 =>
if A='0' then
siguiente <= S00;
else
siguiente <= S0X1;
end if;
when S01 =>
if A='0' then
siguiente <= S0;
else
siguiente <= S0X1;
end if;
when S0X1 =>
if A='0' then
siguiente <= S0;
S <= '1';
else
siguiente <= Init;
end if;
when others =>
siguiente <= Init;
end case;
end process;

end funcional;

Problema 1.4
Contador: número de bits y valor de cuenta máximo
35 𝑚𝑠
𝐶𝑢𝑒𝑛𝑡𝑎 = = 35𝑚 · 5𝑀 = 175000
1⁄
5𝑀𝐻𝑧
log 175000
𝑁 = log 2 175000 = = 17,41 ≅ 17 𝑏𝑖𝑡𝑠
log 2

signal Enable: std_logic;


signal Clear: std_logic;
signal EoC: std_logic;
signal count: unsigned(16 downto 0);

begin

EoC <= '1' when count=174999 and Enable='1' else '0';

process(Clk,Reset)
begin
if Reset='1' then
count <= (others=>'0');
elsif rising_edge(Clk) then
if Clear='1' then
count <= (others=>'0');
elsif Enable='1' then
if count = 2**17-1 then -- También vale 174999
count <= (others=>'0');
else
count <= count+1;
end if;
end if;
end if;
end process;

You might also like