找回密码
 注册
搜索
查看: 717|回复: 3

[讨论] 用VHDL实现键盘译码

[复制链接]
发表于 2007-4-4 20:47:19 | 显示全部楼层 |阅读模式
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity jianpan is
port(clk:in std_logic;
     x:in std_logic_vector(3 downto 0);
     y:buffer std_logic_vector(1 downto 0);
     scan:out std_logic_vector(3 downto 0);
     dout1:out std_logic_vector(3 downto 0);
     dout2:out std_logic_vector(3 downto 0));
end;
architecture one of jianpan is
signal n,f:std_logic_vector(3 downto 0);
signal z:std_logic_vector(5 downto 0);
begin
process(clk)
begin
if clk'event and clk='1' then
y<=y+1;
case y is
when "00"=>scan<="1110";
when "01"=>scan<="1101";
when "10"=>scan<="1011";
when "11"=>scan<="0111";
when others=>scan<="1111";
end case;
end if;
end process;     
process(clk)
begin
  z<=y&x;
  if clk'event and clk='1' then
    case z is
      when "101011"=>n<="0000";
      when "000111"=>n<="0001";
      when "001011"=>n<="0010";
      when "001101"=>n<="0011";
      when "001110"=>n<="0100";
      when "010111"=>n<="0101";
      when "011011"=>n<="0110";
      when "011101"=>n<="0111";
      when "011110"=>n<="1000";
      when "100111"=>n<="1001";
      when others=>n<="ZZZZ";
    end case;
    end if;
    if clk'event and clk='1' then
    case z is
      when "101101"=>f<="1010";
      when "101110"=>f<="1011";
      when "110111"=>f<="0000";
      when others=>f<="ZZZZ";
    end case;
    end if;
    end process;
    dout1<=n;
    dout2<=f;
    end one;
   
功能有的还没有实现,请好心人补全!~!!!!!
发表于 2007-4-4 20:51:09 | 显示全部楼层
[em09]虽然没啥用,但顶一下[em03]
点评回复

使用道具 举报

发表于 2007-4-11 12:03:21 | 显示全部楼层
我用verilog实现了,有需要的朋友可以找我
QQ:112838599
点评回复

使用道具 举报

发表于 2007-4-26 16:21:17 | 显示全部楼层
[em01]
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-9-29 20:25 , Processed in 0.044751 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表