好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

乘法器电路的设计课堂PPT.ppt

35页
  • 卖家[上传人]:M****1
  • 文档编号:590171741
  • 上传时间:2024-09-13
  • 文档格式:PPT
  • 文档大小:268.50KB
  • / 35 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 9.2 乘法器设计n 应用 数字信号处理和数字通信n 地位 影响系统的运行速度n 实现l 并行乘法器l 移位相加乘法器l 查找表乘法器l 加法树乘法器1. 9.2.1 并行乘法器l 结构 用乘法运算符描述 由EDA软件综合l 优点 运算速度快l 缺点 耗用资源多2. 【例9.4】8位并行乘法器module mult( outcome, a, b);parameter size = 8;input[size:1] a, b; // 源操作数output[2*size:1] outcome; // 乘积assign outcome = a*b; // 相乘endmodule3. 8位并行乘法器RTL图4. 9.2.2 移位相加乘法器l 结构 移位寄存器 加法器l 优点 耗用资源少5. 【例9.16】8位二进制数的乘法module mult_for( outcome, a, b );parameter size = 8;input[size:1] a, b;output[2*size:1] outcome;reg[2*size:1] outcome;integer i;6. always @( a or b )begin outcome = 4’h0;for( i = 1; i <= size; i = i+1 ) if( b[i] ) outcome = outcome + ( a << (i-1) );endendmodule7. 乘法器的功能仿真波形图8. 9.2.3 查找表乘法器l 结构 操作数:地址 乘积:存储器l 优点 运算速度快l 缺点 耗用存储资源多9. l 设计思路n 4位查找表乘法器 Y = A×B A = A1×22+A2 B = B1×22+B2 则 Y = ( A1×22+A2 )×( B1×22+B2 ) = A1×B1×24 + A1×B2×22 + A2×B1×22 + A2×B210. n 8位查找表乘法器 Y = A×B A = A1×24+A2 B = B1×24+B2 则 Y = ( A1×24+A2 )×( B1×24+B2 ) = A1×B1×28 + A1×B2×24 + A2×B1×24 + A2×B211. 【例9.5】 8×8查找表乘法器/********** 2×2查找表乘法器 *********/module lookup( out, a, b, clk );output[3:0] out; // 乘积input[1:0] a, b; // 操作数input clk;reg[3:0] out;reg[3:0] address; // 存储器地址12. always @( posedge clk )beginaddress = { a, b };case( address )4'h0:out = 4'b0000;4'h1:out = 4'b0000;4'h2:out = 4'b0000;4'h3:out = 4'b0000;4'h4:out = 4'b0000;4'h5:out = 4'b0001;4'h6:out = 4'b0010;4'h7:out = 4'b009;13. 4'h8:out = 4'b0000;4'h9:out = 4'b0010;4'ha:out = 4'b0100;4'hb:out = 4'b090;4'hc:out = 4'b0000;4'hd:out = 4'b009;4'he:out = 4'b090;4'hf:out = 4'b1001;default: out = 4'bx;endcaseendendmodule14. /*************** 4×4查找表乘法器 ****************/module mult4x4( out, a, b, clk );output[7:0] out; // 乘积input[3:0] a, b; // 操作数input clk;reg[7:0] out;reg[1:0] firsta, firstb; // 操作数高2位reg[1:0] seconda, secondb; // 操作数低2位wire[3:0] outa, outb, outc, outd; // 乘积每2位1组15. always @( posedge clk )beginfirsta = a[3:2];seconda = a[1:0];firstb = b[3:2];secondb = b[1:0];end16. lookup m1( outa, firsta, firstb, clk ), // 元件调用 m2( outb, firsta, secondb, clk ), m3( outc, seconda, firstb, clk ), m4( outd, seconda, secondb, clk );always @( posedge clk )beginout = ( outa << 4 ) + ( outb << 2 ) // 乘积 + ( outc << 2 ) + outd;endendmodule17. 4位查找表乘法器仿真波形图18. /*************** 8×8查找表乘法器 ****************/module mult8x8( out, a, b, clk );output[15:0] out; // 乘积input[7:0] a, b; // 操作数input clk;reg[15:0] out;reg[3:0] firsta, firstb; // 操作数高4位reg[3:0] seconda, secondb; // 操作数低4位wire[7:0] outa, outb, outc, outd; // 乘积每8位1组19. always @( posedge clk )beginfirsta = a[7:4];seconda = a[3:0];firstb = b[7:4];secondb = b[3:0];end20. mult4x4 n1( outa, firsta, firstb, clk ), // 元件调用 n2( outb, firsta, secondb, clk ), n3( outc, seconda, firstb, clk ), n4( outd, seconda, secondb, clk );always @( posedge clk )beginout = ( outa << 8 ) + ( outb << 4 ) // 乘积 + ( outc << 4 ) + outd;endendmodule21. 8位查找表乘法器仿真波形图22. 9.2.4 加法树乘法器l 结构 底层:乘法器 高层:多级加法器l 优点 1个时钟周期完成23. 加法树乘法器结构框图8×1乘法器a×128b78×1乘法器a×64b6加法器8×1乘法器a×32b58×1乘法器a×16b4加法器8×1乘法器a×8b38×1乘法器a×4b2加法器8×1乘法器a×2b18×1乘法器ab0加法器加法器加法器加法器y=a×b24. 【例9.6】8位加法树乘法器module add_tree( out, a, b, clk );output[15:0] out; // 乘积input[7:0] a, b; // 操作数input clk;wire[15:0] out;wire[15:0] out1, c1; // 加法器和wire[13:0] out2;wire[11:0] out3, c2;wire[9:0] out4;25. reg[14:0] temp0; // 最高位乘积reg[13:0] temp1;reg[12:0] temp2;reg[11:0] temp3;reg[10:0] temp4;reg[9:0] temp5;reg[8:0] temp6;reg[7:0] temp7; // 最低位乘积26. /********************** 8×1乘法器 **********************/function[7:0] mult8x1;input[7:0] operand;input sel;beginmult8x1 = ( sel ) ? ( operand ) : 8'b00000000;endendfunction27. /******* 操作数b各位与操作数a相乘 *******/always @( posedge clk )begintemp7 = mult8x1( a, b[0] );temp6 = ( mult8x1( a, b[1] ) ) << 1;temp5 = ( mult8x1( a, b[2] ) ) << 2;temp4 = ( mult8x1( a, b[3] ) ) << 3;temp3 = ( mult8x1( a, b[4] ) ) << 4;temp2 = ( mult8x1( a, b[5] ) ) << 5;temp1 = ( mult8x1( a, b[6] ) ) << 6;temp0 = ( mult8x1( a, b[7] ) ) << 7;end28. /********** 加法器树运算 *********/assign out1 = temp0 + temp1;assign out2 = temp2 + temp3;assign out3 = temp4 + temp5;assign out4 = temp6 + temp7;assign c1 = out1 + out2;assign c2 = out3 + out4;assign out = c1 + c2;endmodule29. 8位加法树乘法器仿真波形图30. 四种乘法器的比较31. 9.3 乘累加器(MAC)的设计 32. 【例9.30】乘累加器(MAC)module MAC( out, opa, opb, clk, clr );output[15:0] out;input[7:0] opa, opb;input clk, clr;wire[15:0] sum;reg[15:0] out;33. function[15:0] mult;input[7:0] opa, opb;reg [15:0] result;integer i;begin result = opa[0] ? opb : 0; for(i = 1; i <= 7; i = i+1)begin if( opa[i] == 1 ) result = result + ( opb << (i-1) );end mult = result;endendfunction34. assign sum = mult( opa, opb ) + out;always @( posedge clk or posedge clr )beginif( clr ) out <= 0;else out <= sum;end endmodule35. 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.