You are on page 1of 13

Funcionamiento de las puertas

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity puertas is port(

clk : in std_logic; -- clk es la señal de reloj

w: in std_logic;--recibe señal de slide y resetea para inicial procesos

v: out std_logic_vector(1 downto 0); --"w" señal para decir que esta cerrado

f: out std_logic);

end puertas;

architecture ejem of puertas is

signal Qp, Qs: std_logic_vector(3 downto 0):= "0000";

begin

comb: process (Qp)

begin

case Qp is

when "0000" =>

Qs <= "0001"; v<= "10";

when "0001" =>

Qs <= "0010"; v<= "10";


when "0010" =>

Qs <= "0011"; v<= "10";

when "0011" =>

Qs <= "0100"; v<= "10";

when "0100" =>

Qs <= "0101"; v<= "11";

when "0101" =>

Qs <= "0110"; v<= "11";

when "0110" =>

Qs <= "0111"; v<= "11";

when "0111" =>

Qs <= "1000"; v<= "11";

when "1000" =>

Qs <= "1001"; v<= "11";

when "1001" =>

Qs <= "1010"; v<= "11";

when "1010" =>

Qs <= "1011"; v<= "01";

when "1011" =>


Qs <= "1100"; v<= "01";

when "1100" =>

Qs <= "1101"; v<= "01";

when "1101" =>

Qs <= "1110"; v<= "01";

when "1110" =>

Qs <= "1111"; v<= "00";

when others =>

Qs <="0000";

end case;

end process comb;

sec: process (w, clk)

begin

if ( w = '1') then

Qp<= "0000";

elsif (clk'event and clk ='1') then

Qp <= Qs;

end if;

end process sec;

end ejem;

_______________________________________________________________________
Divisor de frecuencia (falta acomodar reset)

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity divisor is

port (

clk_in: in std_logic;

reset: in std_logic;

clk_out: out std_logic

);

end divisor;

architecture behavioral of divisor is

signal temporal: std_logic;

signal counter: integer range 0 to 12499999 := 0;

begin

frecuency_divider: process(reset, clk_in)begin

if(reset = '1') then

temporal<='0';

counter <= 0;

elsif rising_edge(clk_in) then

if(counter = 12499999) then

temporal<= NOT(temporal);

counter<= 0;
else

counter<= counter+1;

end if;

end if;

end process;

clk_out<= temporal;

end behavioral;

______________________________________________________________________________

Proceso de los motores (Falta acomodar señales)

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity motores is port (

clk,p: in std_logic;

push: in std_logic_vector (2 downto 0);

slide: in std_logic_vector (2 downto 0);

exh: out std_logic_vector (1 downto 0);

mot: out std_logic_vector (1 downto 0);

s: out std_logic

);

end motores;

architecture funcion of motores is

signal Qp, Qs: std_logic_vector (3 downto 0):="0000";


begin comb: process (Qp, push, slide,p)

begin

case Qp is

when "0000" =>

if (push = "000") then

Qs <= "0000";

elsif (push = "001") then

Qs <= "0011";

elsif ( push = "010") then

Qs <= "0110";

elsif ( push = "100") then

Qs <= "0111";

end if;

exh <= "00";

mot <= "00";

s <= '0';

when "0001" =>

if (push = "000") then

Qs <= "0001";

elsif (push = "001") then

Qs <= "1000";

elsif ( push = "010") then

Qs <= "0100";

elsif ( push = "100") then

Qs <= "0111";

end if;
exh <= "00";

mot <= "00";

s <= '0';

when "0010" =>

if (push = "000") then

Qs <= "0010";

elsif (push = "001") then

Qs <= "1000";

elsif ( push = "010") then

Qs <= "0101";

elsif ( push = "100") then

Qs <= "0101";

end if;

exh <= "00";

mot <= "00";

s <= '0';

when "0011" =>

if (slide = "000") then

Qs <= "0011";

elsif (slide = "001") then

Qs <= "1011";

elsif (slide = "010") then

Qs <= "0011";

elsif (slide = "100") then

Qs <= "0011";
end if;

exh <= "01";

mot <= "00";

s <= '0';

when "0100" =>

if (slide = "000") then

Qs <= "0100";

elsif (slide = "001") then

Qs <= "0100";

elsif (slide = "010") then

Qs <= "1011";

elsif (slide = "100") then

Qs <= "0100";

end if;

exh <= "10";

mot <= "00";

s <= '0';

when "0101" =>

if (slide = "000") then

Qs <= "0101";

elsif (slide = "001") then

Qs <= "0101";

elsif (slide = "010") then

Qs <= "0101";

elsif (slide = "100") then


Qs <= "1011";

end if;

exh <= "11";

mot <= "00";

s <= '0';

when "0110" =>

if (slide = "000") then

Qs <= "0110";

elsif (slide = "001") then

Qs <= "0110";

elsif (slide = "010") then

Qs <= "1011";

elsif (slide = "100") then

Qs <= "0110";

end if;

exh <= "10";

mot <= "10";

s <= '0';

when "0111" =>

if (slide = "000") then

Qs <= "0111";

elsif (slide = "001") then

Qs <= "0111";

elsif (slide = "010") then

Qs <= "0111";
elsif (slide = "100") then

Qs <= "1010";

end if;

exh <= "11";

mot <= "10";

s <= '0';

when "1000" =>

if (slide = "000") then

Qs <= "1000";

elsif (slide = "001") then

Qs <= "1010";

elsif (slide = "010") then

Qs <= "1000";

elsif (slide = "100") then

Qs <= "1000";

end if;

exh <= "01";

mot <= "01";

s <= '0';

when "1001" =>

if (slide = "000") then

Qs <= "1001";

elsif (slide = "001") then

Qs <= "1001";

elsif (slide = "010") then


Qs <= "1010";

elsif (slide = "100") then

Qs <= "1001";

end if;

exh <= "10";

mot <= "01";

s <= '0';

when "1010" =>

if (slide = "000") then

Qs <= "1011";

elsif (slide = "001") then

Qs <= "1011";

elsif (slide = "010") then

Qs <= "1011";

elsif (slide = "100") then

Qs <= "1011";

end if;

exh <= "00";

mot <= "00";

s <= '0';

when "1011" =>

Qs <= "1100";

s <= '1';

when "1100" =>


if (p = '0') then

Qs <= "1100";

elsif ( p = '1') then

if (slide = "000") then

Qs <= "1100";

elsif (slide = "001") then

Qs <= "0000";

elsif (slide = "010") then

Qs <= "0001";

elsif (slide = "100") then

Qs <= "0010";

end if;

end if;

s <= '0';

when others =>

Qs <= "0000";

end case;

end process comb;

sec: process (clk)

begin

if (clk'event and clk='1') then

Qp <= Qs;

end if;

end process sec;

end función;

You might also like