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. This is a small block, which is used to generate random data with a specified distribution. The input for this block is a c++ STL map container. The purpose of the container is to map between a desired value to its distribution.

  3. Only a simple class is included, via a short c++ header file:
    class c_pk_dist {
      public:
      c_pk_dist(map m_dist);
      unsigned char result, prob;
    };

    Like the header, the implementation is simple as well:
    1. #include "pk_rand.h"
    2. c_pk_dist::c_pk_dist(map<unsigned char, unsigned char> m_dist) {
    3.   map<unsigned char, unsigned char>::iterator it;
    4.   prob=rand()%100;
    5.   for ( it=m_dist.begin() ; it != m_dist.end(); it++ ) {
    6.     if(prob < (*it).second) {result=(*it).first; break;}
    7.   }
    8. }

    The usage is a shown below:

    //insert an error
    //number of errors probability %
    map_dist[0] =  80;  //80%
    map_dist[1] =  95;  //15%
    map_dist[2] =  98;  // 3%
    map_dist[6] = 100;  // 2%
    dist = new c_pk_dist(map_dist);






Search This Site


Feedback This Site




new pages on this site