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

Subversion Repositories bluespec-reedsolomon

[/] [bluespec-reedsolomon/] [trunk/] [sw-reedsolomon/] [error_mag.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 "gf_arith.h"
30
#include "error_mag.h"
31
 
32 9 abhiag
// Directive: Synthesize independently
33 4 abhiag
unsigned char poly_eval_inst1 (unsigned char poly[tt], unsigned char alpha_inv)
34
{
35
   return poly_eval(poly, alpha_inv);
36
}
37
 
38 9 abhiag
// Directive: Synthesize independently
39 4 abhiag
unsigned char poly_eval_inst2 (unsigned char poly[tt], unsigned char alpha_inv)
40
{
41
   return poly_eval(poly, alpha_inv);
42
}
43
 
44 9 abhiag
// Directive: Synthesize independently
45 4 abhiag
unsigned char gfdiv_lut_inst (unsigned char dividend, unsigned char divisor)
46
{
47
  return gfdiv_lut(dividend, divisor);
48
}
49
 
50 9 abhiag
// Directive: Synthesize independently
51 4 abhiag
void compute_deriv_inst (unsigned char lambda[tt], unsigned char lambda_deriv[tt])
52
{
53
   compute_deriv(lambda, lambda_deriv);
54
}
55
 
56
 
57 9 abhiag
// Directive: Synthesize independently
58 4 abhiag
void error_mag(unsigned char k, unsigned char lambda[tt], unsigned char omega[tt], unsigned char err_no, unsigned char err_loc[tt], unsigned char alpha_inv[tt],
59
               unsigned char err[kk])
60
{
61
    int loc_idx = 0;
62
    unsigned char lambda_val = 0;
63
    unsigned char omega_val = 0;
64
    unsigned char lambda_deriv[tt];
65
    unsigned char err_temp[tt];
66
 
67
    compute_deriv(lambda, lambda_deriv);
68
    for (int i = 0; i < tt; i++)
69
    {
70
        lambda_val  = poly_eval_inst1(lambda_deriv, alpha_inv[i]);
71
        omega_val   = poly_eval_inst2(omega, alpha_inv[i]);
72
        err_temp[i] = gfdiv_lut_inst(omega_val, lambda_val);
73
    }
74
 
75
    for (int i = 0; i < kk; i++)
76
    {
77
        if ((err_loc[loc_idx] == kk-1-i) && (loc_idx < err_no))
78
        {
79
            err[i] = err_temp[loc_idx];
80
            loc_idx++;
81
        }
82
        else
83
        {
84
            err[i] = 0;
85
        }
86
    }
87
}
88
 

powered by: WebSVN 2.1.0

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