我正在FPGA上开发控制算法,但我不能声称有VHDL的经验。我需要的一种功能是一种'Trigger Upscaler',所以我想增加触发频率而不是减少触发频率。VHDL时钟或触发器上标延迟
下面是一个说明:
我得到50MHz的系统CLK和得到了1个CLK周期的触发脉冲与1千赫频率,从而各一个毫秒。这个触发器是某些微积分运算的开始,它必须比这个运算更快。所以我想知道我是否可以用10 kHz产生一个新的触发器。这里的基本代码我迄今为止:
calc_prescaler: process
begin
wait until rising_edge(clk);
-- When a new trig appears, send 1 tick and reset counters
if trig_in = '1' then
cnt_clk <= (others => '0');
cnt_active <= '1';
trig_out <= '1';
trig_count <= (others => '0');
else
trig_out <= '0';
-- Safety feature: Do not send more ticks than estimated
-- Useful in case trig_in freezes
if trig_count > par_max - 1 then
cnt_active <= '0';
trig_count <= (others => '0');
end if;
if cnt_active = '1' then
cnt_clk <= cnt_clk + 1;
end if;
-- If Counter reaches desired values, send 1 tick and increase tick counter
if cnt_clk = par_fac - 1 then
trig_count <= trig_count + 1;
trig_out <= '1';
cnt_clk <= (others => '0');
end if;
end if;
-- Reset
if res_n = '0' then
trig_out <= '0';
cnt_clk <= (others => '0');
trig_count <= (others => '0');
cnt_active <= '0';
end if;
有两个变量,par_fac与是作为上trig_out蜱数目的期望(高)的触发频率和系统CLK和par_max之间的比率,如果没有新的TRIG_IN。
对我来说迄今为止,但问题是,两个触发器不同步,有1个时钟周期的延迟。
你有什么建议如何修改我的方法?实现任何方式是值得欢迎的,唯一的要求我必须是: - TRIG_IN和trig_out 之间没有延迟 - 如果TRIG_IN蜱停止
太棒了!这显然有效!非常感谢!我只是试了一下。但是不应该降低计数器值(par_fac-2),而应该用1而不是0来初始化计数器。否则,稍后的滴答将过早发送一个clk循环。 – Clemens 2015-03-13 14:51:54