EDA与VHDL题目——流水灯

EDA与VHDL题目——流水灯

代码

library ieee;
use ieee.std_logic_1164.all;
entity runninglight is
port(clk,reset:in std_logic;
	  output:out std_logic_vector(7 downto 0));
end runninglight;

architecture behave of runninglight is
begin
	signal clk1:std_logic_vector(1 downto 0);
	
p1:process(clk)   --进程1,把50MHz分成1Hz
	variable count:integer range 0 to 250000;
	variable count1:integer range 0 to 1;
	begin
		if (clk'event and clk='1') then
			count := count + 1;
			if  count := 250000 then 
				count  := 0;
				count1 = not count1;
			end if; 
			clk1 <= count1;
		end if;
	end process
	
p2:process(clk1)    --进程2, 把1HZ时钟计数并转换对应成移动的灯
	variable count2: integer range 0 to 7;
	begin 
		if (clk1'event and clk1='1') then
			count2 := count2 + 1;
			if count2 := 7 then 
				count2 := 0;
			end if;
		end if;
	case count2 is
		when 0 => output <= "11111110";
		when 1 => output <= "11111101";
		when 2 => output <= "11111011";
		when 3 => output <= "11110111";
		when 4 => output <= "11101111";
		when 5 => output <= "11011111";
		when 6 => output <= "10111111";
		when 7 => output <= "01111111";
		when others => z <= null;
	end case;
	end process;
end behave;
	
	
	
	
		
	



  • 4
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值