移位硬件八位乘法器

合集下载

基于FPGA的8位硬件乘法器设计

基于FPGA的8位硬件乘法器设计

本科毕业设计基于FPGA的8位硬件乘法器设计摘要VHDL(VHSIC Hardware Description Language)是当今最流行的硬件描述语言之一,能够对最复杂的芯片和最完整的电子系统进行描述。

以硬件描述语言作为设计输入,经过简单的综合与布局,快速烧录至FPGA(Field Programmable Gate Array)上进行测试,是现代IC设计验证的技术主流。

乘法器是处理器进行科学计算和数字信号处理的基本硬件结构,是现代微处理器中的重要部件。

乘法器完成一次乘法操作的周期基本上决定了微处理器的主频。

本文基于FPGA,采用VHDL语言,结合MAX+plusⅡ这个强大的软件平台设计了8位二进制乘法器,并对其进行符号扩展,使其可以统一处理8位带符号数和无符号数。

高速乘法器设计通常分为三个关键步骤:部分积产生、部分积累加和最终结果获得。

本文对部分积产生过程采用改进Booth算法,有效减少部分积加法项;为了统一带符号和无符号数,对部分积进行符号扩展;而对部分积的累加则采取3-2压缩器和4-2压缩器进行压缩;最终结果的获得则以一个根据部分积累加结果到达时间的不同进行延迟优化的选择进位加法器将累加结果和累加进位相加而得。

关键词:乘法器改进Booth算法压缩器选择进位加法器The Circuit Design of 8-bit Hardware Multiplier Based on FPGAKe Xiuyan(College of Engineering, South China Agricultural University, Guangzhou 510642, China) Abstract: VHSIC Hardware Description Language, one of today's most popular hardware description languages, is used to describe the most complex chip and most complete electronic systems.The multiplier is not only the basic hardware structure of the processor for scientific computing and digital signal processing but also an important component of modern microprocessors. This design for 8-bit binary multiplier is based on FPGA, using VHDL language, and proved by the MAX+plusⅡsoftware platform. The multiplicand has an extended sign bit so that the multiplier can unify 8-bit signed and unsigned.High-speed multiplier design is usually divided into three key steps: partial product generation circuit, accumulator and adder. In this paper, the partial product generation process uses the modified Booth algorithm, so that the partial product addition terms can be effectively reduced. The accumulation of partial products takes 3-2 compressor and 4-2 compressor to compress. The final result is obtained with select carry adder.Key words: multiplier the modified Booth algorithm compressor select carry adder目录1 前言 (1)1.1 乘法器的研究背景和意义 (1)1.2 乘法器的研究发展状况 (1)2 总体方案确定 (2)2.1 乘法器设计方案 (2)2.2 硬件描述语言VHDL (3)2.2.1 硬件描述语言 (3)2.2.2 VHDL语言简介 (3)2.2.3 VHDL的基本结构 (4)2.2.4 VHDL的优点 (4)2.3 实验工具MAX+plusⅡ (5)2.3.1 MAX+plusⅡ简介 (5)2.3.2 MAX+plusⅡ的设计流程 (6)2.3.3 MAX+plusⅡ的特点 (6)2.4 现场可编辑门阵列(FPGA) (7)2.4.1 FPGA简介 (7)2.4.2 FPGA的基本结构 (7)2.4.3 FPGA的特点 (8)3 理论分析及设计 (9)3.1 乘法器的数据格式 (9)3.1.1 二进制的表示 (9)3.1.2 无符号数的运算 (9)3.1.3 带符号数的运算 (9)3.1.4 带符号数的符号扩展表示 (9)3.2 乘法器算法 (10)3.2.1 移位相加算法 (10)3.2.2 Booth算法 (11)3.2.3 改进型Booth算法 (12)3.3 加法器 (15)3.3.1 半加器 (15)3.3.2 全加器 (16)3.3.3 串行进位加法器 (16)3.3.4 超前进位加法器 (17)3.3.5 选择进位加法器 (18)3.4 压缩器 (19)4 测试与试验分析 (22)4.1 乘法器的总体结构 (22)4.2 乘法器各个模块的仿真 (23)4.2.1 Booth编码器 (23)4.2.2 Booth译码器 (23)4.2.3 部分积产生电路 (24)4.2.4 压缩器 (25)4.2.5 加法器 (26)4.2.6 顶层文件 (27)5 结论 (28)参考文献 (29)附录 (30)致谢 (33)毕业设计成绩评定表1 前言1.1 乘法器的研究背景和意义微电子技术的迅猛发展,计算机技术的不断进步,带动了集成电路工艺的不断增进,数字芯片的集成度不断提高。

