“死代码” 在赛灵思

发布于 2024-07-14 00:49:29 字数 2582 浏览 12 评论 0原文

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

我真的不知道发生了什么导致细胞 3,2,1 在合成中被删除; 我已经审阅了五次以上,并询问了几个不同的人,但我找不到“为什么”。

不寻找解决方案,只是指出原因。

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;

I have some VHDL code I'm writing for a class. However, the synthesis tool identifies cell3, cell2, and cell1 as "dead" code and it won't synthesize it.

I really have no idea what's going on to cause cell 3,2,1 to be removed in synthesis; I've reviewed it some 5+ times and asked several different people and I can't find the "why".

Not looking for a solution, just a pointer to why.

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡少年 2024-07-21 00:49:29

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

cell0 实例化,因为乘法器的“p”输出是可观察的。

All I can suggest without seeing the rest of the code is that your 'c' input to cell_a is unused, which causes all the outputs from cell3/2/1 to be unused (hence, dead code, since it produces no observable results).

cell0 instantiates because multiplier's 'p' output is observable.

戈亓 2024-07-21 00:49:29

由于该块“p”的输出仅为 1 位,因此 cell1-3 可能会通过综合而得到优化。

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

It might be that cell1-3 are getting optimized out by the synthesis since the output of this block "p" is only 1 bit.

You don't need to fully evaluate all the logic to determine whether this bit should be a 0 or a 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文