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

📄 key_scan.vhd

📁 简单易懂的4*4键盘扫描及显示程序。对编写其他形式的键盘扫描程序有一定的指导意义.
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use IEEE.STD_LOGIC_ARITH.ALL;
entity key_scan is
	port(
		clk:in std_logic;
		pin:out std_logic_vector(3 downto 0)
		);
end entity;
architecture scan of key_scan is
signal temp:std_logic_vector(3 downto 0);
begin
--    temp<="0000";
	process(clk)
	begin
		if rising_edge(clk) then
			case temp is
			when "0001"=>temp<="0010";
			when "0010"=>temp<="0100";
			when "0100"=>temp<="1000";
			when "1000"=>temp<="0001";
			when others=>temp<="0001";
			end case;
--			if temp<="0000" then
--				temp<="0010";
--			elsif temp<="0010" then
--				temp<="0100";
--			elsif temp<="0010" then
--				temp<="0100";
---			elsif temp<="0100" then
--				temp<="1000";
--			elsif temp<="1000" then
--				temp<="0001";
--			end if;
--			temp<=rol temp 1;
		end if;
	end process;
	pin<=temp;
end scan;

⌨️ 快捷键说明

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