"如果该端口属于顶级块,则该端口将被保留并保持未连接状态...."在VHDL中

时间:2014-04-28 04:08:44

标签: vhdl hdl

当我综合我的4位乘法器代码时,我在Xilinx中收到以下警告: “如果该端口属于顶级块,或者它属于子块,则该端口将被保留并保持未连接状态,并保留该子块的层次结构。”我没有看到任何问题在我的代码中可能会导致此警告。

代码如下:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_bit.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity mult4X4 is
Port ( Clk : in  bit;
       St : in  bit;
       Mplier : in  unsigned (3 downto 0);
       Mcand : in  unsigned (3 downto 0);
          Result : out unsigned (7 downto 0);
       Done : out  bit);
end mult4X4;

architecture behave1 of mult4X4 is
signal State : integer range 0 to 9;
signal ACC : unsigned (8 downto 0);
alias M : bit is ACC(0);

begin
process(Clk)
begin
    if Clk'event and Clk = '1' then
        case State is
            when 0 =>
                if St = '1' then
                    ACC(8 downto 4) <= "00000";
                    ACC(3 downto 0) <= Mplier;
                    State <= 1;
                end if;
            when 1 | 3 | 5 | 7 =>
                if M = '1' then
                    ACC(7 downto 4) <= ACC(7 downto 4) + Mcand;
                    ACC(8 downto 0) <= '0' & ACC(8 downto 1);
                    State <= State + 1;
                else
                    ACC <= '0' & ACC(8 downto 1);
                    State <= State + 2;
                end if;
            when 2 | 4 | 6 | 8 =>
                ACC <= '0' & ACC(8 downto 1);
                State <= State + 1;
            when 9 =>
                Done <= '1';
                State <= 0;
                Result <= ACC(7 downto 0);
        end case;
    end if;
end process;
--Done <= '1' when State = 9 else '0';
--Result <= ACC(7 downto 0);
end behave1;

2 个答案:

答案 0 :(得分:0)

尝试模拟它。

如果不自己模拟,我猜你会在结果上得到全部'0'。

这些:

                ACC(7 downto 4) <= ACC(7 downto 4) + Mcand;
                ACC(8 downto 0) <= '0' & ACC(8 downto 1);

将导致Multiplicand的影响被消除。 ACC的任务之间没有时间。参见IEEE Std 1076-1993 8.4.1更新投影输出波形(-2008 10.5.2.2执行简单赋值语句),开头“事务序列为......”的段落和以下叙述。 ACC的受影响位(7 downto 4)的第一个分配的预定事务将作为旧事务删除。对于复合类型(和ACC是),它是逐个元素发生的。

由于第二个赋值语句,它看起来会得到全0'。

同样,从简单地阅读你的状态机,这两个ACC任务中的第二个应该只在状态1 |中被删除3 | 5 | 7?

<强>附录

在Yann Verneir指出另一个错误,Done从未被赋予'0'之后,我想我会在状态1中向ACC展示两个赋值语句的效果。 3 | 5 | 7。

一个简单的测试平台:

library ieee;
use ieee.numeric_bit.all;

entity mult4x4_tb is
end entity;

architecture foo of mult4x4_tb is
    signal clk:             bit;
    signal start:           bit;
    signal multiplier:      unsigned (3 downto 0) := X"2";
    signal multiplicand:    unsigned (3 downto 0) := X"4";
    signal result:          unsigned (7 downto 0);
    signal done:            bit;

begin

DUT:
    entity work. mult4x4
        port map (
            Clk => clk,
            St  => start,
            Mplier => multiplier,
            Mcand => multiplicand,
            Result => result,
            Done => done
        );

CLOCK:
    process
    begin
        wait for 10 ns;
        clk <= not clk;
        if Now > 300 ns then
            wait;
        end if;
    end process;

STIM:
    process 
    begin
        wait for 29 ns;
        start <= '1';
        wait for 20 ns;
        start <= '0';
        wait;
    end process;

end architecture;

给出:

mult4x4 testbench

你可以看到,当使用包numeric_bit而不是包std_logic_1164和numeric_std时,除了Result上的所有'0'之外我们什么都看不见。

Yann仅在Done上转让给'1'可以通过以下方式解决:

    case State is
        when 0 =>
            if St = '1' then
                ACC(8 downto 4) <= "00000";
                ACC(3 downto 0) <= Mplier;
                State <= 1;
                Done <= '0';
            end if;

在案例ACC的序列语句中删除1 | 3 | 5 | 7的第二个信号分配,给出了一个适合2 x 4的答案:

mult4x4_tb fixed

答案 1 :(得分:0)

请注意,警告是关于端口的。我希望上面的那条线能够准确地告诉你哪个端口,但它很容易派生出来。

端口将保持未连接状态。这意味着它必须没有效果。无效的最简单方法是不使用。在此过程中会考虑所有端口,因此我们会寻找其他无意义的方法。完成看起来像一个主要候选人;状态机完成时设置为1,但没有重置;这意味着它从未定义变为高,并保持不变。优化器可以用高输出替换它。重置它的合理位置将处于开始状态。

通常,代码没有重置,如果状态机可以从任何状态恢复,但是不能正确模拟,则可能没问题。不要因为状态信号的范围而确定它会复位;如果有10个值,则需要4位来存储,导致6个不可见状态具有未定义的行为;或者它可以很好地编码为一个热,如果不重置可能导致多个状态同时出现。