ASIC/FPGA Design and Verification Out Source Services
C++ Reference model for ECC main code.
-
This code is part of the following
project:
A reference model, in c++, that generates ECC for a 256 bytes.
-
ECC calculation is based on Micron technical note:
TN-29-63: Error Correction Code (ECC) in SLC NAND.
-
Based on the technical note the LP and CP
are calculated in the class constructor:
- c_ecc::c_ecc(const unsigned char a_data[ARRAY_SZ]) {
- unsigned i, j;
- for(i=0; i < ARRAY_SZ; i++) {
- xor_byte(a_data[i]);
- if(i & 0x1) {
- LP[1]=xor_bits ^ LP[1];
- } else {
- LP[0]=xor_bits ^ LP[0];
- ...
- xor_byte(a_data[i] & 0x0f); //3210
- CP[4] ^= xor_bits;
- xor_byte(a_data[i] & 0xf0); //7654
- CP[5] ^= xor_bits;
A second class is responsible for ECC correction:
- class c_e_ccc_correct {
- public:
- c_e_ccc_correct(const c_ecc& prev, const c_ecc& curr);
- void bit_count(const unsigned char& d);
- unsigned char ecc_c[3];
- unsigned char bit_cnt;
- unsigned char bit_add;
- unsigned char byte_ad;
- unsigned i;
- unsigned char total_bit_cnt;
- };
|