




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.,9.2 乘法器设计,应用 数字信号处理和数字通信 地位 影响系统的运行速度 实现 并行乘法器 移位相加乘法器 查找表乘法器 加法树乘法器,.,9.2.1 并行乘法器,结构 用乘法运算符描述 由EDA软件综合 优点 运算速度快 缺点 耗用资源多,.,【例9.4】8位并行乘法器 module mult( outcome, a, b); parameter size = 8; inputsize:1 a, b; / 源操作数 output2*size:1 outcome; / 乘积 assign outcome = a*b; / 相乘 endmodule,.,8位并行乘法器RTL图,.,9.2.
2、2 移位相加乘法器,结构 移位寄存器 加法器 优点 耗用资源少,.,【例9.16】8位二进制数的乘法 module mult_for( outcome, a, b ); parameter size = 8; inputsize:1 a, b; output2*size:1 outcome; reg2*size:1 outcome; integer i;,.,always ( a or b ) begin outcome = 4h0; for( i = 1; i = size; i = i+1 ) if( bi ) outcome = outcome + ( a (i-1) ); end en
3、dmodule,.,乘法器的功能仿真波形图,.,9.2.3 查找表乘法器,结构 操作数:地址 乘积:存储器 优点 运算速度快 缺点 耗用存储资源多,.,设计思路,4位查找表乘法器 Y = AB A = A122+A2 B = B122+B2 则 Y = ( A122+A2 )( B122+B2 ) = A1B124 + A1B222 + A2B122 + A2B2,.,8位查找表乘法器 Y = AB A = A124+A2 B = B124+B2 则 Y = ( A124+A2 )( B124+B2 ) = A1B128 + A1B224 + A2B124 + A2B2,.,【例9.5】 88
4、查找表乘法器 /* 22查找表乘法器 */ module lookup( out, a, b, clk ); output3:0 out; / 乘积 input1:0 a, b; / 操作数 input clk; reg3:0 out; reg3:0 address; / 存储器地址,.,always ( posedge clk ) begin address = a, b ; case( address ) 4h0:out = 4b0000; 4h1:out = 4b0000; 4h2:out = 4b0000; 4h3:out = 4b0000; 4h4:out = 4b0000; 4h5
5、:out = 4b0001; 4h6:out = 4b0010; 4h7:out = 4b009;,.,4h8:out = 4b0000; 4h9:out = 4b0010; 4ha:out = 4b0100; 4hb:out = 4b090; 4hc:out = 4b0000; 4hd:out = 4b009; 4he:out = 4b090; 4hf:out = 4b1001; default: out = 4bx; endcase end endmodule,.,/* 44查找表乘法器 */ module mult4x4( out, a, b, clk ); output7:0 out;
6、 / 乘积 input3:0 a, b; / 操作数 input clk; reg7:0 out; reg1:0 firsta, firstb; / 操作数高2位 reg1:0 seconda, secondb; / 操作数低2位 wire3:0 outa, outb, outc, outd; / 乘积每2位1组,.,always ( posedge clk ) begin firsta = a3:2; seconda = a1:0; firstb = b3:2; secondb = b1:0; end,.,lookup m1( outa, firsta, firstb, clk ), / 元
7、件调用 m2( outb, firsta, secondb, clk ), m3( outc, seconda, firstb, clk ), m4( outd, seconda, secondb, clk ); always ( posedge clk ) begin out = ( outa 4 ) + ( outb 2 ) / 乘积 + ( outc 2 ) + outd; end endmodule,.,4位查找表乘法器仿真波形图,.,/* 88查找表乘法器 */ module mult8x8( out, a, b, clk ); output15:0 out; / 乘积 input7
8、:0 a, b; / 操作数 input clk; reg15:0 out; reg3:0 firsta, firstb; / 操作数高4位 reg3:0 seconda, secondb; / 操作数低4位 wire7:0 outa, outb, outc, outd; / 乘积每8位1组,.,always ( posedge clk ) begin firsta = a7:4; seconda = a3:0; firstb = b7:4; secondb = b3:0; end,.,mult4x4 n1( outa, firsta, firstb, clk ), / 元件调用 n2( ou
9、tb, firsta, secondb, clk ), n3( outc, seconda, firstb, clk ), n4( outd, seconda, secondb, clk ); always ( posedge clk ) begin out = ( outa 8 ) + ( outb 4 ) / 乘积 + ( outc 4 ) + outd; end endmodule,.,8位查找表乘法器仿真波形图,.,9.2.4 加法树乘法器,结构 底层:乘法器 高层:多级加法器 优点 1个时钟周期完成,.,加法树乘法器结构框图,.,【例9.6】8位加法树乘法器 module add_t
10、ree( out, a, b, clk ); output15:0 out; / 乘积 input7:0 a, b; / 操作数 input clk; wire15:0 out; wire15:0 out1, c1; / 加法器和 wire13:0 out2; wire11:0 out3, c2; wire9:0 out4;,.,reg14:0 temp0; / 最高位乘积 reg13:0 temp1; reg12:0 temp2; reg11:0 temp3; reg10:0 temp4; reg9:0 temp5; reg8:0 temp6; reg7:0 temp7; / 最低位乘积,.
11、,/* 81乘法器 */ function7:0 mult8x1; input7:0 operand; input sel; begin mult8x1 = ( sel ) ? ( operand ) : 8b00000000; end endfunction,.,/* 操作数b各位与操作数a相乘 */ always ( posedge clk ) begin temp7 = mult8x1( a, b0 ); temp6 = ( mult8x1( a, b1 ) ) 1; temp5 = ( mult8x1( a, b2 ) ) 2; temp4 = ( mult8x1( a, b3 ) )
12、 3; temp3 = ( mult8x1( a, b4 ) ) 4; temp2 = ( mult8x1( a, b5 ) ) 5; temp1 = ( mult8x1( a, b6 ) ) 6; temp0 = ( mult8x1( a, b7 ) ) 7; end,.,/* 加法器树运算 */ assign out1 = temp0 + temp1; assign out2 = temp2 + temp3; assign out3 = temp4 + temp5; assign out4 = temp6 + temp7; assign c1 = out1 + out2; assign c
13、2 = out3 + out4; assign out = c1 + c2; endmodule,.,8位加法树乘法器仿真波形图,.,四种乘法器的比较,.,9.3 乘累加器(MAC)的设计,.,【例9.30】乘累加器(MAC) module MAC( out, opa, opb, clk, clr ); output15:0 out; input7:0 opa, opb; input clk, clr; wire15:0 sum; reg15:0 out;,.,function15:0 mult; input7:0 opa, opb; reg 15:0 result; integer i; begin result = opa0 ? opb : 0; for(i = 1; i = 7; i = i+1) begin if( opa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 湖北山东学霸数学试卷
- 杭四吴山开学考数学试卷
- 马德龙病超声诊断
- 健康:我们的牙齿
- 急救护理技术知识
- 吉林一模考试数学试卷
- 河南沁阳高考数学试卷
- 高温电气安全课件
- 【《闹钟后盖注塑模具的注塑机的选择与校核分析案例》1100字】
- 【德昌A镇变电站电气一次部分初步设计16000字】
- 第一目击者理论考试题题库110题
- 2024年县乡教师选调进城考试《教育学》题库附答案【综合卷】
- 姑息治疗舒适护理
- 2022智慧健康养老服务与管理专业人才培养调研报告
- 机动车驾驶员安全教育培训课件
- 三坐标检测报告样本
- 焊条烘烤操作规程
- 急性胰腺炎护理常规课件
- 2022海南省财金集团有限公司招聘试题及答案解析
- 读后续写美好品德类代表劳动价值的车篮子讲义-高三英语二轮复习
- 《三国的世界》解说词 第一集 01
评论
0/150
提交评论