1 |
2 |
issei |
//===================================================================
|
2 |
|
|
// Module Name : RsGfInverse
|
3 |
|
|
// File Name : RsGfInverse.cpp
|
4 |
|
|
// Function : RS Decoder GF inverter
|
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 <cstdio>
|
17 |
|
|
//#include <cstdlib>
|
18 |
|
|
#include <stdio.h>
|
19 |
|
|
#include <stdlib.h>
|
20 |
|
|
void RsGfMultiplier( int*, int*,int*, int, int);
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
void RsGfInverse(int *yFinalTab, int *x1Tab, int PrimPoly, int bitSymbol) {
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
//---------------------------------------------------------------
|
27 |
|
|
//
|
28 |
|
|
//---------------------------------------------------------------
|
29 |
|
|
int zz;
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//---------------------------------------------------------------
|
33 |
|
|
// c++ variables
|
34 |
|
|
//---------------------------------------------------------------
|
35 |
|
|
int *y2Tab;
|
36 |
|
|
int *y3Tab;
|
37 |
|
|
int *y6Tab;
|
38 |
|
|
int *y12Tab;
|
39 |
|
|
int *y15Tab;
|
40 |
|
|
int *y30Tab;
|
41 |
|
|
int *y60Tab;
|
42 |
|
|
int *y120Tab;
|
43 |
|
|
int *y240Tab;
|
44 |
|
|
int *y14Tab;
|
45 |
|
|
int *y254Tab;
|
46 |
|
|
int *y508Tab;
|
47 |
|
|
int *y510Tab;
|
48 |
|
|
int *y1020Tab;
|
49 |
|
|
int *y1022Tab;
|
50 |
|
|
int *y62Tab;
|
51 |
|
|
int *y126Tab;
|
52 |
|
|
int *y2044Tab;
|
53 |
|
|
int *y2046Tab;
|
54 |
|
|
int *y4092Tab;
|
55 |
|
|
int *y4094Tab;
|
56 |
|
|
|
57 |
|
|
y2Tab = new int[bitSymbol];
|
58 |
|
|
y3Tab = new int[bitSymbol];
|
59 |
|
|
y6Tab = new int[bitSymbol];
|
60 |
|
|
y12Tab = new int[bitSymbol];
|
61 |
|
|
y15Tab = new int[bitSymbol];
|
62 |
|
|
y30Tab = new int[bitSymbol];
|
63 |
|
|
y60Tab = new int[bitSymbol];
|
64 |
|
|
y120Tab = new int[bitSymbol];
|
65 |
|
|
y240Tab = new int[bitSymbol];
|
66 |
|
|
y14Tab = new int[bitSymbol];
|
67 |
|
|
y254Tab = new int[bitSymbol];
|
68 |
|
|
y508Tab = new int[bitSymbol];
|
69 |
|
|
y510Tab = new int[bitSymbol];
|
70 |
|
|
y1020Tab = new int[bitSymbol];
|
71 |
|
|
y1022Tab = new int[bitSymbol];
|
72 |
|
|
y62Tab = new int[bitSymbol];
|
73 |
|
|
y126Tab = new int[bitSymbol];
|
74 |
|
|
y2044Tab = new int[bitSymbol];
|
75 |
|
|
y2046Tab = new int[bitSymbol];
|
76 |
|
|
y4092Tab = new int[bitSymbol];
|
77 |
|
|
y4094Tab = new int[bitSymbol];
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
//---------------------------------------------------------------
|
81 |
|
|
// Galois multiplier: Y^2 = x1*x1
|
82 |
|
|
//---------------------------------------------------------------
|
83 |
|
|
RsGfMultiplier(y2Tab, x1Tab, x1Tab, PrimPoly, bitSymbol);
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
//---------------------------------------------------------------
|
87 |
|
|
// Galois multiplier: Y^3 = Y^2 *x1
|
88 |
|
|
//---------------------------------------------------------------
|
89 |
|
|
RsGfMultiplier(y3Tab, y2Tab, x1Tab, PrimPoly, bitSymbol);
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
//---------------------------------------------------------------
|
93 |
|
|
// Galois multiplier: Y^6 = Y^3 *Y^3
|
94 |
|
|
//---------------------------------------------------------------
|
95 |
|
|
RsGfMultiplier(y6Tab, y3Tab, y3Tab, PrimPoly, bitSymbol);
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
//---------------------------------------------------------------
|
99 |
|
|
// Galois multiplier: Y^12 = Y^6 *Y^6
|
100 |
|
|
//---------------------------------------------------------------
|
101 |
|
|
RsGfMultiplier(y12Tab, y6Tab, y6Tab, PrimPoly, bitSymbol);
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
//---------------------------------------------------------------
|
105 |
|
|
// Galois multiplier: Y^15 = Y^12 *Y^3
|
106 |
|
|
//---------------------------------------------------------------
|
107 |
|
|
RsGfMultiplier(y15Tab, y12Tab, y3Tab, PrimPoly, bitSymbol);
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
//---------------------------------------------------------------
|
111 |
|
|
// Galois multiplier: Y^30 = Y^15 *Y^15
|
112 |
|
|
//---------------------------------------------------------------
|
113 |
|
|
RsGfMultiplier(y30Tab, y15Tab, y15Tab, PrimPoly, bitSymbol);
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
//---------------------------------------------------------------
|
117 |
|
|
// Galois multiplier: Y^60 = Y^30 *Y^30
|
118 |
|
|
//---------------------------------------------------------------
|
119 |
|
|
RsGfMultiplier(y60Tab, y30Tab, y30Tab, PrimPoly, bitSymbol);
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
//---------------------------------------------------------------
|
123 |
|
|
// Galois multiplier: Y^62 = Y^60 *Y^2
|
124 |
|
|
//---------------------------------------------------------------
|
125 |
|
|
RsGfMultiplier(y62Tab, y60Tab, y2Tab, PrimPoly, bitSymbol);
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
//---------------------------------------------------------------
|
129 |
|
|
// Galois multiplier: Y^120 = Y^60 *Y^60
|
130 |
|
|
//---------------------------------------------------------------
|
131 |
|
|
RsGfMultiplier(y120Tab, y60Tab, y60Tab, PrimPoly, bitSymbol);
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
//---------------------------------------------------------------
|
135 |
|
|
// Galois multiplier: Y^126 = Y^120 *Y^6
|
136 |
|
|
//---------------------------------------------------------------
|
137 |
|
|
RsGfMultiplier(y126Tab, y120Tab, y6Tab, PrimPoly, bitSymbol);
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
//---------------------------------------------------------------
|
141 |
|
|
// Galois multiplier: Y^240 = Y^120 *Y^120
|
142 |
|
|
//---------------------------------------------------------------
|
143 |
|
|
RsGfMultiplier(y240Tab, y120Tab, y120Tab, PrimPoly, bitSymbol);
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
//---------------------------------------------------------------
|
147 |
|
|
// Galois multiplier: Y^14 = Y^12 *Y^2
|
148 |
|
|
//---------------------------------------------------------------
|
149 |
|
|
RsGfMultiplier(y14Tab, y12Tab, y2Tab, PrimPoly, bitSymbol);
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
//---------------------------------------------------------------
|
153 |
|
|
// Galois multiplier: Y^254 = Y^240 *Y^14
|
154 |
|
|
//---------------------------------------------------------------
|
155 |
|
|
RsGfMultiplier(y254Tab, y240Tab, y14Tab, PrimPoly, bitSymbol);
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
//---------------------------------------------------------------
|
159 |
|
|
// Galois multiplier: Y^508 = Y^254 *Y^254
|
160 |
|
|
//---------------------------------------------------------------
|
161 |
|
|
RsGfMultiplier(y508Tab, y254Tab, y254Tab, PrimPoly, bitSymbol);
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
//---------------------------------------------------------------
|
165 |
|
|
// Galois multiplier: Y^510 = Y^508 *Y^2
|
166 |
|
|
//---------------------------------------------------------------
|
167 |
|
|
RsGfMultiplier(y510Tab, y508Tab, y2Tab, PrimPoly, bitSymbol);
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
//---------------------------------------------------------------
|
171 |
|
|
// Galois multiplier: Y^1020 = Y^510 *Y^510
|
172 |
|
|
//---------------------------------------------------------------
|
173 |
|
|
RsGfMultiplier(y1020Tab, y510Tab, y510Tab, PrimPoly, bitSymbol);
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
//---------------------------------------------------------------
|
177 |
|
|
// Galois multiplier: Y^1022 = Y^1020 *Y^2
|
178 |
|
|
//---------------------------------------------------------------
|
179 |
|
|
RsGfMultiplier(y1022Tab, y1020Tab, y2Tab, PrimPoly, bitSymbol);
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
//---------------------------------------------------------------
|
183 |
|
|
// Galois multiplier: Y^2044 = Y^1022 *Y^1022
|
184 |
|
|
//---------------------------------------------------------------
|
185 |
|
|
RsGfMultiplier(y2044Tab, y1022Tab, y1022Tab, PrimPoly, bitSymbol);
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
//---------------------------------------------------------------
|
189 |
|
|
// Galois multiplier: Y^2044 = Y^2044 *Y^2
|
190 |
|
|
//---------------------------------------------------------------
|
191 |
|
|
RsGfMultiplier(y2046Tab, y2044Tab, y2Tab, PrimPoly, bitSymbol);
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
//---------------------------------------------------------------
|
195 |
|
|
// Galois multiplier: Y^4092 = Y^2046 *Y^2046
|
196 |
|
|
//---------------------------------------------------------------
|
197 |
|
|
RsGfMultiplier(y4092Tab, y2046Tab, y2046Tab, PrimPoly, bitSymbol);
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
//---------------------------------------------------------------
|
201 |
|
|
// Galois multiplier: Y^4094 = Y^4092 *Y^2
|
202 |
|
|
//---------------------------------------------------------------
|
203 |
|
|
RsGfMultiplier(y4094Tab, y4092Tab, y2Tab, PrimPoly, bitSymbol);
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
//---------------------------------------------------------------
|
207 |
|
|
// Result assignment 2^8=y^254, 2^9=y^510, 2^10=y^1022
|
208 |
|
|
//---------------------------------------------------------------
|
209 |
|
|
switch(bitSymbol){
|
210 |
|
|
case (3):
|
211 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
212 |
|
|
yFinalTab [zz] = y6Tab[zz];
|
213 |
|
|
}
|
214 |
|
|
break;
|
215 |
|
|
case (4):
|
216 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
217 |
|
|
yFinalTab [zz] = y14Tab[zz];
|
218 |
|
|
}
|
219 |
|
|
break;
|
220 |
|
|
case (5):
|
221 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
222 |
|
|
yFinalTab [zz] = y30Tab[zz];
|
223 |
|
|
}
|
224 |
|
|
break;
|
225 |
|
|
case (6):
|
226 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
227 |
|
|
yFinalTab [zz] = y62Tab[zz];
|
228 |
|
|
}
|
229 |
|
|
break;
|
230 |
|
|
case (7):
|
231 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
232 |
|
|
yFinalTab [zz] = y126Tab[zz];
|
233 |
|
|
}
|
234 |
|
|
break;
|
235 |
|
|
case (8):
|
236 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
237 |
|
|
yFinalTab [zz] = y254Tab[zz];
|
238 |
|
|
}
|
239 |
|
|
break;
|
240 |
|
|
case (9):
|
241 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
242 |
|
|
yFinalTab [zz] = y510Tab[zz];
|
243 |
|
|
}
|
244 |
|
|
break;
|
245 |
|
|
case (10):
|
246 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
247 |
|
|
yFinalTab [zz] = y1022Tab[zz];
|
248 |
|
|
}
|
249 |
|
|
break;
|
250 |
|
|
case (11):
|
251 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
252 |
|
|
yFinalTab [zz] = y2046Tab[zz];
|
253 |
|
|
}
|
254 |
|
|
break;
|
255 |
|
|
case (12):
|
256 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
257 |
|
|
yFinalTab [zz] = y4094Tab[zz];
|
258 |
|
|
}
|
259 |
|
|
break;
|
260 |
|
|
default:
|
261 |
|
|
yFinalTab [0] = 0;
|
262 |
|
|
break;
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
//---------------------------------------------------------------
|
267 |
|
|
// Free memory
|
268 |
|
|
//---------------------------------------------------------------
|
269 |
|
|
delete[] y2Tab;
|
270 |
|
|
delete[] y3Tab;
|
271 |
|
|
delete[] y6Tab;
|
272 |
|
|
delete[] y12Tab;
|
273 |
|
|
delete[] y15Tab;
|
274 |
|
|
delete[] y30Tab;
|
275 |
|
|
delete[] y60Tab;
|
276 |
|
|
delete[] y120Tab;
|
277 |
|
|
delete[] y240Tab;
|
278 |
|
|
delete[] y14Tab;
|
279 |
|
|
delete[] y254Tab;
|
280 |
|
|
delete[] y508Tab;
|
281 |
|
|
delete[] y510Tab;
|
282 |
|
|
delete[] y1020Tab;
|
283 |
|
|
delete[] y1022Tab;
|
284 |
|
|
delete[] y62Tab;
|
285 |
|
|
delete[] y126Tab;
|
286 |
|
|
delete[] y2044Tab;
|
287 |
|
|
delete[] y2046Tab;
|
288 |
|
|
delete[] y4092Tab;
|
289 |
|
|
delete[] y4094Tab;
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
}
|