流水线乘法器

描述

实现4bit无符号数流水线乘法器设计。

电路的接口如下图所示。

输入描述:

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

参考代码

cpp 复制代码
`timescale 1ns/1ns

module 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		
);
    //parameter 
    parameter N = size * 2;
    //defination
    wire [N - 1 : 0] temp [0 : 3];
    
    reg [N - 1 : 0] adder_0;
    reg [N - 1 : 0] adder_1;
    
    //output 
    genvar i;
    generate
        for(i = 0; i < 4; i = i + 1)begin : loop
            assign temp[i] = mul_b[i] ? mul_a << i : 'd0;
        end
    endgenerate
    
    always@(posedge clk or negedge rst_n)begin
        if(!rst_n) adder_0 <= 'd0;
        else adder_0 <= temp[0] + temp[1];
    end
    
    always@(posedge clk or negedge rst_n)begin
        if(!rst_n) adder_1 <= 'd0;
        else adder_1 <= temp[2] + temp[3];
    end
    
    always@(posedge clk or negedge rst_n)begin
        if(!rst_n) mul_out <= 'd0;
        else mul_out <= adder_0 + adder_1;
    end
endmodule
相关推荐
坏孩子的诺亚方舟14 小时前
open_prj22_IIC读写EEPROM、AD/DA、PLSYSMON
fpga开发·mpsoc
cjie22114 小时前
仿真xilinx库加glbl()的作用
fpga开发
禾刀围玉16 小时前
基于FPGA的卷积神经网络实现-方案构想
人工智能·fpga开发·cnn
Aaron158819 小时前
全频段 SDR干扰源模块解决方案(星链干扰、LORA无人机干扰)
人工智能·算法·fpga开发·硬件架构·硬件工程·无人机·信息与通信
Kent Gu1 天前
FPGA JTAG确认
fpga开发
北京青翼科技1 天前
基于VITA57.1的2路125MSPS AD采集、2路250MSPS DA回放FMC子卡丨青翼科技100%国产采集卡
fpga开发·数据采集卡·fmc子卡·ad采集卡
小麦嵌入式1 天前
FPGA入门(四):时序逻辑计数器原理与 LED 闪烁实现
linux·驱动开发·stm32·嵌入式硬件·fpga开发·硬件工程·dsp开发
ALINX技术博客1 天前
【黑金云课堂】FPGA技术教程FPGA基础:呼吸灯实验+RAM/ROM IP设计与验证
网络协议·fpga开发·fpga
ALINX技术博客2 天前
【黑金云课堂】FPGA技术教程Vitis开发:PS端IIC通信
fpga开发·fpga
第二层皮-合肥2 天前
线阵相机坏点校正方案
fpga开发