我要检查一下公交车的活动,直到美国时间4点。所以我需要数一数。时钟频率为8 8MHz。在这方面请帮帮我。
下面的代码可以工作吗?
process(sync_dw_reg,data_edge)
begin
if(rst_n='1' or data_edge='1' )then
gapen<='0';
elsif(falling_edge(sync_dw_reg))then
gapen<='1';
end if;
end process;
process(dec_clk,sync_dw_reg,rst_n,gapen)
begin
if(rst_n='1')then
gapcnt<="000000";
elsif(gapen='1')then
if(dec_clk'event and dec_clk='1')then
if(gapcnt="111111")then
gaperr_bit<='1';
elsif(data_edge='1')then --if this condition comes within 4us then no setting of error
gaperr_bit<='0';
gapcnt<="000000";
else gapcnt<=gapcnt+'1';
end if;
end if;
end if;结束进程;
发布于 2011-05-24 16:21:12
通常,计算出在您的时钟频率下4us有多少个时钟周期。
更好的是,让VHDL为你做这项工作。如果你的设计有一个全局包,里面有一个常数,那就是时钟周期:
constant clock_period : time := 125 ns;然后,您可以执行以下操作:
constant bus_timeout_for_example : natural := 4 us / clock_period;然后,在您的流程中创建一个整数变量。每个时钟周期递增它。当它达到你上面计算的数字时,你的4us就结束了。
编辑:现在你已经发布了一些代码和评论:
gapen可以是一个进程中的一个变量。并检查"clocked“部分中的数字。if gapcnt = bus_timeout then使用我描述的整数类型的变量进行计算--然后您可以与gapen:
https://stackoverflow.com/questions/6105927
复制相似问题