VHDL八位乘法器

上传人:文库****9 文档编号:153175698 上传时间:2020-11-27 格式:DOC 页数:7 大小:187.50KB
返回 下载 相关 举报
VHDL八位乘法器_第1页
第1页 / 共7页
VHDL八位乘法器_第2页
第2页 / 共7页
VHDL八位乘法器_第3页
第3页 / 共7页
VHDL八位乘法器_第4页
第4页 / 共7页
VHDL八位乘法器_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《VHDL八位乘法器》由会员分享,可在线阅读,更多相关《VHDL八位乘法器(7页珍藏版)》请在金锄头文库上搜索。

1、VHDL八位乘法器一 设计思路纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,基于PLD器件外接ROM九九表的乘法器则无法构成单片系统,也不实用。这里介绍由八位加法器构成的以时序逻辑方式设计的八位乘法器,具有一定的实用价值,而且由FPGA构成实验系统后,可以很容易的用ASIC大型集成芯片来完成,性价比高,可操作性强。其乘法原理是:乘法通过逐项移位相加原理来实现,从被乘数的最低位开始,若为1,则乘数左移后与上一次的和相加;若为0,左移后以全零相加,直至被乘数的最高位。二方案设计与论证此设计是由八位加法器构成的以时序逻辑方式设计的八位乘法器,它的核心器件是八加法器

2、,所以关键是设计好八位加法器。方案:由两个四位加法器组合八位加法器,其中四位加法器是四位二进制并行加法器,它的原理简单,资源利用率和进位速度方面都比较好。综合各方面的考虑,决定采用方案二。三工作原理ARICTL是乘法运算控制电路,它的START信号上的上跳沿与高电平有2个功能,即16位寄存器清零和被乘数A7.0向移位寄存器SREG8B加载;它的低电平则作为乘法使能信号,乘法时钟信号从ARICTL的CLK输入。当被乘数被加载于8位右移寄存器SREG8B后,随着每一时钟节拍,最低位在前,由低位至高位逐位移出。当为1时,一位乘法器ANDARITH打开,8位乘数B7.0在同一节拍进入8位加法器,与上一

3、次锁存在16位锁存器REG16B中的高8位进行相加,其和在下一时钟节拍的上升沿被锁进此锁存器。而当被乘数的移出位为0时,一位乘法器全零输出。如此往复,直至8个时钟脉冲后,由ARICTL的控制,乘法运算过程自动中止,ARIEND输出高电平,乘法结束。此时REG16B的输出即为最后的乘积。四工作原理框图五程序清单1library ieee; -四位二进制并行加法器 use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity add4b isport( cin:in std_logic; a,b:in std_logic_ve

4、ctor(3 downto 0); s:out std_logic_vector(3 downto 0); cout:out std_logic);end;architecture one of add4b is signal sint,aa,bb:std_logic_vector(4 downto 0);begin aa=0 & a; bb=0 & b; sint=aa+bb+cin; s=sint(3 downto 0);cout=sint(4);end;2library ieee; -由两个四位二进制并行加法器级联而成的八位二进制加法器;use ieee.std_logic_1164.a

5、ll;use ieee.std_logic_unsigned.all;entity adder8b isport( cin:in std_logic; a,b:in std_logic_vector(7 downto 0); s:out std_logic_vector(7 downto 0); cout:out std_logic);end;architecture one of adder8b iscomponent add4b -对要调用的元件add4b的端口进行说明port( cin:in std_logic; a,b:in std_logic_vector(3 downto 0);

6、s:out std_logic_vector(3 downto 0); cout:out std_logic);end component;signal carryout: std_logic;begin u1:add4b port map(cin,a(3 downto 0),b(3 downto 0),s(3 downto 0),carryout); u2:add4b port map(carryout,a(7 downto 4),b(7 downto 4),s(7 downto 4),cout);end;3.library ieee; -一位乘法器;use ieee.std_logic_1

7、164.all;use ieee.std_logic_unsigned.all;entity andarith isport( abin:in std_logic; din:in std_logic_vector(7 downto 0); dout:out std_logic_vector(7 downto 0);end;architecture one of andarith isbegin process(abin,din)begin for i in 0 to 7 loop dout(i)=din(i) and abin; end loop; end process;end;4.libr

8、ary ieee; -乘法运算控制器 use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity arictl isport( clk,start:in std_logic; clkout,rstall,ariend:out std_logic);end;architecture one of arictl issignal cnt4b:std_logic_vector(3 downto 0);beginrstall=start; process(clk,start)begin if start=1 then cnt4b

9、=0000; elsif clkevent and clk=1 then if cnt4b8 then -小于8则计数,等于8则表明乘法运算已经结束 cnt4b=cnt4b+1; end if;end if;end process;process(clk,cnt4b,start) begin if start=0 then if cnt4b8 then clkout=clk; ariend=0; else clkout=0; ariend=1; end if; else clkout=clk; ariend=0; end if; end process;end;5.library ieee;

10、-16位锁存器 use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity reg16b isport( clk,clr:in std_logic; d:in std_logic_vector(8 downto 0); q:out std_logic_vector(15 downto 0);end;architecture one of reg16b issignal r16s:std_logic_vector(15 downto 0);begin process(clk,clr)begin if clr=1 then

11、r16s=0000000000000000; elsif clkevent and clk=1 then r16s(6 downto 0)=r16s(7 downto 1); r16s(15 downto 7)=d; end if;end process; q=r16s;end;6.library ieee; -8位右移寄存器 use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sreg8b isport( clk,load:in std_logic; din:in std_logic_vector(7 down

12、to 0); qb:out std_logic);end;architecture one of sreg8b issignal reg8:std_logic_vector(7 downto 0);begin process(clk,load)begin if clkevent and clk=1 then if load=1 then reg8=din; else reg8(6 downto 0)=reg8(7 downto 1); end if; end if; end process; qb=reg8(0);end;7.library ieee;-8位乘法器顶层设计use ieee.st

13、d_logic_1164.all;use ieee.std_logic_unsigned.all;entity mult8x8 isport( clk:in std_logic;start:in std_logic; a,b:in std_logic_vector(7 downto 0); dout:out std_logic_vector(15 downto 0); ariend:out std_logic);end;architecture struc of mult8x8 is component adder8b isport( cin:in std_logic; a,b:in std_logic_vector(7 downto 0); s:out std_logic_vector(7 downto 0); cout:out std_logic);end component;component andarith isport( abin:in std_logic; din:in std_logic_vector(7 downto 0);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号