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


V

 

This page shows how to get an argument and pass it to function srand as its seed. It is implemented as part of a c++ series of exercises , that I did.

  1. In ECC project I need to generate random numbers. I first used time for the job. Since the program ends quickly, in regression from script, this was not too good. So I have moved the seed generation to the script and used arg[cv].

    1. #include <time.h>
    2. ...
    3. int main(int argc, char *argv[]) {
    4. ...
    5.   if(argc == 1)
    6.     srand ( time(NULL) );
    7.   else {
    8.     seed=atoi(argv[1]);
    9.     srand (seed);
    10. #ifdef DBG_3 //{
    11.     cout << "argv " << argv[1] << " seed " << seed << endl;
    12. #endif //}
    13.   }
    The bash script uses the variable RANDOM to generate random seed.

    for i in {1..500} ; do
      ./a.out $RANDOM >> ecc_main_1.txt

  ...



Home

some memory VHDL models


A simple c-code program to read a memory array from verilog RTL, using VPI.



Download Area







Search This Site


Feedback This Site




new pages on this site