count16.vhd

来自「实现了16*16点阵上的三色显示的弹球游戏」· VHDL 代码 · 共 27 行

VHD
27
字号
library ieee;
use ieee.std_logic_1164.all;
entity count16 is
	port(clk:in std_logic;
		co:out std_logic;
		qcnt:buffer std_logic_vector(3 downto 0));
end count16;

architecture main of count16 is
	type con is array (0 to 7) of integer range 0 to 3;
	constant act:con:=(0,1,0,2,0,1,0,3);
	shared variable i:integer range 0 to 7:=0;
	signal count:std_logic_vector(3 downto 0):=(others =>'0');
	begin
		qcnt<=count;
		co<='1' when (qcnt="1000") else '0';
		process(clk)
		begin
			if(rising_edge(clk)) then
				count(act(i))<=not count(act(i));
				if(i=7) then
					i:=0;
				else i:=i+1;
				end if;
			end if;
		end process;
	end main;

⌨️ 快捷键说明

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