Hi Toysoldier,You could devote an entire career to this subject ... regardless, here are a few resources I've used in the past that may be helpful: http://csrc.nist.gov/rng (http://csrc.nist.gov/rng) -- everything you wanted to know and more ;-) http://www.embedded.com/showarticle.jhtml?...icleid=20900500 (http://www.embedded.com/showarticle.jhtml?articleid=20900500) -- nice article with some C code http://www.opencores.org/projects.cgi/web/...ng_lib/overview (http://www.opencores.org/projects.cgi/web/rng_lib/overview) -- VHDL code Hope this is helpful. Regards, --Scott
I haven't used it myself, but rand() is provided as a part of the C library. You'll find the details in the newlib documentation.
A good way to get a random number is to use the one out of the C library like monkeyboy said, and seed it with an external hardware counter that you let count away independently (avalon slave that you can read from). The seed value helps randomize the rand() call so that you don't get the same "random" sequence each time. Having an external counter isn't going to be perfect but it will give you a much more random sequence since the likelyhood of the value producing the same seed all the time is going to be really rare.
It all depends what you need the random number for. rand() is good enough for a lot of things, but it generates a fixed sequence of numbers which won't be appropriate for some applications.If you want a real random number then you need to drive it from some sort of non-deterministic process as the earlier links suggested.