KEY_SCAN.VHD
上传用户:dgjihui88
上传日期:2013-07-23
资源大小:43k
文件大小:1k
源码类别:

VHDL/FPGA/Verilog

开发平台:

MultiPlatform

  1. --key_scan.vhd keypress scaner
  2. library ieee ;
  3. use ieee.std_logic_1164.all;
  4. use ieee.std_logic_unsigned.all;
  5. use work.components.all;
  6. entity key_scan is
  7. port(
  8.   col : in std_logic_vector(3 downto 0);--keybord column state
  9.   scan_cnt : in std_logic_vector(3 downto 0);--keybord scan location
  10.   row : out std_logic_vector(3 downto 0);--keybord row state
  11.   key_pressed : out std_logic);--key_pressed->0 unkey_pressed->1
  12. end key_scan;
  13. architecture behavior of key_scan is
  14. begin 
  15.   row<="1110" when scan_cnt(3 downto 2)="00" else--row scan
  16.        "1101" when scan_cnt(3 downto 2)="01" else
  17.        "1011" when scan_cnt(3 downto 2)="10" else
  18.        "0111";
  19.   key_pressed<=col(0) when scan_cnt(1 downto 0)="00" else--colum scan
  20.                col(1) when scan_cnt(1 downto 0)="01" else
  21.                col(2) when scan_cnt(1 downto 0)="10" else
  22.                col(3);
  23. end behavior;