OpenCores
URL https://opencores.org/ocsvn/reed_solomon_decoder/reed_solomon_decoder/trunk

Subversion Repositories reed_solomon_decoder

[/] [reed_solomon_decoder/] [trunk/] [rtl/] [RS_dec.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 aelmahmoud
/* This program is free software: you can redistribute it and/or modify
2
   it under the terms of the GNU General Public License as published by
3
   the Free Software Foundation, either version 3 of the License, or
4
   (at your option) any later version.
5
 
6
   This program is distributed in the hope that it will be useful,
7
   but WITHOUT ANY WARRANTY; without even the implied warranty of
8
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9
   GNU General Public License for more details.
10
 
11
   You should have received a copy of the GNU General Public License
12
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
13
 
14
   Email : semiconductors@varkongroup.com
15
   Tel   : 1-732-447-8611
16
 
17
*/
18
 
19
 
20
 
21
module RS_dec
22
//////////// integration of decoder blocks
23
(
24
  input clk, // input clock 
25
  input reset, // active high asynchronous reset
26
  input CE, // chip enable active high flag for one clock with every input byte (minimum spaceing 8 clocks)
27
  input [7:0] input_byte, // input byte
28
 
29
  output [7:0] Out_byte,   // output byte
30
  output CEO,  // chip enable for the next block will be active high for one clock , every 8 clks
31
  output Valid_out /// valid out for every output block (188 byte)
32
);
33
 
34
 
35
wire CEO_0;
36
 
37
///////////////////////////////////////assigns////////////////////////
38
assign CEO = CEO_0 && Valid_out ;
39
 
40
//////////////////////////////// input_syndromes/////////////////
41
wire S_ready;  // active high flag for one clock to indicate that syndromes is ready 
42
/// syndromes decimal values
43
wire [7:0] s0,s1,s2,s3,s4,s5,s6,s7;
44
wire [7:0] s8,s9,s10,s11,s12,s13,s14,s15;
45
 
46
wire [7:0] In_mem_Read_byte;
47
wire [7:0] In_mem_R_Add;
48
wire  In_mem_RE;
49
 
50
/////////////////////////////////////////////////////////////
51
input_syndromes input_syndromes_unit
52
(
53
.clk(clk),
54
.reset(reset),
55
.CE(CE),  // chip enable active high flag should be active for one clock with every input
56
.input_byte(input_byte), // input byte
57
 
58
//////////////////////////////////////
59
.R_Add(In_mem_R_Add),
60
.RE(In_mem_RE),
61
.Read_byte(In_mem_Read_byte),
62
 
63
/// syndromes 16 elements
64
.S_Ready(S_ready),
65
.s0(s0),.s1(s1),.s2(s2),.s3(s3),.s4(s4),.s5(s5),.s6(s6),.s7(s7),
66
.s8(s8),.s9(s9),.s10(s10),.s11(s11),.s12(s12),.s13(s13),.s14(s14),.s15(s15)
67
 
68
);
69
 
70
/////////////////transport_in2out////////////////////////////////////
71
wire WE_transport;
72
wire [7:0]WrAdd_transport;
73
 
74
wire transport_done;
75
////////////////////////////////////////////////////////////////
76
transport_in2out  transport_in2out_unit
77
(
78
 
79
.clk(clk),
80
.reset(reset),
81
 
82
.S_Ready(S_ready),
83
 
84
.RE(In_mem_RE),
85
.RdAdd(In_mem_R_Add),
86
 
87
.WE(WE_transport),
88
.WrAdd(WrAdd_transport),
89
 
90
.Wr_done(transport_done)
91
 
92
);
93
 
94
 
95
////////BM_lamda//////////////////////////////////////////////////////////
96
wire  L_ready;  // active high flag for one clock to indicate that lamda polynomial is ready
97
wire [7:0] L1,L2,L3,L4,L5,L6,L7,L8;   ///  lamda coeff values in decimal format 
98
 
99
reg [7:0] pow1_BM_lamda,pow2_BM_lamda;
100
reg [7:0] dec1_BM_lamda;
101
 
102
wire  [7:0] add_pow1_BM_lamda,add_pow2_BM_lamda;
103
wire  [7:0] add_dec1_BM_lamda;
104
 
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
BM_lamda   BM_lamda_unit
107
(
108
.clk(clk),
109
.reset(reset),
110
 
111
.erasure_ready(1'b0),
112
.erasure_cnt(4'b0),
113
 
114
 
115
.Sm_ready(S_ready),
116
.Sm1(s0),
117
.Sm2(s1),
118
.Sm3(s2),
119
.Sm4(s3),
120
.Sm5(s4),
121
.Sm6(s5),
122
.Sm7(s6),
123
.Sm8(s7),
124
.Sm9(s8),
125
.Sm10(s9),
126
.Sm11(s10),
127
.Sm12(s11),
128
.Sm13(s12),
129
.Sm14(s13),
130
.Sm15(s14),
131
.Sm16(s15),
132
 
133
 
134
 
135
 
136
.add_pow1(add_pow1_BM_lamda),
137
.add_pow2(add_pow2_BM_lamda),
138
 
139
.add_dec1(add_dec1_BM_lamda),
140
 
141
 
142
 
143
.pow1(pow1_BM_lamda),
144
.pow2(pow2_BM_lamda),
145
 
146
.dec1(dec1_BM_lamda),
147
 
148
 
149
 
150
 
151
.L_ready(L_ready),
152
.L1(L1),
153
.L2(L2),
154
.L3(L3),
155
.L4(L4),
156
.L5(L5),
157
.L6(L6),
158
.L7(L7),
159
.L8(L8)
160
 
161
);
162
 
163
////////////lamda_roots////////////////////////////////////////////////////////////////
164
wire roots_ready;
165
wire [3:0] root_cnt;  //from 0 to 8
166
wire [7:0] r1,r2,r3,r4,r5,r6,r7,r8; // output roots of lamda polynomial (decimal) up to 8 roots
167
 
168
reg [7:0] pow1_lamda_roots;
169
reg [7:0] dec1_lamda_roots,dec2_lamda_roots,dec3_lamda_roots;
170
 
171
wire  [7:0] add_pow1_lamda_roots;
172
wire  [7:0] add_dec1_lamda_roots,add_dec2_lamda_roots,add_dec3_lamda_roots;
173
 
174
////////////////////////////////////////////////////////////////////////////////////////
175
lamda_roots lamda_roots_unit
176
(
177
.CE(L_ready),
178
.clk(clk),
179
.reset(reset),
180
 
181
.Lc0(8'h01),   // always equals one 
182
.Lc1(L1),
183
.Lc2(L2),
184
.Lc3(L3),
185
.Lc4(L4),
186
.Lc5(L5),
187
.Lc6(L6),
188
.Lc7(L7),
189
.Lc8(L8),
190
 
191
.add_GF_ascending(add_pow1_lamda_roots),
192
.add_GF_dec0(add_dec1_lamda_roots),
193
.add_GF_dec1(add_dec2_lamda_roots),
194
.add_GF_dec2(add_dec3_lamda_roots),
195
 
196
.power(pow1_lamda_roots),
197
.decimal0(dec1_lamda_roots),
198
.decimal1(dec2_lamda_roots),
199
.decimal2(dec3_lamda_roots),
200
 
201
.CEO(roots_ready),
202
.root_cnt(root_cnt), ///  up to 8
203
.r1(r1),
204
.r2(r2),
205
.r3(r3),
206
.r4(r4),
207
.r5(r5),
208
.r6(r6),
209
.r7(r7),
210
.r8(r8)
211
);
212
 
213
///////////Omega_Phy//////////////////////////////////////////////////////////////////////
214
wire  poly_ready ;  // active high flag for one clock to indicate that Phy and Omega polynomials are ready
215
 
216
wire   [7:0] O1;    // decimal value of first coeff of Omega polynomial
217
wire   [7:0] O2,O3,O4,O5,O6,O7,O8,O9,O10,O11,O12,O13,O14,O15,O16;  /// power values of omega polynomial coeff from 2:16
218
 
219
wire   [7:0] P1;    // decimal value of first coeff of Phy polynomial
220
wire   [7:0] P3,P5,P7;  /// power values of Phy polynomial coeff 
221
 
222
reg [7:0] dec1_Omega_Phy;
223
reg [7:0] pow1_Omega_Phy,pow2_Omega_Phy,pow3_Omega_Phy;
224
 
225
wire  [7:0] add_dec1_Omega_Phy;
226
wire  [7:0] add_pow1_Omega_Phy,add_pow2_Omega_Phy,add_pow3_Omega_Phy;
227
 
228
 
229
////////////////////////////////////////////////////////////////////////////////////
230
Omega_Phy   Omega_Phy_unit
231
(
232
.clk(clk),
233
.reset(reset),
234
 
235
 
236
.Sm_ready(S_ready),
237
.Sm1(s0),
238
.Sm2(s1),
239
.Sm3(s2),
240
.Sm4(s3),
241
.Sm5(s4),
242
.Sm6(s5),
243
.Sm7(s6),
244
.Sm8(s7),
245
.Sm9(s8),
246
.Sm10(s9),
247
.Sm11(s10),
248
.Sm12(s11),
249
.Sm13(s12),
250
.Sm14(s13),
251
.Sm15(s14),
252
.Sm16(s15),
253
 
254
 
255
 
256
 
257
 
258
.add_pow1(add_pow1_Omega_Phy),
259
.add_pow2(add_pow2_Omega_Phy),
260
.add_pow3(add_pow3_Omega_Phy),
261
 
262
.add_dec1(add_dec1_Omega_Phy),
263
 
264
 
265
 
266
.pow1(pow1_Omega_Phy),
267
.pow2(pow2_Omega_Phy),
268
.pow3(pow3_Omega_Phy),
269
 
270
.dec1(dec1_Omega_Phy),
271
 
272
 
273
 
274
 
275
.L_ready(L_ready),
276
.L1(L1),
277
.L2(L2),
278
.L3(L3),
279
.L4(L4),
280
.L5(L5),
281
.L6(L6),
282
.L7(L7),
283
.L8(L8) ,
284
 
285
 
286
 
287
.poly_ready(poly_ready),
288
.O1(O1),
289
.O2(O2),
290
.O3(O3),
291
.O4(O4),
292
.O5(O5),
293
.O6(O6),
294
.O7(O7),
295
.O8(O8),
296
.O9(O9),
297
.O10(O10),
298
.O11(O11),
299
.O12(O12),
300
.O13(O13),
301
.O14(O14),
302
.O15(O15),
303
.O16(O16),
304
 
305
.P1(P1),
306
.P3(P3),
307
.P5(P5),
308
.P7(P7)
309
 
310
);
311
 
312
//////////////////error_correction///////////////////////////////////////////
313
wire RE_error_correction,WE_error_correction;
314
//// write and read enable for input block storage memory
315
wire  [7:0] Address_error_correction;   //// address to input block storage memory
316
wire  [7:0] correction_value;     //// corrected value  =  initial value xor  correction
317
reg [7:0] initial_value;  //// input initial value
318
 
319
wire  DONE;
320
 
321
 
322
reg [7:0] pow1_error_correction,pow2_error_correction,pow3_error_correction,pow4_error_correction;
323
reg [7:0] dec1_error_correction,dec2_error_correction,dec3_error_correction,dec4_error_correction;
324
 
325
wire  [7:0] add_pow1_error_correction,add_pow2_error_correction,add_pow3_error_correction,add_pow4_error_correction;
326
wire  [7:0] add_dec1_error_correction,add_dec2_error_correction,add_dec3_error_correction,add_dec4_error_correction;
327
 
328
 
329
////////////////////////////////////////////////////////////////////////////////
330
error_correction   error_correction_unit
331
(
332
.clk(clk), // .clock 
333
.reset(reset), // active high asynchronous reset
334
 
335
 
336
 
337
 
338
 
339
.add_pow1(add_pow1_error_correction),
340
.add_pow2(add_pow2_error_correction),
341
.add_pow3(add_pow3_error_correction),
342
.add_pow4(add_pow4_error_correction),
343
 
344
.add_dec1(add_dec1_error_correction),
345
.add_dec2(add_dec2_error_correction),
346
.add_dec3(add_dec3_error_correction),
347
.add_dec4(add_dec4_error_correction),
348
 
349
 
350
 
351
.pow1(pow1_error_correction),
352
.pow2(pow2_error_correction),
353
.pow3(pow3_error_correction),
354
.pow4(pow4_error_correction),
355
 
356
.dec1(dec1_error_correction),
357
.dec2(dec2_error_correction),
358
.dec3(dec3_error_correction),
359
.dec4(dec4_error_correction),
360
 
361
 
362
 
363
 
364
.roots_ready(roots_ready),
365
.root_count(root_cnt),
366
.r1(r1),
367
.r2(r2),
368
.r3(r3),
369
.r4(r4),
370
.r5(r5),
371
.r6(r6),
372
.r7(r7),
373
.r8(r8) ,
374
 
375
 
376
 
377
.poly_ready(poly_ready),
378
.O1(O1),
379
.O2(O2),
380
.O3(O3),
381
.O4(O4),
382
.O5(O5),
383
.O6(O6),
384
.O7(O7),
385
.O8(O8),
386
.O9(O9),
387
.O10(O10),
388
.O11(O11),
389
.O12(O12),
390
.O13(O13),
391
.O14(O14),
392
.O15(O15),
393
.O16(O16),
394
 
395
.P1(P1),
396
.P3(P3),
397
.P5(P5),
398
.P7(P7),
399
 
400
.RE(RE_error_correction),
401
.WE(WE_error_correction),
402
.Address(Address_error_correction),
403
.correction_value(correction_value),
404
.initial_value(initial_value),
405
 
406
.DONE(DONE)
407
 
408
);
409
 
410
///////////////////////out_stage//////////////////////////////////////////////////////////
411
wire RE_out_stage;
412
wire [7:0] RdAdd_out_stage;
413
reg [7:0] In_byte_out_stage;
414
 
415
wire out_done;
416
 
417
reg DONE_ext;   /// if DONE comes before out_stage is completed , extend DONE for the next block
418
/////////////////////////////////////////////////////////////////////////////////////////////
419
out_stage   out_stage_unit
420
(
421
.clk(clk),
422
.reset(reset),
423
 
424
.DONE(DONE || DONE_ext),
425
 
426
.RE(RE_out_stage),
427
 
428
.RdAdd(RdAdd_out_stage),
429
 
430
.In_byte(In_byte_out_stage),
431
 
432
.Out_byte(Out_byte),
433
.CEO(CEO_0),
434
.Valid_out(Valid_out),
435
 
436
.out_done(out_done)
437
);
438
 
439
 
440
//////////////////out_memories//////////////////////////////////////////////////////////
441
reg RE1,WE1,RE2,WE2;
442
reg [7:0] R_Add1,W_Add1,R_Add2,W_Add2;
443
wire [7:0] out_byte1,out_byte2;
444
reg   [7:0] input_byte1,input_byte2;
445
////////////////////////////////////////////////////////////////////////////////////////////
446
DP_RAM #(.num_words(188),.address_width(8),.data_width(8))
447
mem_out_1
448
(
449
.clk(clk),
450
.we(WE1),
451
.re(RE1),
452
.address_read(R_Add1),
453
.address_write(W_Add1),
454
.data_in(input_byte1),
455
.data_out(out_byte1)
456
);
457
 
458
DP_RAM #(.num_words(188),.address_width(8),.data_width(8))
459
mem_out_2
460
(
461
.clk(clk),
462
.we(WE2),
463
.re(RE2),
464
.address_read(R_Add2),
465
.address_write(W_Add2),
466
.data_in(input_byte2),
467
.data_out(out_byte2)
468
);
469
 
470
///////////////////////////////////////////////////////////////////////////////////
471
/////// GF Roms////////////////////////////////////////////////////////////////////
472
 
473
wire [7:0] pow1,pow2,pow3,pow4;    /// output of power memories
474
wire [7:0] dec1,dec2,dec3,dec4;        /// output of decimal memories
475
 
476
reg  [7:0] add_pow1,add_pow2,add_pow3,add_pow4;  /// address to power memories
477
reg  [7:0] add_dec1,add_dec2,add_dec3,add_dec4;    /// address to decimal memories
478
 
479
////// instant of GF_matrix_ascending_binary Rom////////////////////////////////////
480
GF_matrix_ascending_binary   power_rom_instant1
481
(
482
.clk(clk),
483
.re(1'b1),
484
.address_read(add_pow1),
485
.data_out(pow1)
486
);
487
/////// instant of GF_matrix_ascending_binary Rom////////////////////////////////////
488
GF_matrix_ascending_binary   power_rom_instant2
489
(
490
.clk(clk),
491
.re(1'b1),
492
.address_read(add_pow2),
493
.data_out(pow2)
494
);
495
///////// instant of GF_matrix_ascending_binary Rom////////////////////////////////////
496
GF_matrix_ascending_binary   power_rom_instant3
497
(
498
.clk(clk),
499
.re(1'b1),
500
.address_read(add_pow3),
501
.data_out(pow3)
502
);
503
////// instant of GF_matrix_ascending_binary Rom////////////////////////////////////
504
GF_matrix_ascending_binary   power_rom_instant4
505
(
506
.clk(clk),
507
.re(1'b1),
508
.address_read(add_pow4),
509
.data_out(pow4)
510
);
511
//////////GF_matrix_dec Rom //////////////////////////
512
GF_matrix_dec rom_instant_1
513
(
514
.clk(clk),
515
.re(1'b1),
516
.address_read(add_dec1),
517
.data_out(dec1)
518
);
519
//////////GF_matrix_dec Rom //////////////////////////
520
GF_matrix_dec rom_instant_2
521
(
522
.clk(clk),
523
.re(1'b1),
524
.address_read(add_dec2),
525
.data_out(dec2)
526
);
527
 
528
//////////GF_matrix_dec Rom //////////////////////////
529
GF_matrix_dec rom_instant_3
530
(
531
.clk(clk),
532
.re(1'b1),
533
.address_read(add_dec3),
534
.data_out(dec3)
535
);
536
 
537
//////////GF_matrix_dec Rom //////////////////////////
538
GF_matrix_dec rom_instant_4
539
(
540
.clk(clk),
541
.re(1'b1),
542
.address_read(add_dec4),
543
.data_out(dec4)
544
);
545
 
546
/////////////////////////////////////////////////////////////
547
 
548
/////////////////////////////////////////////////////////////////////////
549
///////////////////////////////////////////////Main FSM//////////////////
550
/////////////////////////////////////////////////////////////////////////
551
 
552
reg S_flag,L_flag,R_flag,T_flag,out_flag;
553
 
554
parameter state1  = 6'b000001;
555
parameter state2  = 6'b000010;
556
parameter state3  = 6'b000100;
557
parameter state4  = 6'b001000;
558
parameter state5  = 6'b010000;
559
parameter state6  = 6'b100000;
560
reg [5:0] state = state1;
561
 
562
 
563
 
564
always@(posedge clk or posedge reset)
565
begin
566
        if(reset)
567
                begin
568
                        S_flag<=0;L_flag<=0;R_flag<=0;T_flag<=0;
569
                        out_flag<=0;
570
                        DONE_ext<=0;
571
                        state<=state1;
572
                end
573
        else
574
                begin
575
 
576
                        ///////////////////////////////////////////////////////////////////////////////////
577
                        if(S_ready)
578
                                begin
579
                                        T_flag<=1;
580
                                end
581
 
582
                        if(transport_done)
583
                                begin
584
                                        T_flag<=0;
585
                                end
586
                        ///////////////////////////////////////////////////////////////////////////////////
587
                        if(DONE )
588
                                out_flag<=1;
589
                        if(out_done && !DONE_ext && !DONE)
590
                                out_flag<=0;
591
                        ///////////////////////////////////////////////////////////////////////////////////
592
                        if(DONE  && out_flag && !out_done)
593
                        ///when error correction is done before out_stage end past operation, DONE_ext will be used
594
                                DONE_ext<=1;
595
                        if(out_done)
596
                        ///// when out_stage is done no need for the DONE_ext flag as the out_stage block has allready use it
597
                                DONE_ext<=0;
598
                        ///////////////////////////////////////////////////////////////////////////////////
599
 
600
                        case(state)
601
                        /////////////////////////////////////////////////////////////////////
602
                        state1:begin
603
                                if(S_ready)
604
                                        begin
605
                                                S_flag<=1;
606
                                                state<=state2;
607
                                        end
608
                        end
609
                        ////////////////////////////////////////////////////////////
610
                        state2:begin
611
                                if(L_ready)
612
                                        begin
613
                                                S_flag<=0;
614
                                                L_flag<=1;
615
                                                state<=state3;
616
                                        end
617
                        end
618
                        ////////////////////////////////////////////////////////////
619
                        state3:begin
620
                                if(roots_ready)
621
                                        begin
622
                                                L_flag<=0;
623
                                                R_flag<=1;
624
                                                state<=state4;
625
                                        end
626
                        end
627
                        ////////////////////////////////////////////////////////////////
628
                        default:begin   ///state4
629
                                if(DONE)
630
                                        begin
631
                                                R_flag<=0;
632
                                                state<=state1;
633
                                        end
634
                        end
635
                        /////////////////////////////////////////////////////////////
636
 
637
                        endcase
638
                end
639
end
640
 
641
 
642
wire [2:0] control;
643
 
644
assign control ={R_flag,L_flag,S_flag};
645
 
646
 
647
////////////////    GF memories switching ////////////////////
648
always@(*)
649
begin
650
 
651
        ////////////////////////////////////////////////////////////////////////////
652
        add_pow1<=0;
653
        add_pow2<=0;
654
        add_pow3<=0;
655
        add_pow4<=0;
656
        add_dec1<=0;
657
        add_dec2<=0;
658
        add_dec3<=0;
659
        add_dec4<=0;
660
        pow1_BM_lamda<=0;
661
        pow2_BM_lamda<=0;
662
        dec1_BM_lamda<=0;
663
        pow1_lamda_roots<=0;
664
        pow1_Omega_Phy<=0;
665
        pow2_Omega_Phy<=0;
666
        pow3_Omega_Phy<=0;
667
        dec1_lamda_roots<=0;
668
        dec2_lamda_roots<=0;
669
        dec3_lamda_roots<=0;
670
        dec1_Omega_Phy<=0;
671
        pow1_error_correction<=0;
672
        pow2_error_correction<=0;
673
        pow3_error_correction<=0;
674
        pow4_error_correction<=0;
675
        dec1_error_correction<=0;
676
        dec2_error_correction<=0;
677
        dec3_error_correction<=0;
678
        dec4_error_correction<=0;
679
        ////////////////////////////////////////////////////////////////////////////
680
        case (control)
681
        ///////////////////////////////////////////////////////////////////////////
682
                3'b001:begin
683
                        add_pow1<=add_pow1_BM_lamda;
684
                        add_pow2<=add_pow2_BM_lamda;
685
 
686
                        add_dec1<=add_dec1_BM_lamda;
687
 
688
                        pow1_BM_lamda<=pow1;
689
                        pow2_BM_lamda<=pow2;
690
 
691
                        dec1_BM_lamda<=dec1;
692
                end
693
        /////////////////////////////////////////////////////////////////////////
694
                3'b010:begin
695
                        add_pow1<=add_pow1_lamda_roots;
696
                        add_pow2<=add_pow1_Omega_Phy;
697
                        add_pow3<=add_pow2_Omega_Phy;
698
                        add_pow4<=add_pow3_Omega_Phy;
699
 
700
                        add_dec1<=add_dec1_lamda_roots;
701
                        add_dec2<=add_dec2_lamda_roots;
702
                        add_dec3<=add_dec3_lamda_roots;
703
                        add_dec4<=add_dec1_Omega_Phy;
704
 
705
                        pow1_lamda_roots<=pow1;
706
                        pow1_Omega_Phy<=pow2;
707
                        pow2_Omega_Phy<=pow3;
708
                        pow3_Omega_Phy<=pow4;
709
 
710
                        dec1_lamda_roots<=dec1;
711
                        dec2_lamda_roots<=dec2;
712
                        dec3_lamda_roots<=dec3;
713
                        dec1_Omega_Phy<=dec4;
714
                end
715
        //////////////////////////////////////////////////////////////////////////////////////          
716
                3'b100:begin
717
                        add_pow1<=add_pow1_error_correction;
718
                        add_pow2<=add_pow2_error_correction;
719
                        add_pow3<=add_pow3_error_correction;
720
                        add_pow4<=add_pow4_error_correction;
721
 
722
                        add_dec1<=add_dec1_error_correction;
723
                        add_dec2<=add_dec2_error_correction;
724
                        add_dec3<=add_dec3_error_correction;
725
                        add_dec4<=add_dec4_error_correction;
726
 
727
                        pow1_error_correction<=pow1;
728
                        pow2_error_correction<=pow2;
729
                        pow3_error_correction<=pow3;
730
                        pow4_error_correction<=pow4;
731
 
732
                        dec1_error_correction<=dec1;
733
                        dec2_error_correction<=dec2;
734
                        dec3_error_correction<=dec3;
735
                        dec4_error_correction<=dec4;
736
 
737
                end
738
        ////////////////////////////////////////////////////////////////////////////////
739
        endcase
740
end
741
///////////////////////////////////////////////////////////////////////////////////////////////////
742
 
743
 
744
 
745
///////  Wrting control for out_memories ///////////////////////////////
746
always@(posedge clk or posedge reset)
747
begin
748
        if(reset)
749
                begin
750
                        WE1<=0;
751
                        WE2<=0;
752
 
753
                        W_Add1<=0;
754
                        W_Add2<=0;
755
 
756
                        input_byte1<=0;
757
                        input_byte2<=0;
758
                end
759
 
760
        else
761
                begin
762
 
763
                        if(T_flag)
764
                                begin
765
/////////////////////////////////////////////////transport_in2out
766
                                                if (WE_transport )
767
                                                        begin
768
                                                                WE1<=1;
769
                                                                WE2<=0;
770
 
771
                                                                W_Add1<=WrAdd_transport;
772
                                                                W_Add2<=0;
773
 
774
                                                                input_byte1<=In_mem_Read_byte;
775
                                                                input_byte2<=0;
776
                                                        end
777
                                                else
778
                                                        begin
779
                                                                WE2<=1;
780
                                                                WE1<=0;
781
 
782
                                                                W_Add2<=WrAdd_transport;
783
                                                                W_Add1<=0;
784
 
785
                                                                input_byte2<=In_mem_Read_byte;
786
                                                                input_byte1<=0;
787
                                                        end
788
                                end
789
 
790
                        else
791
                                begin
792
//////////////////////////////////////////////////error correction
793
                                                if (WE_transport )
794
                                                        begin
795
                                                                WE1<=WE_error_correction;
796
                                                                WE2<=0;
797
 
798
                                                                W_Add1<=Address_error_correction;
799
                                                                W_Add2<=0;
800
 
801
                                                                input_byte1<=correction_value;
802
                                                                input_byte2<=0;
803
                                                        end
804
                                                else
805
                                                        begin
806
                                                                WE2<=WE_error_correction;
807
                                                                WE1<=0;
808
 
809
                                                                W_Add2<=Address_error_correction;
810
                                                                W_Add1<=0;
811
 
812
                                                                input_byte2<=correction_value;
813
                                                                input_byte1<=0;
814
                                                        end
815
///////////////////////////////////////////////////////////////////////////////////////////////////////////
816
                                end
817
                end
818
end
819
 
820
/////////////////////////////////  Reading control for out_memories ///////////////////////////////
821
always@(posedge clk or posedge reset)
822
begin
823
        if(reset)
824
                begin
825
                        RE1<=0;
826
                        RE2<=0;
827
                        R_Add1<=0;
828
                        R_Add2<=0;
829
                        initial_value<=0;
830
                        In_byte_out_stage<=0;
831
                end
832
        else
833
                begin
834
                        if(R_flag)
835
                                begin
836
                                        if (WE_transport )
837
                                                begin
838
                                                        RE1<=RE_error_correction;
839
                                                        R_Add1<=Address_error_correction;
840
                                                        initial_value<=out_byte1;
841
                                                end
842
                                        else
843
                                                begin
844
                                                        RE2<=RE_error_correction;
845
                                                        R_Add2<=Address_error_correction;
846
                                                        initial_value<=out_byte2;
847
                                                end
848
                                end
849
 
850
                        if(out_flag)
851
                                begin
852
                                        if(RE_out_stage)
853
                                                begin
854
                                                        RE1<=1;
855
                                                        R_Add1<=RdAdd_out_stage;
856
                                                        In_byte_out_stage<=out_byte1;
857
                                                end
858
                                        else
859
                                                begin
860
                                                        RE2<=1;
861
                                                        R_Add2<=RdAdd_out_stage;
862
                                                        In_byte_out_stage<=out_byte2;
863
                                                end
864
                                end
865
                end
866
end
867
 
868
endmodule
869
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.