*/
Fast Random Number Generator - Keil Shell V1.0
Submitted By:
Graham Cole
Rating:





(
Rate It)
The function rand16() returns a 16-bit (unsigned int)
pseudo-randomly generated value. The functions are written in a
Keil shell and are easily incorporated into a Keil C51 based
project. However, all the functionality is expressed in
assembler and the functions may easily be converted to work
with any assembly language environment. A test harness is also
provided.
NOTE: Some downloads must be obtained through publishers´s site.
Do you want to get your software listed on this site? Go to our
submissions area.
Screenshot
Details
Number of downloads:
3819
Comments (2)
Keil C51 rand() Comparison
(Not rated)
Posted by: Graham Cole on Tuesday, June 22, 2004
The most recent versions of the Keil C51 library have a revised rand() function based upon my suggestions. The Keil version uses the generator (MASKXn) that is given as the default in this download.
The Keil version places lfsr in memory in accordance with the selected memory model, but always generates code similar to rand16() for the large model. As a consequence, the Keil library version is not as well optimised as rand16() built with the small or compact memory model. The Keil library version returns a 15-bit value to match the usual value of RAND_MAX of 32767. Laudably, the Keil library rand() automatically initialises lfsr if it is found to be in the uninitialised state.
Keil state that rand() is re-entrant http://www.keil.com/support/man/docs/c51/c51_lib_math.htm).
Keil rand() may generate unexpected results if it is called both from main() and from an ISR, but rand()'s automatic initialisation feature will prevent it getting stuck. rand16() does not have this feature and is not re-entrant.
Excellent and very interesting.




Posted on Thursday, September 16, 2004
I learn a lot about LFSRs from this. Having several versions of the rand16 was at first a little confusing, but the text gives a full explanation.
Add Your Rating