赛灵思 VHDL 锁存器警告故障排除



Xilinx 正在推断我编写的 VHDL 代码的锁存器。我查找了造成这种情况的可能原因,发现这通常是由于不完整的 if 或案例陈述。我已经通过并确保包括其他和何时其他陈述,但我仍然收到警告。我相信这也影响了我正在从事的另一个项目,所以我想了解为什么会这样。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity state_machine is
    port(trig, en: in std_logic; cstate,nstate: out std_logic_vector(0 to 2)); 
end state_machine;
architecture Behavioral of state_machine is
signal cstate_s,nstate_s: std_logic_vector(0 to 2);
begin
cstate <= cstate_s;
nstate <= nstate_s;
process(en, cstate_s)
begin
    if en = '1' then
        nstate_s <= "111";
        if cstate_s = "111" then
            nstate_s <= "011";
        elsif cstate_s = "011" then
            nstate_s <= "100";
        elsif cstate_s = "100" then
            nstate_s <= "101";
        elsif cstate_s = "101" then
            nstate_s <= "110";
        elsif cstate_s = "110" then
            nstate_s <= "111";
        else
            null;
        end if;
    else
        null;
    end if;
end process;
process(trig, nstate_s)
begin
    if rising_edge(trig) then
        cstate_s <= nstate_s;
    else
        null;
    end if;
end process;
end Behavioral;

警告:Xst:737 - 找到信号的 3 位锁存器。闩锁可能 从不完整的大小写或 if 语句生成。我们不 建议在 FPGA/CPLD 设计中使用锁存器,因为它们可能会导致 时序问题。

为了在

合成组合过程时没有合成锁存器,因此在beginend process;之间必须没有路径,其中未分配该过程的所有输出。这称为完成分配。流程的输出是分配在其内任何位置的任何signal

你有这样的路径。当执行任何包含 null 语句的路径时,不会将第一个进程 (nstate_s( 的输出分配给。因此,您将获得合成闩锁。仅仅有一个null声明是没有意义的。如果您真的不在乎在这些路径中为输出分配了什么值,请将输出分配给'-',这意味着在 VHDL 中不关心

顺便说一下(假设trig是一个时钟(,你的第二个过程不是组合的(它是顺序的(,所以你不需要服从完整的分配;你的else分支是不必要的。

最新更新