在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3379|回复: 6

[求助] vhdl按键计数器

[复制链接]
发表于 2011-12-1 23:51:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
输入:clk,reset,b1,b2: std_logic;其中,b1,b2表示两个按键,b1没按下一次,计数器加1,b2没按下一次,计数器减一。
该如何实现?消抖部分一坐处理,这里不用考虑。
发表于 2011-12-4 22:46:39 | 显示全部楼层
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity VHDL is
generic
        (
                DATA_WIDTH : natural := 8
        );

        port
        (
                b1           : in std_logic;
                b2           : in std_logic;
                result : out std_logic_vector((DATA_WIDTH-1) downto 0)
        );

end entity;

architecture rtl of VHDL is
signal result_l :std_logic_vector((DATA_WIDTH-1) downto 0);
begin

        process(b1,b2)
        begin
         if (b1='1') then
         result_l<=result_l+'1';
         elsif (b2='1') then
         result_l <=result_l-'1';
         end if;
end process;
result<=result_l;
end rtl;
发表于 2011-12-4 22:49:47 | 显示全部楼层
没有验证,只是使用quartus ii10.1编译综合了一下,没有问题,很简单的功能,应该没问题!
 楼主| 发表于 2011-12-5 00:05:43 | 显示全部楼层
我试了,貌似检测不到上升沿。
发表于 2011-12-5 00:30:50 | 显示全部楼层
把2楼的改成同步时序就可以了
if  clk'event and clk='1' then
         if (b1='1') then
         result_l<=result_l+'1';
         elsif (b2='1') then
         result_l <=result_l-'1';
         end if;
end if
发表于 2011-12-5 00:36:06 | 显示全部楼层
把2楼的改成同步时序就可以了
if  clk'event and clk='1' then
         if (b1='1') then
         result_l<=result_l+'1';
         elsif (b2='1') then
         result_l <=result_l-'1';
         end if;
end if
发表于 2011-12-5 10:57:49 | 显示全部楼层
5楼对的,在输入端口添加clk和reset后,在if (b1='1') then 前面还要添加复位信号控制。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-6 17:20 , Processed in 0.025558 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表