VHDL过程混淆与敏感性列表

时间:2014-08-09 19:43:25

标签: vhdl xilinx-ise

我正在通过在线阅读书籍(自由范围VHDL)学习VHDL,并通过Xilinx ISE Webpack 14.7在我的Nexsys2上复制示例。我正在重读自由范围VHDL文本,目前正在讨论流程的章节。我对过程是什么以及它是如何工作有深刻的理解,但我实现了一个例子,我不理解结果。

我使用以下代码实现了8到1 mux。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity mux81 is
    port( d_in : in std_logic_vector(7 downto 0);
            sel : in std_logic_vector(2 downto 0);
            ce : in std_logic;
            F : out std_logic);
end mux81;

architecture my_mux81 of mux81 is
begin
mux_proc: process(d_in, sel, ce)
    begin
        if (ce = '1') then
            if (sel = "111") then
                F <= d_in(7);
            elsif (sel = "110") then
                F <= d_in(6);
            elsif (sel = "101") then
                F <= d_in(5);
            elsif (sel = "100") then
                F <= d_in(4);
            elsif (sel = "011") then
                F <= d_in(3);
            elsif (sel = "010") then
                F <= d_in(2);
            elsif (sel = "001") then
                F <= d_in(1);
            elsif (sel = "000") then
                F <= d_in(0);
            else
                F <= '0';   
            end if;
        else
            F <= '0';
        end if;
    end process mux_proc;
end my_mux81;

仅当'ce'信号为'1'时才执行多路复用操作。一切都按预期工作。然后,我通过从灵敏度列表中删除“ce”信号来尝试实验。根据我对过程语句的理解,它只应在灵敏度列表中的信号发生变化时执行。通过移除'ce'信号,电路不应单独响应'ce'变化。这是修改后的电路:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity mux81 is
    port( d_in : in std_logic_vector(7 downto 0);
            sel : in std_logic_vector(2 downto 0);
            ce : in std_logic;
            F : out std_logic);
end mux81;

architecture my_mux81 of mux81 is
begin
mux_proc: process(d_in, sel)
    begin
        if (ce = '1') then
            if (sel = "111") then
                F <= d_in(7);
            elsif (sel = "110") then
                F <= d_in(6);
            elsif (sel = "101") then
                F <= d_in(5);
            elsif (sel = "100") then
                F <= d_in(4);
            elsif (sel = "011") then
                F <= d_in(3);
            elsif (sel = "010") then
                F <= d_in(2);
            elsif (sel = "001") then
                F <= d_in(1);
            elsif (sel = "000") then
                F <= d_in(0);
            else
                F <= '0';   
            end if;
        else
            F <= '0';
        end if;
    end process mux_proc;
end my_mux81;

如您所见,唯一的变化是从敏感度列表中删除了'ce'。但是,当我实现这个电路时,它的运行方式与灵敏度列表中具有“ce”的版本完全相同。换句话说,保持信号“d_in”和“sel”不变,但修改“ce”导致进程语句执行并改变输出信号,好像'ce'仍在灵敏度列表中。当我运行综合时,我没有得到任何警告。这就像程序假设'ce'也应该受到监控,但我认为这也应该产生警告...

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

许多综合工具忽略了灵敏度列表。检查综合工具中的警告,您可能会发现它警告缺少CE信号。

不完整的敏感性列表是一个臭名昭着的问题原因,因为模拟和后合成行为不一样!

通常,您不想使用级别敏感的锁存器。它们会造成各种麻烦,而且比普通的旧同步逻辑更难以验证。

如果确实想要创建一个级别敏感的锁存器,您应该实例化一个由FPGA供应商提供的锁存器,或者确定使用哪种编码方式来使您的综合工具推断锁存器