完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
这是一个实现4*4的键盘检测功能的程序,但是仿真的时候前面一段出现了未知值,而且后面的有了些延迟,比如说行列分别是第二行第二列检测出零信号,但检测出来的却是第一行第二列有按键按下。
附有代码如下: --分频器--这是一个6分频的分频器 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity divider is port(clk :in std_logic; clk1kHZ :out std_logic ); end divider; architecture arch_divider of divider is signal cnt :integer range 0 to 2:=0;--249999-- signal tmp_clk :std_logic :='0'; begin process(clk) begin if(clk'event and clk='1') then if(cnt=2) then cnt<=0; tmp_clk<=not tmp_clk; else cnt<=cnt+1; end if; end if; end process; clk1kHZ<=tmp_clk; end arch_divider; --0-3计数器-- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; 这是一个计数器,计1是第一行信号输出0,计2时第二行信号输出0,以此类推 entity counter is port(clk:in std_logic; output: out std_logic_vector(0 to 1)); end counter; architecture arch_c of counter is signal cnt:std_logic_vector(0 to 1):="00"; begin process(clk) begin if(clk'event and clk='1') then if(cnt="11") then cnt<="00"; else cnt<=cnt+1; end if; end if; output<=cnt; end process; end arch_c; --行信号输出-- library ieee ; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity scanin is port( countersign:in std_logic_vector(0 to 1); outsign:out std_logic_vector(0 to 3)); end scanin; architecture arch_si of scanin is begin process(countersign) begin case countersign is when"00" => outsign<="1110"; when"01" => outsign<="1101"; when"10" => outsign<="1011"; when"11" => outsign<="0111"; when others => null; end case; end process; end arch_si; --列信号读入-- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity scanout is port(clk:in std_logic; countersign:in std_logic_vector(0 to 1); input:in std_logic_vector(0 to 3); output:out std_logic_vector(0 to 3)); end scanout; architecture arch_so of scanout is begin process begin wait until falling_edge(clk); case countersign is when"00"=> case input is when"1110" => output<="0000"; when"1101" => output<="0001"; when"1011" => output<="0010"; when"0111" => output<="0011"; when others=>null; end case; when"01"=> case input is when"1110" => output<="0100"; when"1101" => output<="0101"; when"1011" => output<="0110"; when"0111" => output<="0111"; when others=>null; end case; when"10"=> case input is when"1110" => output<="1000"; when"1101" => output<="1001"; when"1011" => output<="1010"; when"0111" => output<="1011"; when others=>null; end case; when"11"=> case input is when"1110" => output<="1100"; when"1101" => output<="1101"; when"1011" => output<="1110"; when"0111" => output<="1111"; when others=>null; end case; when others=>null; end case; end process; end arch_so; --47译码器-- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decoder47 is port(input:in std_logic_vector(0 to 3); abcdefg:out std_logic_vector(0 to 6)); end decoder47; architecture arch_d of decoder47 is begin process(input) begin case input is when "0000" => abcdefg<="1001111";--显示1-- when "0001" => abcdefg<="0010010";--显示2-- when "0010" => abcdefg<="0000110";--显示3-- when "0011" => abcdefg<="0001000";--显示A-- when "0100" => abcdefg<="1001100";--显示4-- when "0101" => abcdefg<="0100100";--显示5-- when "0110" => abcdefg<="0100000";--显示6-- when "0111" => abcdefg<="1100000";--显示B-- when "1000" => abcdefg<="0001111";--显示7-- when "1001" => abcdefg<="0000000";--显示8-- when "1010" => abcdefg<="0000100";--显示9-- when "1011" => abcdefg<="0110001";--显示C-- when "1100" => abcdefg<="0111000";--显示F-- when "1101" => abcdefg<="0000001";--显示0-- when "1110" => abcdefg<="0110000";--显示E-- when "1111" => abcdefg<="1000010";--显示D-- when others => null; end case; end process; end arch_d;
|
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
各位大神,为什么这个multsim14中电压表测出的电压值不对?需要设置哪里吗?
3053 浏览 1 评论
multisim14.0,变压器仿真为什么出现这样的错误结果?
13280 浏览 2 评论
16972 浏览 1 评论
Multisim14.2中CD4538高电平输出为什么只有5V?
18972 浏览 2 评论
17804 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-2-9 09:44 , Processed in 0.476210 second(s), Total 73, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191