📄 8位流水灯.vhd
字号:
--8位流水灯程序,采用双进程实现。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity relamp is
port(clock:in std_logic;
y:out std_logic_vector(7 downto 0));
end relamp;
architecture behv of relamp is
signal y_temp:std_logic_vector(7 downto 0);
signal clk:std_logic;
signal cntbuf: integer range 7 downto 0;
signal freqbuf: integer range 78124 downto 0;
begin
process(clock)
begin
if clock'event and clock='1' then
if freqbuf=78124 then
clk<='1';
freqbuf<=0;
else
clk<='0';
freqbuf<=freqbuf+1;
end if;
end if;
end process;
process(clk)
begin
if clk'event and clk='1' then
if cntbuf=7 then cntbuf<=0;
else cntbuf<=cntbuf+1;
end if;
end if;
case cntbuf is
when 0=>y_temp<="00000001";
when 1=>y_temp<="00000010";
when 2=>y_temp<="00000100";
when 3=>y_temp<="00001000";
when 4=>y_temp<="00010000";
when 5=>y_temp<="00100000";
when 6=>y_temp<="01000000";
when others=> y_temp<="10000000";
end case;
end process;
y<=y_temp;
end behv;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -