前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >串行乘法器

串行乘法器

作者头像
瓜大三哥
发布2018-02-24 16:36:48
发布2018-02-24 16:36:48
6650
举报
文章被收录于专栏:瓜大三哥瓜大三哥
代码语言:js
复制
module ade(
clk,x,y,q
    );
 input clk;
 input [7:0]x,y;
 output [15:0]q;
 reg [15:0]q;
 parameter s0=0,s1=1,s2=2;
 reg [2:0]count=0;
 reg [1:0]state=0;
 reg [15:0]p1,t;
 reg [7:0]y_reg;
 always @ (posedge clk)
 begin
case(state)
s0:
begin
y_reg<=y;
state<=s1;
count<=0;
p1<=0;
t<={{8{x[7]}},x};
end
s1:
begin
if(count==7)
begin
state<=s2;
end
else
begin
if(y_reg[0]==1)
begin
p1<=p1+t;
y_reg<=y_reg>>1;
t<=t<<1;
count<=count+1;
state<=s1;
end
else
begin
p1<=p1;
y_reg<=y_reg>>1;
t<=t<<1;
count<=count+1;
state<=s1;
end
end
end
s2:
begin
q<=p1;
state<=s0;
end
endcase
 end
Endmodule
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2016-06-17,如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

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