【问题标题】:"Dead code" in XilinxXilinx 中的“死代码”
【发布时间】:2009-02-18 21:06:20
【问题描述】:

我正在为一个班级编写一些 VHDL 代码。但是,合成工具将 cell3、cell2 和 cell1 识别为“死”代码,并且不会对其进行合成。

我真的不知道发生了什么导致单元格 3、2、1 在合成中被删除;我已经对其进行了 5 次以上的审查,并询问了几个不同的人,但我找不到“为什么”。

不是在寻找解决方案,只是一个指向原因的指针。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;



entity multiply is
    Port ( a : in  STD_LOGIC_VECTOR (3 downto 0);
           b : in  STD_LOGIC;
           clk : in  STD_LOGIC;
           rst : in  STD_LOGIC;

           p : out  STD_LOGIC);

end multiply;

architecture Behavioral of multiply is

    component cell_a port(
                s: in std_logic;
                c: in std_logic;
                a: in std_logic;
                b: in std_logic;
                clk: in std_logic;

                c_out: out std_logic;
                s_out: out std_logic);
    end component;

    signal c_s_0: std_logic;    --loopback wire for cell 0 from carry to sum
    signal c_s_1: std_logic;
    signal c_s_2: std_logic;
    signal c_s_3: std_logic;

    signal xfer1_0: std_logic;  --wire between 1 and 0
    signal xfer2_1: std_logic;  --"     2 and 1
    signal xfer3_2: std_logic;      --"     3 and 2


begin

    cell3: cell_a port map(
                                    clk => clk, 
                                    s => c_s_3 , c => '0',   a => a(3), b => b,
                                    c_out => c_s_3, s_out => xfer3_2
                                    );

    cell2: cell_a port map(
                                    clk => clk, 
                                    s => c_s_2 , c => xfer3_2, a => a(2), b => b, 
                                    c_out => c_s_2, s_out => xfer2_1
                                    );

    cell1: cell_a port map(
                                    clk => clk, 
                                    s => c_s_1, c => xfer2_1, a => a(1), b => b, 
                                    c_out => c_s_1, s_out => xfer1_0
                                    );

    cell0: cell_a port map(
                                    clk => clk, 
                                    s => c_s_0 , c => xfer1_0, a => a(0), b => b, 
                                    c_out => c_s_0, s_out => p
                                    );
    process(clk)
    begin
        if(clk'event and clk = '1') then
            if(rst = '1') then
            --reset logic here. Magic happens and the circuit goes to all 0
            end if;
        end if;
    end process;
end Behavioral;

【问题讨论】:

    标签: vhdl synthesis dead-code


    【解决方案1】:

    如果没有看到其余代码,我只能建议您对 cell_a 的“c”输入未使用,这会导致 cell3/2/1 的所有输出都未使用(因此,死代码,因为它不会产生可观察到的结果)。

    cell0 实例化,因为乘数的 'p' 输出是可观察的。

    【讨论】:

    • 谢谢。如果我想到这一点,我会在几个小时前完成。谢谢。
    【解决方案2】:

    可能是 cell1-3 正在通过合成得到优化,因为这个块“p”的输出只有 1 位。

    您不需要完全评估所有逻辑来确定该位应该是 0 还是 1。

    【讨论】:

    • 显然你这样做了,否则它就不会被写出来。正如我在回答中所说,这更有可能是 cell_a 架构中的错误。
    • 我不明白你的评论。我可以写一些不需要的东西,并且该逻辑将被综合工具优化。例如,如果我写出 = in | !in,然后综合工具会优化出 OR 门和 INV 门,写出 = 1。
    • 是的,但如果您打算将其包含在内,但事实并非如此,则更有可能是您的错误。该问题暗示开发人员希望使用所有代码,而没有使用它的事实是不正确的。
    • DasBoot,我想让细胞真正一些事情。这就是问题所在。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多