PYNQ: PYTHON PRODUCTIVITY FOR ZYNQ

Pseudo Random number generation

Hi,
I would like to implement a stochastic selection and need to generate floating-point pseudo-random numbers. I tried to use rand() function but it didn’t work. Could you please give me some pointers on how to implement a random number generator in HLS?

Thanks
Gandhimathi

I realized that rand() call can not be synthesized and went implementing random number generator following this link.
http://www.firstpr.com.au/dsp/rand31/rand31-park-miller-carta.cc.txt

I verified by implementing it as an IP and with Jupiter notebook. I was able to generate floating-point random numbers.

But when I used the random number generator functionality in my random selection HLS code, I could not make the random selection to work.
Am I missing anything in the function las()?
In Jupiter notebook, I am initializing the arrays a, and b. And write some integer value at the address of s. When I checked for the floating-point number at the address for rno and the random index at the address of index, It is showing only 0s.
I am wondering how can I expect that upon initializing a, b and s, the function las() will be invoked? and which in turn invoke randn()
Do I have to use any control signals? Please, give me some pointers.

Thanks
Gandhimathilas.cpp (2.0 KB)

I removed return statement from the randn() function and instead used a floating-point pointer for the “randno” variable. Now I am able to see it in Jupiter notebook. I also found a few bugs in my code in computing “beata” and after correcting them the code works as expected.
I uploaded the working code though I haven’t done any optimization.

las.cpp (1.8 KB)

Is it fine to upload the corrected code for cross-check ?

Yes. I uploaded the code in the previous post itself.