


----------------------------------------------------------------------------------
-- Company: 
-- Engineer: 
-- 
-- Create Date:    16:13:46 01/04/2011 
-- Design Name: 
-- Module Name:    KnightRiderFutofeny - 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;

-- 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 KnightRiderFutofeny is
    Port ( pCLK : in  STD_LOGIC;
			  pRESET	: in STD_LOGIC;
           pLED0_9 : out  STD_LOGIC_VECTOR (9 downto 0));
end KnightRiderFutofeny;

architecture Behavioral of KnightRiderFutofeny is

	signal sLED0_9 : STD_LOGIC_VECTOR (9 downto 0);
	signal sDir, sRESET 	: STD_LOGIC;

begin
	pLED0_9 <= sLED0_9;
	sRESET <= pRESET;

	--ClockDeMux : 
	process(pCLK, sRESET, sDIR)
	begin
		if (sRESET = '1') then 
			 sDir <= '0';
			 sLED0_9 <= 	"0000000001";
		elsif (pCLK' event and pCLK = '1') then
				if sDir = '0' then
					case sLED0_9  is
						when "0000000001" => sLED0_9 <= "0000000010";
						when "0000000010" => sLED0_9 <= "0000000100";
						when "0000000100" => sLED0_9 <= "0000001000";
						when "0000001000" => sLED0_9 <= "0000010000";
						when "0000010000" => sLED0_9 <= "0000100000";
						when "0000100000" => sLED0_9 <= "0001000000";
						when "0001000000" => sLED0_9 <= "0010000000";
						when "0010000000" => sLED0_9 <= "0100000000";
						when others => sLED0_9 <= "0000000000";			
					end case;
					if sLED0_9 = "0100000000" then
						sDir <= '1';
						sLED0_9 <= 	"1000000000";
					end if;
				end if;		
				if sDir = '1' then 
					case sLED0_9  is
						when "1000000000" => sLED0_9 <= "0100000000";
						when "0100000000" => sLED0_9 <= "0010000000";
						when "0010000000" => sLED0_9 <= "0001000000";
						when "0001000000" => sLED0_9 <= "0000100000";
						when "0000100000" => sLED0_9 <= "0000010000";
						when "0000010000" => sLED0_9 <= "0000001000";
						when "0000001000" => sLED0_9 <= "0000000100";
						when "0000000100" => sLED0_9 <= "0000000010";
						when others => sLED0_9 <= "0000000000";			
					end case;
					if sLED0_9 = "0000000010" then
						sDir <= '0';
						sLED0_9 <= 	"0000000001";
					end if;
				end if;						
		end if;
	end process;	
end Behavioral; 