有关4X4矩阵键盘FPGA的程序的分析,有谁帮我分析一下这个状态机的程序啊

有关4X4矩阵键盘FPGA的程序的分析,有谁帮我分析一下这个状态机的程序啊,第1张

是应该还有col的输出,这才是整个扫描程序的重点。亏悔如果扫描的原理懂了的话,程序好像也没这么难理解啊,简单讲一下,在NO_KEY_PRESSED,col输出0000,如果有按键按下,当前行的row连接到col,则按下的那一行电平为0,转到SCAN_COL0。行值由row可知,开始逐列销芦正扫描以确定列值;在SCAN_COL0状态,col输出1000,若是第一列的按键,则row应该变哗源为1111,即可确定是第一列,否则转到第二列扫描,col输出0100···类推

library ieeeuse ieee.std_logic_1164.all

entity keyarray is port(

sysclk : in std_logic

key1 : in std_logic_vector(3 downto 0)

key2 : out std_logic_vector(3 downto 0)

duan : out std_logic_vector(7 downto 0)

wei : out std_logic

)

end keyarray

architecture rtl of keyarray issignal led: std_logic_vector(7 downto 0)

begin

process(sysclk)VARIABLE sig_com : std_logic_vector(3 downto 0) := "1110"

begin

if(sysclk 'event and sysclk='1')then

case sig_com is

WHEN "1110" =>

key2<=sig_com

if(key1/="1111")then

led<=sig_com &key1

sig_com:="1110"

else

sig_com:="1101"

end if

WHEN "1101" =>

key2<=sig_com

if(key1/="1111")then

led<=sig_com&key1

sig_com:="1101"

else

sig_com:="1011"

end if

WHEN "1011" =>

key2<=sig_com

if(key1/="1111")then

led<=sig_com&key1

sig_com:="1011"

else

sig_com:="0111"弯亮枝

end if

WHEN "0111" =>

key2<=sig_com

if(key1/="1111")then

led<=sig_com &key1

sig_com:="0111"

else

sig_com:="1110"

end if

when others =>sig_com:="1110"

end case

end if

end process

process(sysclk)begin

wei<='1'

case led is

when "01110111" =>duan <埋敏="11111000" --7

when "10110111" =>duan <="10000011" --b

when "11010111" =>duan <="10001110" --f

when "11100111" =>duan <="10110000" --3

when "01111110" =>duan <="10011001" --4

when "10111110" =>duan <="键御10000000" --8

when "11011110" =>duan <="11000110" --c

when "11101110" =>duan <="11000000" --0

when "01111101" =>duan <="10010010" --5

when "10111101" =>duan <="10010000" --9

when "11011101" =>duan <="10100001" --d

when "11101101" =>duan <="11111001" --1

when "01111011" =>duan <="10000010" --6

when "10111011" =>duan <="10001000" --a

when "11011011" =>duan <="10000110" --e

when "11101011" =>duan <="10100100" --2

when others=>duan <="11000000" --0

end case

end process

end rtl


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8190946.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存