源代码
module multiply(
input [7:0] a,
input [7:0] b,
output wire [15:0] result
);
(*use_dsp48 = "yes"*) wire [15:0] result;
assign result = a*b;
endmodule
仿真代码
module multiply_tb();
reg [7:0] a;
reg [7:0] b;
wire [15:0] result;
initial
begin
a = 5;
b = 9;
#10;
a = 4;
b = 6;
#10;
a = 7;
b = 8;
#10;
$finish;
end
multiply u_multiply(
.a(a),
.b(b),
.result(result)
);
endmodule
仿真结果
注意事项:
(1)存储乘法运算结果的寄存器位宽,等于2个乘数的位宽之和。
&#x