在一个情况下,我如何修复"Latches may be generated from incomplete c



请帮助我

我试着用选择器做4位ALU。我收到这样的错误:

**警告:Xst:737-发现信号<Z<1>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Z<0>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Znot<3>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Znot<2>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Znot<1>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Znot<0>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。

警告:Xst:737-发现信号的1位锁存器<Z<2>gt;。锁存可能由不完整的case或if语句生成。我们不建议在FPGA/CPLD设计中使用锁存器,因为它们可能会导致时序问题。**

我写了这个代码:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Multiplexor is
Port ( A, B, C, D : in  STD_LOGIC;
S : in  STD_LOGIC_VECTOR (2 downto 0);
Z : out  STD_LOGIC_VECTOR (2 downto 0);
Znot : out  STD_LOGIC_VECTOR (3 downto 0));
end Multiplexor;
architecture tabla of Multiplexor is
begin
process(S, A, B, C, D)
begin
case (S) is 
when "000" => --Suma--
Z(2) <= ((A and C) or (B and C and D) or (A and B and D));
Z(1) <= (((not(A))and (not (B))and C) or ((not(A)) and C and (not(D))) or (A and (not (B)) and (not (C))) or (A and (not (C)) and (not (D))) or ((not (A)) and B and (not (C)) and D) or (A and B and C and D));
Z(0) <= (((not(B)) and D) or (B and (not(D))));
when "001" => --Resta--
Z(2) <= (((not(A)) and C) or ((not(A)) and C and D) or (A and (not(C)) and (not(D))) or (A and B and (not(C))));
Z(1) <= (((not(A)) and (not(B)) and C) or ((not(A)) and C and D) or (A and (not(C)) and (not(D))) or (A and B and (not(C))));
Z(0) <= (((not(B)) and D) or (B and (not(D))));
when "010" => --Comparación--
Z(2) <= (((not(A)) and C) or ((not(A)) and (not(B)) and D) or ((not(B)) and C and D));
Z(1) <= ((A and (not(C))) or (B and (not(C)) and (not(D))) or (A and B and (not(D))));
Z(0) <= (((not(A)) and (not(B)) and (not(C)) and (not(D))) or ((not(A)) and B and (not(C)) and D) or (A and (not(B)) and C and (not(D))) or (A and B and C and D));
when "011" => --AND--
Z(2) <= '0';
Z(1) <= (A and C);
Z(0) <= (B and D);
when "100" => --OR--
Z(2) <= '0';
Z(1) <= (C or A);
Z(0) <= (D or B);
when "101" => --XOR--
Z(2) <= '0';
Z(1) <= (((not(A)) and C) or (A and (not(C))));
Z(0) <= (((not(B)) and D) or (B and ((not(D)))));
when "110" => --NOT--
Znot(3) <= (not(A));
Znot(2) <= (not(B));
Znot(1) <= (not(C));
Znot(0) <= (not(D));
when others =>
Znot(3) <= '0';
Znot(2) <= '0';
Znot(1) <= '0';
Znot(0) <= '0';
Z(2) <= '0';
Z(1) <= '0';
Z(0) <= '0';
end case;
end process;
end tabla;

正如注释中所述,您不会为每个案例的Case语句中的所有输出信号分配一个值。由于语言标准的摘录可以使用有点技术性和不透明的语言,我将尝试写一个对初学者友好的解释。

您的case语句有七个输出,Z(0..2(和Znot(0..3(。您的过程属于组合类型(即不计时(。这种结构的标准描述是为所有情况分配所有输出。如果你查看你的第一个评估(当="000"时(,你可以看到你只给Z赋值。这意味着你希望Znot保留它以前的值,这意味着一个内存元素。非时钟存储器元件被称为锁存器。

收到警告的原因是Latches违反了同步设计实践。FPGA被设计为同步工作。这些工具知道这一点,而且在99%的情况下,闩锁是意外的,会发出警告。他们没有提出错误的原因是,在某些角落的情况下,需要使用闩锁,但这仅供专家使用。

暗示内存元素的正确方法是使用寄存器。在这种情况下,暗示这将是用时钟驱动您的流程。如果这是不可取的,那么在每种情况下都明确说明每个输出的期望值。

相关内容

最新更新