Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Codeword Class Reference

#include <codeword.h>

Collaboration diagram for Codeword:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Codeword ()
void setSourceWordLen (unsigned long k)
CW_PATTERN_t getNextCwPat ()
CW_PATTERN_t getNextCwPatOLD (unsigned long dtus_per_group, CW_PATTERN_t cw_pat)

Protected Types

enum  { MAX_DEGREE = 63 }

Protected Attributes

unsigned int k
CW_PATTERN_t n
CW_PATTERN_t cw_index
CW_PATTERN_t cw_pat
CW_PATTERN_t cw_saved

Static Protected Attributes

CW_PATTERN_t primitive_polynomial [MAX_DEGREE+1]

Member Enumeration Documentation

anonymous enum [protected]
 

Enumeration values:
MAX_DEGREE 

Definition at line 92 of file codeword.h.

00092 { MAX_DEGREE = 63 };


Constructor & Destructor Documentation

Codeword::Codeword  ) 
 

Definition at line 108 of file codeword.cc.

00108                    :
00109     k(1),
00110     n(1),
00111     cw_index(0),
00112     cw_pat(0),
00113     cw_saved(0)
00114 {
00115 }


Member Function Documentation

CW_PATTERN_t Codeword::getNextCwPat  ) 
 

Definition at line 142 of file codeword.cc.

References cw_index, cw_pat, cw_saved, k, and primitive_polynomial.

Referenced by MFTPSndAgent::init_user_file(), and MFTPSndAgent::send_data().

00143 {
00144     assert(cw_pat != 0); // or else prior call to setSourceWordLen(...) has not been made
00145     CW_PATTERN_t ret;
00146     CW_PATTERN_t cw_tmp;
00147 
00148     // step 1
00149     if(cw_index != 0) {
00150         cw_pat <<= 1;
00151         if(cw_pat >= n) {
00152             cw_pat ^= primitive_polynomial[k-1];
00153             assert(cw_pat < n);
00154         }
00155     }
00156 
00157     // step 2
00158     if(cw_index == k) { cw_saved = cw_pat; cw_tmp = n-1; }
00159     else if(cw_pat == n-1) cw_tmp = cw_saved;
00160     else cw_tmp = cw_pat;
00161 
00162     // step 3
00163     if(cw_index < k) ret = (CW_PATTERN_t) 1 << cw_index;
00164     else ret = (cw_tmp << 1) | 1;
00165 
00166     // step 4
00167     cw_index = (cw_index + 1) & (n-1);    // "& (n-1)" is equivalent to "% n" here
00168 
00169     return ret;
00170 }

CW_PATTERN_t Codeword::getNextCwPatOLD unsigned long  dtus_per_group,
CW_PATTERN_t  cw_pat
 

void Codeword::setSourceWordLen unsigned long  k  ) 
 

Definition at line 117 of file codeword.cc.

References cw_index, cw_pat, cw_saved, k, MAX_DEGREE, and primitive_polynomial.

Referenced by MFTPSndAgent::init_user_file().

00118 {
00119     k = k_;
00120     n = ((CW_PATTERN_t) 1) << (k-1);
00121     cw_index = (unsigned long) 0;
00122     cw_pat = 1;
00123     cw_saved = 0;
00124     assert(k <= 8 * sizeof(CW_PATTERN_t));
00125     if(k > MAX_DEGREE + 1 || primitive_polynomial[k-1] == 0) {
00126         fprintf(stderr, "codeword.cc: sorry, the group size %lu is not supported.\n",
00127                 (unsigned long) k);
00128         exit(0);
00129     }
00130     if(k > 8 * sizeof(CW_PATTERN_t)) {
00131         fprintf(stderr, "codeword.cc: sorry, the group size %lu that you selected\n",
00132                 (unsigned long) k);
00133         fprintf(stderr, "requires a datatype of at least %lu bits. To achieve this,\n",
00134                 (unsigned long) k);
00135         fprintf(stderr, "adjust Codeword::size in file \"codeword.h\" accordingly.\n");
00136         exit(0);
00137     }
00138 }


Member Data Documentation

CW_PATTERN_t Codeword::cw_index [protected]
 

Definition at line 97 of file codeword.h.

Referenced by getNextCwPat(), and setSourceWordLen().

CW_PATTERN_t Codeword::cw_pat [protected]
 

Definition at line 98 of file codeword.h.

Referenced by getNextCwPat(), and setSourceWordLen().

CW_PATTERN_t Codeword::cw_saved [protected]
 

Definition at line 99 of file codeword.h.

Referenced by getNextCwPat(), and setSourceWordLen().

unsigned int Codeword::k [protected]
 

Definition at line 95 of file codeword.h.

Referenced by getNextCwPat(), and setSourceWordLen().

CW_PATTERN_t Codeword::n [protected]
 

Definition at line 96 of file codeword.h.

CW_PATTERN_t Codeword::primitive_polynomial [static, protected]
 

Definition at line 37 of file codeword.cc.

Referenced by getNextCwPat(), and setSourceWordLen().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:36:05 2004 for NS2.26SourcesOriginal by doxygen 1.3.3