VHDL 编码错误 "Else clause after check for clock not supported"

VHDL coding error "Else clause after check for clock not supported"

我正在尝试制作一个计数器,它在每 64 个时钟脉冲后发出一个进位信号。当我尝试综合如下所示的代码时,(在 Vivado 中)出现以下错误,

Else clause after check for clock not supported.

(在标有'!!'的线上)

我在另一个项目中做了非常相似的事情,但我没有在那里遇到任何错误,所以我真的不知道哪里出了问题。有帮助吗?

entity refresh_counter is
     port( CLK : in STD_LOGIC;
           CLR : in STD_LOGIC;
           CARRY : out STD_LOGIC);
end refresh_counter;

architecture Behavioral of refresh_counter is
begin

process(CLK)
variable tel : integer;
begin
    if (CLK'event and CLK = '1') then
        if CLR = '1' then
            tel := 0;
        end if;
    else
        if (tel < 63) then            !!
            tel := tel + 1;
        else
            CARRY <= '1';
            tel := 0;
        end if;
    end if;

end process;
end Behavioral;

正如@scary_jeff 在评论部分提到的,您的else 没有意义,因为您实际上无法实施not at rising edge。这是一个可以完成这项工作的实现。

进程有两个变量n_carryn_tel。您可以将它们视为 FSM 的组合输出。在时钟的上升沿,这两个变量分别传送到carrytel

CLR为高的情况下,0将被转移。

n_carryn_tel逻辑是在硬件中组合实现的。它以 tel 作为输入,并在流程中的 if-elsif-else 序列中对决策进行编码。

library std;
library ieee;
use ieee.std_logic_1164.all;
entity refresh_counter is
     port( CLK : in STD_LOGIC;
           CLR : in STD_LOGIC;
           CARRY : out STD_LOGIC);
end refresh_counter;

architecture Behavioral of refresh_counter is
signal tel: integer := 0;
begin

process(CLK, CLR, tel)
variable n_tel: integer := 0;
variable n_carry: STD_LOGIC := '0';
begin

    if (tel < 63) then
        n_carry := '0';
        n_tel := tel + 1;
    elsif (tel = 63) then
        n_carry := '1';
        n_tel := 0;
    else
        -- This case should never arise in practice
        n_carry := '0';
        n_tel := 0;
    end if;

    if (CLK'event and CLK = '1') then
        if CLR = '1' then
            tel <= 0;
            CARRY <= '0';
        else
            tel <= n_tel;
            CARRY <= n_carry;
        end if;
    end if;

end process;
end Behavioral;