设计计数器时遇到的问题

2019-03-25 09:09发布

我正在用CPLD设计一个计时计数模块:按下reset清零,按一下start开始计时,按一下stop停止计时把结果传给单片机,现在就是控制不了stop,就是仿真时start为高电平1时计数器工作,为0时停止计数,stop控制不了,请问应该怎样才能控制呢?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
8条回答
eeleader
2019-03-25 23:28

在原程序上修改一下即可!

 

if(reset='0') then

 cnt<=0;

 bus<=0;

elsif clk'event and clk='1' then

start_reg<=start;

stop_reg<=stop;

if (start='1') and (start_reg='0') then

           start_flag<='1';

           cnt<=0;

elsif (stop='1') and (stop_reg='0') then

           start_flag<='0';

           bus<=cnt;

elsif (start_flag='1') then

          cnt<=cnt+1;

end if;

end if;

一周热门 更多>