【问题标题】:Xilinx VHDL latch warning troubleshootingXilinx VHDL 锁存器警告故障排除
【发布时间】:2017-03-31 16:27:10
【问题描述】:

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

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;

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

【问题讨论】:

  • nstate_s 的 if 语句优先级编码器/多路复用器不完整。您涵盖了条件值“011”、“100”、“101”、“110”和“111”,并且有一个为空语句的 else 语句。这意味着对于条件值“000”、“001”和“010”,您不会在定义锁存器的 nstate_s 上驱动不同的值。更改 else 情况以驱动 cstate_s 的当前值。 else null 在 cstate_s 寄存器中是多余的,它保存在 trig 上升沿设置的值。您应该能够在不使用空语句的情况下完成您的设计生涯。
  • 合成中使用的唯一值是二进制表示值('0'、'1'、'L'和'H'映射到'0'和'1',而使用'Z'推断高阻抗状态)。 else (或 case others 选择)应涵盖用于综合的二进制值和用于仿真的所有未指定值。这两种用途并非不相容。请参阅 IEEE Std 1076-2008 16.8.2 标准逻辑类型的解释。指定元值(U'、'X'、'W' 和 '–')的语句在综合中被忽略。

标签: warnings vhdl xilinx synthesis


【解决方案1】:

为了在合成组合进程时没有合成锁存器,beginend process; 之间必须没有路径,其中进程的所有输出都未分配。这称为完成作业。进程的输出是分配在其中任何位置的任何signal

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-01
    • 2015-09-08
    • 1970-01-01
    • 2011-01-23
    • 1970-01-01
    • 2012-05-23
    • 2010-11-09
    • 1970-01-01
    相关资源
    最近更新 更多