8位乘法器设计

8位乘法器设计

8位乘法器设计一、摘要纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,基于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的输出即为最后的乘积。

三、方案设计与分析方案一:八位直接宽位加法器,它的速度较快,但十分耗费硬件资源,对于工业化设计是不合理的。

方案二:由两个四位加法器组合八位加法器,其中四位加法器是四位二进制并行加法器,它的原理简单,资源利用率和进位速度等方面较好,综合各方面的考虑,决定采用第二种方案。

3.1程序清单1.library 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 downto 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;2.library ieee; --由两个四位二进制并行加法器级联而成的八位二进制加法器;use ieee.std_logic_1164.all;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);s:out std_logic_vector(3 downto 0);cout:out std_logic);end component;signal carryout: std_logic;beginu1: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_1164.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 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.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 clk'event and clk='1' thenif cnt4b<8 then --小于8则计数,等于8则表明乘法运算已经结束cnt4b<=cnt4b+1;end if;end if;end process;process(clk,cnt4b,start)beginif start='0' thenif cnt4b<8 thenclkout<=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( 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<="0000000000000000";elsif clk'event and clk='1' thenr16s(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 downto 0);qb:out std_logic);end;architecture one of sreg8b issignal reg8:std_logic_vector(7 downto 0);beginprocess(clk,load)beginif clk'event and clk='1' thenif 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_logic_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 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(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);signal dtbin :std_logic_vector(8 downto 0);signal dtbout :std_logic_vector(15 downto 0);begindout<=dtbout; gndint<='0';u1:arictl port map( clk,start,intclk,rstall,ariend);u2:sreg8b port map(intclk,rstall,b,qb);u3:andarith port map(qb,a,andsd);u4:adder8b port map(gndint,dtbout(15 downto 8),andsd,dtbin(7 downto 0),dtbin(8));u5:reg16b port map(intclk,rstall,dtbin,dtbout);end;3.2仿真结果(1)输入波形图(2)输出波形图3.3工作原理图cin a[7..0]b[7..0]s[7..0]coutadder8binst1abin din[7..0]dout[7..0]andarithinst2clkstart clkout rstallariend arictl inst3clk clr d[8..0]q[15..0]reg16b inst5clk loaddin[7..0]qbsreg8b inst6dout[15..0]OUTPUTVCCB[7..0]INPUT VCCA[7..0]INPUT dout5[15..0]OUTPUT二、方案综合评价与结论它由两个四位加法器组合八位加法器,其中四位加法器是四位二进制并行加法器,它的原理简单,资源利用率和进位速度方面都比较好,电路原理简单,连线很少,制作起来方便易行,总体来说还是很成功的。

8位乘法器的设计

8位乘法器的设计

本科生毕业论文(设计)8位乘法器的设计姓名:指导教师:院系:信息工程学院专业:计算机科学与技术提交日期: 2010/4/30目录中文摘要 (2)外文摘要 (3)1.绪论 (4)1.1概述 (4)1.2 VHDL和MAX+PIUS简介 (5)1.3 实验平台 (6)2.乘法器初步设计 (7)2.1 设计思想 (7)2.2乘法器原理 (7)2.3乘法器设计流程 (8)3. 乘法器具体设计 (9)3.1右移寄存器的设计 (9)3.2 加法器模块的设计 (10)3.2.1 4位加法器的设计 (10)3.2.2 8位加法器的设计 (11)3.3 乘1模块设计 (13)3.4锁存器模块设计 (14)4. 乘法器仿真 (17)4.1 8位加法器仿真 (17)4.2 乘1模块仿真 (17)4.3 锁存器模块仿真 (18)4.4 8位乘法器仿真 (18)结束语 (19)参考文献 (20)致谢 (21)8位乘法器的设计摘要:在微处理器芯片中,乘法器是进行数字信号处理的核心,同时也是微处理器中进行数据处理的关键部件,它已经是现代计算机必不可少的一部分。

