1 |
2 |
rud_dp |
//***************************************************************//
|
2 |
|
|
// Chien Search and Error Evaluator (CSEE) block find //
|
3 |
|
|
// error location (Xi) while determine its error magnitude (Yi). //
|
4 |
|
|
// This CSEE block implement Chien search algorithm to find //
|
5 |
|
|
// location of an error and Fourney Formula to compute the error //
|
6 |
|
|
// error value. Error value will be outputted serially and has //
|
7 |
|
|
// to be synchronous with output of FIFO Register. //
|
8 |
|
|
//***************************************************************//
|
9 |
|
|
|
10 |
|
|
module CSEEblock(lambda0, lambda1, lambda2, lambda3, lambda4,
|
11 |
|
|
lambda5, lambda6, homega0, homega1, homega2,
|
12 |
|
|
homega3, homega4, homega5, errorvalue, clock1,
|
13 |
|
|
clock2, active_csee, reset, lastdataout, evalerror,
|
14 |
|
|
en_outfifo, rootcntr);
|
15 |
|
|
|
16 |
|
|
input [4:0] lambda0, lambda1, lambda2, lambda3, lambda4,
|
17 |
|
|
lambda5, lambda6;
|
18 |
|
|
input [4:0] homega0, homega1, homega2, homega3, homega4, homega5;
|
19 |
|
|
input clock1, clock2, active_csee, reset;
|
20 |
|
|
input lastdataout, evalerror, en_outfifo;
|
21 |
|
|
output [4:0] errorvalue;
|
22 |
|
|
output [2:0] rootcntr;
|
23 |
|
|
|
24 |
|
|
wire [4:0] cs0_out, cs1_out, cs2_out, cs3_out, cs4_out, cs5_out,
|
25 |
|
|
cs6_out;
|
26 |
|
|
wire [4:0] fn0_out, fn1_out, fn2_out, fn3_out, fn4_out, fn5_out;
|
27 |
|
|
wire [4:0] oddlambda, evenlambda, lambdaval;
|
28 |
|
|
wire [4:0] omegaval, fourney_out, inv_oddlambda;
|
29 |
|
|
wire zerodetect;
|
30 |
|
|
wire [4:0] andtree_out;
|
31 |
|
|
reg load;
|
32 |
|
|
reg enrootcnt;
|
33 |
|
|
reg [2:0] rootcntr;
|
34 |
|
|
|
35 |
|
|
parameter st0=0, st1=1;
|
36 |
|
|
reg state, nxt_state;
|
37 |
|
|
|
38 |
|
|
//*****//
|
39 |
|
|
// FSM //
|
40 |
|
|
//*****//
|
41 |
|
|
always@(posedge clock2 or negedge reset)
|
42 |
|
|
begin
|
43 |
|
|
if(~reset)
|
44 |
|
|
state = st0;
|
45 |
|
|
else
|
46 |
|
|
state = nxt_state;
|
47 |
|
|
end
|
48 |
|
|
|
49 |
|
|
always@(state or active_csee or lastdataout)
|
50 |
|
|
begin
|
51 |
|
|
case(state)
|
52 |
|
|
st0 : begin
|
53 |
|
|
if(active_csee)
|
54 |
|
|
nxt_state = st1;
|
55 |
|
|
else
|
56 |
|
|
nxt_state = st0;
|
57 |
|
|
end
|
58 |
|
|
st1 : begin
|
59 |
|
|
if(lastdataout)
|
60 |
|
|
nxt_state = st0;
|
61 |
|
|
else
|
62 |
|
|
nxt_state = st1;
|
63 |
|
|
end
|
64 |
|
|
default: nxt_state = st0;
|
65 |
|
|
endcase
|
66 |
|
|
end
|
67 |
|
|
|
68 |
|
|
always@(state)
|
69 |
|
|
begin
|
70 |
|
|
case(state)
|
71 |
|
|
st0 : begin
|
72 |
|
|
load = 0;
|
73 |
|
|
enrootcnt = 0;
|
74 |
|
|
end
|
75 |
|
|
st1 : begin
|
76 |
|
|
load = 1;
|
77 |
|
|
enrootcnt = 1;
|
78 |
|
|
end
|
79 |
|
|
default: begin
|
80 |
|
|
load = 0;
|
81 |
|
|
enrootcnt = 0;
|
82 |
|
|
end
|
83 |
|
|
endcase
|
84 |
|
|
end
|
85 |
|
|
|
86 |
|
|
//********************************//
|
87 |
|
|
// Counter for roots of lambda(x) //
|
88 |
|
|
// with synchronous hold //
|
89 |
|
|
//********************************//
|
90 |
|
|
always@(posedge clock2)
|
91 |
|
|
begin
|
92 |
|
|
if(enrootcnt)
|
93 |
|
|
begin
|
94 |
|
|
if(zerodetect)
|
95 |
|
|
rootcntr <= rootcntr + 1;
|
96 |
|
|
else
|
97 |
|
|
rootcntr <= rootcntr;
|
98 |
|
|
end
|
99 |
|
|
else
|
100 |
|
|
rootcntr <= 3'b0;
|
101 |
|
|
end
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
//*******************//
|
105 |
|
|
// Chien Seach block //
|
106 |
|
|
//*******************//
|
107 |
|
|
degree0_cell cs0_cell(lambda0, cs0_out, clock1, load, evalerror);
|
108 |
|
|
degree1_cell cs1_cell(lambda1, cs1_out, clock1, load, evalerror);
|
109 |
|
|
degree2_cell cs2_cell(lambda2, cs2_out, clock1, load, evalerror);
|
110 |
|
|
degree3_cell cs3_cell(lambda3, cs3_out, clock1, load, evalerror);
|
111 |
|
|
degree4_cell cs4_cell(lambda4, cs4_out, clock1, load, evalerror);
|
112 |
|
|
degree5_cell cs5_cell(lambda5, cs5_out, clock1, load, evalerror);
|
113 |
|
|
degree6_cell cs6_cell(lambda6, cs6_out, clock1, load, evalerror);
|
114 |
|
|
|
115 |
|
|
assign oddlambda = cs1_out ^ cs3_out ^ cs5_out;
|
116 |
|
|
assign evenlambda = (cs0_out ^ cs2_out) ^ (cs4_out ^ cs6_out);
|
117 |
|
|
assign lambdaval = oddlambda ^ evenlambda;
|
118 |
|
|
|
119 |
|
|
//*****************************************//
|
120 |
|
|
// Error Evaluator (Fourney Formula) block //
|
121 |
|
|
//*****************************************//
|
122 |
|
|
degree0_cell fn0_cell(homega0, fn0_out, clock1, load, evalerror);
|
123 |
|
|
degree1_cell fn1_cell(homega1, fn1_out, clock1, load, evalerror);
|
124 |
|
|
degree2_cell fn2_cell(homega2, fn2_out, clock1, load, evalerror);
|
125 |
|
|
degree3_cell fn3_cell(homega3, fn3_out, clock1, load, evalerror);
|
126 |
|
|
degree4_cell fn4_cell(homega4, fn4_out, clock1, load, evalerror);
|
127 |
|
|
degree5_cell fn5_cell(homega5, fn5_out, clock1, load, evalerror);
|
128 |
|
|
|
129 |
|
|
assign omegaval = (fn0_out ^ fn1_out) ^ (fn2_out ^ fn3_out) ^
|
130 |
|
|
(fn4_out ^ fn5_out);
|
131 |
|
|
|
132 |
|
|
inverscomb invers(oddlambda, inv_oddlambda);
|
133 |
|
|
lcpmult multiplier(inv_oddlambda, omegaval, fourney_out);
|
134 |
|
|
|
135 |
|
|
//*****************************//
|
136 |
|
|
// Zero detect and error value //
|
137 |
|
|
//*****************************//
|
138 |
|
|
assign zerodetect = ~((lambdaval[0]|lambdaval[1]) |
|
139 |
|
|
(lambdaval[2]|lambdaval[3]) | lambdaval[4]);
|
140 |
|
|
assign andtree_out[0] = fourney_out[0] & zerodetect;
|
141 |
|
|
assign andtree_out[1] = fourney_out[1] & zerodetect;
|
142 |
|
|
assign andtree_out[2] = fourney_out[2] & zerodetect;
|
143 |
|
|
assign andtree_out[3] = fourney_out[3] & zerodetect;
|
144 |
|
|
assign andtree_out[4] = fourney_out[4] & zerodetect;
|
145 |
|
|
|
146 |
|
|
//assign errorvalue = andtree_out;
|
147 |
|
|
register5_wl erroreg(andtree_out, errorvalue, clock2, en_outfifo);
|
148 |
|
|
|
149 |
|
|
endmodule
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
//******************************************************//
|
153 |
|
|
// Modul-modul chien search cell dibentuk dgn perkalian //
|
154 |
|
|
|
155 |
|
|
//***********************************************//
|
156 |
|
|
// Module for terms whose degree is zero //
|
157 |
|
|
//***********************************************//
|
158 |
|
|
module degree0_cell(in, out, clock, load, compute);
|
159 |
|
|
|
160 |
|
|
input [4:0] in;
|
161 |
|
|
output [4:0] out;
|
162 |
|
|
input clock, compute, load;
|
163 |
|
|
wire [4:0] outmux, outreg;
|
164 |
|
|
|
165 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
166 |
|
|
mux2_to_1 multiplex(in, outreg, outmux, compute);
|
167 |
|
|
assign out = outreg;
|
168 |
|
|
|
169 |
|
|
endmodule
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
//********************************************************//
|
173 |
|
|
// Module that computes term with degree one. //
|
174 |
|
|
// Constructed by a variable-constant multiplier with //
|
175 |
|
|
// alpha^1 as constant. //
|
176 |
|
|
//********************************************************//
|
177 |
|
|
module degree1_cell(in, out, clock, load, compute);
|
178 |
|
|
|
179 |
|
|
input [4:0] in;
|
180 |
|
|
output [4:0] out;
|
181 |
|
|
input clock, load, compute;
|
182 |
|
|
wire [4:0] outmux;
|
183 |
|
|
wire [0:4] outmult, outreg;
|
184 |
|
|
|
185 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
186 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
187 |
|
|
|
188 |
|
|
//Multipy variable-alpha^1
|
189 |
|
|
assign outmult[0] = outreg[4];
|
190 |
|
|
assign outmult[1] = outreg[0];
|
191 |
|
|
assign outmult[2] = outreg[1] ^ outreg[4];
|
192 |
|
|
assign outmult[3] = outreg[2];
|
193 |
|
|
assign outmult[4] = outreg[3];
|
194 |
|
|
|
195 |
|
|
assign out = outreg;
|
196 |
|
|
|
197 |
|
|
endmodule
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
//********************************************************//
|
201 |
|
|
// Module that computes term with degree two.
|
202 |
|
|
// Constructed by a variable-constant multiplier with
|
203 |
|
|
// alpha^2 as constant. //
|
204 |
|
|
//********************************************************//
|
205 |
|
|
module degree2_cell(in, out, clock, load, compute);
|
206 |
|
|
|
207 |
|
|
input [4:0] in;
|
208 |
|
|
output [4:0] out;
|
209 |
|
|
input clock, load, compute;
|
210 |
|
|
wire [4:0] outmux;
|
211 |
|
|
wire [0:4] outmult, outreg;
|
212 |
|
|
|
213 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
214 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
215 |
|
|
|
216 |
|
|
//Multipy variable-alpha^2
|
217 |
|
|
assign outmult[0] = outreg[3];
|
218 |
|
|
assign outmult[1] = outreg[4];
|
219 |
|
|
assign outmult[2] = outreg[0] ^ outreg[3];
|
220 |
|
|
assign outmult[3] = outreg[1] ^ outreg[4];
|
221 |
|
|
assign outmult[4] = outreg[2];
|
222 |
|
|
|
223 |
|
|
assign out = outreg;
|
224 |
|
|
|
225 |
|
|
endmodule
|
226 |
|
|
|
227 |
|
|
//********************************************************//
|
228 |
|
|
// Module that computes term with degree three. //
|
229 |
|
|
// Constructed by a variable-constant multiplier with //
|
230 |
|
|
// alpha^3 as constant. //
|
231 |
|
|
//********************************************************//
|
232 |
|
|
module degree3_cell(in, out, clock, load, compute);
|
233 |
|
|
|
234 |
|
|
input [4:0] in;
|
235 |
|
|
output [4:0] out;
|
236 |
|
|
input clock, load, compute;
|
237 |
|
|
wire [4:0] outmux;
|
238 |
|
|
wire [0:4] outmult, outreg;
|
239 |
|
|
|
240 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
241 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
242 |
|
|
|
243 |
|
|
//Multipy variable-alpha^3
|
244 |
|
|
assign outmult[0] = outreg[2];
|
245 |
|
|
assign outmult[1] = outreg[3];
|
246 |
|
|
assign outmult[2] = outreg[2] ^ outreg[4];
|
247 |
|
|
assign outmult[3] = outreg[0] ^ outreg[3];
|
248 |
|
|
assign outmult[4] = outreg[1] ^ outreg[4];
|
249 |
|
|
|
250 |
|
|
assign out = outreg;
|
251 |
|
|
|
252 |
|
|
endmodule
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
//********************************************************//
|
256 |
|
|
// Module that computes term with degree four. //
|
257 |
|
|
// Constructed by a variable-constant multiplier with //
|
258 |
|
|
// alpha^4 as constant. //
|
259 |
|
|
//********************************************************//
|
260 |
|
|
module degree4_cell(in, out, clock, load, compute);
|
261 |
|
|
|
262 |
|
|
input [4:0] in;
|
263 |
|
|
output [4:0] out;
|
264 |
|
|
input clock, load, compute;
|
265 |
|
|
wire [4:0] outmux;
|
266 |
|
|
wire [0:4] outmult, outreg;
|
267 |
|
|
|
268 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
269 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
270 |
|
|
|
271 |
|
|
//Multipy variable-alpha^4
|
272 |
|
|
assign outmult[0] = outreg[1] ^ outreg[4];
|
273 |
|
|
assign outmult[1] = outreg[2];
|
274 |
|
|
assign outmult[2] = outreg[1] ^ outreg[3] ^ outreg[4];
|
275 |
|
|
assign outmult[3] = outreg[2] ^ outreg[4];
|
276 |
|
|
assign outmult[4] = outreg[0] ^ outreg[3];
|
277 |
|
|
|
278 |
|
|
assign out = outreg;
|
279 |
|
|
|
280 |
|
|
endmodule
|
281 |
|
|
|
282 |
|
|
//********************************************************//
|
283 |
|
|
// Module that computes term with degree five. //
|
284 |
|
|
// Constructed by a variable-constant multiplier with //
|
285 |
|
|
// alpha^5 as constant. //
|
286 |
|
|
//********************************************************//
|
287 |
|
|
module degree5_cell(in, out, clock, load, compute);
|
288 |
|
|
|
289 |
|
|
input [4:0] in;
|
290 |
|
|
output [4:0] out;
|
291 |
|
|
input clock, load, compute;
|
292 |
|
|
wire [4:0] outmux;
|
293 |
|
|
wire [0:4] outmult, outreg;
|
294 |
|
|
|
295 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
296 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
297 |
|
|
|
298 |
|
|
//Multipy variable-alpha^5
|
299 |
|
|
assign outmult[0] = outreg[0] ^ outreg[3];
|
300 |
|
|
assign outmult[1] = outreg[1] ^ outreg[4];
|
301 |
|
|
assign outmult[2] = outreg[0] ^ outreg[2] ^ outreg[3];
|
302 |
|
|
assign outmult[3] = outreg[1] ^ outreg[3] ^ outreg[4];
|
303 |
|
|
assign outmult[4] = outreg[2] ^ outreg[4];
|
304 |
|
|
|
305 |
|
|
assign out = outreg;
|
306 |
|
|
|
307 |
|
|
endmodule
|
308 |
|
|
|
309 |
|
|
//********************************************************//
|
310 |
|
|
// Module that computes term with degree six. //
|
311 |
|
|
// Constructed by a variable-constant multiplier with //
|
312 |
|
|
// alpha^6 as constant. //
|
313 |
|
|
//********************************************************//
|
314 |
|
|
module degree6_cell(in, out, clock, load, compute);
|
315 |
|
|
|
316 |
|
|
input [4:0] in;
|
317 |
|
|
output [4:0] out;
|
318 |
|
|
input clock, load, compute;
|
319 |
|
|
wire [4:0] outmux;
|
320 |
|
|
wire [0:4] outmult, outreg;
|
321 |
|
|
|
322 |
|
|
register5_wl register(outmux, outreg, clock, load);
|
323 |
|
|
mux2_to_1 multiplexer(in, outmult, outmux, compute);
|
324 |
|
|
|
325 |
|
|
//Multipy variable-alpha^6
|
326 |
|
|
assign outmult[0] = outreg[2] ^ outreg[4];
|
327 |
|
|
assign outmult[1] = outreg[0] ^ outreg[3];
|
328 |
|
|
assign outmult[2] = outreg[1] ^ outreg[2];
|
329 |
|
|
assign outmult[3] = outreg[0] ^ outreg[2] ^ outreg[3];
|
330 |
|
|
assign outmult[4] = outreg[1] ^ outreg[3] ^ outreg[4];
|
331 |
|
|
|
332 |
|
|
assign out = outreg;
|
333 |
|
|
|
334 |
|
|
endmodule
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
//***********************************************************//
|
338 |
|
|
// Invers Multiplication module for GF(2^5) is formed by AND //
|
339 |
|
|
// and XOR gates. This module is derived directly from //
|
340 |
|
|
// Fermat Theorem, which state that //
|
341 |
|
|
// beta^(-1) = beta^2.beta^(2^2).beta^(2^3).beta^(2^4), //
|
342 |
|
|
// for beta member of GF(2^5). //
|
343 |
|
|
// Note: this module is only used in CSEE block //
|
344 |
|
|
//***********************************************************//
|
345 |
|
|
module inverscomb(in, out);
|
346 |
|
|
|
347 |
|
|
input [0:4] in;
|
348 |
|
|
output [0:4] out;
|
349 |
|
|
|
350 |
|
|
//form product consists of AND gates
|
351 |
|
|
wire p0, p1, p2, p3, p4 , p5 , p6, p7, p8, p9,
|
352 |
|
|
p10, p11, p12, p13, p14, p15, p16, p17, p18,
|
353 |
|
|
p19, p20, p21, p22, p23, p24;
|
354 |
|
|
//form intermediate sum of the product that can be reused
|
355 |
|
|
wire s0, s1, s2, s3, s4, s5, s6;
|
356 |
|
|
|
357 |
|
|
//form intermediate sum of product that is only used by single function
|
358 |
|
|
wire t0, t1, t2;
|
359 |
|
|
|
360 |
|
|
assign p0 = in[0]&in[1];
|
361 |
|
|
assign p1 = in[0]&in[2];
|
362 |
|
|
assign p2 = in[0]&in[3];
|
363 |
|
|
assign p3 = in[0]&in[4];
|
364 |
|
|
assign p4 = in[1]&in[2];
|
365 |
|
|
assign p5 = in[1]&in[3];
|
366 |
|
|
assign p6 = in[1]&in[4];
|
367 |
|
|
assign p7 = in[2]&in[4];
|
368 |
|
|
assign p8 = in[3]&in[4];
|
369 |
|
|
assign p9 = in[2]&in[3];
|
370 |
|
|
assign p10 = p0&in[2];
|
371 |
|
|
assign p11 = p0&in[4];
|
372 |
|
|
assign p12 = p2&in[4];
|
373 |
|
|
assign p13 = p9&in[0];
|
374 |
|
|
assign p14 = p4&in[3];
|
375 |
|
|
assign p15 = p8&in[2];
|
376 |
|
|
assign p16 = p7&in[1];
|
377 |
|
|
assign p17 = p2&in[1];
|
378 |
|
|
assign p18 = p3&in[2];
|
379 |
|
|
assign p19 = p6&in[3];
|
380 |
|
|
assign p20 = p4&p8;
|
381 |
|
|
assign p21 = p1&p5;
|
382 |
|
|
assign p22 = p3&p5;
|
383 |
|
|
assign p23 = p2&p7;
|
384 |
|
|
assign p24 = p1&p6;
|
385 |
|
|
|
386 |
|
|
assign s0 = p1 ^ p15;
|
387 |
|
|
assign s1 = ((p6 ^ p12) ^ p14);
|
388 |
|
|
assign s2 = (in[4] ^ p0) ^ p21;
|
389 |
|
|
assign s3 = (in[1] ^ in[3]) ^ (p2 ^ p3) ^ (p24 ^ p10);
|
390 |
|
|
assign s4 = (p4 ^ p5) ^ (p20 ^ p7) ^ p17;
|
391 |
|
|
assign s5 = (in[2] ^ p5) ^ (p22 ^ p23);
|
392 |
|
|
assign s6 = p11 ^ p20;
|
393 |
|
|
|
394 |
|
|
assign t0 = (in[0] ^ p2) ^ (p4 ^ p10);
|
395 |
|
|
assign t1 = (in[3] ^ p0) ^ p24;
|
396 |
|
|
assign t2 = p19 ^ p23;
|
397 |
|
|
|
398 |
|
|
assign out[0] = ((s0 ^ s1) ^ (s2 ^ s5)) ^ ((s6 ^ p13) ^ t0);
|
399 |
|
|
assign out[1] = ((s0 ^ s1) ^ s2) ^ (s3 ^ (s6 ^ p16));
|
400 |
|
|
assign out[2] = (s0 ^ s4) ^ ((p13 ^ p8) ^ t1);
|
401 |
|
|
assign out[3] = ((s0 ^ s1) ^ (s2 ^ s5)) ^ ((p16 ^ p8) ^ (p9 ^ p18) ^ p7);
|
402 |
|
|
assign out[4] = (s0 ^ s1) ^ (s3 ^ s4) ^ (p9 ^ t2);
|
403 |
|
|
|
404 |
|
|
endmodule
|