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.
-
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.
-
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:
- #include "pk_rand.h"
- c_pk_dist::c_pk_dist(map<unsigned char, unsigned char> m_dist) {
- map<unsigned char, unsigned char>::iterator it;
- prob=rand()%100;
- for ( it=m_dist.begin() ; it != m_dist.end(); it++ ) {
- if(prob < (*it).second) {result=(*it).first; break;}
- }
- }
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);
|