booth算法「Booth算法小数」
用booth算法求[x*y]补。x=0.1101,y=-0.1010
首先编程把原码变为补码,这个资料很多,可以查看
booth乘法的源码是:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity mp is
Port ( ai : in std_logic_vector(7 downto 0);
bi : in std_logic_vector(7 downto 0)
done : out std_logic;
clk : in std_logic;
op : out std_logic_vector(15 downto 0));
end mp;
architecture Behavioral of mp is
begin
process(ai,bi,clk)
variable a,b,m : std_logic_vector( 7 downto 0);
variable cp: std_logic_vector( 1 downto 0);
variable t: std_logic ;
variable counter: integer;
begin
if clk'event and clk='1' then
counter:=0;
t:='0';
a:=ai;
b:=bi;
m:="00000000";
cp:=b(0)'0';
done='0';
while counter8 loop
case cp is
when "10"= m:=m-a;
when "01"= m:=m+a;
when others=m:=m;
end case;
t:=b(0);
b:=m(0)b(7 downto 1);
m:=m(7)m(7 downto 1);
cp:=b(0)t;
counter:=counter+1;
end loop;
op= mb;
done='1';
end if;
end process;
end Behavioral;
这个是8位乘法器,你可以稍作修改
补码booth算法中移位的问题!
我日!等了半天 这么个破问题也没人解决 幸好我自己弄懂了
首先右移的时候把部分积R0和乘数RI 看为一个整体
然后看R0最高位是什么 是0就在后面加个0 然后整体往右移 要是1就加1
得到的就是结果!
用Booth算法计算7x(-3)的4位补码乘法运算,要求写出每一步运算过程及运算结果
110 : ~1101 + 1 = 0011
011 : 1101 3=1101000
sum= 0000_0011+1110_1000 =1110_1011= (-21)
已知x=0.110111,y=-0.101010用Booth算法(补码一位乘)计算x·y,要求写出其运算过程。
[x] 原 =0.110111 , [y] 原 =1.101110 , x*=0.110111 , y*=0.101110 原码一位乘: 部分积 乘数y* 说明 0.000 000 +0.000 000 101 11 0 部分积初值为0,乘数为0加0 0.000 000 0.000 000 +0.110 111 010 11 1 右移一位 乘数为1,加上x* 0.110 111 0.011 011 +0.110 111 101 01 1 右移一位 乘数为1,加上x* 1.010 010 0.101 001 +0.110 111 010 10 1 右移一位 乘数为1,加上x* 1.100 000 0.110 000 +0.000 000 001 01 0 右移一位 乘数为0,加上0 0.110 000 0.011 000 +0.110 111 000 10 1 右移一位 乘数为1,加上x* 1.001 111 0.100 111 100 010 右移一位 即 x*×y*=0.100 111 100 010 , z0=x0 Å y0=0 Å 1=1 , [x×y] 原 =1.100 111 100 010 , x·y= -0. 100 111 100 010 原码两位乘: [-x*] 补 =1.001 001 , 2x*=1.101 110 部分积 乘数y* C j 说明 000.000 000 + 001.101 110 001011 10 0 部分积初值为0,C j =0 根据y n-1 y n C j =100,加2x*,保持C j =0 001.101 110 0 000. 011 011 + 111. 001 001 10 001 0 11 10 001 0 11 0 右移2位 根据y n-1 y n C j =110,加[-x*] 补 ,置C j =1 111 . 100 100 111 . 111 001 +111 . 001 001 00 100 0 10 1 右移2位 根据y n-1 y n C j =101,加[-x*] 补 ,置C j =1 111. 000 010 111. 110 000 +000.110 111 10 001 0 00 1 右移2位 根据y n-1 y n C j =001,加x*,保持C j =0 000.10
我算的这个booth算法哪错了,谢谢
例:[x]补=0.0101,[y]补=1.0101 求: [x· y]补。
解:求解过程如下表所示。其中乘数取两位符号位即11.0101,[-x]补=1.1011取三符号位为111.1011。
部分积
乘数
说 明
000.0000
+ 000.0101
1101010
判断位为010,加[x]补
000.0101
000.0001
+ 000.0101
0111010
→2位
判断位为010,加[x]补
000.0110
000.0001
+ 111.1011
01
1001110
→2位
判断位为110,加[-x]补
111.1100
1001
最后一步不移位,得[x· y]补
故[x· y]补=1.11001001
booth补码乘法算法中乘数的右移规则是什么?
你没有发现这里是A和Q合为一体,即A的最后一位补给Q的第一位了吗?
