-- The Electronic Gardener -- -- Mark Kudryk, Kim Ellis -- -- Module Name: devtimer.vhd -- Author: Kim Ellis -- Date: November 07, 1998 -- Status: Completed --------------------------------------------------------------- -- Description: -- Device Timer Module for Spot Watering -- The timer counts down from a fixed setting, -- producing a timeout signal for the device state machine --------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.std_logic_unsigned.all; entity devtimer is port( reset : in std_logic; second : in std_logic; timer_moist : in std_logic; timeout_moist : buffer std_logic ); end devtimer; architecture a of devtimer is constant sec_30 : std_logic_vector(5 downto 0) :="011110"; signal count_moist : std_logic_vector( 5 downto 0 ); begin process( second, reset ) begin if reset = '1' then timeout_moist <= '1'; count_moist <= sec_30; elsif rising_edge( second ) then if (timer_moist = '0' and timeout_moist = '0') then if count_moist /= "000000" then count_moist <= count_moist - '1'; timeout_moist <= '0'; else timeout_moist <= '1'; count_moist <= sec_30; end if; elsif (timer_moist = '1' and timeout_moist = '1') then timeout_moist <= '0'; elsif timer_moist = '1' and timeout_moist='0' then count_moist <= sec_30; end if; end if; end process; end a;