⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyscan66

📁 本人初学VHDL时编的比较系统的VHDL源程序 巨实用
💻
字号:
--          KEY BOARD
-------------------------------------
--000  *A*   	*B*   	*C*		*D*		*E*		*F*

--001  *G*   	*H*   	*I*		*J*		*K*		*L*

--010  *M*   	*N*   	*O*		*P*		*Q*		*R*

--011  *S*   	*T*   	*U*		*V*		*W*		*X*

--100  *Y*   	*Z*   	*1*		*2*		*3*		*4*

--101  *5*   	*6*   	*7*		*8*		*9*		*#*

--	  000	001		010		011		100		101	
--
--



library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity scan is
    port (
        b: in STD_LOGIC_VECTOR (5 downto 0);	-- 列
        row: buffer STD_LOGIC_VECTOR (5 downto 0);	--行
        Cout: out STD_LOGIC_VECTOR (5 downto 0); 	--
        Irq: out STD_LOGIC;
	   
	   clk: in STD_LOGIC; --时钟
	   r: in STD_LOGIC			-- 复位
    );
end scan;

architecture scan_arch of scan is

signal dd:STD_LOGIC_VECTOR (2 downto 0);	--行扫描计数器
signal dd1:STD_LOGIC_VECTOR (2 downto 0);	--行译码信号
signal line:STD_LOGIC_VECTOR (2 downto 0); 	--列译码信号
signal keydown:std_logic;					 --按下键

signal CCout: STD_LOGIC_VECTOR (5 downto 0); 
signal IIrq: STD_LOGIC;

begin

count: process (r, clk  )
	begin
	if ( r='1' ) then dd<="000";
	elsif( clk'event and clk = '1') then
			dd <= dd + '1';
			end if ;
end process count ;
 with dd select
   row<=  "011111"	when"000",
     	"101111"	when"001",
     	"110111"	when"010",
     	"111011"	when"011",
		"111101"	when"100",
		"111110"	when"101",
     	"ZZZZZZ"	when others ;

with row select
   	  dd1<= 	"000"when"011111",
     		"001"when"101111",
     		"010"when"110111",
     		"011"when"111011",
			"100"when"111101",
			"101"when"111110",
     		"ZZZ"when others ;
   
keydown<= b(0) and b(1) and b(2) and b(3) and b(4) and b(5);

with b select
  	line<= 	"000"when"011111",
     		"001"when"101111",
     		"010"when"110111",
     		"011"when"111011",
			"100"when"111101",
			"101"when"111110",
     		"ZZZ"when others ;
   

process ( keydown,clk,r  )
begin
	if ( r='1' ) then CCout<="000000";
					IIrq <= '0';
		elsif( clk'event and clk = '1') then
   				if (keydown = '0') then
      				CCout <= dd1&line ;
	 				IIrq <= '1' ;
    				end if;
	end if;
end process ;

Cout <= CCout ;
Irq <= IIrq;

end scan_arch;

⌨️ 快捷键说明

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