Vhdl 通过采样信号避免亚稳态
我试图在下面用VHDL对这个电路进行编码,以避免在我的项目中出现亚稳态 这是我到目前为止编写的代码:Vhdl 通过采样信号避免亚稳态,vhdl,Vhdl,我试图在下面用VHDL对这个电路进行编码,以避免在我的项目中出现亚稳态 这是我到目前为止编写的代码: library ieee; use ieee.std_logic_1164.all; entity Metastability is port ( clk : in std_logic; key : in std_logic; reset : in std_logic; Led : out std_logic ); end Metastabil
library ieee;
use ieee.std_logic_1164.all;
entity Metastability is
port ( clk : in std_logic;
key : in std_logic;
reset : in std_logic;
Led : out std_logic
);
end Metastability ;
architecture rtl of Metastability is
signal metastable : std_logic;
signal stabel : std_logic;
begin
process(clk,reset)
begin
if (reset ='1') then
metastable <= '0';
stabel <= metastable;
Led <= stabel;
else if rising_edge(clk) then
metastable <= key;
stabel <= metastable;
Led <= stabel;
end if;
end if;
end process;
end rtl;
但当我在modelsim中模拟它时,stabel信号在两个时钟周期过去之前不会改变其状态,另外一个额外的Led变为“1”。为什么呢
有两个问题: 重置 重置时,您希望将编译时已知的固定值分配给信号。所以你应该改变 您应该从时钟进程中删除对Led信号的分配,而是同时进行分配:
process(clk, reset)
begin
…
metastable <= … ;
stabel <= … ;
end process;
Led <= stabel;
变成
if (reset = '1') then
…
elsif rising_edge(clk) then
…
end if;
还有什么奇怪和出乎意料的呢?当我运行sim卡代码时,稳定的信号在两个时钟周期过去之前不会改变它的状态,另外一个是Led的“1”。为什么呢?我刚刚在编辑的问题中添加了sim卡的图片!:LED通常不计时。因此,您可以简单地将稳定的Led分配到时钟进程之外,延迟将下降到预期的2个周期。您所描述的是两级同步器。你从输出中得到的东西可以被认为是“稳定的”。然而,亚稳态的可能性仍然很小,这在超高速或高可靠性电路中可能是一个问题。在那里,您有时需要三个或更多的阶段同步器,以进一步减少亚稳态的变化。感谢您的回应!:现在我想我有了更好的理解!
process(clk, reset)
begin
…
metastable <= … ;
stabel <= … ;
end process;
Led <= stabel;
if (reset = '1') then
…
else
if rising_edge(clk) then
…
end if;
end if;
if (reset = '1') then
…
elsif rising_edge(clk) then
…
end if;