⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lfsr.cpp

📁 无线通信系统中密钥流生成器——LILI-II。以VC++为编程工具
💻 CPP
字号:
#include "stdafx.h"
#include "LFSR.H"
CString LFSR::ctos(char aq[N])
{
	int i;
	CString s;
	for(i=0;i<length;i++)
	{
		if(aq[i]) s+='1';
		else s+='0';
	}
    return s;
}
//The function of Fibonacci LFSR
void LFSR::Fibonacci()
{
	int j; 
	char fb;
	fb=0;
	for(j=0;j<length;j++)
	{
		fb+=q[j]*a[j];
	}
	fb=fb%2;
	for(j=0;j<length-1;j++) 
	{
		a[j]=a[j+1];
	}
	a[length-1]=fb;
	
}
//The function of Galois LFSR
void LFSR::Galois()
{   
	int j;
	int t;
	t=a[0];
	if (t==1)
    for(j=0;j<length-1;j++)
	{
		a[j]=(a[j+1]+q[j])%2;	 
	}
	else
		for(j=0;j<length-1;j++)
		{
			a[j]=a[j+1];	 
		}
    a[length-1]=q[length-1]*t;
}
//F_G introduce the value of m_radio3
void LFSR::Run(int F_G) 
{
	if (!F_G) Fibonacci();
	else Galois();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -