VHDL八位乘法器_第1页
VHDL八位乘法器_第2页
VHDL八位乘法器_第3页
免费预览已结束,剩余5页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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

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

3、TH 打开, 8 位乘数 B7.0 在同一节拍进入 8 位加法器,与上一次锁存在 16 位锁存器 REG16B 中的高 8 位进行相加,其和在下一时钟节拍的上升沿被锁进此锁存器。 而当被乘数的移出位为 0 时,一位乘法器全零输出。如此往复,直至 8 个时钟脉冲后,由 ARICTL 的控制,乘法运算过程自动中止, ARIEND 输出高电平,乘法结束。此时 REG16B 的输出即为最后的乘积。四工作原理框图arictlreg16bclkclkoutclkq15.0OUTPUTdout15.0startrstallclrariendd8.0inst3adder8binst5sreg8bandarit

4、hcins7.0a7.0coutclkqbabindout7.0b7.0loaddin7.0inst1B7.0INPUTdin7.0VCCinst6inst2A7.0INPUTVCCOUTPUTdout515.0五程序清单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_vector(3 downto 0);s:out std_logic_vector(3 down

5、to 0);cout:out std_logic);end;architecture one of add4b issignal sint,aa,bb:std_logic_vector(4 downto 0);beginaa=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.all;use ieee.std_logic_unsigned.all;entity adder8b i

6、sport( 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);s:out std_logic_vector(3 downto 0);cout:out std_logic);e

7、nd component;signal carryout: std_logic;beginu1:add4bportmap(cin,a(3downto0),b(3downto0),s(3downto0),carryout);u2:add4b port map(carryout,a(7 downto 4),b(7 downto 4),s(7 downto4),cout);end;3.library ieee;- 一位乘法器 ;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity andarith isport( abi

8、n:in std_logic;din:in std_logic_vector(7 downto 0);dout:out std_logic_vector(7 downto 0);end;architecture one of andarith isbeginprocess(abin,din)beginfor i in 0 to 7 loopdout(i)=din(i) and abin;end loop;end process;end;4.library ieee;- 乘法运算控制器use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.

9、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)beginif start=1 then cnt4b=0000;elsif clkevent and clk=1 thenif cnt4b8 then- 小于 8 则计数,等于 8 则表明乘法运算已经结束cn

10、t4b=cnt4b+1;end if;end if;end process;process(clk,cnt4b,start)beginif start=0 thenif cnt4b8thenclkout=clk;ariend=0;else clkout=0; ariend=1;end if;else clkout=clk; ariend=0;end if;end process;end;5.library ieee;-16 位锁存器use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity reg16b isport(

11、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);beginprocess(clk,clr)beginif clr=1 then r16s=00000;elsif clkevent and clk=1thenr16s(6 downto 0)=r16s(7 downto 1);r16s(15 downto 7)=d;e

12、nd 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 downto 0);qb:out std_logic);end;architecture one of sreg8b issignal reg8:std_logic_vector(7 downto 0);beginprocess(cl

13、k,load)beginif clkevent and clk=1thenif 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.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mult8x8 isport( clk:in std_logic;start:in std_logic;a,b:in std_logi

14、c_vector(7 downto 0);dout:out std_logic_vector(15 downto 0);ariend:out std_logic);end;architecture struc of mult8x8 iscomponent 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

15、 std_logic;din:in std_logic_vector(7 downto 0);dout:out std_logic_vector(7 downto 0);end component;component arictl isport( clk,start:in std_logic;clkout,rstall,ariend:out std_logic);end component;component reg16b isport( clk,clr:in std_logic;d:in std_logic_vector(8 downto 0);q:out std_logic_vector(

16、15 downto 0);end component;component sreg8b isport( clk,load:in std_logic;din:in std_logic_vector(7 downto 0);qb:out std_logic);end component;signal gndint:std_logic;signal intclk:std_logic;signal rstall:std_logic;signal qb :std_logic;signal andsd:std_logic_vector(7 downto 0);signaldtbin :std_logic_vector(8 downto 0);signaldtbout :std_logic_vector(15 downto 0);begindout=dtbout; gndint=0;u1:arictl port map( clk,start,intc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论