Algorithm 布斯乘法算法

Algorithm 布斯乘法算法,algorithm,vhdl,multiplication,Algorithm,Vhdl,Multiplication,我是VHDL新手,正在尝试编写Booth的乘法算法。我使用的是XILINX,当我合成代码时,我得到了很多警告: 上限已分配但从未使用 产品已使用但从未分配 LowerPrevLSB已分配但从未使用 Lower已分配但从未使用 A_2sComp已分配但从未使用 Z的常量值为0 产品的常量值为0 我认为我分配和编写的代码是正确的,但显然我不是。任何建议和帮助都将不胜感激 library IEEE; use IEEE.NUMERIC_STD.ALL; use IEEE.STD_LOGIC_1164

我是VHDL新手,正在尝试编写Booth的乘法算法。我使用的是XILINX,当我合成代码时,我得到了很多警告:

  • 上限
    已分配但从未使用
  • 产品
    已使用但从未分配
  • LowerPrevLSB
    已分配但从未使用
  • Lower
    已分配但从未使用
  • A_2sComp
    已分配但从未使用
  • Z
    的常量值为0
  • 产品
    的常量值为0
我认为我分配和编写的代码是正确的,但显然我不是。任何建议和帮助都将不胜感激

library IEEE;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.ALL;
use IEEE.STD_LOGIC_unsigned.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;

-- X * Y = Z
entity BoothMultiplier is
    generic
    (
        numBits_X : integer := 8;
        numBits_Y : integer := 8
    );
    port
    (
        CLK : in std_logic;
        X : in std_logic_vector((numBits_X - 1) downto 0);
        Y : in std_logic_vector((numBits_Y - 1) downto 0);
        Z : out std_logic_vector((numBits_X + numBits_Y - 1) downto 0)  
    );

end BoothMultiplier;

architecture Behavioral of BoothMultiplier is

    -- Two's Complement Function
    function TwosComplement(inputNum : std_logic_vector) return std_logic_vector;

    function TwosComplement(inputNum : std_logic_vector) return std_logic_vector is
        variable temp : std_logic_vector(inputNum'range);
        begin
            temp := (not inputNum) + 1;
            return temp;
    end TwosComplement;
    -- End Two's Complement Function

    -- MIN Function
    function MIN(Left, Right : integer) return integer;

    function MIN(Left, Right : integer) return integer is
    begin
        if Left < Right then return Left;
        else return Right;
        end if;
    end Min;
    -- End MIN Function

    -- MAX Function
    function MAX(Left, Right : integer) return integer;

    function MAX(Left, Right : integer) return integer is
    begin
        if Left > Right then return Left;
        else return Right;
        end if;
    end MAX;
    -- End MAX Function

    -- Signals
    signal Upper : std_logic_vector(MAX(numBits_X, numBits_Y) - 1 downto 0)
                    := (others => '0');
    signal Lower : std_logic_vector(MIN(numBits_X, numBits_Y) - 1 downto 0)
                    := (others => '0');
    signal LowerPrevLSB : std_logic := '0';
    signal Product : std_logic_vector(numBits_X + numBits_Y - 1 downto 0)
                        := (others => '0');
    signal A, A_2sComp : std_logic_vector(MAX(numBits_X, numBits_y) - 1 downto 0)
                := (others => '0');
    signal counter : integer := 0;
    -- End Signals

begin

    assert Z'length = (X'length + Y'length) report "Bad Product Length" severity failure;

    Lower <= X when (numBits_X <= numBits_Y) else Y;
    A <= X when (numBits_X > numBits_Y) else Y;
    A_2sComp <= TwosComplement(A);

    process(CLK)
    begin
        if rising_edge(CLK) then
            if (Lower(0) = '0' and LowerPrevLSB = '1') then
                Upper <= Upper + A;
            elsif (Lower(0) = '1' and LowerPrevLSB = '0') then
                Upper <= Upper + A_2sComp;
            end if;
            LowerPrevLSB <= Lower(0);
            Product <= Upper & Lower;
            for i in 0 to Product'length - 2 loop
                Product(i) <= Product(i+1);
            end loop;
            Product(Product'length-1) <= Product(Product'length-1);
            Upper <= Product(Product'length - 1 downto MIN(numBits_X, numBits_Y));
            Lower <= Product(MIN(numBits_X, numBits_Y) - 1 downto 0);
            counter <= counter + 1;
            if (counter = MIN(numBits_X, numBits_Y)) then
                Z <= Product;
            end if;
        end if;
    end process;

end Behavioral;
IEEE库;
使用IEEE.NUMERIC_STD.ALL;
使用IEEE.STD_LOGIC_1164.ALL;
使用IEEE.STD_LOGIC_arith.ALL;
使用IEEE.STD_LOGIC_unsigned.ALL;
--如果使用,请取消注释以下库声明
--具有有符号或无符号值的算术函数
--使用IEEE.NUMERIC_STD.ALL;
--如果正在实例化,请取消对以下库声明的注释
--此代码中的任何Xilinx原语。
--UNISIM图书馆;
--使用UNISIM.VComponents.all;
--X*Y=Z
实体BoothMultiplier是
通用的
(
numBits_X:整数:=8;
numBits_Y:整数:=8
);
港口
(
CLK:标准逻辑中;
X:在标准逻辑向量中((numBits_X-1)降到0);
Y:在标准逻辑向量中((numBits_Y-1)降到0);
Z:out标准逻辑向量((numBits_X+numBits_Y-1)向下至0)
);
端部BoothMultiplier;
BoothMultiplier的结构是
--二元互补函数
函数2完成(inputNum:std_logic_vector)返回std_logic_vector;
函数2完成(inputNum:std\u logic\u vector)返回std\u logic\u vector为
变量温度:标准逻辑向量(输入数值范围);
开始
温度:=(非inputNum)+1;
返回温度;
结束二次完成;
--二端补码函数
--最小函数
函数MIN(左、右:整数)返回整数;
函数MIN(左、右:整数)返回整数为
开始
如果左<右,则返回左;
否则返回权;
如果结束;
结束分钟;
--最小结束函数
--最大函数
函数MAX(左、右:整数)返回整数;
函数MAX(左、右:整数)返回整数为
开始
如果左>右,则返回左;
否则返回权;
如果结束;
末端最大值;
--端点最大值函数
--信号
信号上限:标准逻辑向量(最大值(numBits X,numBits Y)-1到0)
:=(其他=>'0');
信号降低:标准逻辑向量(最小值(numBits_X,numBits_Y)-1到0)
:=(其他=>'0');
信号下限REVLSB:std_逻辑:='0';
信号产品:标准逻辑向量(numBits_X+numBits_Y-1到0)
:=(其他=>'0');
信号A,A2sComp:std_逻辑_向量(最大值(numBits_X,numBits_y)-1到0)
:=(其他=>'0');
信号计数器:整数:=0;
--结束信号
开始
断言Z'长度=(X'长度+Y'长度)报告“不良产品长度”严重故障;

Lower在VHDL中,进程中对同一信号的连续赋值会覆盖以前的赋值,因此:

if (Lower(0) = '0' and LowerPrevLSB = '1') then
    Upper <= Upper + A;
elsif (Lower(0) = '1' and LowerPrevLSB = '0') then
    Upper <= Upper + A_2sComp;
end if;
...
Upper <= Product(Product'length - 1 downto MIN(numBits_X, numBits_Y));
如果(较低的(0)='0'和较低的PREVLSB='1'),则

那么,在不使用连续作业的情况下,我将如何实现我的布斯乘法目标?