[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [oc] Again! modulo arithmetic hardware



> On Mon, 11 Mar 2002, Marko Mlinar wrote:
>
> > > 2) Generate a random number of 9 bits (or larger) in width. Use a >
> > logic core that inputs of 9 bits and outputs the count of bits > set.
>
> > I am not an expert in random math, but I would say this new distribution
> > is not random anymore.
>
> You're right, too.  Actually, the output of this process will be random,
> but the distribution won't be flat.

Well, if you give it a thought it turns out that given an n-bit flat
distribution random binary number source you cannot get any static solution
to truncate it to an interval 0..9 with flat distribution. To do that you
would have to group the numbers between 0..2^n-1 into 10 groups with exactly
the same number of numbers in them. That can't be done!

You have to add memory to get a soluton:

What you can for example do is to generate a 4-bit number.
For numbers 0..9 you output the actual value.
For number 10 you output 0 for the first time and 5 for the second time it
appears.
For number 11 you output 1 for the first time and 6 for the second time it
appears.
For number 12 you output 2 for the first time and 7 for the second time it
appears.
For number 13 you output 3 for the first time and 8 for the second time it
appears.
For number 14 you output 4 for the first time and 9 for the second time it
appears.
For number 15 you output 0 for the first time, 1 for the second, etc. 15 for
the 15th time.

You can implement that with some registers/counters and a few logic. This
will give you true flat distribution - if I'm right - without having large
inputs and slow modulo logic.

Andras Tantos



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

--
To unsubscribe from cores mailing list please visit http://www.opencores.org/mailinglists.shtml