前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >流水线乘法器

流水线乘法器

作者头像
瓜大三哥
发布2018-02-24 16:31:53
6890
发布2018-02-24 16:31:53
举报
文章被收录于专栏:瓜大三哥瓜大三哥
代码语言:js
复制
module mul_addtree(
clk,rst_n,mul_a,mul_b,mul_out
    );
 parameter MUL_WIDTH=4;
 parameter MUL_RESULT=8;
 input clk;
 input rst_n;
 input [MUL_WIDTH-1:0]mul_a;
 input [MUL_WIDTH-1:0]mul_b;
 output [MUL_RESULT-1:0]mul_out;
 reg [MUL_RESULT-1:0]mul_out;
 reg [MUL_RESULT-1:0]store0;
 reg [MUL_RESULT-1:0]store1;
 reg [MUL_RESULT-1:0]store2;
 reg [MUL_RESULT-1:0]store3;
 reg [MUL_RESULT-1:0]add01;
 reg [MUL_RESULT-1:0]add23;
 always @( posedge clk or negedge rst_n )
 begin
if(!rst_n)
begin
mul_out<=8'b0000_0000;
store0<=8'b0000_0000;
store1<=8'b0000_0000;
store2<=8'b0000_0000;
store3<=8'b0000_0000;
add01<=8'b0000_0000;
add23<=8'b0000_0000;
end
else
begin
store0<=mul_b[0]?{4'b0000,mul_a}:8'b0000_0000;
store1<=mul_b[1]?{3'b000,mul_a,1'b0}:8'b0000_0000;
store2<=mul_b[2]?{2'b00,mul_a,2'b00}:8'b0000_0000;
store3<=mul_b[3]?{1'b0,mul_a,3'b000}:8'b0000_0000;
add01<=store0+store1;
add23<=store2+store3;
mul_out<=add01+add23;
end
 end
endmodule
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2016-06-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 瓜大三哥 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档