开方运算的DSP实现
2019-07-13 09:59发布
生成海报
-
//===============================================
-
-
//函数名:VSqrt3
-
//功能: 实现对32位定点数的开方
-
//性能: 60M主频28015硬件下运行时间小于10us
-
//转自:http://read.pudn.com/downloads180/sourcecode/mpi/840129/sqrt.c__.htm
-
-
unsigned long VSqrt3(unsigned long x )
-
{
-
unsigned long x1;
-
int s=1;
-
unsigned long g0,g1;
-
-
if(x<=1) return x;
-
-
x1=x-1;
-
if(x1>65535)
-
{
-
s+=8;
-
x1>>=16;
-
}
-
if(x1>255)
-
{
-
s+=4;
-
x1>>=8;
-
}
-
if(x1>15)
-
{
-
s+=2;
-
x1>>=4;
-
}
-
if(x1>3)
-
{
-
s+=1;
-
}
-
g0=1;
-
g0=g0<
-
g1 =(g0 +(x>>s))>>1;
-
-
while(g1
-
{
-
g0=g1;
-
g1=(g0+x/g0)>>1;
-
}
-
return g0;
-
}
-
-
//===============================================
-
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