---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 15:23:48 04/02/2009 -- Design Name: -- Module Name: led_show - 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_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 led_show is Port ( iCLK : in STD_LOGIC; -- clock procesora inRST : in STD_LOGIC; -- dugme reset inRL : in STD_LOGIC; -- dugme rotate left inRR : in STD_LOGIC; -- dugme rotate right inSTOP : in STD_LOGIC; -- dugme stop inBL : in STD_LOGIC; -- dugme blink oLED : out STD_LOGIC_VECTOR (7 downto 0)); -- izlazi ka diodama end led_show; architecture Behavioral of led_show is --11999999 constant cCLOCK_MAX: integer := 10 ; -- otkucaji clocka za pola sekunde signal sTICK_COUNT: integer := 0; -- brojac otkucaja clock-a signal sSTATE: integer := 0; -- stanja (test = 0 , stop = 1 , rl =2, rr = 3 , bl = 4) signal sSEK: integer :=0; -- brojac sekundi za test stanje signal sTEMP: std_logic_vector (7 downto 0):= "11111111"; -- za blinkanje dioda signal sLED: std_logic_vector (7 downto 0) := "11111111"; begin process(iCLK) begin if(iCLK'event and iCLK='1' ) then if(sSTATE/=0) then sSEK<=0; end if; sTICK_COUNT<= sTICK_COUNT + 1; if(sTICK_COUNT= cCLOCK_MAX) then sSEK<= sSEK+1; sTICK_COUNT<=0; end if; if(inRST='0' or sSTATE = 0) then sSTATE<=0; if(sSEK=3) then sSTATE<=1; sSEK<=0; end if; elsif(sSTATE = 1 and inRL = '0') then sSTATE<=2; elsif(sSTATE = 1 and inRR = '0') then sSTATE<=3; elsif(sSTATE = 1 and inBL = '0') then sSTATE<=4; elsif(inSTOP = '0') then sSTATE<=1; end if; end if; --else -- end if; -- end if; end process; process(iCLK) begin if(iCLK'event and iCLK='1') then case (sSTATE) is when 0 => sLED<="11111111"; when 1 => sLED<="10000000"; -- oLED<=sLED; when 2 => if(sTICK_COUNT= 0) then sLED<=sLED(6 downto 0) & sLED(7); end if; when 3 => if(sTICK_COUNT= 0) then sLED<= sLED(0) & sLED(7 downto 1); end if; when 4 => if(sTICK_COUNT= 0) then sLED<=sTEMP; sTEMP<=not sTEMP; --sLED <= sTEMP; end if; when others => sLED<="11111111"; -- oLED<=sLED; end case; oLED<=sLED; end if; end process; end Behavioral;