VHDL八位乘法器.docx

上传人:b****1 文档编号:23084924 上传时间:2023-04-30 格式:DOCX 页数:9 大小:165.52KB
下载 相关 举报
VHDL八位乘法器.docx_第1页
第1页 / 共9页
VHDL八位乘法器.docx_第2页
第2页 / 共9页
VHDL八位乘法器.docx_第3页
第3页 / 共9页
VHDL八位乘法器.docx_第4页
第4页 / 共9页
VHDL八位乘法器.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

VHDL八位乘法器.docx

《VHDL八位乘法器.docx》由会员分享,可在线阅读,更多相关《VHDL八位乘法器.docx(9页珍藏版)》请在冰豆网上搜索。

VHDL八位乘法器.docx

VHDL八位乘法器

VHDL八位乘法器

一.设计思路

纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,基于PLD器件外接ROM九九表的乘法器则无法构成单片系统,也不实用。

这里介绍由八位加法器构成的以时序逻辑方式设计的八位乘法器,具有一定的实用价值,而且由FPGA构成实验系统后,可以很容易的用ASIC大型集成芯片来完成,性价比高,可操作性强。

其乘法原理是:

乘法通过逐项移位相加原理来实现,从被乘数的最低位开始,若为1,则乘数左移后与上一次的和相加;若为0,左移后以全零相加,直至被乘数的最高位。

二.方案设计与论证

此设计是由八位加法器构成的以时序逻辑方式设计的八位乘法器,它的核心器件是八加法器,所以关键是设计好八位加法器。

方案:

由两个四位加法器组合八位加法器,其中四位加法器是四位二进制并行加法器,它的原理简单,资源利用率和进位速度方面都比较好。

综合各方面的考虑,决定采用方案二。

三.工作原理

ARICTL是乘法运算控制电路,它的START信号上的上跳沿与高电平有2个功能,即16位寄存器清零和被乘数A[7...0]]向移位寄存器SREG8B加载;它的低电平则作为乘法使能信号,乘法时钟信号从ARICTL的CLK输入。

当被乘数被加载于8位右移寄存器SREG8B后,随着每一时钟节拍,最低位在前,由低位至高位逐位移出。

当为1时,一位乘法器ANDARITH打开,8位乘数B[7..0]在同一节拍进入8位加法器,与上一次锁存在16位锁存器REG16B中的高8位进行相加,其和在下一时钟节拍的上升沿被锁进此锁存器。

而当被乘数的移出位为0时,一位乘法器全零输出。

如此往复,直至8个时钟脉冲后,由ARICTL的控制,乘法运算过程自动中止,ARIEND输出高电平,乘法结束。

此时REG16B的输出即为最后的乘积。

四.工作原理框图

五.程序清单

1.libraryieee;----四位二进制并行加法器

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityadd4bis

port(cin:

instd_logic;

a,b:

instd_logic_vector(3downto0);

s:

outstd_logic_vector(3downto0);

cout:

outstd_logic);

end;

architectureoneofadd4bis

signalsint,aa,bb:

std_logic_vector(4downto0);

begin

aa<='0'&a;

bb<='0'&b;

sint<=aa+bb+cin;

s<=sint(3downto0);

cout<=sint(4);

end;

2.libraryieee;--由两个四位二进制并行加法器级联而成的八位二进制加法器;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityadder8bis

port(cin:

instd_logic;

a,b:

instd_logic_vector(7downto0);

s:

outstd_logic_vector(7downto0);

cout:

outstd_logic);

end;

architectureoneofadder8bis

componentadd4b--对要调用的元件add4b的端口进行说明

port(cin:

instd_logic;

a,b:

instd_logic_vector(3downto0);

s:

outstd_logic_vector(3downto0);

cout:

outstd_logic);

endcomponent;

signalcarryout:

std_logic;

begin

u1:

add4bportmap(cin,a(3downto0),b(3downto0),s(3downto0),carryout);

u2:

add4bportmap(carryout,a(7downto4),b(7downto4),s(7downto4),cout);

end;

3.libraryieee;--一位乘法器;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityandarithis

