Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

ASIC/FPGA Design and Verification Out Source Services

C++ Reference model for ECC main code.

  1. This code is part of the following project: A reference model, in c++, that generates ECC for a 256 bytes.

  2. The tasks of the c++ main is to inject random data, check the results of the ECC and print debug messages.

  3. Code Description:
    ECC class and data arrays instantiation:

    unsigned char a_data[ARRAY_SZ];
    unsigned char b_data[ARRAY_SZ];
    unsigned char bit_err;
    c_ecc *ecc, *err;
    c_e_ccc_correct *correct;

    Random variables:

    unsigned char shift, loc;
    c_pk_dist *dist;
    map<unsigned char, unsigned char> map_dist;
    Note: The distribution allows to specify the probability of each desired number of errors in percents: link

    map_dist[0] =  80; //80% single error
    map_dist[1] =  95; //15% double error
    map_dist[2] =  98; // 3%
    map_dist[6] = 100; // 2%
    dist = new c_pk_dist(map_dist);


  4. The input data is generated in random:
    for(i=0; i < ARRAY_SZ; i++) {a_data[i]=rand() % 256; b_data[i]=a_data[i];}

    Once the number of error is generated, it is inserted in random location (determined by two parameters: byte and bit location).
    1. for(i = 0; i <= dist->result; i++) {
    2.   shift=rand()%8;          //bit  location
    3.   loc =rand()%ARRAY_SZ;    //byte location
    4.   bit_err=1 << shift;
    5.   if(a_data[loc] & bit_err) a_data[loc] &= ~bit_err; else a_data[loc] |= bit_err;
    6. }


  5. If a single error was inserted, it must be fixed. If not the main code issues an error message.

    1. for(i=0; i < ARRAY_SZ; i++)
    2.   if(b_data[i] != a_data[i]) {
    3.     if(j == 1) cout << "Error * ";









Search This Site


Feedback This Site




new pages on this site