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

📄 kasami.c

📁 kasami伪码产生器
💻 C
字号:
/* * $Log: kasami.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *_kasami_id = "$Id: kasami.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "kasami.h"#include "gf.h"//// It creates a Kasami code generator. Only the generator polynomial // for the main m-sequence is specified through the arguments. // The sub-sequence polynomial is calculated internally based on the// main polynomial. The relative shift of the subsequence is controlled// by the subsequence 'seed' argument. The initial state of the main// m-sequence generator is fixed to 1. Note that 'seed' does not correspond// to a 'serial shift' directly, if this makes sense to you. The valid range// of 'seed' is from 0 to 2^(deg/2)-1, so that 2^(deg/2) number of different// Kasami sequences can be obtained.//Kasami *kasami_create( unsigned deg, ulong poly, ulong seed ){  Kasami *kasami;  ulong subpoly;  unsigned subdeg;  if ( deg & 1 ) {    fprintf(stderr, "kasami_create: .. the degree of the main m-seq polynomial"	    " should be even.\n");    return NULL; // odd main degree  }  if ( deg > 30 ) {    fprintf(stderr, "kasami_create: ..cannot handle deg > 30\n");    fprintf(stderr, "try kasamil_create() for the degrees upto 62.\n");    return NULL; // too high degree  }    subdeg  = deg >> 1;  subpoly = find_subpoly( deg, poly );  kasami = (Kasami*) malloc( sizeof(Kasami) );  kasami->mseq0 = mseq_create( deg, poly, 1 );  kasami->mseq1 = mseq_create( subdeg, subpoly, seed & ((1<<subdeg)-1) );  return kasami;}//// kasami_free() deallocates the memory space for // the Kasami sequence generator.//void kasami_free( Kasami *kasami ){  mseq_free( kasami->mseq0 );  mseq_free( kasami->mseq1 );  free( kasami );}// kasami() gives the next Kasami sequence in unipolar form, ie 1 or 0.char kasami( Kasami *id ){  return mseq(id->mseq0) ^ mseq(id->mseq1);}

⌨️ 快捷键说明

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