WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2012-Nov-13 19:09:40

JaeYoung Kim
Member
Registered: 2012-May-07
Posts: 17

random function seed

Hello

I'm currently working on WARPv2 using real-time OFDM reference design ( not WARP LAB)

In the MAC code, I need to generate random numbers and it looks like rand() works like random function in standard C library.

The problem is that it looks like seed is fixed. In Linux, we can change seed using time function like srand(time(0)). However, it is not working in the WARP.

Could you let me know how to change seed (using time or whatever other method )?

Offline

 

#2 2012-Nov-13 20:01:08

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: random function seed

Those functions are part of the Xilinx-supplied standard C library. I'm not really sure how their implementation of pseudo-random number generation works. I think we've used srand() before, seeding it with bits from the RSSI ADC when a radio is in standby (the bottom few bits of the ADC will be random-ish, reading noise on the RSSI line when the MAX2829 is idle).

Offline

 

#3 2012-Nov-14 03:55:10

Christian
Member
Registered: 2010-Feb-26
Posts: 124

Re: random function seed

rand();
srand(..);

There is a bug in the srand function in the Xilinx C lib. You need to call rand() once before calling srand. otherwise, srand will not apply the argument. Besides, I don't know, if the time(0) function gives a valid return value. I suggest using another source, e.g. noise read for randomness or dip switch vaslues for repeatability.

Offline

 

#4 2012-Nov-14 18:27:54

JaeYoung Kim
Member
Registered: 2012-May-07
Posts: 17

Re: random function seed

Thanks for your comments :)

Offline

 

Board footer