FPGA中乘法器是很稀缺的资源,但也是我们做算法必不可少的资源。7系列及之前的FPGA都是25x18的DSP,UltraScale中是27x18,我们可以通过调IP Core的方式或者原语的方式来进行乘法操作。在里面可以设置有符号还是无符号数乘法。
当然,我们也可以直接使用*
符合来进行乘法,对于无符号的乘法
reg [7:0] ubyte_a;
reg [7:0] ubyte_b;
(* use_dsp48="yes" *)
output reg[15:0] u_res;
always @ ( posedge clk ) begin
if(rst)
u_res <= 'b0;
else
u_res <= ubyte_a * ubyte_b;
end
有符号乘法可以在Verilo