CODE_TRAN.VHD
上传用户:dgjihui88
上传日期:2013-07-23
资源大小:43k
文件大小:1k
源码类别:
VHDL/FPGA/Verilog
开发平台:
MultiPlatform
- --code_tran.vhd keyboard position to button code transformer
- library ieee ;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_arith.all;
- use ieee.std_logic_unsigned.all;
- entity code_tran is
- port(
- scan_cnt : in std_logic_vector(3 downto 0) ;--keybord scan count
- clk : in std_logic ;--clock
- butt_code : out std_logic_vector(3 downto 0)) ;--button code
- end code_tran ;
- architecture behavior of code_tran is
- begin
- code_tran:process(clk)
- begin
- if(clk'event and clk='1') then
- case scan_cnt is --encoding
- when "0000"=> butt_code <= "0001";--1
- when "0001"=> butt_code <= "0010";--2
- when "0010"=> butt_code <= "0011";--3
- when "0011"=> butt_code <= "1100";--c
- when "0100"=> butt_code <= "0100";--4
- when "0101"=> butt_code <= "0101";--5
- when "0110"=> butt_code <= "0110";--6
- when "0111"=> butt_code <= "1101";--d
- when "1000"=> butt_code <= "0111";--7
- when "1001"=> butt_code <= "1000";--8
- when "1010"=> butt_code <= "1001";--9
- when "1011"=> butt_code <= "1110";--e
- when "1100"=> butt_code <= "1010";--a
- when "1101"=> butt_code <= "0000";--0
- when "1110"=> butt_code <= "1011";--b
- when others => butt_code <= "1111";--f
- end case;
- end if;
- end process;
- end behavior;