You are on page 1of 4

---------------------------------------------------------------------------------- Company:

-- Engineer:
--- Create Date:
23:00:25 01/27/2012
-- Design Name:
-- Module Name:
lift - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
--use IEEE.STD_LOGIC_signed.ALL;
--use IEEE.std_logic_arith.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity lift is
Port ( close, motor : out std_logic;
buz : out std_logic;
reqfl : in std_logic_vector(3 DOWNTO 0);
clk : in std_logic;
up,dwn : out std_logic;
--fan : in std_logic;
stop : in std_logic
--current : in std_logic_vector(3 DOWNTO 0)
);
end lift;
architecture Behavioral of lift is
TYPE state_typ is (idle,moving,stp);
SIGNAL state : state_typ;
signal crnt_fl : std_logic_vector(3 DOWNTO 0);
signal re_temp_fl : std_logic_vector(3 DOWNTO 0):="0000";
SIGNAL opend:std_logic;
begin

stm : PROCESS(stop,reqfl,clk,state)

begin
if(stop='1')then
opend <='0';
close <= '1';
motor <= '0';
up <= '0';
dwn <='0';
--fan <= '0';
buz <= '0';
crnt_fl <= "0000";
elsif(stop='0') then
opend <='1';
close <= '0';
motor <= '1';
up <= '0';
dwn <='0';
--fan <= '1';
buz <= '0';
--crnt_fl <= "0000";
re_temp_fl <= reqfl;
--crnt_fl<=current;
if(clk' event and clk='1')then
case state is
when idle =>
if(crnt_fl = re_temp_fl)then
state <= idle;
else
state <= moving;
end if;
opend <='0';
close <= '1';
motor <= '0';
up <= '0';
dwn <='0';
--fan <= '0';
buz <= '0';

when moving =>


if(crnt_fl < re_temp_fl)then
--state <= moving;
opend <='0';
close <= '1';
motor <= '1';
up <= '1';
dwn <='0';
--fan <= '1';
if(opend='1') then
buz <= '1';
else
buz <= '0';

end if;
crnt_fl<= crnt_fl + "0001";
elsif(crnt_fl > re_temp_fl)then
--state <= moving;
opend <='0';
close <= '1';
motor <= '1';
up <= '0';
dwn <='1';
--fan <= '1';
if(opend='1') then
buz <= '1';
else
buz <= '0';
end if;
crnt_fl<= crnt_fl - "0001";
elsif(crnt_fl = re_temp_fl)then
state <=idle ;
opend <='1';
close <= '0';
motor <= '0';
up <= '0';
dwn <='0';
--fan <= '0';
buz <='0';
end if;
--when stp =>
--if(crnt_fl < re_temp_fl)then
--state <= moving;
--opend <='0';
--close <= '1';
--motor <= '1';
--up <= '1';
--dwn <='0';
--fan <= '1';
--if(opend='1') then
--buz <= '1';
--else
--buz <= '0';
--end if;
--crnt_fl<= crnt_fl + "0001";
--elsif(crnt_fl > re_temp_fl)then
--state <= moving;
--opend <='0';
--close <= '1';
--motor <= '1';
--up <= '0';
--dwn <='1';
--fan <= '1';
--if(opend='1') then
--buz <= '1';
--else
--buz <= '0';
--crnt_fl<= crnt_fl - "0001";
--end if;
--elsif(crnt_fl = re_temp_fl)then

--state <=stp ;
--opend <='1';
--close <= '0';
--motor <= '0';
--up <= '0';
--dwn <='0';
--fan <= '0';
--buz <='0';
--end if;
when others=>null;
end case;
end if;
end if;
end process;
end Behavioral;

You might also like