1 |
2 |
issei |
//===================================================================
|
2 |
|
|
// Module Name : RsDecodeChienEmulator
|
3 |
|
|
// File Name : RsDecodeChienEmulator.cpp
|
4 |
|
|
// Function : RS decoder chien 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 |
|
|
void RsGfMultiplier( int*, int*,int*, int, int);
|
18 |
|
|
void RsGfInverse( int*, int*, int, int);
|
19 |
|
|
|
20 |
|
|
void RsDecodeChienEmulator(int *numError,int *errorOutTab, int DataSize, int TotalSize, int PrimPoly, int bitSymbol, int *MrefTab, int *PrefTab, int *LambdaInTab, int *OmegaInTab, int *EpsilonInTab, int *ErasureInTab) {
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
//---------------------------------------------------------------
|
24 |
|
|
// C++ variables int
|
25 |
|
|
//---------------------------------------------------------------
|
26 |
|
|
int syndromeLength;
|
27 |
|
|
int aa,bb,ff,ii,jj,kk,tt,zz;
|
28 |
|
|
int tempix;
|
29 |
|
|
int MaxValue;
|
30 |
|
|
int param1;
|
31 |
|
|
int initValue;
|
32 |
|
|
int numErrorReg2 = 0;
|
33 |
|
|
int numErrorReg = 0;
|
34 |
|
|
int mmTabSize = (bitSymbol*2) -1;
|
35 |
|
|
int idx1;
|
36 |
|
|
int idx2;
|
37 |
|
|
int tempo2;
|
38 |
|
|
int index;
|
39 |
|
|
int Pidx;
|
40 |
|
|
int init;
|
41 |
|
|
int tempNum;
|
42 |
|
|
int lambdaFlag;
|
43 |
|
|
|
44 |
|
|
//---------------------------------------------------------------
|
45 |
|
|
// syndrome length calculation
|
46 |
|
|
//---------------------------------------------------------------
|
47 |
|
|
syndromeLength = TotalSize - DataSize;
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
//---------------------------------------------------------------
|
51 |
|
|
// C++ variables pointer
|
52 |
|
|
//---------------------------------------------------------------
|
53 |
|
|
int *x1Tab;
|
54 |
|
|
int *x2Tab;
|
55 |
|
|
int *initTab;
|
56 |
|
|
|
57 |
|
|
int *LambdaRegTab;
|
58 |
|
|
int *LambdaUpTab;
|
59 |
|
|
|
60 |
|
|
int *LambdaRegTab2;
|
61 |
|
|
int *LambdaUpTab2;
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
int *lambdaSum;
|
66 |
|
|
int *lambdaEven;
|
67 |
|
|
int *lambdaOdd;
|
68 |
|
|
int *lambdaSumReg;
|
69 |
|
|
int *lambdaEvenReg;
|
70 |
|
|
int *lambdaEvenReg2;
|
71 |
|
|
int *lambdaEvenReg3;
|
72 |
|
|
int *lambdaOddReg;
|
73 |
|
|
int *lambdaOddReg2;
|
74 |
|
|
int *lambdaOddReg3;
|
75 |
|
|
int *denomE0;
|
76 |
|
|
int *denomE0Reg;
|
77 |
|
|
int *denomE0Inv;
|
78 |
|
|
int *denomE0InvReg;
|
79 |
|
|
int *denomE1;
|
80 |
|
|
int *denomE1Reg;
|
81 |
|
|
int *denomE1Inv;
|
82 |
|
|
int *denomE1InvReg;
|
83 |
|
|
int *bidon;
|
84 |
|
|
int *numeReg;
|
85 |
|
|
int *numeReg2;
|
86 |
|
|
int *errorValueE0;
|
87 |
|
|
int *errorValueE1;
|
88 |
|
|
int *ppTab;
|
89 |
|
|
int *bbTab;
|
90 |
|
|
int *ttTab;
|
91 |
|
|
int *powerTab;
|
92 |
|
|
int *coeffTab;
|
93 |
|
|
int *OmegaRegTab;
|
94 |
|
|
int *OmegaNewTab;
|
95 |
|
|
int *omegaSum;
|
96 |
|
|
int *omegaSumReg;
|
97 |
|
|
int *EpsilonRegTab;
|
98 |
|
|
int *EpsilonNewTab;
|
99 |
|
|
int *epsilonSum;
|
100 |
|
|
int *epsilonSumReg;
|
101 |
|
|
int *epsilonOdd;
|
102 |
|
|
int *epsilonOddReg;
|
103 |
|
|
int *errorOutTabBin;
|
104 |
|
|
int *productTab;
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
//------------------------------------------------------------------------
|
108 |
|
|
// MaxValue calculation
|
109 |
|
|
//------------------------------------------------------------------------
|
110 |
|
|
MaxValue = 2;
|
111 |
|
|
for(ii=0; ii<(bitSymbol-1); ii++){
|
112 |
|
|
MaxValue = MaxValue*2;
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
coeffTab = new int[MaxValue];
|
117 |
|
|
initTab = new int[MaxValue];
|
118 |
|
|
lambdaSum = new int[bitSymbol];
|
119 |
|
|
lambdaEven = new int[bitSymbol];
|
120 |
|
|
lambdaOdd = new int[bitSymbol];
|
121 |
|
|
lambdaSumReg = new int[bitSymbol];
|
122 |
|
|
lambdaEvenReg = new int[bitSymbol];
|
123 |
|
|
lambdaEvenReg2 = new int[bitSymbol];
|
124 |
|
|
lambdaEvenReg3 = new int[bitSymbol];
|
125 |
|
|
lambdaOddReg = new int[bitSymbol];
|
126 |
|
|
lambdaOddReg2 = new int[bitSymbol];
|
127 |
|
|
lambdaOddReg3 = new int[bitSymbol];
|
128 |
|
|
x1Tab = new int[bitSymbol];
|
129 |
|
|
x2Tab = new int[bitSymbol];
|
130 |
|
|
denomE0 = new int[bitSymbol];
|
131 |
|
|
denomE0Reg = new int[bitSymbol];
|
132 |
|
|
denomE0Inv = new int[bitSymbol];
|
133 |
|
|
denomE0InvReg = new int[bitSymbol];
|
134 |
|
|
denomE1 = new int[bitSymbol];
|
135 |
|
|
denomE1Reg = new int[bitSymbol];
|
136 |
|
|
denomE1Inv = new int[bitSymbol];
|
137 |
|
|
denomE1InvReg = new int[bitSymbol];
|
138 |
|
|
bbTab = new int[bitSymbol];
|
139 |
|
|
ttTab = new int[bitSymbol];
|
140 |
|
|
ppTab = new int[bitSymbol];
|
141 |
|
|
numeReg = new int[bitSymbol];
|
142 |
|
|
numeReg2 = new int[bitSymbol];
|
143 |
|
|
bidon = new int[bitSymbol];
|
144 |
|
|
errorValueE0 = new int[bitSymbol];
|
145 |
|
|
errorValueE1 = new int[bitSymbol];
|
146 |
|
|
omegaSum = new int[bitSymbol];
|
147 |
|
|
omegaSumReg = new int[bitSymbol];
|
148 |
|
|
epsilonSum = new int[bitSymbol];
|
149 |
|
|
epsilonSumReg = new int[bitSymbol];
|
150 |
|
|
epsilonOdd = new int[bitSymbol];
|
151 |
|
|
epsilonOddReg = new int[bitSymbol];
|
152 |
|
|
LambdaRegTab = new int[syndromeLength*bitSymbol];
|
153 |
|
|
LambdaUpTab = new int[syndromeLength*bitSymbol];
|
154 |
|
|
|
155 |
|
|
LambdaRegTab2 = new int[syndromeLength*bitSymbol];
|
156 |
|
|
LambdaUpTab2 = new int[syndromeLength*bitSymbol];
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
OmegaRegTab = new int[syndromeLength*bitSymbol];
|
160 |
|
|
OmegaNewTab = new int[syndromeLength*bitSymbol];
|
161 |
|
|
EpsilonRegTab = new int[(syndromeLength+1)*bitSymbol];
|
162 |
|
|
EpsilonNewTab = new int[(syndromeLength+1)*bitSymbol];
|
163 |
|
|
powerTab = new int[bitSymbol];
|
164 |
|
|
errorOutTabBin = new int[bitSymbol];
|
165 |
|
|
productTab = new int[(syndromeLength+1)*bitSymbol];
|
166 |
|
|
|
167 |
|
|
//---------------------------------------------------------------
|
168 |
|
|
// initialize lambdaFlag
|
169 |
|
|
//---------------------------------------------------------------
|
170 |
|
|
lambdaFlag = 1;
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
//---------------------------------------------------------------
|
174 |
|
|
//+ initialize powerTab
|
175 |
|
|
//---------------------------------------------------------------
|
176 |
|
|
powerTab[0] = 1;
|
177 |
|
|
for (ii=1; ii<bitSymbol;ii++){
|
178 |
|
|
powerTab[ii] = 2*powerTab[ii-1];
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
//------------------------------------------------------------------------
|
183 |
|
|
//- coeffTab initialize
|
184 |
|
|
//------------------------------------------------------------------------
|
185 |
|
|
coeffTab [0] = 0;
|
186 |
|
|
coeffTab [1] = MaxValue - TotalSize;
|
187 |
|
|
param1 = MaxValue - TotalSize;
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
//------------------------------------------------------------------------
|
191 |
|
|
//- x1Tab initialize
|
192 |
|
|
//------------------------------------------------------------------------
|
193 |
|
|
x1Tab[0] = 1;
|
194 |
|
|
for (ii=1;ii<bitSymbol;ii++){
|
195 |
|
|
x1Tab[ii] = 0;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
//------------------------------------------------------------------------
|
200 |
|
|
//- x2Tab initialize
|
201 |
|
|
//------------------------------------------------------------------------
|
202 |
|
|
x2Tab[0] = 0;
|
203 |
|
|
x2Tab[1] = 1;
|
204 |
|
|
for (ii=2;ii<bitSymbol;ii++){
|
205 |
|
|
x2Tab[ii] = 0;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
//------------------------------------------------------------------------
|
210 |
|
|
//- phase 1 : initTab calculation
|
211 |
|
|
//------------------------------------------------------------------------
|
212 |
|
|
for(ii=0;ii<MaxValue;ii++){
|
213 |
|
|
|
214 |
|
|
//------------------------------------------------------------------------
|
215 |
|
|
//- ppTab = x1Tab * x2Tab
|
216 |
|
|
//------------------------------------------------------------------------
|
217 |
|
|
RsGfMultiplier(ppTab, x1Tab, x2Tab, PrimPoly, bitSymbol);
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
//------------------------------------------------------------------------
|
221 |
|
|
//- reassign x1Tab
|
222 |
|
|
//------------------------------------------------------------------------
|
223 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
224 |
|
|
x1Tab[zz] = ppTab[zz];
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
//------------------------------------------------------------------------
|
229 |
|
|
//- Binary To Decimal initValue[dec] = x1Tab[bin]
|
230 |
|
|
//------------------------------------------------------------------------
|
231 |
|
|
initValue = 0;
|
232 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
233 |
|
|
initValue = initValue + x1Tab[zz] * powerTab[zz];
|
234 |
|
|
}
|
235 |
|
|
initTab[ii] = initValue;
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
//------------------------------------------------------------------------
|
240 |
|
|
//- Decimal To Binary x1Tab[bin] = x2Tab[bin] = tempix[dec]
|
241 |
|
|
//------------------------------------------------------------------------
|
242 |
|
|
tempix = initTab[param1-1];
|
243 |
|
|
|
244 |
|
|
for (zz =bitSymbol-1; zz>=0;zz--) {
|
245 |
|
|
if (tempix >= powerTab[zz]) {
|
246 |
|
|
tempix = tempix - powerTab[zz];
|
247 |
|
|
x1Tab [zz] = 1;
|
248 |
|
|
x2Tab [zz] = 1;
|
249 |
|
|
}else{
|
250 |
|
|
x1Tab [zz] = 0;
|
251 |
|
|
x2Tab [zz] = 0;
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
//------------------------------------------------------------------------
|
257 |
|
|
//- phase 2
|
258 |
|
|
//------------------------------------------------------------------------
|
259 |
|
|
for (ii = 1;ii<(syndromeLength+1); ii++){
|
260 |
|
|
|
261 |
|
|
//------------------------------------------------------------------------
|
262 |
|
|
//- ppTab = x1Tab * x2Tab
|
263 |
|
|
//------------------------------------------------------------------------
|
264 |
|
|
RsGfMultiplier(ppTab, x1Tab, x2Tab, PrimPoly, bitSymbol);
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
//------------------------------------------------------------------------
|
268 |
|
|
//- reassign x1Tab
|
269 |
|
|
//------------------------------------------------------------------------
|
270 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
271 |
|
|
x2Tab[zz] = ppTab[zz];
|
272 |
|
|
}
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
//------------------------------------------------------------------------
|
276 |
|
|
//- Binary To Decimal initValue[dec] = x2Tab[bin]
|
277 |
|
|
//------------------------------------------------------------------------
|
278 |
|
|
initValue = 0;
|
279 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
280 |
|
|
initValue = initValue + x2Tab[zz] * powerTab[zz];
|
281 |
|
|
}
|
282 |
|
|
tempo2= initValue;
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
//------------------------------------------------------------------------
|
286 |
|
|
//- index search
|
287 |
|
|
//------------------------------------------------------------------------
|
288 |
|
|
index = 0;
|
289 |
|
|
for (jj=0;jj<MaxValue;jj++){
|
290 |
|
|
if (initTab[jj]==tempo2){
|
291 |
|
|
if (jj == (MaxValue-1)){
|
292 |
|
|
index = 0;
|
293 |
|
|
}else{
|
294 |
|
|
index = jj;
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
}
|
298 |
|
|
coeffTab[ii+1] = index+1;
|
299 |
|
|
}
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
//---------------------------------------------------------------
|
304 |
|
|
// initialize LambaRegTab
|
305 |
|
|
//---------------------------------------------------------------
|
306 |
|
|
for (ii=0; ii < syndromeLength; ii++) {
|
307 |
|
|
for (zz=0; zz < bitSymbol; zz++) {
|
308 |
|
|
LambdaRegTab[ii*bitSymbol+zz] = 0;
|
309 |
|
|
}
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
//---------------------------------------------------------------
|
313 |
|
|
// initialize OmegaRegTab
|
314 |
|
|
//---------------------------------------------------------------
|
315 |
|
|
for (ii=0; ii < syndromeLength; ii++) {
|
316 |
|
|
for (zz=0; zz < bitSymbol; zz++) {
|
317 |
|
|
OmegaRegTab[ii*bitSymbol+zz] = 0;
|
318 |
|
|
}
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
for (zz=0; zz < bitSymbol; zz++) {
|
324 |
|
|
lambdaSum [zz] = 0;
|
325 |
|
|
lambdaEven [zz] = 0;
|
326 |
|
|
lambdaOdd [zz] = 0;
|
327 |
|
|
omegaSum [zz] = 0;
|
328 |
|
|
epsilonSum [zz] = 0;
|
329 |
|
|
epsilonOdd [zz] = 0;
|
330 |
|
|
lambdaSumReg[zz] = 0;
|
331 |
|
|
lambdaEvenReg3[zz] = 0;
|
332 |
|
|
lambdaEvenReg2[zz] = 0;
|
333 |
|
|
lambdaEvenReg[zz] = 0;
|
334 |
|
|
lambdaOddReg3[zz] = 0;
|
335 |
|
|
lambdaOddReg2[zz] = 0;
|
336 |
|
|
lambdaOddReg[zz] = 0;
|
337 |
|
|
denomE0[zz] = 0;
|
338 |
|
|
denomE1[zz] = 0;
|
339 |
|
|
denomE0Inv[zz] = 0;
|
340 |
|
|
denomE1Inv[zz] = 0;
|
341 |
|
|
denomE0Reg[zz] = 0;
|
342 |
|
|
denomE1Reg[zz] = 0;
|
343 |
|
|
denomE0InvReg[zz] = 0;
|
344 |
|
|
denomE1InvReg[zz] = 0;
|
345 |
|
|
numeReg2[zz] = 0;
|
346 |
|
|
numeReg[zz] = 0;
|
347 |
|
|
omegaSumReg[zz] = 0;
|
348 |
|
|
epsilonSumReg[zz] = 0;
|
349 |
|
|
epsilonOddReg[zz] = 0;
|
350 |
|
|
errorValueE0[zz] = 0;
|
351 |
|
|
errorValueE1[zz] = 0;
|
352 |
|
|
}
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
//---------------------------------------------------------------
|
356 |
|
|
// Chien algorithm loop
|
357 |
|
|
//---------------------------------------------------------------
|
358 |
|
|
for (ii=0; ii < (TotalSize+4); ii++) {
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
//---------------------------------------------------------------
|
363 |
|
|
// ii == 0
|
364 |
|
|
//---------------------------------------------------------------
|
365 |
|
|
if (ii ==0){
|
366 |
|
|
|
367 |
|
|
//---------------------------------------------------------------
|
368 |
|
|
// reset productTab
|
369 |
|
|
//---------------------------------------------------------------
|
370 |
|
|
for (tt=0; tt < syndromeLength*bitSymbol; tt++) {
|
371 |
|
|
productTab [tt] = 0;
|
372 |
|
|
}
|
373 |
|
|
|
374 |
|
|
//---------------------------------------------------------------
|
375 |
|
|
// update productTab
|
376 |
|
|
//---------------------------------------------------------------
|
377 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
378 |
|
|
if (coeffTab[zz] == 0) {
|
379 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
380 |
|
|
productTab[zz*bitSymbol+bb] = LambdaInTab[zz*bitSymbol+bb];
|
381 |
|
|
}
|
382 |
|
|
}else{
|
383 |
|
|
ttTab[0] = 1;
|
384 |
|
|
|
385 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
386 |
|
|
|
387 |
|
|
bbTab[0] = 0;
|
388 |
|
|
bbTab[1] = 1;
|
389 |
|
|
|
390 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
391 |
|
|
|
392 |
|
|
//------------------------------------------------------------------------
|
393 |
|
|
//------------------------------------------------------------------------
|
394 |
|
|
for(ff=1; ff<coeffTab[zz]+1; ff++){
|
395 |
|
|
//------------------------------------------------------------------------
|
396 |
|
|
// ppTab = ttTab * bbTab
|
397 |
|
|
//------------------------------------------------------------------------
|
398 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
399 |
|
|
|
400 |
|
|
//------------------------------------------------------------------------
|
401 |
|
|
// reassign ttTab
|
402 |
|
|
//------------------------------------------------------------------------
|
403 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
404 |
|
|
ttTab[kk] = ppTab[kk];
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
//------------------------------------------------------------------------
|
408 |
|
|
// write P_OUT[0]
|
409 |
|
|
//------------------------------------------------------------------------
|
410 |
|
|
if (ff==coeffTab[zz]) {
|
411 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
412 |
|
|
init = 0;
|
413 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
414 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
415 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
416 |
|
|
if (tempNum == 1) {
|
417 |
|
|
//------------------------------------------------------------------------
|
418 |
|
|
// search
|
419 |
|
|
//------------------------------------------------------------------------
|
420 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
421 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
422 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
423 |
|
|
if (bidon [idx2] == 0) {
|
424 |
|
|
bidon [idx2] = 1;
|
425 |
|
|
} else {
|
426 |
|
|
bidon [idx2] = 0;
|
427 |
|
|
}
|
428 |
|
|
}
|
429 |
|
|
}
|
430 |
|
|
}
|
431 |
|
|
}
|
432 |
|
|
//------------------------------------------------------------------------
|
433 |
|
|
// printf
|
434 |
|
|
//------------------------------------------------------------------------
|
435 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
436 |
|
|
if (bidon[idx2] == 1) {
|
437 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ LambdaInTab[zz*bitSymbol+idx2];
|
438 |
|
|
}
|
439 |
|
|
}
|
440 |
|
|
}
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
//---------------------------------------------------------------
|
448 |
|
|
// update LambdaRegTab
|
449 |
|
|
//---------------------------------------------------------------
|
450 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
451 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
452 |
|
|
LambdaRegTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
//---------------------------------------------------------------
|
460 |
|
|
// reset productTab
|
461 |
|
|
//---------------------------------------------------------------
|
462 |
|
|
for (tt=0; tt < syndromeLength*bitSymbol; tt++) {
|
463 |
|
|
productTab [tt] = 0;
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
//---------------------------------------------------------------
|
467 |
|
|
// update productTab
|
468 |
|
|
//---------------------------------------------------------------
|
469 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
470 |
|
|
if (coeffTab[zz] == 0) {
|
471 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
472 |
|
|
productTab[zz*bitSymbol+bb] = OmegaInTab[zz*bitSymbol+bb];
|
473 |
|
|
}
|
474 |
|
|
}else{
|
475 |
|
|
ttTab[0] = 1;
|
476 |
|
|
|
477 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
478 |
|
|
|
479 |
|
|
bbTab[0] = 0;
|
480 |
|
|
bbTab[1] = 1;
|
481 |
|
|
|
482 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
483 |
|
|
|
484 |
|
|
//------------------------------------------------------------------------
|
485 |
|
|
//------------------------------------------------------------------------
|
486 |
|
|
for(ff=1; ff<coeffTab[zz]+1; ff++){
|
487 |
|
|
//------------------------------------------------------------------------
|
488 |
|
|
// ppTab = ttTab * bbTab
|
489 |
|
|
//------------------------------------------------------------------------
|
490 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
491 |
|
|
|
492 |
|
|
//------------------------------------------------------------------------
|
493 |
|
|
// reassign ttTab
|
494 |
|
|
//------------------------------------------------------------------------
|
495 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
496 |
|
|
ttTab[kk] = ppTab[kk];
|
497 |
|
|
}
|
498 |
|
|
|
499 |
|
|
//------------------------------------------------------------------------
|
500 |
|
|
// write P_OUT[0]
|
501 |
|
|
//------------------------------------------------------------------------
|
502 |
|
|
if (ff==coeffTab[zz]) {
|
503 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
504 |
|
|
init = 0;
|
505 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
506 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
507 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
508 |
|
|
if (tempNum == 1) {
|
509 |
|
|
//------------------------------------------------------------------------
|
510 |
|
|
// search
|
511 |
|
|
//------------------------------------------------------------------------
|
512 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
513 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
514 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
515 |
|
|
if (bidon [idx2] == 0) {
|
516 |
|
|
bidon [idx2] = 1;
|
517 |
|
|
} else {
|
518 |
|
|
bidon [idx2] = 0;
|
519 |
|
|
}
|
520 |
|
|
}
|
521 |
|
|
}
|
522 |
|
|
}
|
523 |
|
|
}
|
524 |
|
|
//------------------------------------------------------------------------
|
525 |
|
|
// printf
|
526 |
|
|
//------------------------------------------------------------------------
|
527 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
528 |
|
|
if (bidon[idx2] == 1) {
|
529 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ OmegaInTab[zz*bitSymbol+idx2];
|
530 |
|
|
}
|
531 |
|
|
}
|
532 |
|
|
}
|
533 |
|
|
}
|
534 |
|
|
}
|
535 |
|
|
}
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
//---------------------------------------------------------------
|
540 |
|
|
// update OmegaRegTab
|
541 |
|
|
//---------------------------------------------------------------
|
542 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
543 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
544 |
|
|
OmegaRegTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
545 |
|
|
}
|
546 |
|
|
}
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
//---------------------------------------------------------------
|
551 |
|
|
// reset productTab
|
552 |
|
|
//---------------------------------------------------------------
|
553 |
|
|
for (tt=0; tt < (syndromeLength+1)*bitSymbol; tt++) {
|
554 |
|
|
productTab [tt] = 0;
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
|
558 |
|
|
//---------------------------------------------------------------
|
559 |
|
|
// update productTab
|
560 |
|
|
//---------------------------------------------------------------
|
561 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
562 |
|
|
if (coeffTab[zz] == 0) {
|
563 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
564 |
|
|
productTab[zz*bitSymbol+bb] = EpsilonInTab[zz*bitSymbol+bb];
|
565 |
|
|
}
|
566 |
|
|
}else{
|
567 |
|
|
ttTab[0] = 1;
|
568 |
|
|
|
569 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
570 |
|
|
|
571 |
|
|
bbTab[0] = 0;
|
572 |
|
|
bbTab[1] = 1;
|
573 |
|
|
|
574 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
575 |
|
|
|
576 |
|
|
//------------------------------------------------------------------------
|
577 |
|
|
//------------------------------------------------------------------------
|
578 |
|
|
for(ff=1; ff<coeffTab[zz]+1; ff++){
|
579 |
|
|
//------------------------------------------------------------------------
|
580 |
|
|
// ppTab = ttTab * bbTab
|
581 |
|
|
//------------------------------------------------------------------------
|
582 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
583 |
|
|
|
584 |
|
|
//------------------------------------------------------------------------
|
585 |
|
|
// reassign ttTab
|
586 |
|
|
//------------------------------------------------------------------------
|
587 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
588 |
|
|
ttTab[kk] = ppTab[kk];
|
589 |
|
|
}
|
590 |
|
|
|
591 |
|
|
//------------------------------------------------------------------------
|
592 |
|
|
// write P_OUT[0]
|
593 |
|
|
//------------------------------------------------------------------------
|
594 |
|
|
if (ff==coeffTab[zz]) {
|
595 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
596 |
|
|
init = 0;
|
597 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
598 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
599 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
600 |
|
|
if (tempNum == 1) {
|
601 |
|
|
//------------------------------------------------------------------------
|
602 |
|
|
// search
|
603 |
|
|
//------------------------------------------------------------------------
|
604 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
605 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
606 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
607 |
|
|
if (bidon [idx2] == 0) {
|
608 |
|
|
bidon [idx2] = 1;
|
609 |
|
|
} else {
|
610 |
|
|
bidon [idx2] = 0;
|
611 |
|
|
}
|
612 |
|
|
}
|
613 |
|
|
}
|
614 |
|
|
}
|
615 |
|
|
}
|
616 |
|
|
//------------------------------------------------------------------------
|
617 |
|
|
// printf
|
618 |
|
|
//------------------------------------------------------------------------
|
619 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
620 |
|
|
if (bidon[idx2] == 1) {
|
621 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ EpsilonInTab[zz*bitSymbol+idx2];
|
622 |
|
|
}
|
623 |
|
|
}
|
624 |
|
|
}
|
625 |
|
|
}
|
626 |
|
|
}
|
627 |
|
|
}
|
628 |
|
|
}
|
629 |
|
|
|
630 |
|
|
|
631 |
|
|
//---------------------------------------------------------------
|
632 |
|
|
// update EpsilonRegTab
|
633 |
|
|
//---------------------------------------------------------------
|
634 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
635 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
636 |
|
|
EpsilonRegTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
637 |
|
|
}
|
638 |
|
|
}
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
}else{
|
642 |
|
|
|
643 |
|
|
//---------------------------------------------------------------
|
644 |
|
|
// reset productTab
|
645 |
|
|
//---------------------------------------------------------------
|
646 |
|
|
for (tt=0; tt < syndromeLength*bitSymbol; tt++) {
|
647 |
|
|
productTab [tt] = 0;
|
648 |
|
|
}
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
//---------------------------------------------------------------
|
652 |
|
|
// update productTab
|
653 |
|
|
//---------------------------------------------------------------
|
654 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
655 |
|
|
if (zz == 0) {
|
656 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
657 |
|
|
productTab[zz*bitSymbol+bb] = LambdaRegTab[zz*bitSymbol+bb];
|
658 |
|
|
}
|
659 |
|
|
}else{
|
660 |
|
|
ttTab[0] = 1;
|
661 |
|
|
|
662 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
663 |
|
|
|
664 |
|
|
bbTab[0] = 0;
|
665 |
|
|
bbTab[1] = 1;
|
666 |
|
|
|
667 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
668 |
|
|
|
669 |
|
|
//------------------------------------------------------------------------
|
670 |
|
|
//------------------------------------------------------------------------
|
671 |
|
|
for(ff=1; ff<zz+1; ff++){
|
672 |
|
|
//------------------------------------------------------------------------
|
673 |
|
|
// ppTab = ttTab * bbTab
|
674 |
|
|
//------------------------------------------------------------------------
|
675 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
676 |
|
|
|
677 |
|
|
//------------------------------------------------------------------------
|
678 |
|
|
// reassign ttTab
|
679 |
|
|
//------------------------------------------------------------------------
|
680 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
681 |
|
|
ttTab[kk] = ppTab[kk];
|
682 |
|
|
}
|
683 |
|
|
|
684 |
|
|
//------------------------------------------------------------------------
|
685 |
|
|
// write P_OUT[0]
|
686 |
|
|
//------------------------------------------------------------------------
|
687 |
|
|
if (ff==zz) {
|
688 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
689 |
|
|
init = 0;
|
690 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
691 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
692 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
693 |
|
|
if (tempNum == 1) {
|
694 |
|
|
//------------------------------------------------------------------------
|
695 |
|
|
// search
|
696 |
|
|
//------------------------------------------------------------------------
|
697 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
698 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
699 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
700 |
|
|
if (bidon [idx2] == 0) {
|
701 |
|
|
bidon [idx2] = 1;
|
702 |
|
|
} else {
|
703 |
|
|
bidon [idx2] = 0;
|
704 |
|
|
}
|
705 |
|
|
}
|
706 |
|
|
}
|
707 |
|
|
}
|
708 |
|
|
}
|
709 |
|
|
//------------------------------------------------------------------------
|
710 |
|
|
// printf
|
711 |
|
|
//------------------------------------------------------------------------
|
712 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
713 |
|
|
if (bidon[idx2] == 1) {
|
714 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ LambdaRegTab[zz*bitSymbol+idx2];
|
715 |
|
|
}
|
716 |
|
|
}
|
717 |
|
|
}
|
718 |
|
|
}
|
719 |
|
|
}
|
720 |
|
|
}
|
721 |
|
|
}
|
722 |
|
|
|
723 |
|
|
|
724 |
|
|
//---------------------------------------------------------------
|
725 |
|
|
// calulate LambdaUpTab
|
726 |
|
|
//---------------------------------------------------------------
|
727 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
728 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
729 |
|
|
LambdaUpTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
730 |
|
|
}
|
731 |
|
|
}
|
732 |
|
|
|
733 |
|
|
|
734 |
|
|
//---------------------------------------------------------------
|
735 |
|
|
// reset productTab
|
736 |
|
|
//---------------------------------------------------------------
|
737 |
|
|
for (tt=0; tt < syndromeLength*bitSymbol; tt++) {
|
738 |
|
|
productTab [tt] = 0;
|
739 |
|
|
}
|
740 |
|
|
|
741 |
|
|
|
742 |
|
|
//---------------------------------------------------------------
|
743 |
|
|
// update productTab
|
744 |
|
|
//---------------------------------------------------------------
|
745 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
746 |
|
|
if (zz == 0) {
|
747 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
748 |
|
|
productTab[zz*bitSymbol+bb] = OmegaRegTab[zz*bitSymbol+bb];
|
749 |
|
|
}
|
750 |
|
|
}else{
|
751 |
|
|
ttTab[0] = 1;
|
752 |
|
|
|
753 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
754 |
|
|
|
755 |
|
|
bbTab[0] = 0;
|
756 |
|
|
bbTab[1] = 1;
|
757 |
|
|
|
758 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
759 |
|
|
|
760 |
|
|
//------------------------------------------------------------------------
|
761 |
|
|
//------------------------------------------------------------------------
|
762 |
|
|
for(ff=1; ff<zz+1; ff++){
|
763 |
|
|
//------------------------------------------------------------------------
|
764 |
|
|
// ppTab = ttTab * bbTab
|
765 |
|
|
//------------------------------------------------------------------------
|
766 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
767 |
|
|
|
768 |
|
|
//------------------------------------------------------------------------
|
769 |
|
|
// reassign ttTab
|
770 |
|
|
//------------------------------------------------------------------------
|
771 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
772 |
|
|
ttTab[kk] = ppTab[kk];
|
773 |
|
|
}
|
774 |
|
|
|
775 |
|
|
//------------------------------------------------------------------------
|
776 |
|
|
// write P_OUT[0]
|
777 |
|
|
//------------------------------------------------------------------------
|
778 |
|
|
if (ff==zz) {
|
779 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
780 |
|
|
init = 0;
|
781 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
782 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
783 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
784 |
|
|
if (tempNum == 1) {
|
785 |
|
|
//------------------------------------------------------------------------
|
786 |
|
|
// search
|
787 |
|
|
//------------------------------------------------------------------------
|
788 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
789 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
790 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
791 |
|
|
if (bidon [idx2] == 0) {
|
792 |
|
|
bidon [idx2] = 1;
|
793 |
|
|
} else {
|
794 |
|
|
bidon [idx2] = 0;
|
795 |
|
|
}
|
796 |
|
|
}
|
797 |
|
|
}
|
798 |
|
|
}
|
799 |
|
|
}
|
800 |
|
|
//------------------------------------------------------------------------
|
801 |
|
|
// printf
|
802 |
|
|
//------------------------------------------------------------------------
|
803 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
804 |
|
|
if (bidon[idx2] == 1) {
|
805 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ OmegaRegTab[zz*bitSymbol+idx2];
|
806 |
|
|
}
|
807 |
|
|
}
|
808 |
|
|
}
|
809 |
|
|
}
|
810 |
|
|
}
|
811 |
|
|
}
|
812 |
|
|
}
|
813 |
|
|
|
814 |
|
|
|
815 |
|
|
//---------------------------------------------------------------
|
816 |
|
|
// calulate OmegaNewTab
|
817 |
|
|
//---------------------------------------------------------------
|
818 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
819 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
820 |
|
|
OmegaNewTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
821 |
|
|
}
|
822 |
|
|
}
|
823 |
|
|
|
824 |
|
|
//---------------------------------------------------------------
|
825 |
|
|
// reset productTab
|
826 |
|
|
//---------------------------------------------------------------
|
827 |
|
|
for (tt=0; tt < (syndromeLength+1)*bitSymbol; tt++) {
|
828 |
|
|
productTab [tt] = 0;
|
829 |
|
|
}
|
830 |
|
|
|
831 |
|
|
//---------------------------------------------------------------
|
832 |
|
|
// update productTab
|
833 |
|
|
//---------------------------------------------------------------
|
834 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
835 |
|
|
|
836 |
|
|
|
837 |
|
|
if (zz == 0) {
|
838 |
|
|
for (bb = 0; bb <bitSymbol;bb++){
|
839 |
|
|
productTab[zz*bitSymbol+bb] = EpsilonRegTab[zz*bitSymbol+bb];
|
840 |
|
|
}
|
841 |
|
|
}else{
|
842 |
|
|
ttTab[0] = 1;
|
843 |
|
|
|
844 |
|
|
for (kk = 1; kk <bitSymbol;kk++){ ttTab[kk] = 0;}
|
845 |
|
|
|
846 |
|
|
bbTab[0] = 0;
|
847 |
|
|
bbTab[1] = 1;
|
848 |
|
|
|
849 |
|
|
for (kk = 2; kk <bitSymbol;kk++){ bbTab[kk] = 0;}
|
850 |
|
|
|
851 |
|
|
//------------------------------------------------------------------------
|
852 |
|
|
//------------------------------------------------------------------------
|
853 |
|
|
for(ff=1; ff<zz+1; ff++){
|
854 |
|
|
|
855 |
|
|
//------------------------------------------------------------------------
|
856 |
|
|
// ppTab = ttTab * bbTab
|
857 |
|
|
//------------------------------------------------------------------------
|
858 |
|
|
RsGfMultiplier(ppTab, ttTab, bbTab, PrimPoly, bitSymbol);
|
859 |
|
|
|
860 |
|
|
//------------------------------------------------------------------------
|
861 |
|
|
// reassign ttTab
|
862 |
|
|
//------------------------------------------------------------------------
|
863 |
|
|
for (kk = 0; kk <bitSymbol;kk++){
|
864 |
|
|
ttTab[kk] = ppTab[kk];
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
|
868 |
|
|
//------------------------------------------------------------------------
|
869 |
|
|
// write P_OUT[0]
|
870 |
|
|
//------------------------------------------------------------------------
|
871 |
|
|
if (ff==zz) {
|
872 |
|
|
for (Pidx=0; Pidx<bitSymbol; Pidx++){
|
873 |
|
|
init = 0;
|
874 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){bidon [idx2] = 0;}
|
875 |
|
|
for (idx1=0; idx1<mmTabSize;idx1++){
|
876 |
|
|
tempNum = PrefTab [Pidx*mmTabSize+idx1];
|
877 |
|
|
if (tempNum == 1) {
|
878 |
|
|
//------------------------------------------------------------------------
|
879 |
|
|
// search
|
880 |
|
|
//------------------------------------------------------------------------
|
881 |
|
|
for (idx2=0; idx2<bitSymbol;idx2++){
|
882 |
|
|
tempNum = MrefTab[idx1*bitSymbol+idx2];
|
883 |
|
|
if ((tempNum > 0) && (ttTab[tempNum-1] == 1)) {
|
884 |
|
|
if (bidon [idx2] == 0) {
|
885 |
|
|
bidon [idx2] = 1;
|
886 |
|
|
} else {
|
887 |
|
|
bidon [idx2] = 0;
|
888 |
|
|
}
|
889 |
|
|
}
|
890 |
|
|
}
|
891 |
|
|
}
|
892 |
|
|
}
|
893 |
|
|
//------------------------------------------------------------------------
|
894 |
|
|
// printf
|
895 |
|
|
//------------------------------------------------------------------------
|
896 |
|
|
for (idx2=0; idx2<bitSymbol; idx2++){
|
897 |
|
|
if (bidon[idx2] == 1) {
|
898 |
|
|
productTab[zz*bitSymbol+Pidx] = productTab[zz*bitSymbol+Pidx] ^ EpsilonRegTab[zz*bitSymbol+idx2];
|
899 |
|
|
}
|
900 |
|
|
}
|
901 |
|
|
}
|
902 |
|
|
}
|
903 |
|
|
}
|
904 |
|
|
}
|
905 |
|
|
}
|
906 |
|
|
|
907 |
|
|
//---------------------------------------------------------------
|
908 |
|
|
// calulate EpsilonNewTab
|
909 |
|
|
//---------------------------------------------------------------
|
910 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
911 |
|
|
for (aa=0; aa < bitSymbol; aa++) {
|
912 |
|
|
EpsilonNewTab[zz*bitSymbol+aa] = productTab[zz*bitSymbol+aa];
|
913 |
|
|
}
|
914 |
|
|
}
|
915 |
|
|
|
916 |
|
|
//---------------------------------------------------------------
|
917 |
|
|
// calculate lambdaSum
|
918 |
|
|
//---------------------------------------------------------------
|
919 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
920 |
|
|
lambdaSum[bb] = 0;
|
921 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
922 |
|
|
lambdaSum[bb] = lambdaSum[bb] ^ LambdaRegTab[zz*bitSymbol+bb];
|
923 |
|
|
}
|
924 |
|
|
}
|
925 |
|
|
|
926 |
|
|
//---------------------------------------------------------------
|
927 |
|
|
// calculate lambdaEven
|
928 |
|
|
//---------------------------------------------------------------
|
929 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
930 |
|
|
lambdaEven[bb] = 0;
|
931 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
932 |
|
|
if (zz % 2 == 0){
|
933 |
|
|
lambdaEven[bb] = lambdaEven[bb] ^ LambdaRegTab[zz*bitSymbol+bb];
|
934 |
|
|
}
|
935 |
|
|
}
|
936 |
|
|
}
|
937 |
|
|
|
938 |
|
|
|
939 |
|
|
//---------------------------------------------------------------
|
940 |
|
|
// calculate lambdaOdd
|
941 |
|
|
//---------------------------------------------------------------
|
942 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
943 |
|
|
lambdaOdd[bb] = 0;
|
944 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
945 |
|
|
if (zz % 2 == 1){
|
946 |
|
|
lambdaOdd[bb] = lambdaOdd[bb] ^ LambdaRegTab[zz*bitSymbol+bb];
|
947 |
|
|
}
|
948 |
|
|
}
|
949 |
|
|
}
|
950 |
|
|
|
951 |
|
|
//---------------------------------------------------------------
|
952 |
|
|
// calculate omegaSum
|
953 |
|
|
//---------------------------------------------------------------
|
954 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
955 |
|
|
omegaSum[bb] = 0;
|
956 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
957 |
|
|
omegaSum[bb] = omegaSum[bb] ^ OmegaRegTab[zz*bitSymbol+bb];
|
958 |
|
|
}
|
959 |
|
|
}
|
960 |
|
|
|
961 |
|
|
|
962 |
|
|
//---------------------------------------------------------------
|
963 |
|
|
// calculate epsilonSum
|
964 |
|
|
//---------------------------------------------------------------
|
965 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
966 |
|
|
epsilonSum[bb] = 0;
|
967 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
968 |
|
|
epsilonSum[bb] = epsilonSum[bb] ^ EpsilonRegTab[zz*bitSymbol+bb];
|
969 |
|
|
}
|
970 |
|
|
}
|
971 |
|
|
|
972 |
|
|
|
973 |
|
|
//---------------------------------------------------------------
|
974 |
|
|
// calculate epsilonOdd
|
975 |
|
|
//---------------------------------------------------------------
|
976 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
977 |
|
|
epsilonOdd[bb] = 0;
|
978 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
979 |
|
|
if (zz % 2 == 1){
|
980 |
|
|
epsilonOdd[bb] = epsilonOdd[bb] ^ EpsilonRegTab[zz*bitSymbol+bb];
|
981 |
|
|
}
|
982 |
|
|
}
|
983 |
|
|
}
|
984 |
|
|
|
985 |
|
|
//---------------------------------------------------------------
|
986 |
|
|
// calculate denomE0
|
987 |
|
|
//---------------------------------------------------------------
|
988 |
|
|
RsGfMultiplier(denomE0, lambdaOddReg, epsilonSumReg, PrimPoly, bitSymbol);
|
989 |
|
|
|
990 |
|
|
|
991 |
|
|
//---------------------------------------------------------------
|
992 |
|
|
// calculate denomE1
|
993 |
|
|
//---------------------------------------------------------------
|
994 |
|
|
RsGfMultiplier(denomE1, lambdaSumReg, epsilonOddReg, PrimPoly, bitSymbol);
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
//---------------------------------------------------------------
|
998 |
|
|
// calculate denomE0Inv
|
999 |
|
|
//---------------------------------------------------------------
|
1000 |
|
|
RsGfInverse(denomE0Inv, denomE0Reg, PrimPoly, bitSymbol);
|
1001 |
|
|
|
1002 |
|
|
|
1003 |
|
|
//---------------------------------------------------------------
|
1004 |
|
|
// calculate denomE1Inv
|
1005 |
|
|
//---------------------------------------------------------------
|
1006 |
|
|
RsGfInverse(denomE1Inv, denomE1Reg, PrimPoly, bitSymbol);
|
1007 |
|
|
|
1008 |
|
|
//---------------------------------------------------------------
|
1009 |
|
|
// calculate errorValueE0
|
1010 |
|
|
//---------------------------------------------------------------
|
1011 |
|
|
RsGfMultiplier(errorValueE0, numeReg2, denomE0InvReg, PrimPoly, bitSymbol);
|
1012 |
|
|
|
1013 |
|
|
|
1014 |
|
|
//---------------------------------------------------------------
|
1015 |
|
|
// calculate errorValueE1
|
1016 |
|
|
//---------------------------------------------------------------
|
1017 |
|
|
RsGfMultiplier(errorValueE1, numeReg2, denomE1InvReg, PrimPoly, bitSymbol);
|
1018 |
|
|
|
1019 |
|
|
//---------------------------------------------------------------
|
1020 |
|
|
// calculate errorOut
|
1021 |
|
|
//---------------------------------------------------------------
|
1022 |
|
|
if (ii>3) {
|
1023 |
|
|
if (ErasureInTab [ii-4] == 1){
|
1024 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1025 |
|
|
errorOutTabBin [bb] = errorValueE1[bb];
|
1026 |
|
|
}
|
1027 |
|
|
}else{
|
1028 |
|
|
lambdaFlag = 1;
|
1029 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1030 |
|
|
if (lambdaEvenReg3 [bb] != lambdaOddReg3[bb]){
|
1031 |
|
|
lambdaFlag = 0;
|
1032 |
|
|
}
|
1033 |
|
|
}
|
1034 |
|
|
|
1035 |
|
|
if (lambdaFlag == 1) {
|
1036 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1037 |
|
|
errorOutTabBin [bb] = errorValueE0[bb];
|
1038 |
|
|
}
|
1039 |
|
|
}else{
|
1040 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1041 |
|
|
errorOutTabBin [bb] = 0;
|
1042 |
|
|
}
|
1043 |
|
|
}
|
1044 |
|
|
}
|
1045 |
|
|
|
1046 |
|
|
//---------------------------------------------------------------
|
1047 |
|
|
// bin to dec
|
1048 |
|
|
//---------------------------------------------------------------
|
1049 |
|
|
tempNum = 0;
|
1050 |
|
|
for(kk=0; kk< bitSymbol; kk++){
|
1051 |
|
|
tempNum = tempNum + errorOutTabBin[kk] * powerTab[kk];
|
1052 |
|
|
}
|
1053 |
|
|
errorOutTab[ii-4] = tempNum;
|
1054 |
|
|
}
|
1055 |
|
|
|
1056 |
|
|
//---------------------------------------------------------------
|
1057 |
|
|
// update numErrorReg2
|
1058 |
|
|
//---------------------------------------------------------------
|
1059 |
|
|
lambdaFlag = 1;
|
1060 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1061 |
|
|
if (lambdaEven [bb] != lambdaOdd[bb]){
|
1062 |
|
|
lambdaFlag = 0;
|
1063 |
|
|
}
|
1064 |
|
|
}
|
1065 |
|
|
|
1066 |
|
|
if (ii == (TotalSize)){
|
1067 |
|
|
if (lambdaFlag==1) {
|
1068 |
|
|
numErrorReg2 = numErrorReg + 1;
|
1069 |
|
|
}else{
|
1070 |
|
|
numErrorReg2 = numErrorReg;
|
1071 |
|
|
}
|
1072 |
|
|
}
|
1073 |
|
|
|
1074 |
|
|
//---------------------------------------------------------------
|
1075 |
|
|
// update numErrorReg
|
1076 |
|
|
//---------------------------------------------------------------
|
1077 |
|
|
if (ii == 0){
|
1078 |
|
|
numErrorReg = 0;
|
1079 |
|
|
}else{
|
1080 |
|
|
if (lambdaFlag==1) {
|
1081 |
|
|
numErrorReg = numErrorReg + 1;
|
1082 |
|
|
}
|
1083 |
|
|
}
|
1084 |
|
|
|
1085 |
|
|
|
1086 |
|
|
//---------------------------------------------------------------
|
1087 |
|
|
// update LambdaRegTab
|
1088 |
|
|
//---------------------------------------------------------------
|
1089 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
1090 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1091 |
|
|
LambdaRegTab[zz*bitSymbol+bb] = LambdaUpTab[zz*bitSymbol+bb];
|
1092 |
|
|
}
|
1093 |
|
|
}
|
1094 |
|
|
|
1095 |
|
|
//---------------------------------------------------------------
|
1096 |
|
|
// update OmegaRegTab
|
1097 |
|
|
//---------------------------------------------------------------
|
1098 |
|
|
for (zz=0; zz < syndromeLength; zz++) {
|
1099 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1100 |
|
|
OmegaRegTab[zz*bitSymbol+bb] = OmegaNewTab[zz*bitSymbol+bb];
|
1101 |
|
|
}
|
1102 |
|
|
}
|
1103 |
|
|
|
1104 |
|
|
|
1105 |
|
|
//---------------------------------------------------------------
|
1106 |
|
|
// update EpsilonRegTab
|
1107 |
|
|
//---------------------------------------------------------------
|
1108 |
|
|
for (zz=0; zz <= syndromeLength; zz++) {
|
1109 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1110 |
|
|
EpsilonRegTab[zz*bitSymbol+bb] = EpsilonNewTab[zz*bitSymbol+bb];
|
1111 |
|
|
}
|
1112 |
|
|
}
|
1113 |
|
|
|
1114 |
|
|
//---------------------------------------------------------------
|
1115 |
|
|
// update registers
|
1116 |
|
|
//---------------------------------------------------------------
|
1117 |
|
|
for (bb=0; bb < bitSymbol; bb++) {
|
1118 |
|
|
lambdaSumReg [bb] = lambdaSum[bb];
|
1119 |
|
|
lambdaEvenReg3 [bb] = lambdaEvenReg2[bb];
|
1120 |
|
|
lambdaEvenReg2 [bb] = lambdaEvenReg [bb];
|
1121 |
|
|
lambdaEvenReg [bb] = lambdaEven [bb];
|
1122 |
|
|
lambdaOddReg3 [bb] = lambdaOddReg2[bb];
|
1123 |
|
|
lambdaOddReg2 [bb] = lambdaOddReg [bb];
|
1124 |
|
|
lambdaOddReg [bb] = lambdaOdd [bb];
|
1125 |
|
|
denomE0Reg [bb] = denomE0 [bb];
|
1126 |
|
|
denomE1Reg [bb] = denomE1 [bb];
|
1127 |
|
|
denomE0InvReg [bb] = denomE0Inv [bb];
|
1128 |
|
|
denomE1InvReg [bb] = denomE1Inv [bb];
|
1129 |
|
|
numeReg2 [bb] = numeReg [bb];
|
1130 |
|
|
numeReg [bb] = omegaSumReg [bb];
|
1131 |
|
|
omegaSumReg [bb] = omegaSum [bb];
|
1132 |
|
|
epsilonSumReg [bb] = epsilonSum[bb];
|
1133 |
|
|
epsilonOddReg [bb] = epsilonOdd[bb];
|
1134 |
|
|
}
|
1135 |
|
|
}
|
1136 |
|
|
}
|
1137 |
|
|
|
1138 |
|
|
|
1139 |
|
|
//---------------------------------------------------------------
|
1140 |
|
|
// assign numError
|
1141 |
|
|
//---------------------------------------------------------------
|
1142 |
|
|
numError [0] = numErrorReg2;
|
1143 |
|
|
|
1144 |
|
|
|
1145 |
|
|
//---------------------------------------------------------------
|
1146 |
|
|
// Free memory
|
1147 |
|
|
//---------------------------------------------------------------
|
1148 |
|
|
delete[] x1Tab;
|
1149 |
|
|
delete[] x2Tab;
|
1150 |
|
|
delete[] initTab;
|
1151 |
|
|
delete[] LambdaRegTab;
|
1152 |
|
|
delete[] LambdaUpTab;
|
1153 |
|
|
delete[] LambdaRegTab2;
|
1154 |
|
|
delete[] LambdaUpTab2;
|
1155 |
|
|
delete[] lambdaSum;
|
1156 |
|
|
delete[] lambdaEven;
|
1157 |
|
|
delete[] lambdaOdd;
|
1158 |
|
|
delete[] lambdaSumReg;
|
1159 |
|
|
delete[] lambdaEvenReg;
|
1160 |
|
|
delete[] lambdaEvenReg2;
|
1161 |
|
|
delete[] lambdaEvenReg3;
|
1162 |
|
|
delete[] lambdaOddReg;
|
1163 |
|
|
delete[] lambdaOddReg2;
|
1164 |
|
|
delete[] lambdaOddReg3;
|
1165 |
|
|
delete[] denomE0;
|
1166 |
|
|
delete[] denomE0Reg;
|
1167 |
|
|
delete[] denomE0Inv;
|
1168 |
|
|
delete[] denomE0InvReg;
|
1169 |
|
|
delete[] denomE1;
|
1170 |
|
|
delete[] denomE1Reg;
|
1171 |
|
|
delete[] denomE1Inv;
|
1172 |
|
|
delete[] denomE1InvReg;
|
1173 |
|
|
delete[] bidon;
|
1174 |
|
|
delete[] numeReg;
|
1175 |
|
|
delete[] numeReg2;
|
1176 |
|
|
delete[] errorValueE0;
|
1177 |
|
|
delete[] errorValueE1;
|
1178 |
|
|
delete[] ppTab;
|
1179 |
|
|
delete[] bbTab;
|
1180 |
|
|
delete[] ttTab;
|
1181 |
|
|
delete[] powerTab;
|
1182 |
|
|
delete[] coeffTab;
|
1183 |
|
|
delete[] OmegaRegTab;
|
1184 |
|
|
delete[] OmegaNewTab;
|
1185 |
|
|
delete[] omegaSum;
|
1186 |
|
|
delete[] omegaSumReg;
|
1187 |
|
|
delete[] EpsilonRegTab;
|
1188 |
|
|
delete[] EpsilonNewTab;
|
1189 |
|
|
delete[] epsilonSum;
|
1190 |
|
|
delete[] epsilonSumReg;
|
1191 |
|
|
delete[] epsilonOdd;
|
1192 |
|
|
delete[] epsilonOddReg;
|
1193 |
|
|
delete[] errorOutTabBin;
|
1194 |
|
|
delete[] productTab;
|
1195 |
|
|
|
1196 |
|
|
|
1197 |
|
|
}
|