Вы находитесь на странице: 1из 2

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating


---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity jkl is
Port ( current_floor : in STD_LOGIC;
required_floor : in STD_LOGIC;
clk : in STD_LOGIC;
door_lock : in STD_LOGIC;
up : out STD_LOGIC;
down : out STD_LOGIC;
buzzor : out STD_LOGIC);
end jkl;

architecture Behavioral of jkl is


type state_type is (s0,s1,s2,s3);
signal state:state_type;
begin
process(clk)
begin
if (clk'event and clk='1') then
case state is
when s0=>
if (door_lock ='1') then
up<='0';
down<='0';
buzzor<='1';
elsif (current_floor='0' and required_floor ='0') then
up<='0';
down<='0';
buzzor<='0';
end if;

when s1=>
if (door_lock ='1') then
up<='0';
down<='0';
buzzor<='1';
elsif (current_floor='0' and required_floor ='1') then
up<='1';
down<='0';
buzzor<='0';
end if;

when s2=>
if (door_lock ='1') then
up<='0';
down<='0';
buzzor<='1';
elsif (current_floor='1' and required_floor ='0') then
up<='0';
down<='1';
buzzor<='0';
end if;

when s3=>
if (door_lock ='1') then
up<='0';
down<='0';
buzzor<='1';
elsif (current_floor='1' and required_floor ='1') then
up<='0';
down <='0';
buzzor<='0';
end if;
end case;

end if;
end process;

end behavioral;

Вам также может понравиться