本文主要是在于如何运用标准硬件描述语言(VHDL)完成八位乘法器,以及如何做二进制位相乘的运算过程。

该乘法器是由八位加法器构成的以时序方式设计八位乘法器,通过逐项移位相加来实现乘法功能,并以MAX+Plus II 软件工具进行模拟,仿真并予以显示。

关键字:乘法器;标准硬件描述语言(VHDL);移位相加;MAX+Plu s II8-bit multiplier designAbstract:In the microprocessor chip, the multiplier is a digital signal processing core microprocessor is also a key component of data processing, it is already an essential part of the modern computer. This article is on how to use standard hardware description language (VHDL) to complete eight multipliers, as well as how to make the process of a binary bit multiplication operation. The multiplier is composed of eight adder to timing approach in designing eight multiplier, achieved by adding the multiplication-by-shift function, and in MAX + Plus II software tools for simulation, emulation and be displayed.Keywords: multiplier; standard hardware description language (VHDL); shift sum; MAX + Plus II1.绪论1.1概述本课题的设计来源是基于标准硬件描述语言(Very High Speed Integrated Circuit Hardware Description Language,VHDL)及MAX + Plus II(Multiple Array Matrix Programmable Logic User System)软件开发工具的进行模拟仿真的8位乘法器,用于实现8位移位相加乘法器的乘法运算功能。

EDA_8位乘法器_实验报告

EDA_8位乘法器_实验报告

南华大学船山学院实验报告(2009 ~2010 学年度第二学期)课程名称EDA实验名称8位乘法器姓名学号专业计算机科学与班级01技术地点8-212 教师一、实验目的:学习和了解八位乘法的原理和过程二、设计思路:纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,基于PLD 器件外接ROM 九九表的乘法器则无法构成单片系统,也不实用。

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

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

三、实验逻辑图:四、实验代码:1) 选通与门模块的源程序ANDARITH.VHD LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL; ENTITY ANDARITH IS PORT (ABIN:IN STD_LOGIC;DIN:IN STD_LOGIC_VECTOR (7 DOWNTO 0) DOUT:OUT STD_LOGIC_VECTOR (7 DOWNTO 0)); END ANDARITH;ARCHITECTURE ART OF ANDARITH IS BEGINPROCESS (ABIN ,DIN) BEGINFOR I IN 0 TO 7 LOOPDOUT (I)<=DIN (I)AND ABIN; END LOOP;ARICTLCLKEND PROCESS;END ART;2) 16位锁存器的源程序REG16B.VHDLIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL;ENTITY REG16B IS PORT (CLK:IN STD_LOGIC;CLR:IN STD_LOGIC;D:IN STD_LOGIC_VECTOR (8 DOWNTO 0)Q:OUT STD_LOGIC_VECTOR(15 DOWNTO 0));END REG16B;ARCHITECTURE ART OF REG16B ISSIGNAL R16S:STD_LOGIC_VECTOR(15 DOWNTO 0);BEGIN PROCESS (CLK,CLR)BEGINIF CLR = '1' THEN R16S<= "0000000000000000";ELSIF CLK'EVENT AND CLK = '1'THENR16S(6 DOWNTO 0)<=R16S(7 DOWNTO 1);R16S(15 DOWNTO 7)<=D;END IF;END PROCESS;Q<=R16S;END ART;3) 8位右移寄存器的源程序SREG8B.VHDLIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY SREG8B ISPORT (CLK:IN STD_LOGIC; LOAD :IN STD _LOGIC; BIN:IN STD_LOGIC_VECTOR(7DOWNTO 0);QB:OUT STD_LOGIC );END SREG8B;ARCHITECTURE ART OF SREG8B ISSIGNAL REG8B:STD_LOGIC_VECTOR(7 DOWNTO 0); BEGINPROCESS (CLK,LOAD)BEGINIF CLK'EVENT AND CLK= '1' THENIF LOAD = '1' THEN REG8<=DIN;ELSE REG8(6 DOWNTO0)<=REG8(7 DOWNTO 1); END IF;END IF;END PROCESS;QB<= REG8 (0);END ART;4) 乘法运算控制器的源程序ARICTL.VHD LIBRARYUSE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY ARICTL ISPORT ( CLK:IN STD_LOGIC; START:INSTD_LOGIC;CLKOUT:OUT STD_LOGIC; RSTALL:OUTSTD_LOGIC;ARIEND:OUT STD_LOGIC );END ARICTL;ARCHITECTURE ART OF ARICTL IS SIGNAL CNT4B:STD_LOGIC_VECTOR(3 DOWNTO 0);BEGINRSTALL<=START;PROCESS (CLK,START)BEGINIF START = '1' THEN CNT4B<= "0000";ELSIF CLK'EVENT AND CLK = '1' THENIF CNT4B<8 THENCNT4B=CNT4B+1;END IF;END IF;END PROCESS;PROCESS (CLK,CNT4B,START)BEGINIF START = '0' THENIF CNT4B<8 THENCLKOUT <=CLK; ARIEND<= '0';ELSE CLKOUT <= '0'; ARIEND<= '1';END IF;ELSE CLKOUT <=CLK; ARIEND<= '0';END IF;END PROCESS;END ART;5) 8位乘法器的源程序MULTI8X8.VHDLIBRARYIEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY MULTI8X8 ISPORT(CLK:IN STD_LOGIC;START:IN STD_LOGIC;A:IN STD_LOGIC_VECTOR(7 DOWNTO 0);B:IN STD_LOGIC_VECTOR(7 DOWNTO 0);ARIEND:OUT STD_LOGIC;DOUT:OUT STD_LOGIC_VECTOR(15 DOWNTO 0)); END MULTI8X8;ARCHITECTURE ART OF MULTI8X8 ISCOMPONENT ARICTLPORT(CLK:IN STD_LOGIC;START:IN STD_LOGIC; CLKOUT:OUT STD_LOGIC;RSTALL:OUT STD_LOGIC; ARIEND:OUT STD_LOGIC);END COMPONENT;COMPONENT ANDARITHPORT(ABIN:IN STD_LOGIC;DIN:IN STD_LOGIC_VECTOR(7 DOWNTO 0); DOUT:OUT_STD_LOGIC_VECTOR( 7 DOWNTO 0) ); END COMPONENT;COMPONENT ADDER8B...COMPONENT SREG8B...COMPONENT REG16B...SIGNAL GNDINT:STD_LOGIC;SIGNALINTCLK:STD_LOGIC;SIGNAL RSTALL:STD_LOGIC;SIGNAL QB:STD_LOGIC;SIGNAL ANDSD:STD_LOGIC_VECTOR(7 DOWNTO 0); SIGNAL DTBIN:STD_LOGIC_VECTOR(8 DOWNTO 0); SIGNAL DTBOUT:STD_LOGIC_VECTOR(15 DOWNTO 0); BEGINDOUT<=DTBOUT;GNDINT<= '0';U1:ARICTL PORT MAP(CLK=>CLK,START=>START,CLKOUT=>INTCLK,RSTALL=>RSTALL,ARIEND=>ARIEND); U2:SREG8B PORT MAP(CLK=>INTCLK,LOAD=>RSTALL.DIN=>B,QB=>QB);U3:ANDARITH PORT MAP(ABIN=>QB,DIN=>A,DOUT=>ANDSD);U4:ADDER8B PORTMAP(CIN=>GNDINT,A=>DTBOUT(15 DOWNTO 8),B=>ANDSD,S=>DTBIN(7 DOWNTO 0),COUT=>DTBIN(8));U5:REG16B PORT MAP(CLK =>INTCLK,CLR=>RSTALL,D=>DTBIN,Q=>DTBOUT);END ART;五、实验结果:六、实验心得:通过本实验基本上了解了八位乘法的工作原理:乘法通过逐项移位相加原理来实现,从被乘数的最低位开始,若为1,则乘数左移后与上一次的和相加;若为0,左移后以全零相加,直至被乘数的最高位。

移位相加8位硬件乘法器电路电子课程设计

移位相加8位硬件乘法器电路电子课程设计

移位相加8位硬件乘法器电路电子课程设计电子课程设计---移位相加8位硬件乘法器电路设计学院:电子信息工程学院班级: 通信071501姓名:许瀛指导老师:高文华2009年12月目录一.设计任务与要求 (2)二.总体框图 (3)三.选择器件 (4)四.功能模块 (5)五.总体设计电路图………………………………………………………………15六.心得体会 (17)移位相加8位硬件乘法起一、设计任务与要求设计一个乘法器的控制模块,接受实验系统上的连续脉冲,当给定启动/清零信号后,能自动发出CLK信号驱动乘法运算,当8个脉冲后自动停止。

设计一个纯组合电路的8X8等于16位的乘法器(选择不同的流水线方式),具体说明并比较这几种乘法器的逻辑资源占用情况和运行速度情况。

二、总体框图控制16位锁存器/分段8位右移1位乘8位加7段数码1、模块功能A、运算控制模块:控制电路的起始和终止。

B、8位右移寄存器:在时钟脉冲的作用下,高位寄存器的数码送给低位寄存器,作为低位寄存器的次态输出;每输入一个时钟脉冲,寄存器的数据就顺序向右移动一位。

C、1位乘法器:D、8位加法器:E、16位锁存器/右移寄存器:此设计是由八位加法器构成的以时序逻辑方式设计的八位乘法器,它的核心器件是八位加法器,所以关键是设计好八位加法器。

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

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

2、设计思路:纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,由八位加法器构成的以时序逻辑方式设计的八位乘法器,具有一定的实用价值,而且由FPGA 构成实验系统后,可以很容易的用ASIC大型集成芯片来完成,性价比高,可操作性强。

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

基于fpga八位硬件乘法器课程设计

基于fpga八位硬件乘法器课程设计

基于FPGA的八位硬件乘法器课程设计,可以分以下几个步骤进行:
1. 确定设计要求:根据要求,设计一个能对两个八位二进制数进行乘法运算的硬件电路。

需要考虑到输入、输出、各种控制信号等。

2. 确定设计方案:根据设计要求,确定具体的设计方案。

可以使用Verilog语言进行描述,包括输入输出端口的定义、状态转移的描述等。

3. 编写Verilog代码:根据设计方案,编写Verilog代码。

代码需要对各种信号进行定义,并实现相应的逻辑功能。

4. 进行仿真:在编写完代码后,进行功能仿真。

可以使用ModelSim等仿真工具进行验证。

对代码进行仿真测试,在设计出现问题时可以及时进行调试和修改。

5. 进行综合和布局布线:通过综合和布局布线操作,将Verilog代码映射到FPGA芯片上,并生成bit文件,用于烧录到FPGA芯片中。

6. 进行验证:将bit文件烧录到FPGA芯片中,进行验证。

可以通过开发板上的按键等方式,输入两个八位二进制数并进行乘法运算,同时显示结果。

设计八位硬件乘法器需要了解数字电路设计基础知识和Verilog语言的使用。

同时,需要熟练掌握FPGA开发板的使用,以及相关的开发工具(如Quartus II等)的使用。

基于FPGA的8位移位相加型硬件乘法器的设计

基于FPGA的8位移位相加型硬件乘法器的设计

基于FPGA的8位移位相加型硬件乘法器的设计作者:张建妮来源:《智能计算机与应用》2014年第04期摘要:乘法器是数字信号处理中非常重要的模块。

本文首先介绍了硬件乘法器的原理,在此基础上提出了硬件乘法器的设计方法,最后再利用EDA技术,在FPGA开发平台上,通过VHDL编程和图形输入对其进行了实现,具有实用性强、性价比高、可操作性强等优点。

关键词:硬件乘法器;加法器; VHDL中图分类号:TP2 文献标识码:A文章编号:2095-2163(2014)04-0087-04Abstract:Multiplier is very important in digital signal processing module. In this paper, the principle of the hardware multiplier is introduced at first. Based on it, a design method is put forward.Finally , using EDA technology,the hardware -multiplier is implemented through VHDL programming combining with the input mode of schematic diagram on the FPGA development platform. The design has strong practicability ,high cost-effective, strong operability, etc.Key words:Hardware-Multiplier; Adder; VHDL0引言在数字信号处理中,经常会遇到卷积、数字滤波、FFT等运算,而在这些运算中则存在大量类似ΣA(k)B(n-k)的算法过程。

