&引用;如果该端口属于顶级块,则该端口将被保留并保持未连接状态……”;用VHDL语言
当我合成4位乘法器的代码时,我在Xilinx中收到以下警告: “如果此端口属于顶级块或子块,并且此子块的层次结构被保留,则此端口将被保留并保持未连接状态。”我认为代码中没有任何问题会导致此警告 代码如下:&引用;如果该端口属于顶级块,则该端口将被保留并保持未连接状态……”;用VHDL语言,vhdl,hdl,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 functio
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;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
使用IEEE.numeric_bit.ALL;
--如果使用,请取消注释以下库声明
--具有有符号或无符号值的算术函数
--使用IEEE.NUMERIC_STD.ALL;
--如果正在实例化,请取消对以下库声明的注释
--此代码中的任何Xilinx原语。
--UNISIM图书馆;
--使用UNISIM.VComponents.all;
实体mult4X4是
端口(时钟:以位为单位;
St:以比特为单位;
Mplier:无符号(3到0);
Mcand:在无符号(3到0)中;
结果:输出无符号(7到0);
完成:输出位);
结束mult4X4;
mult4X4的体系结构行为1为
信号状态:整数范围0至9;
信号ACC:无符号(8至0);
别名M:位为ACC(0);
开始
过程(Clk)
开始
如果Clk'事件和Clk='1',则
案例状态为
当0=>
如果St='1',则
ACC(8到4)尝试模拟它
如果不是我自己模拟的话,我猜你在结果上得到了所有的“0”
这些:
ACC(7 downto 4) <= ACC(7 downto 4) + Mcand;
ACC(8 downto 0) <= '0' & ACC(8 downto 1);
给出:
您可以看到,当使用package numeric_bit而不是packages std_logic_1164和numeric_std时,我们在结果中只看到所有“0”
Yann仅在完成时分配给“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;
案例状态为
当0=>
如果St='1',则
ACC(8到4)注意,警告是关于端口的。我希望上面的这行代码会准确地告诉您是哪个端口,但推导起来很容易
端口将保持未连接状态。这意味着它一定没有效果。没有效果的最简单方法就是不用。所有的端口都在这个过程中被考虑,所以我们寻找其他没有意义的方式。Done看起来像一个主要候选人;当状态机完成时设置为1,但没有重置;这意味着它从未定义变为高,并保持不变。优化器可以用一个高输出来代替它。重置它的合理位置是在启动条件下
一般情况下,代码没有重置,如果状态机可以从任何状态恢复,但无法正确模拟,则可以重置。不要仅仅因为状态信号的范围而确定它是否会重置;如果有10个值,则需要4位来存储,从而导致6个行为未定义的不可见状态;或者,它很可能被编码为一个hot,如果不重置,可能会导致多个状态同时出现
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;