调用FPGA内部乘法器

1.当两个变量相乘
在这里插入图片描述

2.变量与常数相乘
在这里插入图片描述
3.要求乘法器/加法器不使用DSP block实现
在synplify pro中有一个编译指令syn_multstyle,可以实现这个功能,参见synplify pro帮助文件中的说明:

syn_multstyle Attribute 
Attribute; Lattice (LatticeECP2S/ECP2M/ECP2, LatticeECP/EC, LatticeXP2/XP, Lattice SC/SCM, MachXO, and ORCA). This attribute determines how multipliers are implemented: as dedicated hardware multiplier blocks or as logic. 
This attribute only applies to families that use DSP blocks on the device. You can use the block_mult value to implement dedicated hardware DSP blocks. To override this behavior, specify a value of logic.  
Verilog Syntax and Example 
object /* synthesis syn_multstyle = "block_mult | logic" */ ; 
module mult(a,b,c,r,en);
input [7:0] a,b;
output [15:0] r;
input [15:0] c;
input en;
wire [15:0] temp /* synthesis syn_multstyle="logic" */;
assign temp = a*b;
assign r = en ? temp : c;
endmodule

使用方法:先给 ab 赋值给一个wire型变量,然后给这个变量施加/ synthesis syn_multstyle = “logic” /的编译指令,然后再用寄存器锁存该变量。
虽然逻辑功能一样,但是为了使用/
synthesis syn_multstyle = “logic” */只能如此操作。

parameter WIDTH = 16;
wire [WIDTH*2-1:0] mult_keep /* synthesis  syn_multstyle = "logic" */ ; 
assign mult_keep = a*b;
reg [WIDTH*2-1:0] mult /* synthesis  syn_multstyle = "logic" */ ;

always @(posedge clk or posedge rst) 
     begin
        if (rst)
           mult = 32'd0;
          else
           mult = mult_keep;
      end 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值