为了账号安全,请及时绑定邮箱和手机立即绑定

如何仅在一个时钟周期内获得32位输入的平方根?

如何仅在一个时钟周期内获得32位输入的平方根?

我想在Verilog中设计一个可综合的模块,在计算32位给定输入的平方根时仅需一个周期。
查看完整描述

3 回答

?
胡说叔叔

TA贡献1804条经验 获得超8个赞

我的代码在这里


    module sqrt(

input[31:0]a,

output[15:0]out

    );

reg [31:0]temp;

reg[14:0]x;


always@(a)

begin

if(a<257)x=4;

if(a>256 && a<65537)x=80;

if(a>65536 && a<16777217)x=1000;

if(a>16777216 && a<=4294967295)x=20000;

temp=(x+(a/x))/2;

temp=(temp+(a/temp))/2;

temp=(temp+(a/temp))/2;

temp=(temp+(a/temp))/2;

temp=(temp+(a/temp))/2;

temp=(temp+(a/temp))/2;

temp=(temp+(a/temp))/2;

end


assign out=temp;

endmodule

分享编辑


查看完整回答
反对 回复 2019-12-06
  • 3 回答
  • 0 关注
  • 646 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信