OpenCores
URL https://opencores.org/ocsvn/bluespec-reedsolomon/bluespec-reedsolomon/trunk

Subversion Repositories bluespec-reedsolomon

[/] [bluespec-reedsolomon/] [trunk/] [sw-reedsolomon/] [rs_decode.cpp] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 abhiag
//----------------------------------------------------------------------//
2
// The MIT License 
3
// 
4
// Copyright (c) 2008 Abhinav Agarwal, Alfred Man Cheuk Ng
5
// Contact: abhiag@gmail.com
6
// 
7
// Permission is hereby granted, free of charge, to any person 
8
// obtaining a copy of this software and associated documentation 
9
// files (the "Software"), to deal in the Software without 
10
// restriction, including without limitation the rights to use,
11
// copy, modify, merge, publish, distribute, sublicense, and/or sell
12
// copies of the Software, and to permit persons to whom the
13
// Software is furnished to do so, subject to the following conditions:
14
// 
15
// The above copyright notice and this permission notice shall be
16
// included in all copies or substantial portions of the Software.
17
// 
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
// OTHER DEALINGS IN THE SOFTWARE.
26
//----------------------------------------------------------------------//
27
 
28
#include "global_rs.h"
29
#include "syndrome.h"
30
#include "berlekamp.h"
31
#include "chien_search.h"
32
#include "error_mag.h"
33
#include "error_correct.h"
34
#include "rs_fifo.h"
35
 
36 9 abhiag
 
37 4 abhiag
// Top level decoder module
38
void rs_decode (unsigned char n, unsigned char t, unsigned char in_d[nn],
39
                unsigned char *k, unsigned char out_d[kk])
40
{
41
   unsigned char temp_k = n - 2*t;
42
   unsigned char s[2*tt];
43
   unsigned char c[tt+2];
44
   unsigned char w[tt+2];
45
   unsigned char lambda[tt];
46
   unsigned char omega[tt];
47
   unsigned char err_no;
48
   unsigned char err_loc[kk];
49
   unsigned char alpha_inv[tt];
50
   unsigned char err[kk];
51
   unsigned char in_data[kk];
52
   unsigned char in_d_2[nn];
53
 
54 9 abhiag
   // Create copy of input to pass to fifo to error corrector
55
   // Directive: Unroll loop maximally
56 4 abhiag
Simple_rs1:   for (int i = 0; i < nn; i++)
57
       in_d_2[i] = in_d[i];
58
 
59
   *k = temp_k;
60
   rs_fifo(temp_k, in_d, in_data);
61
   syndrome(temp_k, t, in_d_2, s);
62
   berlekamp(t, s, lambda, omega);
63
   chien_search(kk, tt, lambda, &err_no, err_loc, alpha_inv);
64
   error_mag(kk, lambda, omega, err_no, err_loc, alpha_inv, err);
65
   error_correct(temp_k, in_data, err, out_d);
66
 
67
}

powered by: WebSVN 2.1.0

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