因此,乘法器是数字信号处理中必不可少的一个模块。

中山学院EDA综合实验报告-8位硬件乘法器设计

中山学院EDA综合实验报告-8位硬件乘法器设计
三、实验结论与心得
在实验老师的指导下,我圆满完成了实验任务,有了不少收获,其中了解到了移位相加原理构成乘法器与用组合逻辑电路直接设计的同样功能的电路优势,并且在加深了如何通过VerilogHDL生成原理图器件并进行相应仿真,最后学习了应用移位相加原理设计8位乘法器。
3、ADDER8BT的仿真图及分析
如图所示,红色剪头表示8+11=19,绿色剪头表示8+9=17,紫色剪头表示8+9+1=18,这说明S=A+B+CIN。
4、完整乘法器的仿真图及分析
如图所示,红色剪头表示外部按键START按下(给SREG8BT的LOAD高电平)时给ARIEND一个高电平输出,绿色剪头处的Q为31104,而31104<<1结果为0xF300,此处最高位为0xF3,即相乘的结果为0xF3,这里表示B的数值0xF3乘以A的数值0xC8第4位再加上前3位的结果,因为前3位相乘后的结果为0,因此这里相乘的结果为0xF3,紫色剪头也是同理。
如图所示,在第一个2,此时输出Q=1536,其二进制表示为0000 0110 0000 0000,由VerilogHDL代码可知R16S[6:0]<=R16S[7:1]即R16S[6:0] = 0,R16S[15:7] = 12,此结果与Q输出结果一致绿色剪头与紫色剪头也是同理。
学生实验报告
系别
电子信息学院
课程名称
《EDA综合实验》
班级
实验名称
8位硬件乘法器设计
姓名
实验时间
学号
指导教师
成绩
批改时间
报告内容
一、实验目的和任务
1、学习应用移位相加原理设计8位乘法器。
2、了解移位相加原理构成乘法器与用组合逻辑电路直接设计的同样功能的
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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

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

关键词:加法器,寄存器,一位乘法器,锁存器。

AbstractThe pure combinatory logic constitution multiplier although the working speed quite is quick,But too takes the hardware resources,Realizes the wide position multiplier with difficulty.Meets the ROM multiplication table based on the PLD component outside the multiplier then is unable to constitute themonolithic system,Also is impracticaHere introduced constitutes by eight accumulators by the succession logic way design eight multipliers,Has the certain practical value, Moreover constitutes the experimental system after FPGA,May be very easy to complete with the ASIC large-scale integration chip,The natural price is higherthan,Feasibility.一.设计思路纯组合逻辑构成的乘法器虽然工作速度比较快,但过于占用硬件资源,难以实现宽位乘法器,基于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.library 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 downto 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);end;2.library ieee --由两个四位二进制并行加法器级联而成的八位二进制加法器;use ieee.std_logic_1164.all;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);s:out std_logic_vector(3 downto 0);cout:out std_logic);end component;signal carryout: std_logic;beginu1: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_1164.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 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.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 clk'event and clk='1' thenif cnt4b<8 then --小于8则计数,等于8则表明乘法运算已经结束cnt4b<=cnt4b+1;end if;end if;end process;process(clk,cnt4b,start)beginif start='0' thenif cnt4b<8 thenclkout<=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( 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<="0000000000000000";elsif clk'event and clk='1' thenr16s(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 downto 0);qb:out std_logic);end;architecture one of sreg8b issignal reg8:std_logic_vector(7 downto 0);beginprocess(clk,load)beginif clk'event and clk='1' thenif 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_logic_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 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(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);signal dtbin :std_logic_vector(8 downto 0);signal dtbout :std_logic_vector(15 downto 0);begindout<=dtbout; gndint<='0';u1:arictl port map( clk,start,intclk,rstall,ariend);u2:sreg8b port map(intclk,rstall,b,qb);u3:andarith port map(qb,a,andsd);u4:adder8b port map(gndint,dtbout(15 downto 8),andsd,dtbin(7 downto 0),dtbin(8));u5:reg16b port map(intclk,rstall,dtbin,dtbout);end;六.仿真结果图以下是8位乘法器顶层设计的仿真波形图,其它各模块的仿真波形图省略。

相关文档
最新文档