ICE 发表于 2010-6-28 00:12:25

verilog编写的键盘扫描程序

verilog编写的键盘扫描程序
-- keyscan
--Author:ZHANGXiangyang
--Data:20080401
------------------------------------------

--4*4按键,两个四位一体数码管,显示的时候全部显示相同的字,是一个简单的版本,还没有添加消抖,添加之后再发,
--因为开始自己 学习的时候也遇到很多困难,希望能对大家有所帮助.
--编程的时候一定要结合自己的硬件结构
LIBRARY IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity keyscantest is
port(
col
       
utstd_logic_vector(3 downto 0);--接四列
clk:in std_logic;       --时钟,频率范围:
led
       
ut std_logic_vector(6 downto 0);--接七段数码管
row:in std_logic_vector(3 downto 0));--接四行
end keyscantest;
architecture behave of keyscantest is
signal count :std_logic_vector(3 downto 0);--计数
begin
a1:process(clk)
begin
   if(clk'event and clk='1')then--时钟上升沿计数
   count<=count+1;
   end if;
end process a1;
c1:process(clk)
begin
   if(clk'event and clk='1')then
    if(count=1)then
    col<="0010"; --第一列置高电平
    if(row="0001"
        http://bbs.vibesic.com/images/smilies/default/wink.gif
then --读入第一行,若为高,显示"0"
      led<="0111111";
    elsif(row="0010"
        http://bbs.vibesic.com/images/smilies/default/wink.gif
then
      led<="1100110";
    elsif(row="0100"
        http://bbs.vibesic.com/images/smilies/default/wink.gif
then
      led<="1111111";
    elsif(row="1000")then
      led<="0111001";
    else
      led<="0000000";
    end if;
    elsif(count=2)then
    col<="0100";
    if(row="0001")then
    led<="0000110";
    elsif(row="0010")then
    led<="1101101";
    elsif(row="0100")then
    led<="1101111";
    elsif(row="1000")then
    led<="1011110";
    else
    led<="0000000";
    end if;
   elsif(count=3)then
    col<="1000";
    if(row="0001")then
    led<="1011011";
    elsif(row="0010")then
    led<="1111101";
    elsif(row="0100")then
    led<="1110111";
    elsif(row="1000")then
    led<="1111001";
    else
    led<="0000000";
    end if;
   elsif(count=4)then
   col<="0001";
   if(row="0001")then
   led<="1001111";
   elsif(row="0010")then
   led<="0000111";
   elsif(row="0100")then
   led<="1111100";
   elsif(row="1000")then
   led<="1110001";
   else
   led<="0000000";
   end if;
    end if;
end if;
end process c1;

end behave;

CHA 发表于 2010-6-28 01:51:29

真是好东西啊!

interig 发表于 2010-6-28 03:32:38

没有人响应啊?说明两个问题,一个是我做的还不够好,没有引起大家的兴趣.二是很多人可能不知道这是我自己原闯啊.我一定好好努力,争取写出更多好帖子来.

HANG 发表于 2010-6-28 03:47:13

对我们初学者还是很有帮助的哈,谢谢了哈

HANG 发表于 2010-6-28 04:54:56

大牛啊,你太强了

ngtim 发表于 2010-6-28 05:46:34

牛逼!!!!!!!!

ICE 发表于 2010-6-28 07:03:01

niu ren!!!!!!!!!!!

inter 发表于 2010-6-28 08:31:22

ding ding ding!!!!!!!!!!!1

UFO 发表于 2010-6-28 08:53:49

好                   的

inter 发表于 2010-6-28 09:11:38

还可以就是复杂了点,我以前也写过,包含防抖动,时钟可以跑到10MHz
页: [1] 2
查看完整版本: verilog编写的键盘扫描程序