永发信息网

你好,我想用VHDL检测两个外部信号的上升沿之间的时间差,应该怎么写代码啊?

答案:1  悬赏:20  手机版
解决时间 2021-03-28 05:33
你好,我想用VHDL检测两个外部信号的上升沿之间的时间差,应该怎么写代码啊?
最佳答案
我做了两个输入信号(Signal_1,Signal_2)的上升沿检测(Edge_1,Edge_2),然后以Edge_1开始count,Edge_2终了count。
这样时间差就是count的值,输出是CntOut。时间差和你的时钟也有关。

---------------------------------------------------
--shift input to detect edge
process(CLK, nRESET)
begin
if nRESET = '0' then
Signal_1 <= '0';
Signal_2 <= '0';
elsif CLK'event and CLK = '1' then
rSignal_1 <= Signal_1;
rSignal_2 <= Signal_2;
end if;
end process;

--here is posedge
Edge_1 <= Signal_1 and (not rSignal_1);
Edge_2 <= Signal_2 and (not rSignal_2);
--posedge state from signal_1 to signal_2
process(CLK, nRESET)
begin
if nRESET = '0' then
StateOn <= '0';
elsif CLK'event and CLK = '1' then
if (Edge_1 == '1') then
StateOn <= '1';
elsif (Edge_2 == '1') then
StateOn <= '0';
end if;
end if;
end process;

--interval between edge
process(CLK, nRESET)
begin
if nRESET = '0' then
Cnt <= (others=>'0');
elsif CLK'event and CLK = '1' then
if (StateOn == '1') then
Cnt <= Cnt + '1';
else
Cnt <= (others=>'0');
end if;
end if;
end process;

--output interval
process(CLK, nRESET)
begin
if nRESET = '0' then
CntOut <= (others=>'0');
elsif CLK'event and CLK = '1' then
if (Edge_2 == '1') then
CntOut <= Cnt;
end if;
end if;
end process;追问非常感谢,晚上验证一下,谢谢!追答用时钟打一拍 然后逻辑电路一下就可以了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
g375高铁可在天津站上车吗
我家门口想装一个防盗门物业有权利不同意吗
为什么我的电脑上的酷狗每放完一首歌都在桌面
16S rRNA序列blast问题
比较债券投资与应付债券的会计处理有何相似与
简述局域网的分类及各自特点
-Excuseme.Couldyoutellme________gettoShan
方向盘带助力汽车换了轮胎以后突然变重了
请问12年鑫腾辉XTH-M650雕铣机现在要多少钱一
N2H2是什么化学物,怎么读
梦是怎么回事?
广东除了深圳广州市考,珠海有吗
CCD TCD1208输出波形不正常,SH,1,2,RS信号都
当今最大的货运海船是多大
南宁市内有哪些地方可以烧烤
推荐资讯
比的前项和后项同时乘或除以非0的数,比值不
重庆市区里哪个区最繁华?
(-3.3)+1.6+(-2.7)+2.4
11G101-3图集第92页中描述钢筋锚固为什么同时
10万秒是多长时间
佳人在古代代表什么
强如王家卫,为什么也跟风拍叶问系列
刚学佛家里不供佛在街上买了两个莲蓬放在家里
棱镜多肉和静夜多肉的区别是什么?很像!
有甲、乙两道算题,每道需执行1小时,其中处
我现在怀孕一个多月,煮面时不小心将带了八四
狂风泊舟是什么肖
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?