Low level routine
fr - eng


mllsrs_c - pseudo noise random sequences generator computational routine

Parameters

File content


/* mllsrs_c subroutine
 * Maximal Linear Length Shift Register Sequence Generator
 * IRCOM GROUP - Author : A.Layec
 *
 * Copyright (C) 2007 Alan Layec
 *
 * This file is part of modnumlib.
 *
 * modnumlib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * modnumlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with modnumlib; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

/* REVISION HISTORY :
 * $Log$
 */

#include "modnum_lib.h"

/* mllsrs_c routine de calcul dynamique de séquence à longueur max.
 * N     : longueur du registre
 * ny    : longueur du vecteur de sortie désirée
 * y     : adresse de départ du vecteur résultat y[0..ny-1]
 * reg   : registre 
 * coef  : coef du registre 
 */

void mllsrs_c(int *N, int *ny,double *y,int *reg, int *coef)
{
 /*Déclaration des variables*/ 
 int i,j,l;

 for(l=0;l<(*ny);l++)
    {
     /*Delivre la valeur du dernier bit sur le registre y[]*/
     if((*reg)&1==1) y[l]=1;
     else y[l]=-1; /*attention ici -1 et pas 0*/

     /*Calcul de la nouvelle valeur du bit de poid fort*/
     for(i=0;i<(*N);i++)
     {
      /*Test sur la valeur du coefficient i*/
      if(((*coef)&(1<<i))!=0)
      {
       /*Cas c_i=1*/
       if(i!=0)
       {
        /*Réalise opération XOR*/
        if((((*reg)>>i)&1)==j) j=0; 
        else j=1;
       }
      else j=(*reg)&1;
      }
     }
     /*Décale le registre de 1 bit vers la droite*/
     (*reg) = (*reg)>>1;

     /*Ajoute le bit de poid fort*/
     (*reg) += (j<<((*N)-1));
    }
 return;
}

Authors

IRCOM Group Alan Layec