我想在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
分享編輯
添加回答
舉報
0/150
提交
取消