【发布时间】: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