首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]这段检测有无触发信号的程序为什么不行啊

[求助]这段检测有无触发信号的程序为什么不行啊

各位大侠,请帮忙看看这段程序。我想以1s为周期,每1s内若无触发信号(对触发信号trigger的上升沿检测)则输出为0,有触发信号时输出为1.这段程序编译能通过,但不论仿真还是下到FPGA板子上都不正常工作,实在想不明白为什么,请各位大侠指教。

library ieee;
use ieee.std_logic_1164.all;
entity testchufa is
port(trigger:in std_logic;
clk:in std_logic;
endisput std_logic:='0');
end;
architecture one of testchufa is
signal i:integer :=0;
begin
process(clk)
begin
if clk'event and clk='1' then
i<=i+1;
if i=50000000 then
i<=0;
end if;
end if;
end process;
process(i,trigger )
variable num:integer:=0;
begin
if trigger'event and trigger='1' then
if i<50000000 then
num:=num+1;
end if;
end if;

if i=50000000 then
if num=0 then
endisp<='0';
else endisp<='1';
end if;

num:=0;
end if;
end process;
end one;

你的逻辑很乱呀。

真诚让沟通更简单! QQ:767914192

if trigger'event and trigger='1' then

用这个来检测信号的上升沿不好呀。这种方式一般是用来描述时钟的上升沿的。

真诚让沟通更简单! QQ:767914192

检测上升沿这样做:

triggerbuf <= trigger;

triggerrise <= trigger and (not triggerbuf);

然后

if i = 5000000 then

if triggerrise = '1' then

endisp <= '1';

else

endisp <= '0';

end if;

end if;

真诚让沟通更简单! QQ:767914192

尽量不要用变量,应用信号。

真诚让沟通更简单! QQ:767914192
版主讲个很细啊   学习了
顶一下
返回列表