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

Subversion Repositories bluespec-reedsolomon

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 9 to Rev 8
    Reverse comparison

Rev 9 → Rev 8

/bluespec-reedsolomon/trunk/sw-reedsolomon/syndrome.cpp
29,16 → 29,14
#include "gf_arith.h"
#include "syndrome.h"
 
 
#pragma hls_design
// Parameters k and t need to be dynamically used for each packet
// However, this version uses static values for simplicity
 
// Directive: Synthesize independently
void syndrome (unsigned char k, unsigned char t, unsigned char r[nn], unsigned char s[2*tt])
{
unsigned char r_temp;
 
// Directive: Unroll loop maximally
#pragma unroll true
Syn_Init: for (int j=0; j<2*tt; j++)
s[j]=0;
 
46,9 → 44,11
{
r_temp = r[i];
// Directive: Unroll loop maximally
#pragma unroll true
Syn_Inner: for (int j = 0; j < 2*tt; ++ j)
{
// cout << "(" << (int) r [j] << ") "
// << (int) a << " : " << (int) s [i] << endl;
s[j] = gfmult_hw (s [j], alpha(j+1)) ^ r_temp;
}
}
/bluespec-reedsolomon/trunk/sw-reedsolomon/berlekamp.cpp
29,53 → 29,53
#include "gf_arith.h"
#include "berlekamp.h"
 
// Directive: Synthesize independently
#pragma design
void gfmult_array_array_hw (unsigned char res_vec[tt+2], unsigned char in_vec0[tt+2], unsigned char in_vec1[tt+2])
{
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
res_vec[i] = gfmult_hw(in_vec0[i],in_vec1[i]);
}
 
// Directive: Synthesize independently
#pragma design
void gfmult_scalar_array_hw1 (unsigned char res_vec[tt+2], unsigned char val, unsigned char in_vec[tt+2])
{
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
res_vec[i] = gfmult_hw(val,in_vec[i]);
}
 
// Directive: Synthesize independently
#pragma design
void gfmult_scalar_array_hw2 (unsigned char res_vec[tt+2], unsigned char val, unsigned char in_vec[tt+2])
{
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
res_vec[i] = gfmult_hw(val,in_vec[i]);
}
 
// Directive: Synthesize independently
#pragma design
void gfadd_array_array_hw1 (unsigned char in_vec0[tt+2], unsigned char in_vec1[tt+2])
{
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
in_vec0[i] = gfadd_hw(in_vec0[i], in_vec1[i]);
}
 
// Directive: Synthesize independently
#pragma design
void gfadd_array_array_hw2 (unsigned char in_vec0[tt+2], unsigned char in_vec1[tt+2])
{
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
in_vec0[i] = gfadd_hw(in_vec0[i], in_vec1[i]);
}
 
 
// Directive: Synthesize independently
#pragma design
unsigned char gfsum_array_hw (unsigned char in_vec[tt+2])
{
unsigned char res = 0;
 
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < tt+2; ++i)
res = gfadd_hw(res, in_vec[i]);
 
102,7 → 102,7
syn_shift_reg[0] = 0;
temp[0] = 0;
 
// Directive: Unroll loop maximally
#pragma unroll true
BerlInit: for (int i = 1; i < tt+2; i++)
{
c [i] = 0;
121,7 → 121,7
BerlOuter:
for (int i = 0; i < 2*tt; i++ )
{
// Directive: Unroll loop maximally
#pragma unroll true
BerlShift: for (int k = tt+1; k > 0; --k)
{
syn_shift_reg[k] = syn_shift_reg[k-1];
132,6 → 132,10
p[0] = 0;
a[0] = 0;
// d = 0;
// BerlComplex1: for (int k = 0; k < tt+2; ++k)
// d = gfadd_hw(d, gfmult_hw(c[k], syn_shift_reg[k]));
 
gfmult_array_array_hw(temp, c, syn_shift_reg);
d = gfsum_array_hw(temp);
 
138,7 → 142,7
if (d != 0)
{
ddstar = gfmult_hw(d, dstar);
// Directive: Unroll loop maximally
#pragma unroll true
BerlSimple1: for (int k = 0; k < tt+2; ++k)
{
t1 [k] = p [k];
149,7 → 153,7
{
l = i - l + 1;
 
// Directive: Unroll loop maximally
#pragma unroll true
BerlSimple2: for (int k = 0; k < tt+2; ++k)
{
p [k] = c [k];
158,6 → 162,12
dstar = gfinv_lut ( d );
}
 
// BerlComplex2: for (int k = 0; k < tt+2; ++k)
// {
// c[k] = gfadd_hw(c[k], gfmult_hw(ddstar,t1[k]));
// w[k] = gfadd_hw(w[k], gfmult_hw(ddstar,t2[k]));
// }
 
gfmult_scalar_array_hw1(temp, ddstar, t1);
gfadd_array_array_hw1(c,temp);
gfmult_scalar_array_hw2(temp, ddstar, t2);
166,7 → 176,7
}
}
// Directive: Unroll loop maximally
#pragma unroll true
BerlCopy: for (int k = 0; k < tt; ++k)
{
c_out[k] = c[k+1];
/bluespec-reedsolomon/trunk/sw-reedsolomon/error_correct.cpp
29,7 → 29,7
#include "gf_arith.h"
#include "error_correct.h"
 
// Directive: Synthesize independently
#pragma design
void error_correct( unsigned char k, unsigned char in_data[kk], unsigned char err[kk],
unsigned char out_data[kk])
{
/bluespec-reedsolomon/trunk/sw-reedsolomon/chien_search.cpp
29,7 → 29,7
#include "gf_arith.h"
#include "chien_search.h"
 
// Directive: Synthesize independently
#pragma design
void chien_search( unsigned char k, unsigned char t, unsigned char lambda[tt],
unsigned char *err_no, unsigned char err_loc[tt], unsigned char alpha_inv[tt])
{
40,19 → 40,19
unsigned char err_loc_temp[tt];
unsigned char alpha_inv_temp[tt];
 
// Directive: Unroll loop maximally
#pragma unroll yes
Chien_AssignInArray: for (int i = 0; i < tt; i++)
lambda_a[i] = lambda[i];
for (int i = nn-1; i >= 0; i--)
{
// Directive: Unroll loop maximally
#pragma unroll yes
Chien_Inner1: for (int j = 0; j < tt; j++)
lambda_a[j] = gfmult_hw(lambda_a[j], alpha(j+1));
 
accum = 1;
// Directive: Unroll loop maximally
#pragma unroll yes
Chien_Inner2: for (int j = 0; j < tt; j++)
accum = gfadd_hw(accum, lambda_a[j]);
 
66,7 → 66,7
}
}
// Directive: Unroll loop maximally
#pragma unroll yes
Chien_AssignOutArray: for (int i = 0; i < tt; i++)
{
err_loc[i] = err_loc_temp[i];
/bluespec-reedsolomon/trunk/sw-reedsolomon/README
12,26 → 12,3
 
For synthesis, import into a C based design tool, set appropriate HW parameters
and synthesize for a particular platform.
 
For our case study of generating hardware from this code, the following
transformations and directives were used for improving performance:
 
- Break up complex functions into smaller & simpler computational
segments/loops to allow independent optimizations, for example see
berlekamp.cpp, each loop labelled for further directives.
 
- Modify loops dependent on dynamic bounds to use static bounds and
mask output to give correct result.
 
- Unroll 'For' loops with fixed static bounds maximally, marked in
code as comments corresponding to each loop to be unrolled. Loops
unrolled in berlekamp.cpp, chien_search.cpp, gf_arith.cpp,
syndrome.cpp.
 
- Synthesize hardware units for individual functions rather than the
entire logic as a single unit, marked in code as comments for
independent synthesis.
 
- Use appropriate streaming buffers for communication between
functional units. Buffers should allow fine-grained pipeline
parallelism across a single data block where possible.
/bluespec-reedsolomon/trunk/sw-reedsolomon/error_mag.cpp
29,25 → 29,25
#include "gf_arith.h"
#include "error_mag.h"
 
// Directive: Synthesize independently
#pragma design
unsigned char poly_eval_inst1 (unsigned char poly[tt], unsigned char alpha_inv)
{
return poly_eval(poly, alpha_inv);
}
 
// Directive: Synthesize independently
#pragma design
unsigned char poly_eval_inst2 (unsigned char poly[tt], unsigned char alpha_inv)
{
return poly_eval(poly, alpha_inv);
}
 
// Directive: Synthesize independently
#pragma design
unsigned char gfdiv_lut_inst (unsigned char dividend, unsigned char divisor)
{
return gfdiv_lut(dividend, divisor);
}
 
// Directive: Synthesize independently
#pragma design
void compute_deriv_inst (unsigned char lambda[tt], unsigned char lambda_deriv[tt])
{
compute_deriv(lambda, lambda_deriv);
54,7 → 54,7
}
 
 
// Directive: Synthesize independently
#pragma design
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],
unsigned char err[kk])
{
/bluespec-reedsolomon/trunk/sw-reedsolomon/gf_arith.cpp
42,12 → 42,12
 
unsigned int temp = 0;
 
// Directive: Unroll loop maximally
#pragma unroll yes
for (int i = 0; i < 8; i++)
if (b & (1 << i))
temp ^= (unsigned int)(a << i);
// Directive: Unroll loop maximally
#pragma unroll yes
for (int k = 15; k > 7; k--)
if (temp & (1 << k))
temp ^= (unsigned int)(pp_char << (k - 8));
380,6 → 380,11
{
if (n == 0)
return 1;
// unsigned char a = 2;
// for (int i = 1; i < n; ++ i)
// a = gfmult_hw (a, 2);
// return gfinv_lut( a );
return gfinv_lut( alpha (n) );
}
 
393,7 → 398,7
// Assumption: First bit of Lambda (alpha**0) is not transmitted
void compute_deriv (unsigned char lambda[tt], unsigned char lambda_deriv[tt])
{
// Directive: Unroll loop maximally
#pragma unroll true
for (int i = 0; i < tt; i++)
lambda_deriv[i] = (i % 2 == 0) ? lambda[i] : 0;
}
403,7 → 408,7
{
unsigned char val = 0;
// Directive: Unroll loop maximally
#pragma unroll true
for (int j = tt-1; j >= 0; j--)
{
val = gfadd_hw(gfmult_hw(val, alpha_inv), poly[j]);
411,3 → 416,7
return val;
}
 
// int main() {
// for(int i=0; i<256; i++)
// cout << "," << (int)gfinv_lut(i) << endl;
// };
/bluespec-reedsolomon/trunk/sw-reedsolomon/test_rs_decode.cpp
31,10 → 31,15
#include "rs_decode.h"
using namespace std;
 
#ifdef CCS_SCVERIFY
#include "mc_testbench.h"
void testbench::main(/*int argc, char argv []*/)
#else
 
int main ()
#endif
{
//Send one encoded file with errors (16 bytes set to 0) multiple times.
//Send one encoded file with errors multiple times.
unsigned char n = nn;
unsigned char t = tt;
unsigned char r [255] = {223, 0, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 253, 9, 60, 220, 91, 202, 48, 83, 201, 181, 81, 123, 117, 63, 98, 219, 20, 9, 71, 13, 231, 180, 105, 110, 114, 104, 147, 18, 55, 145, 170, 26};
45,8 → 50,11
 
for (int j = 0; j < 3; ++j)
{
#ifdef CCS_SCVERIFY
exec_rs_decode(n, t, r, &k, out_d);
#else
rs_decode(n, t, r, &k, out_d);
 
#endif
for (int i = 0; i < k; ++ i)
cout << "out_d["<<i<<"]= "<< (int)out_d[i] << endl;
}
/bluespec-reedsolomon/trunk/sw-reedsolomon/rs_decode.cpp
33,7 → 33,7
#include "error_correct.h"
#include "rs_fifo.h"
 
 
#pragma hls_design top
// Top level decoder module
void rs_decode (unsigned char n, unsigned char t, unsigned char in_d[nn],
unsigned char *k, unsigned char out_d[kk])
51,8 → 51,6
unsigned char in_data[kk];
unsigned char in_d_2[nn];
// Create copy of input to pass to fifo to error corrector
// Directive: Unroll loop maximally
Simple_rs1: for (int i = 0; i < nn; i++)
in_d_2[i] = in_d[i];
 

powered by: WebSVN 2.1.0

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