深圳有哪些面馆加盟:求教vhdl的流水灯程序

来源:百度文库 编辑:高校问答 时间:2024/04/28 18:37:07
流水灯
功能要求:1、设计能带8个LED发光管发光,并按照要求轮流发光,产生流水灯的流动效果。
2、应具有两种以上不同风格的流动闪亮效果。
3、有起动、停止控制键。
4、有流动闪亮效果选择设置键。

Use Shift Registers, you can have a switch to choose shift left or shift right.

I will give you some ideas, MODIFY it yourself:
Change the code to make "start" and "stop" logic work.
--------------------------
library ieee ;
use ieee.std_logic_1164.all;

entity mylight is
port (start : in std_logic;
stop : in std_logic;
shift_left : in std_logic;
Q : out std_logic_vector(7 downto 0)
);
end mylights;

architechture behavior of mylights is

signal lights : std_logic_vector(7 downto 0);

process (clk, start, stop, shift_left)
begin
if (start = '0' or stop = '1') then
lights <= (others => '1');
elsif (clk'event and clk = '1') then
if (shift_left = '1') then
lights <= lights(6 downto 0) & '0';
else
lights <= '0' & lights(7 downto 1);
end;
end;
end process;

Q <= lights;

end behavior;