Altera_Forum
Honored Contributor
13 years agoGenerate a random number with C
Hi,
i would like to know how to generate a random number by using C. I wrote the following code :
srand(time(NULL));
int x = rand()%(4-1)+1;
printf("%d", x);
However, the generated numbers are always the same. It must be because of the seed which is given by the time. Because there is no memory of the time on the FPGA, the seed is always the same. Would you have a simple solution for me or could you help me to bypass my problem ? Thanks !