⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 light.vhd

📁 这个是国外大学的项目代码
💻 VHD
字号:
------------------------------------------------------------------------
--  light.vhd -- 
------------------------------------------------------------------------
--  Authors : Albert Zemba & Mihai Cucicea
------------------------------------------------------------------------
-- Software version: Xilinx ISE 7.1i 
--                   WebPack
------------------------------------------------------------------------
-- This source file contains the light component
------------------------------------------------------------------------
--  Behavioral description
-- It returns 8 signals which will be mapped to the output leds
-- It creates a dinamic light effect(clk must be small and 
-- here will be mapped to 6hz )

------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity light is
	port (clk,reset: in std_logic;
		done: in std_logic;
		led1,led2,led3,led4,led5,led6,led7,led8 : out std_logic);
end light;

architecture Behavioral of light is
signal dir: std_logic:='0';
signal led:std_logic_vector (8 downto 1):="00000000";
begin

	process (clk)
	begin
		if (clk'event and clk='1') then
			if (reset='1') then
				led<="00000000";
				dir<='0';
			else
				if (done='1') then
					if (dir='0') then
						if (led="00000000") then led<="10000000"; end if;
						if (led="10000000") then led<="11000000"; end if;
						if (led="11000000") then led<="11100000"; end if;
						if (led="11100000") then led<="01110000"; end if;
						if (led="01110000") then led<="00111000"; end if;
						if (led="00111000") then led<="00011100"; end if;
						if (led="00011100") then led<="00001110"; end if;
						if (led="00001110") then led<="00000111"; end if;
						if (led="00000111") then led<="00000011"; end if;
						if (led="00000011") then led<="00000001"; end if;
						if (led="00000001") then 
							led<="00000000"; 
							dir<='1'; 
						end if;
					end if;
					if (dir='1') then
						if (led="00000000") then led<="00000001"; end if;
						if (led="00000001") then led<="00000011"; end if;
						if (led="00000011") then led<="00000111"; end if;
						if (led="00000111") then led<="00001110"; end if;
						if (led="00001110") then led<="00011100"; end if;
						if (led="00011100") then led<="00111000"; end if;
						if (led="00111000") then led<="01110000"; end if;
						if (led="01110000") then led<="11100000"; end if;
						if (led="11100000") then led<="11000000"; end if;
						if (led="11000000") then led<="10000000"; end if;
						if (led="10000000") then 
							led<="00000000"; 
							dir<='0'; 
						end if;
					end if;
				end if;
			end if;
		led1<=led(1);led2<=led(2);led3<=led(3);led4<=led(4);
		led8<=led(8);led7<=led(7);led6<=led(6);led5<=led(5);
		end if;				
	end process;

end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -