1 |
2 |
issei |
//===================================================================
|
2 |
|
|
// Module Name : RsDecodePolymulEmulator
|
3 |
|
|
// File Name : RsDecodePolymulEmulator.cpp
|
4 |
|
|
// Function : RTL Decoder polymul emulator
|
5 |
|
|
//
|
6 |
|
|
// Revision History:
|
7 |
|
|
// Date By Version Change Description
|
8 |
|
|
//===================================================================
|
9 |
|
|
// 2009/02/03 Gael Sapience 1.0 Original
|
10 |
|
|
//
|
11 |
|
|
//===================================================================
|
12 |
|
|
// (C) COPYRIGHT 2009 SYSTEM LSI CO., Ltd.
|
13 |
|
|
//
|
14 |
|
|
#include <stdio.h>
|
15 |
|
|
#include <stdlib.h>
|
16 |
|
|
#include <iostream>
|
17 |
|
|
|
18 |
|
|
void RsGfMultiplier( int*, int*,int*, int, int);
|
19 |
|
|
void RsDecodePolymulEmulator(int *sumRegTab, int DataSize, int TotalSize, int PrimPoly, int bitSymbol, int *syndromeRegTab, int *epsilonRegTab) {
|
20 |
|
|
|
21 |
|
|
//---------------------------------------------------------------
|
22 |
|
|
// C++ variables
|
23 |
|
|
//---------------------------------------------------------------
|
24 |
|
|
int syndromeLength;
|
25 |
|
|
int flagEpsilon;
|
26 |
|
|
int aa,ii,jj,zz;
|
27 |
|
|
int tempNum;
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
//---------------------------------------------------------------
|
31 |
|
|
// syndrome Length calculation
|
32 |
|
|
//---------------------------------------------------------------
|
33 |
|
|
syndromeLength = TotalSize - DataSize;
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
//---------------------------------------------------------------
|
37 |
|
|
// C++ variables
|
38 |
|
|
//---------------------------------------------------------------
|
39 |
|
|
int *epsilonMSB;
|
40 |
|
|
int *ppTab;
|
41 |
|
|
int *tempixTab;
|
42 |
|
|
int *powerTab;
|
43 |
|
|
epsilonMSB = new int[bitSymbol];
|
44 |
|
|
ppTab = new int[bitSymbol];
|
45 |
|
|
tempixTab = new int[bitSymbol];
|
46 |
|
|
powerTab = new int[bitSymbol];
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
//---------------------------------------------------------------
|
50 |
|
|
// powerTab calculation
|
51 |
|
|
//---------------------------------------------------------------
|
52 |
|
|
powerTab[0] = 1;
|
53 |
|
|
for (ii=1; ii<bitSymbol;ii++){
|
54 |
|
|
powerTab[ii] = 2*powerTab[ii-1];
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
//---------------------------------------------------------------
|
59 |
|
|
//---------------------------------------------------------------
|
60 |
|
|
for (ii = 0; ii<(syndromeLength+2); ii++){
|
61 |
|
|
|
62 |
|
|
//---------------------------------------------------------------
|
63 |
|
|
// ii == 0
|
64 |
|
|
//---------------------------------------------------------------
|
65 |
|
|
if (ii ==0){
|
66 |
|
|
//---------------------------------------------------------------
|
67 |
|
|
// check if epsilon MSB is null
|
68 |
|
|
//---------------------------------------------------------------
|
69 |
|
|
flagEpsilon = 0;
|
70 |
|
|
for (jj=0;jj<bitSymbol;jj++){
|
71 |
|
|
if (epsilonRegTab[syndromeLength*bitSymbol+jj] !=0){
|
72 |
|
|
flagEpsilon = 1;
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
//---------------------------------------------------------------
|
76 |
|
|
// assign sumRegTab
|
77 |
|
|
//---------------------------------------------------------------
|
78 |
|
|
if (flagEpsilon == 0){
|
79 |
|
|
for (jj=0;jj<(syndromeLength*bitSymbol);jj++){
|
80 |
|
|
sumRegTab[jj]=0;
|
81 |
|
|
}
|
82 |
|
|
}else{
|
83 |
|
|
for (jj=0;jj<(syndromeLength*bitSymbol);jj++){
|
84 |
|
|
sumRegTab[jj]=syndromeRegTab[jj];
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
//---------------------------------------------------------------
|
88 |
|
|
// calculate epsilonMSB
|
89 |
|
|
//---------------------------------------------------------------
|
90 |
|
|
for (jj=0;jj<bitSymbol;jj++){
|
91 |
|
|
epsilonMSB[jj] = epsilonRegTab[(syndromeLength*bitSymbol)+jj];
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
//---------------------------------------------------------------
|
95 |
|
|
// ii > 0
|
96 |
|
|
//---------------------------------------------------------------
|
97 |
|
|
else{
|
98 |
|
|
//---------------------------------------------------------------
|
99 |
|
|
// Multiplier
|
100 |
|
|
//---------------------------------------------------------------
|
101 |
|
|
for (jj=syndromeLength-1;jj>=0;jj--){
|
102 |
|
|
|
103 |
|
|
for (zz=0;zz<bitSymbol;zz++){
|
104 |
|
|
tempixTab [zz] = syndromeRegTab[jj*bitSymbol+ zz];
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
RsGfMultiplier(ppTab, epsilonMSB, tempixTab, PrimPoly, bitSymbol);
|
108 |
|
|
|
109 |
|
|
if (jj>0){
|
110 |
|
|
for (aa=0;aa<(bitSymbol);aa++){
|
111 |
|
|
sumRegTab[jj*bitSymbol+aa]= sumRegTab[(jj-1)*bitSymbol+aa] ^ ppTab[aa];
|
112 |
|
|
}
|
113 |
|
|
}else{
|
114 |
|
|
for (aa=0;aa<(bitSymbol);aa++){
|
115 |
|
|
sumRegTab[aa]= ppTab[aa];
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
//---------------------------------------------------------------
|
122 |
|
|
// calculate epsilonMSB
|
123 |
|
|
//---------------------------------------------------------------
|
124 |
|
|
if (ii<(syndromeLength+1)){
|
125 |
|
|
for (jj=0;jj<bitSymbol;jj++){
|
126 |
|
|
epsilonMSB[jj] = epsilonRegTab[((syndromeLength-ii)*bitSymbol)+jj];
|
127 |
|
|
}
|
128 |
|
|
}else{
|
129 |
|
|
for (jj=0;jj<bitSymbol;jj++){
|
130 |
|
|
epsilonMSB[jj] = 0;
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
//---------------------------------------------------------------
|
138 |
|
|
// free memory
|
139 |
|
|
//---------------------------------------------------------------
|
140 |
|
|
delete[] epsilonMSB;
|
141 |
|
|
delete[] ppTab;
|
142 |
|
|
delete[] tempixTab;
|
143 |
|
|
delete[] powerTab;
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
}
|