为什么会得到推断的锁存器?
Why am getting inferred latches?
我知道当没有定义所有可能的路径时会发生推断锁存器,但我已经考虑在我的过程中避免这种情况:
信号是:
signal BothButtons : std_logic_vector (1 downto 0) ;
过程是:
Signaling : process(button0, button1)
begin
if (button0= '0') AND (button1 = '0') then
BothButtons <= "00";
elsif (button0= '0') AND (button1 = '1') then
BothButtons <= "01";
elsif (button0= '1') AND (button1 = '0') then
BothButtons <= "10";
elsif (button0= '1') AND (button1 = '1') then
BothButtons <= "11";
end if;
end process;
这让我发疯,感谢任何帮助,也许我对一些非常简单的事情缺乏理解!
错误是:
Warning (10631): VHDL Process Statement warning at swDisplay.vhd(28): inferring latch(es) for signal or variable "BothButtons", which holds its previous value in one or more paths through the process
据我所知,我不是同时为信号分配两个值,而是在不同情况下接收值?
这次我使用先前的信号来驱动另一个进程的输出,但其中出现了另一个锁存器,这次我确实考虑了任何其他值并放置了一个 "else" 语句来注意的,但没有运气:
Counting : process(BothButtons)
variable count0 : integer range 0 to 9; -- to hold the counter value
begin
if BothButtons = "00" then
count0 := 0;
elsif BothButtons = "01" then
count0 := count0 + 1;
elsif BothButtons = "10" then
count0 := count0;
elsif BothButtons = "11" then
count0 := count0;
else
count0 := 0;
end if;
对于那些想知道的人,是的,这是学术练习的一部分!
如果 button0 既不是“0”也不是“1”会怎样?这是你的闩锁。 (ditto button1) 即使 'H'
和 'L'
也会混淆它,即使这些对你或我有明确的含义...
现在您需要哪些 BothButtons <= button0 & button1;
没有做的事情? (我可能误解了你遇到的问题)
你有锁存器,因为你有一个没有时钟的内存进程。
在您给出的第一个示例中,您只需要在 if-case 的末尾添加一个 else
。否则它会被迫使用以前的值,这要求它有一些关于这个以前值的记忆。内存需要锁存器或触发器 - 如果没有时钟,它就被迫使用锁存器。
在第二个示例中,count0 := count0 + 1;
和 count0 := count0;
行使用了上一次流程迭代的值。这需要记忆。没有时钟的内存会给你闩锁。
我知道当没有定义所有可能的路径时会发生推断锁存器,但我已经考虑在我的过程中避免这种情况:
信号是:
signal BothButtons : std_logic_vector (1 downto 0) ;
过程是:
Signaling : process(button0, button1)
begin
if (button0= '0') AND (button1 = '0') then
BothButtons <= "00";
elsif (button0= '0') AND (button1 = '1') then
BothButtons <= "01";
elsif (button0= '1') AND (button1 = '0') then
BothButtons <= "10";
elsif (button0= '1') AND (button1 = '1') then
BothButtons <= "11";
end if;
end process;
这让我发疯,感谢任何帮助,也许我对一些非常简单的事情缺乏理解!
错误是:
Warning (10631): VHDL Process Statement warning at swDisplay.vhd(28): inferring latch(es) for signal or variable "BothButtons", which holds its previous value in one or more paths through the process
据我所知,我不是同时为信号分配两个值,而是在不同情况下接收值?
这次我使用先前的信号来驱动另一个进程的输出,但其中出现了另一个锁存器,这次我确实考虑了任何其他值并放置了一个 "else" 语句来注意的,但没有运气:
Counting : process(BothButtons)
variable count0 : integer range 0 to 9; -- to hold the counter value
begin
if BothButtons = "00" then
count0 := 0;
elsif BothButtons = "01" then
count0 := count0 + 1;
elsif BothButtons = "10" then
count0 := count0;
elsif BothButtons = "11" then
count0 := count0;
else
count0 := 0;
end if;
对于那些想知道的人,是的,这是学术练习的一部分!
如果 button0 既不是“0”也不是“1”会怎样?这是你的闩锁。 (ditto button1) 即使 'H'
和 'L'
也会混淆它,即使这些对你或我有明确的含义...
现在您需要哪些 BothButtons <= button0 & button1;
没有做的事情? (我可能误解了你遇到的问题)
你有锁存器,因为你有一个没有时钟的内存进程。
在您给出的第一个示例中,您只需要在 if-case 的末尾添加一个 else
。否则它会被迫使用以前的值,这要求它有一些关于这个以前值的记忆。内存需要锁存器或触发器 - 如果没有时钟,它就被迫使用锁存器。
在第二个示例中,count0 := count0 + 1;
和 count0 := count0;
行使用了上一次流程迭代的值。这需要记忆。没有时钟的内存会给你闩锁。