Changeset 4347

Show
Ignore:
Timestamp:
07/12/07 16:19:39 (6 years ago)
Author:
hvolos
Message:

Started writing tests for the conv fec

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • SigProc/trunk/SigProc/autotest_sources/Fec_conv_testsuite.h

    r4346 r4347  
    6060    }; 
    6161 
     62    void testEncoder(){ 
     63        unsigned int inputVector[20]={1,0,0,0,1,0,0,1,1,1,0,1,1,0,1,0,1,1,1,0}; 
     64        unsigned int outputVector[35]; 
     65        unsigend int outputVectorTest[35]; 
     66    unsigned short int data2Enc[20],encData[20],noOfSymbols=0; 
     67    signed short int tmp; 
     68    unsigned short int numberOfBits=0, numberOfOutBits=0; 
     69        unsigned int genPoly[5]; 
     70        genPoly[0]=159; 
     71        genPoly[1]=188; 
     72        genPoly[2]=110; 
     73        genPoly[3]=173; 
     74        genPoly[4]=223; 
     75        SigProc::trellisTable *theTrellisTable; 
     76        theTrellisTable=new SigProc::trellisTable(genPoly, 
     77                (short unsigned int)4, 
     78                (short unsigned int)5, 
     79                (short unsigned int)2); 
     80        SigProc::fec_conv_encoder  * encoder; 
     81        encoder->SetTrellisTable(theTrellisTable); 
     82  
     83         
     84        numberOfBits=20 
     85        noOfSymbols=numberOfBits/theTrellisTable->k; 
     86        unsigned short int mode =1; 
     87 
     88            ///Adjust the output lengh according to the encoding mode 
     89            switch (mode){ 
     90                case 0: 
     91                    ///The encoder starts from zero state 
     92                    numberOfOutBits=noOfSymbols*theTrellisTable->n; 
     93                    break; 
     94                case 1: 
     95                    ///The encoder starts and ends at the zero state         
     96                    numberOfOutBits=(noOfSymbols+theTrellisTable->K)*theTrellisTable->n; 
     97                    break; 
     98                default: 
     99            }; 
     100             
     101            encoder->ResetState(); 
     102             
     103            for (unsigned int i=0;i<noOfSymbols;i++){ 
     104                 for (unsigned int j=0;j<theTrellisTable->k;j++){ 
     105                    data2Enc[j]=inputVector[i*theTrellisTable->k+j]; 
     106                 } 
     107             
     108                
     109             
     110                encoder->Encode(data2Enc,encData); 
     111         
     112                for (int j=0;j<theTrellisTable->n;j++){ 
     113                     tmp=(short int )encData[j]; 
     114                   outputVector[i*theTrellisTable->n+j]=tmp; 
     115                 } 
     116            } 
     117 
     118            ///If mode=1 add additional symbols to make the last state of the encoder zero 
     119            if (mode==1){ 
     120                     
     121                 for (unsigned int j=0;j<theTrellisTable->k;j++){ 
     122                    data2Enc[j]=0; 
     123                 } 
     124 
     125                  for (unsigned int i=noOfSymbols;i<noOfSymbols+theTrellisTable->K;i++){ 
     126                             
     127                         encoder->Encode(data2Enc,encData); 
     128         
     129                        for (int j=0;j<theTrellisTable->n;j++){ 
     130                         tmp=(short int )encData[j]; 
     131                         outputVector[i*theTrellisTable->n+j]=tmp; 
     132                        } 
     133                        
     134                } 
     135 
     136            };             
     137 
     138        }//else 
     139    } 
    62140}; 
    63141