流水线乘法器

描述

实现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
相关推荐
ZYNQRFSOC3 小时前
基于XCKU5P纯逻辑 NVME测试
fpga开发
FPGA小迷弟7 小时前
使用FPGA开发高速AD/DA芯片的接口学习
fpga开发
stars-he8 小时前
FPGA学习笔记(6)逻辑设计小结与以太网发送前置
笔记·学习·fpga开发
燎原星火*8 小时前
FPGA 逻辑级数
fpga开发
175063319451 天前
Vivado Zynq7020 生成正弦波(查表法) + 行为级仿真
fpga开发
Terasic友晶科技1 天前
4-DE10-Nano的HDMI方块移动案例——I2C通信协议
fpga开发·i2c·hdmi·de10-nano·i2c通信协议
云雾J视界1 天前
FPGA在AI时代的角色重塑:硬件可重构性与异构计算的完美结合
fpga开发·边缘计算·gpu·vitis·ai推理·azure云·异构编程
s09071362 天前
FPGA中CIC设计注意事项
算法·fpga开发·cic滤波器
Aaron15882 天前
RFSOC+VU13P在无线信道模拟中的技术应用分析
数据结构·人工智能·算法·fpga开发·硬件架构·硬件工程·射频工程
碎碎思2 天前
BerkeleyLab Bedrock:为 FPGA 与加速计算打造的开源基石
fpga开发·开源