VHDL时钟或触发器放大延迟
我正在开发FPGA上的控制算法,但我不能说我对VHDL有经验。我需要的一个功能是一种“触发器放大”,所以我想增加触发器频率,而不是降低它 这里有一个解释: 我得到了一个50 MHz的系统时钟,得到了一个触发脉冲,频率为1 kHz,1个时钟周期,因此每毫秒触发一次。这个触发是某些演算的开始,它必须运行得更快。所以我想知道我是否能产生一个10千赫的新触发器。以下是迄今为止我掌握的基本代码:VHDL时钟或触发器放大延迟,vhdl,Vhdl,我正在开发FPGA上的控制算法,但我不能说我对VHDL有经验。我需要的一个功能是一种“触发器放大”,所以我想增加触发器频率,而不是降低它 这里有一个解释: 我得到了一个50 MHz的系统时钟,得到了一个触发脉冲,频率为1 kHz,1个时钟周期,因此每毫秒触发一次。这个触发是某些演算的开始,它必须运行得更快。所以我想知道我是否能产生一个10千赫的新触发器。以下是迄今为止我掌握的基本代码: calc_prescaler: process begin wait until rising_
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;
计算预分频器:过程
开始
等待上升沿(clk);
--当新触发器出现时,发送1个勾号并重置计数器
如果trig_in='1',则
cnt_clk“0”);
cnt_active在任何顺序逻辑中,输出总是相对于输入延迟一个时钟周期。这意味着您无法为流程内的每个触发器输入生成第一个勾号
if trig_in = '1' then
cnt_clk <= (others => '0');
cnt_active <= '1';
--trig_out <= '1'; don't do this
trig_count <= (others => '0');
如果trig_in='1',则
cnt_clk“0”);
你真是太棒了!这显然有效!谢谢!我刚试过。但不应降低计数器值(par_fac-2),而应使用1而不是0初始化计数器。否则,后面的滴答声将提前发送一个时钟周期。
if cnt_clk = par_fac - 1 then
trig_count <= trig_count + 1;
--trig_out <= '1'; don't do this
cnt_clk <= (others => '0');
end if;
-- instead:
if cnt_clk = par_fac - 2 then
trig_out <= '1';
end if;