UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer fk5747
Observer
2,280 Views
Registered: ‎04-16-2012

generate random number

hi

I want everytime that I program my board, the program generates a random number. I write this part of code:

.

.

  r = rand() % 10000000;
  random_addr = r - (r % 32);
  DDR_test_addr = XPAR_DDR2_SDRAM_MPMC_BASEADDR + random_addr;

.

.

but every time I program the board the random number is the same. I also use srand which dose not help.

could you help me?

0 Kudos
1 Reply
Mentor hgleamon1
Mentor
2,278 Views
Registered: ‎11-14-2011

Re: generate random number

After a small amount of research, I see that you seem to be tapping on the door of a pretty sizeable issue. Truly random numbers are next to impossible to generate and you will probably need to add some complexity by choosing a seed value and manipulating it (see many threads on LFSR).

 

However, perhaps this link here can help you.

 

Regards,

 

Howard

 

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos