diseño-labo4

13
(UNIVERSIDAD DEL PERÚ, Decana de América) FACULTAD FIEE “Laboratorio 4“ PREVIO CURSO : Diseño digital (LABORATORIO) PROFESOR : Alfredo Granados Ly ALUMNO : Zavaleta Narvaez Andre CÓDIGO : 10190108

Upload: samuel-baldeon-yllaconza

Post on 10-Apr-2016

5 views

Category:

Documents


0 download

DESCRIPTION

laboratorio

TRANSCRIPT

Page 1: diseño-labo4

(UNIVERSIDAD DEL PERÚ, Decana de América)

FACULTAD FIEE“Laboratorio 4“

PREVIO

CURSO : Diseño digital (LABORATORIO)

PROFESOR : Alfredo Granados Ly

ALUMNO : Zavaleta Narvaez Andre

CÓDIGO : 10190108

Informe Final Nº 4

Page 2: diseño-labo4

Laboratorio 4

1. Implementación de un contador para la siguiente cuenta: 0,7,4,3,1, 0,7,4,3,1 que tenga una señal de RESET y fuerce al estado inicial. Utilice máquina de estado (utilice ME–Moore).

library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

entity cuenta is port( clk, reset : in std_logic;

salida : out std_logic_vector(2 downto 0));end cuenta;architecture solucion of cuenta istype estado is (s0,s1,s2,s3,s4);signal e : estado;begin

process(clk,reset)beginif reset = '1' then

salida <= "000";elsif rising_edge(clk) thencase e is when s0 =>

e <= s1;salida <= "000";

when s1 =>e <= s2;

salida <= "111";when s2 =>

e <= s3;salida <= "100";

when s3 =>e <= s4;

salida <= "011";when s4 =>

e <= s1;salida <= "001";

end case;end if;end process;

end solucion;

Page 3: diseño-labo4

Laboratorio 4

2. Implemente un detector para la siguiente secuencia: 01101010 debe tenar la capacidad de traslape. Utilice MEF-Mealy.

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

entity secuencia isPort ( dato,clk : in std_logic;

salida : out std_logic);

end secuencia;architecture solucion of secuencia istype estado is (s0,s1,s2,s3,s4,s5,s6,s7);signal es,ep : estado;begin

process(clk)beginif rising_edge(clk) then

ep <= es;end if;end process;

process(ep,dato)begin

es<= ep;case ep is when s0 =>

if dato = '0' thenes<= s1;salida<='0';

elsees<= s0 ;salida <= '0';

end if;when s1 =>

Page 4: diseño-labo4

Laboratorio 4

if dato = '0' thenes<= s1;salida<='0';

elsees<= s2;salida <= '0';

end if;when s2 =>

if dato = '0' thenes<= s1;salida<='0';

elsees<= s3;salida <= '0';

end if;when s3 =>

if dato = '0' thenes<= s4;salida<='0';

elsees<= s0;salida <= '0';

end if;when s4 =>

if dato = '0' thenes<= s1;salida<='0';

elsees<= s5;salida <= '0';

end if;when s5 =>

if dato = '0' thenes<= s6;salida<='0';

elsees<= s3;salida <= '0';

end if;when s6 =>

if dato = '0' thenes<= s1;salida<='0';

elsees<= s7;salida <= '0';

end if;when s7 =>

if dato = '0' thenes<= s0;salida<='1';

elsees<= s3;salida <= '0';

end if;

Page 5: diseño-labo4

Laboratorio 4

end case;end process;

end solucion;

3. Se pide implementar el siguiente sistema en VHDL. Cuando se pulse START se abre la llave dejando caer un líquido hasta que llegue a alcanzar el nivel del sensor, momento el cual se cierra la llave. En los display se debe indicar el tiempo transcurrido. Considere una señal de reloj de 1Hz.

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

Page 6: diseño-labo4

Laboratorio 4

entity tanque isPort( start,sensor,clk : in std_logic;

llave: out std_logic; cont1,cont2 : buffer std_logic_vector(3 downto 0));

end tanque;architecture solucion of tanque istype estado is (s0,s1);signal es,ep : estado;begin

process(clk)beginif rising_edge(clk) then

ep <= es;case ep is

when s0 =>cont1 <="0000";cont2 <= "0000";

when s1 =>cont1<= cont1 +1;if cont1 = 9 then

cont1 <= "0000";cont2 <=cont2 +1;if cont2 = 9 then

cont2 <= "0000";end if;

end if;end case; end if;end process;

process(ep,start,sensor)begin

es <= ep;case ep is

when s0 => llave <= '0';

if start = '0' thenes <= s0;

elsees <= s1;

end if;when s1 =>

llave <= '1';if sensor = '1' then

es <= s0;else

es <= s1;end if;

end case;end process;

end solucion;

Page 7: diseño-labo4

Laboratorio 4

4. Se desea implementar un circuito que genere el bit de paridad impar de un dato de 8 bits (data_in) que llega serialmente. La secuencia de los datos se inicia con un bit de START que siempre es 0, seguido de los 8 bits de datos. La secuencia original (data_in) no tiene el bit de paridad.

Se debe generar la cadena de salida (data_out) de manera seguida a la cadena de entrada (data_in) pero con el bit de paridad impar después del octavo bit de dato (un ejemplo se muestra en el gráfico anterior).

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

entity pariedad isPort( clk , data : in std_logic;

z : out std_logic);end pariedad;

Page 8: diseño-labo4

Laboratorio 4

architecture solucion of pariedad istype estados is (s0,s1,s2);signal ep,es : estados;signal P : std_logic;signal cont : std_logic_vector(3 downto 0);begin

process(clk)beginif rising_edge(clk) then

ep <= es;if ep= s0 or ep = s2 then

cont <= "0000";else

cont <= cont +1;end if;

end if;end process;

process(ep,data)begines <= ep;case ep iswhen s0 =>

z <= '1';P <= '0';if data = '1' then

es <= s0;else

es <= s1;end if;

when s1 =>z <= data;P <= P xor data;if cont = "1000" then

es <= s2;else

es <= s1;end if;

when s2 =>z <= not P;P <= '0';if data = '1' then

es <= s0;else

es <= s1;end if;

end case;end process;

Page 9: diseño-labo4

Laboratorio 4

end solucion;

5. Se desea implementar el siguiente circuito:

Cuando se pulse START por primera vez debe sonar la sirena de acuerdo a la señal Fout, la segunda vez que se pulse START debe dejar de sonar

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

entity alarma isPort( clk , start : in std_logic;

fout : out std_logic);end alarma;

architecture solucion of alarma istype estados is (s0,s1);signal ep,es: estados;signal fout1,z1,z2: std_logic;signal cont1,cont2 : std_logic_vector(24 downto 0);begin

Page 10: diseño-labo4

Laboratorio 4

process(clk)beginif rising_edge(clk) thencont1 <= cont1 +1;

if cont1 = 49999999 thenz1 <= not z1;cont1 <= (others =>'0');

end if;end if;end process;

process(clk)beginif rising_edge(clk) then

cont2 <= cont2 +1;if cont2 = 99999 then

z2 <= not z2;cont2 <= (others =>'0');

end if;end if;end process;

process(clk)beginif rising_edge(clk) then

ep <= es;end if;end process;

process(ep)begines <= ep;case ep iswhen s0 =>

fout <= '0';if start = '1' then

es <= s1;else

es<= s0;end if;

when s1 =>if z1 = '0' then

fout <= z2;elsif z1 = '1'then

fout <= '0';end if;if start = '1' then

Page 11: diseño-labo4

Laboratorio 4

es <= s1;else

es<= s0;end if;

end case;end process;

end solucion;

6. Se desea implementar un circuito transmisor de datos seriales. El dato se recibe de manera paralela a 8 bits cuando se activa la señal START. Los datos deben salir acompañados de un bit de inicio (START: que siempre es cero) y un bit de parada (STOP: que siempre es uno). La velocidad de transmisión es de 9600 bps (bits por segundo). La frecuencia de reloj es de 1MHz.

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;

entity datos isport( clk,start : in std_logic;

data : in std_logic_vector(7 downto 0); tx : buffer std_logic_vector(9 downto 0));

end datos;architecture solucion of datos istype estado is (s0,s1);signal EA : estado;begin

process(clk,start)beginif rising_edge(clk) then

case EA iswhen s0 =>

Page 12: diseño-labo4

Laboratorio 4

tx <= (others => '0');if start = '1' then

EA <= s1;else

EA <= s0;end if;

when s1 =>tx <= '0'&data&'1';if tx(0) = '1' then

EA <= s0;else

EA <= s1;end if;

end case;end if;end process;

end solucion;