![]() |
Psuedorandom numbers
Well I have been studying psuedorandom sequences for Microchip microcontrollers based on seeds and so far the fastest I have found is thusly from mondo technology:
Code:
chop movf val1,w ;get the 1st |
Re: Psuedorandom numbers
Quite a bit longer than 10 instruction cycles but here is what our prof made us use for a lab earlier this year:
static unsigned long int SEED_X = 521288629L; // this is a 32-bit constant static unsigned long int SEED_Y = 362436069L; // this is a 32-bit constant unsigned int random() { static unsigned int a = 18000, b = 30903; SEED_X = a*(SEED_X&65535) + (SEED_X>>16); // requires 16X16 multiply, 32bit add SEED_Y = b*(SEED_Y&65535) + (SEED_Y>>16); // requires 16X16 multiply, 32bit add return (SEED_X + SEED_Y)/2; // requires 32bit add, 32bit shift } We had to implement this in ASM for our Lab before we started C so I have an ASM implementation, if you want to see it PM me. |
Re: Psuedorandom numbers
use a linear congruential generator - probably the best in terms of ease of use to simplicity ratio. It's on wikipedia
-Salik |
| All times are GMT -5. The time now is 00:55. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi