搜狗输入法win10:突发数字通信中的同步独特字选取

来源:百度文库 编辑:中科新闻网 时间:2024/05/04 07:31:15
说明:数据包括导言和独特字两部分,
导言(Preamble)一般采用某固定的符号;
数字通信中,假设误比特率(BER)为p;
设独特字(UW) 长度为L,导言长度为W;
则独特字一共有2L个,我们的目的就是
从中选择一个误检概率最小的序列作为最
优的UW。
同步的过程为:
先通过一些方法如功率检测,确定大致
的帧头,当然结果是处于一个范围中(称为
检测窗) ,因此还需要进一步的处理。
设定一个阀值T,当接收序列中顺序地从
某位置开始的L个比特与UW相同的位数大
于等于T时,就认为该位置为UW所在位置。
显然由于通信中的噪音会造成误码,从而
会有误检的可能。

补充:源码如下
#include "math.h"
#define L 6
#define W 8
#include "stdio.h"
#include "conio.h"

long double pcount(int T ,long double pwrong,unsigned P ,unsigned UW);

main()
{
long double prb=1,tempprb=1;
unsigned P=0xaa; /*必需在此设置导言为1010...*/
long double pwrong=0.005; /*在此设置误比特率*/
struct panduw
{ /*使用结构体令uw占用一个长字的低L位,p占后面W位*/
unsigned uw:L;
unsigned p:W;
};

union upuw
{ /*将结构体套在共用体里方便只用一个变量同时进行接收值的遍历*/
struct panduw puw;
unsigned long temp;
}tempuw,UW;

int T=1,tempt=1;

UW.temp=0;
tempuw.temp=0;

while(1)
{ /*在while的大循环里对所有的uw进行遍历*/
for(tempt=1;tempt<=L;tempt++)
{ /*在for的循环里对特定的uw对阀值T进行遍历*/
tempprb=pcount(tempt,pwrong,P,tempuw.puw.uw);
printf("%d\t",tempuw.puw.uw);
if(tempprb<prb) {prb=tempprb;T=tempt;UW.puw.uw=tempuw.puw.uw;}
}

tempuw.puw.uw++;
if(tempuw.puw.uw==0) break ; /*当完成对uw的遍历时uw由于溢出变为0*/
}

printf("T=%d\nUW=%x\nP=%lf\n",T,UW.puw.uw,prb);
getch();

}

long double pcount(int T ,long double pwrong,unsigned P ,unsigned UW)
{ /*pccount用于对所有可能的接收值进行遍历并计算误判的概率*/
int i,num=0,t=T;
unsigned long over=pow(2,L+W);
long double p0=0;
unsigned long dif;
struct panduw
{ /*将p及uw按顺序存贮结构按位存贮在一个字节里*/
unsigned uw:L;
unsigned p:W;
};

union upuw
{
struct panduw puw;
unsigned long temp;
}ture,recieve,check,temp1;
/*ture为设定的p及uw,recieve用于遍历接收值,check及temp1用于接收序列
recieve中的任意L位序列进行检测*/

temp1.temp=0;
temp1.puw.uw=(pow(2,L)-1);

ture.temp=0;
ture.puw.uw=UW;
ture.puw.p=P ;

check.temp=0;
check.puw.uw=UW;

recieve.temp=0;

while(1)
{ /*在while循环里,对所有可能的接收值recieve进行遍历*/
/*并用位检测机检测*/
for(i=W+1;i>0;i--)
{ /*对一个特定的接收值recieve,,将check与temp1进行左移位并进行检测*/

dif=recieve.temp^check.temp; /*异或位操作把不同的位数标志为1*/
dif&=temp1.temp; /*消除非检测的L为以外的位的影响*/
num=countone(dif);
if((i==W+1)&&(L-num)<t)
{
dif=recieve.temp^ture.temp;
num=countone(dif);
p0+=(pow(pwrong,num)*pow((1-pwrong),(L+W-num)));
}
if((L-num)>=t&&(i!=W+1))
{
dif=recieve.temp^ture.temp;
num=countone(dif);
p0+=(pow(pwrong,num)*pow((1-pwrong),(L+W-num)));
}
check.temp<<=1;
temp1.temp<<=1;

}
/*由于在for循环中进行了移位需从新初始化check及temp1*/
check.temp=0;
check.puw.uw=UW;
/*temp1在与uw在字节相同的低L位初始化为1,其余为0*/
temp1.temp=0;
temp1.puw.uw=(pow(2,L)-1);

recieve.temp++;
if((recieve.temp==0)||(recieve.temp==over)) break;
}

return p0;

}

int countone(unsigned long num)
{ /*计算参数num二进制存贮中为1的位数,累加在total中并返回*/
int total=0;
unsigned long i=num;
while(i!=0)
{
if(i%2) total++;
i>>=1;
}
return total;
}

本人是菜鸟,这是从别处找来的一个程序源码,看得不太懂,望哪位高手指点一下,感激不尽!!