【FPGA学习笔记】VL56 流水线乘法器
实现4bit无符号数流水线乘法器设计。
电路的接口如下图所示。

题解主体
4bit流水线乘法器的设计采用乘法竖式运算的思想,本质是将乘法运算转换为加法运算。具体实现思路如下图:
最后的temp0、temp1、temp2、temp3的相加结果就是相乘结果。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
`timescale 1ns/1nsmodule multi_pipe#( parameter size = 4)( input clk , input rst_n , input [size-1:0] mul_a , input [size-1:0] mul_b , output reg [size*2-1:0] mul_out );/********************************************************************/reg [7:0] addr01;reg [7:0] addr23;wire [7:0] temp0 ;wire [7:0] temp1 ;wire [7:0] temp2 ;wire [7:0] temp3 ;assign temp0 = mul_b[0]? {4'b0, mul_a} : 'd0;assign temp1 = mul_b[1]? {3'b0, mul_a, 1'b0} : 'd0;assign temp2 = mul_b[2]? {2'b0, mul_a, 2'b0} : 'd0;assign temp3 = mul_b[3]? {1'b0, mul_a, 3'b0} : 'd0;always @(posedge clk or negedge rst_n) begin if(~rst_n) begin addr01 <= 'd0; addr23 <= 'd0; mul_out <= 'd0; end else begin addr01 <= temp0 + temp1; addr23 <= temp2 + temp3; mul_out <= addr01 + addr23; endendendmodule |

浙公网安备 33010602011771号