https://www.cnblogs.com/shengansong/archive/2011/05/23/2054401.html
一、对两个二进制数进行相乘运算,运用列式求法我们可以得知,乘法最终就是由加法和移位运算构成的,由此可以用高速度的加法和移位实现乘法操作,具体代码如下:
module multi_4bits_pipelining(mul_a, mul_b, clk, rst_n, mul_out);
input [3:0] mul_a, mul_b;
input clk;
input rst_n;
output [7:0] mul_out;
reg [7:0] mul_out;
reg [7:0] stored0;
reg [7:0] stored1;
reg [7:0] stored2;
reg [7:0] stored3;
reg [7:0] add01;
reg [7:0] add23;
always @(posedge clk or negedge rst_n) begin
if(!rst_n) begin
mul_out <= 0;
stored0 <= 0;
stored1 <= 0;
stored2 <= 0;
stored3 <= 0;
add01 <= 0;
add23 <= 0;
end
else begin
stored0