信号temp2无法合成,同步描述错误

ice*_*y96 0 vhdl

entity timer is
    Port ( click : in  STD_LOGIC;
           clear : out  STD_LOGIC;
           t_unlock : out  STD_LOGIC);
end timer;

architecture Behavioral of timer is
    signal temp2 : integer range 0 to 20 := 0;
begin
    process
    begin
        if rising_edge(click) then
            temp2<=0;
            clear<='0';
            t_unlock<='0';
        else
            temp2<=temp2+1 after 15 ns;
        end if;
        if temp2=6 then
            clear<='1';
        elsif temp2=20 then
            t_unlock<='1';
        end if;
    end process;
end Behavioral;
Run Code Online (Sandbox Code Playgroud)

我写了这段代码,编译器说:

Signal temp2 cannot be synthesized, bad synchronous description. The description style you are using to describe a synchronous element (register, memory, etc.) is not supported in the current software release.
Run Code Online (Sandbox Code Playgroud)

我搜索了stackoverflow,他们说``错误的同步描述错误''通常意味着您描述了一个硬件中不存在的寄存器(时钟元素)。但是我不知道如何解决我的问题。

Mor*_*mer 5

VHDL必须遵循一些综合工具特定的编码准则,该工具才能将VHDL代码转换为FPGA实现。为了实现到具有异步复位的触发器,样式可以是:

process (clk, rst) is
begin
  -- Clock
  if rising_edge(clk) then
    ... -- Update at clock
  end if;
  -- Asynchronous reset
  if rst = '1' then
    ... -- Update at reset
  end if;
end process;
Run Code Online (Sandbox Code Playgroud)

就您的代码而言,您似乎没有使用异步重置,因此模板可以简化为:

process (clk) is
begin
  if rising_edge(clk) then
    ... -- Update at clock
  end if;
end process;
Run Code Online (Sandbox Code Playgroud)

现在,练习是使您的代码适合该模板,但是很遗憾,很难根据提供的代码确定确切的意图。

  • 不,`if rst ='1'then ... elsifrise_edge(clk)then ... end if;`形式意味着非复位部分驱动的信号必须在复位时保持稳定,即使在上升clk时也是如此,因为时钟部分将永远无法到达。这需要保持/闩锁操作,这可能不是故意的。用`ifising_edge(clk)然后...结束if; 如果rst ='1',则...结束if;形式的信号不是通过复位即可通过时钟更新,这与普通的触发器操作相匹配。不会有多个驱动程序,因为所有驱动程序都在同一进程中。 (4认同)