port(abin:

instd_logic;

din:

instd_logic_vector(7downto0);

dout:

outstd_logic_vector(7downto0));

end;

architectureoneofandarithis

begin

process(abin,din)

begin

foriin0to7loop

dout(i)<=din(i)andabin;

endloop;

endprocess;

end;

4.libraryieee;--乘法运算控制器

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityarictlis

port(clk,start:

instd_logic;

clkout,rstall,ariend:

outstd_logic);

end;

architectureoneofarictlis

signalt4b:

std_logic_vector(3downto0);

begin

rstall<=start;

process(clk,start)

begin

ifstart='1'thent4b<="0000";

elsifclk'eventandclk='1'then

ift4b<8then--小于8则计数,等于8则表明乘法运算已经结束

t4b<=cnt4b+1;

endif;

endif;

endprocess;

process(clk,cnt4b,start)

begin

ifstart='0'then

ift4b<8then

clkout<=clk;ariend<='0';

elseclkout<='0';ariend<='1';

endif;

elseclkout<=clk;ariend<='0';

endif;

endprocess;

end;

5.libraryieee;--16位锁存器

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityreg16bis

port(clk,clr:

instd_logic;

d:

instd_logic_vector(8downto0);

q:

outstd_logic_vector(15downto0));

end;

architectureoneofreg16bis

signalr16s:

std_logic_vector(15downto0);

begin

process(clk,clr)

begin

ifclr='1'thenr16s<="0000000000000000";

elsifclk'eventandclk='1'then

r16s(6downto0)<=r16s(7downto1);

r16s(15downto7)<=d;

endif;

endprocess;

q<=r16s;

end;

6.libraryieee;--8位右移寄存器

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitysreg8bis

port(clk,load:

instd_logic;

din:

instd_logic_vector(7downto0);

qb:

outstd_logic);

end;

architectureoneofsreg8bis

signalreg8:

std_logic_vector(7downto0);

begin

process(clk,load)

begin

ifclk'eventandclk='1'then

ifload='1'thenreg8<=din;

elsereg8(6downto0)<=reg8(7downto1);

endif;

endif;

endprocess;

qb<=reg8(0);

end;

7.libraryieee;--8位乘法器顶层设计

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitymult8x8is

port(clk:

instd_logic;

start:

instd_logic;

a,b:

instd_logic_vector(7downto0);

dout:

outstd_logic_vector(15downto0);

ariend:

outstd_logic);

end;

architecturestrucofmult8x8is

componentadder8bis

port(cin:

instd_logic;

a,b:

instd_logic_vector(7downto0);

s:

outstd_logic_vector(7downto0);

cout:

outstd_logic);

endcomponent;

componentandarithis

port(abin:

instd_logic;

din:

instd_logic_vector(7downto0);

dout:

outstd_logic_vector(7downto0));

endcomponent;

componentarictlis

port(clk,start:

instd_logic;

clkout,rstall,ariend:

outstd_logic);

endcomponent;

componentreg16bis

port(clk,clr:

instd_logic;

d:

instd_logic_vector(8downto0);

q:

outstd_logic_vector(15downto0));

endcomponent;

componentsreg8bis

port(clk,load:

instd_logic;

din:

instd_logic_vector(7downto0);

qb:

outstd_logic);

endcomponent;

signalgndint:

std_logic;

signalintclk:

std_logic;

signalrstall:

std_logic;

signalqb:

std_logic;

signalandsd:

std_logic_vector(7downto0);

signaldtbin:

std_logic_vector(8downto0);

signaldtbout:

std_logic_vector(15downto0);

begin

dout<=dtbout;gndint<='0';

u1:

arictlportmap(clk,start,intclk,rstall,ariend);

u2:

sreg8bportmap(intclk,rstall,b,qb);

u3:

andarithportmap(qb,a,andsd);

u4:

adder8bportmap(gndint,dtbout(15downto8),andsd,dtbin(7downto0),dtbin(8));

u5:

reg16bportmap(intclk,rstall,dtbin,dtbout);

end;

六.仿真结果图

  以下是8位乘法器顶层设计的仿真波形图,其它各模块的仿真波形图省略。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1