
用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 counter<8 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<= m&b;
done<='1';
end if;
end process;
end Behavioral;
这个是8位乘法器,你可以稍作修改
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 counter<8 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<= m&b;
done<='1';
end if;
end process;
end Behavioral;
这个是8位乘法器,你可以稍作修改
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?

2023-06-12 广告
单片机,即单片微控制器,也称为单片微型计算机,是将中央处理器(CPU)、存储器(ROM,RAM)、输入/输出接口和其他功能部件集成在一块 在一个小块的集成电路上,从而实现对整个电路或系统的数字式控制。单片机不是完成某一个逻辑功能的芯片,而是...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询