8位流水灯.vhd

来自「以上是VHDL硬件描述语言写的一个简单锝路流水灯程序,希望对刚接触VHDL的朋友」· VHDL 代码 · 共 52 行

VHD
52
字号
--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 + =
减小字号Ctrl + -
显示快捷键?