-- KK08-30 Wiper Single Cycle--SECOND METHOD     	E235 11 1108

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--|||||||||||||||||||||||||||||||||||||||||
entity Wiper is 
	port 
	(
	cw_sw: 	in		std_logic;	--Clockwise switch
	ccw_sw: 	in 	std_logic;	--Counterclockwise switch
	run_sw:	in		std_logic;	--Run switch
	
	cw_out: 	out 	std_logic;	--CW signal to motor driver
	ccw_out: out 	std_logic;	--CCW signal to motor driver
	run_out:	out	std_logic	--Enable signal to motor driver
	); 
end Wiper;

--|||||||||||||||||||||||||||||||||||||||||
architecture behavioral of Wiper is 

signal cwo 			:	std_logic := '0';
signal ccwo			:	std_logic := '0';
signal runsig		:	std_logic := '0';
--=========================================
begin
	process (cw_sw, ccw_sw, run_sw) is 
	begin
		if (run_sw = '1') then
				runsig <= '1';
		end if;
		
		if ((runsig = '1') and (ccw_sw = '1')) then
			cwo	<= '1';
			ccwo	<= '0';	
		end if;
		
		if (cwc_sw = '1') then
			cwo <= '1';
			ccwo <= '0';
		end if;
			
		if ((cwo = '1') and (cw_sw = '1')) then
			runsig <= '0';
			cwo <= '0';
			ccwo <= '0';
		end if;
		
		cw_out <= cwo;
		ccw_out <= ccwo;
		run_out <= runsig;
	end process;
end architecture behavioral;