打印

【求助】ps2键盘实验

[复制链接]
1442|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lixin6886518|  楼主 | 2010-10-4 10:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好,这是一个ps2键盘实验, ps2clk;ps2data 是键盘的时钟,数据输入,dataout是经过下面程序一系列转化而成的键盘的扫描码,我不明白ps2clk,ps2data的内容是什么,是怎样转化为扫描码的,还请大家给我一个答案,在这里先谢谢各位啦!(红色部分尤其不懂)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity key_board is
port( clr    : in std_logic;
      clk400 : in std_logic;   --400KHZ
      ps2clk : in std_logic;
  ps2data : in std_logic;
  dataout : out std_logic_vector(15 downto 0)
     );
end key_board;
architecture Behavioral of key_board is
signal clk : std_logic:='0';
signal data : std_logic:='0';
signal shift1,shift2 : std_logic_vector(10 downto 0);
signal ps2c,ps2d : std_logic;
begin
ps2c<=ps2clk;
ps2d<=ps2data;
dataout<=shift1(8 downto 1) & shift2(8 downto 1);
process(clk400,clr)
variable tempclk : std_logic_vector(7 downto 0):=X"00";
variable tempdata: std_logic_vector(7 downto 0):=X"00";
begin
if(clr='0') then
  tempclk:=X"00";
  tempdata:=X"00";
  clk<='0';
  data<='0';
else if(clk400'event and clk400='1') then
      tempclk(0):=ps2c;
  tempclk(7 downto 1):=tempclk(6 downto 0);
  tempdata(0):=ps2d;
  tempdata(7 downto 1):=tempdata(6 downto 0);
end if;
end if;

if(tempclk="11111111") then
clk<='1';
else
    if(tempclk="00000000") then
         clk<='0';
     end if;
end if;


if(tempdata="11111111") then
data<='1';
else
  if(tempdata="00000000") then
    data<='0';
  end if;
end if;

end process;

process(clk,clr)
begin
if(clr='0')then
shift1<=(others => '0');
shift2<=(others => '0');
else if(clk'event and clk='0') then
   shift1(10)<=data;
shift1(9 downto 0)<=shift1(10 downto 1);
shift2(10)<=shift1(0);
shift2(9 downto 0)<=shift2(10 downto 1);
--   shift1(0)<=data;
-- shift1(10 downto 1)<=shift1(9 downto 0);
-- shift2(0)<=shift1(10);
-- shift2(10 downto 1)<=shift2(9 downto 0);
end if;
end if;
end process;
end Behavioral;

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

12

帖子

1

粉丝