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

Re: [oc] Again! modulo arithmetic hardware



Modify number 1 again

Generate 8 bit random number.

Take low 4 bits.
If .gt. 9
    take high 4 bits
    if .gt. 9
        add low 4 bits to high 4 bits (producing number in range of 20:30)
        subtract 10
        if .gt. 9
            generate new random number and try again
        endif
    endif
endif

The above only generates an extra random number once in 256 iterations.

Jim Dempsey

----- Original Message -----
From: "Jim Dempsey" <tapedisk@ameritech.net>
To: <cores@opencores.org>
Sent: Saturday, March 09, 2002 10:34 AM
Subject: Re: [oc] Again! modulo arithmetic hardware


> Two simple ways come to mind.
>
> 1) Generate a larger binary random number [0:255] (8 bits).
> take any 4 bits of this number to produce a random number
> between 0:15. Discard any number above 9 (i.e. regenerate
> another random number). Only when you discard will you
> need to regenerate. To reduce regeneration somewhat you could
> perhaps take the low 4 bits for your first pick. If that fails
> take the high 4 bits. If that fails then regenerate new random
> number.
>
> 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.
>
> Jim Dempsey
>
> ----- Original Message -----
> From: "jae lim" <jlim0011@yahoo.com>
> To: <cores@opencores.org>
> Cc: <paul.mcfeeters@ntlworld.com>
> Sent: Friday, March 08, 2002 5:35 PM
> Subject: [oc] Again! modulo arithmetic hardware
>
>
> > Hello everyone
> >
> > Thank you for your reply.
> >
> > I am trying to generate a random number that is
> > between [0, 9), let us say R. Frist I use LFSR to
> > generate a number that is between [0,64), let say L,
> > and then doing modulo arithmetic in forms of R mod L
> > in order to make the the real random number that I
> > want locating between [0, 9). This random number is
> > used in the arbiter, so I want to make it take as less
> > clock cycle as possible. Do you guys have any idea how
> > to implement it?
> >
> > Thank you very much!!
> >
> > Jay
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Try FREE Yahoo! Mail - the world's greatest free email!
> > http://mail.yahoo.com/
> >
> > --
> > To unsubscribe from cores mailing list please visit
> http://www.opencores.org/mailinglists.shtml
> >
>
>
> --
> To unsubscribe from cores mailing list please visit
http://www.opencores.org/mailinglists.shtml
>
>


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