21.07.2015 Views

"TMS320C55x DSP Library DSPLIB Programmer's Reference"

"TMS320C55x DSP Library DSPLIB Programmer's Reference"

"TMS320C55x DSP Library DSPLIB Programmer's Reference"

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

and16Overflow Handling MethodologyNo scaling implemented for overflow prevention.Special Requirements No special requirements.Implementation Notes Rand16() is written so that it can be called from a C program. Prior to callingrand16(), rand16i() can be called to initialize the random number generatorseed value. The C routine passes two parameters to rand16(): A pointer to therandom number array *r and the count of random numbers (nr) desired. Therandom numbers are declared as short or 16 bit values. Two constantsRNDMULT and RNDINC are defined in the function. The algorithm is sensitiveto the choice of RNDMULT and RNDINC so exercise caution when changingthese.MThis value is based on the system that the routine runs. Thisroutine returns a random number from 0 to 65536 (64K) andis NOT internally bounded. If you need a min/max limit, thismust be coded externally to this routine.RNDSEEDRNDMULTAn arbitrary constant that can be any value between 0 and64K. If 0 (zero) is chosen, then RNDINC should be somevalue greater than 1. Otherwise, the first two values will be 0and 1. To change the set of random numbers generated bythis routine, change the RNDSEED value. In this routine,RNDSEED is initialized to 21845, which is 65536/3.Should be chosen such that the last three digits fall in thepattern even_digit–2–1 such as xx821, xx421 etc.RNDMULT = 31821 is used in this routine.RNDINCIn general, this constant can be any prime number related toM. Research shows that RNDINC (the increment value)should be chosen by the following formula:RNDINC = ((1/2 – (1/6 * SQRT(3))) * M). Using M=65536,RNDINC was picked as 13849.The random seed initialized in rand16i() is used to generate the first randomnumber. Each random number generated is used to generate the next numberin the series. The random number is generated in the accumulator (32 bits) byusing the multiply-accumulate (MAC) unit to do the computation. In the courseof the algorithm if there is intermediate overflow, the overflow flag bit in statusregister is set. At the end of the algorithm, the overflow flag is tested for anyintermediate overflow conditions.ExampleSee examples/rand16 subdirectory4-82

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!