Xilinx正在推断我编写的VHDL代码的锁存器。我查找了可能的原因并发现它通常是由于不完整的if或case语句。我已经通过并确保包括其他和其他声明,但我仍然收到警告。我相信这也影响了我正在研究的另一个项目,所以我想了解为什么会这样。
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设计中使用锁存器,因为它们可能会导致 时间问题。
答案 0 :(得分:3)
为了在合成组合过程时没有合成锁存器,begin
和end process;
之间必须没有路径,其中进程的所有输出都不是分配。这称为完整分配。该流程的输出是在其中的任何位置分配的任何signal
。
你有这样的道路。执行包含null
语句的任何路径时,不会分配第一个进程(nstate_s
)的输出。因此,您将获得合成的锁存器。只有null
声明是没有意义的。如果您真的不关心在这些路径中为输出分配了什么值,请将输出分配给'-'
,这意味着不关心在VHDL中。
顺便说一下(假设trig
是一个时钟),你的第二个进程不是组合的(它是顺序),因此你不需要服从完整的赋值; 1}}分支是不必要的。