FPGA Implementation of Uniform Random Number Based on Residue Method

This paper presents the implementation and comparisons of uniform random number on Field Programable Gate Array (FPGA). Uniform random numbers are generated based on residue method. The circuit of generating uniform random number is presented in general view. The circuit is constructed from a multiplexer, a multiplier, buffers and some basic gates. FPGA implementation of the designed circuit has been done into various Xilinx chips. Simulation results are viewed clearly in the paper. Random numbers are generated based on different parameters. Comparisons upon occupied area and maximum frequency from different Xilinx chip are examined. Virtex 7 is the fastest chip and Virtex 4 is the best choice in terms of occupied area. Finally, Uniform random numbers have been generated successfully on FPGA using residue method.


I. IntroductIon
Random numbers are used almost in all computer simulations to generate random numbers or samples.The random numbers need to mimic a real condition of any input to computer programs.Uniform random number is the mostly wide used because it is very simple.
Nowadays, many electronic applications do not require a computer or a processor.They have been replaced by an embedded integrated circuit (IC) containing real circuits instead of programs.The applications able to perform tasks faster and more efficient.
Many applications using embedded IC require random numbers.The real circuit for generating random numbers have been proposed [1]- [5].
In this work, we proposed a very simple circuit to generate uniform random numbers.The circuit has been designed based on residue method.The idea has been initialized using Matlab code [6].The randomness and repetition of numbers generation has been tested using chisquare formulated in [7].
The rest of the paper is organized as follows.Section II deals with theory of how to generate random numbers using residue method.The circuit design is viewed and explained deeply in section III.The next section provides implementations results and a few discussions of this.Conclusions are presented in section IV.

II. Background
In general, the probability density function (pdf) of uniform random number variables is given by Eq. (1) [7], [8]: Uniform distribution of the generated random number is shown in Fig. 1.The numbers between a and b with magnitude 1/(b-a) and the total area of the distribution is 1.
There is a well-known method commonly used to generate random numbers uniformly called residue method.The idea of the method is by taking modulo of generated sequence random numbers [9].
Parameters multiplication factor a, b and m have to be chosen carefully in order to avoid repetition of similar numbers before m.Usually, good results can be obtained by choosing b=0 [9]- [11].Meanwhile seed (X) should be different every time random numbers are generated.

III. Method
Fig. 2 shows designed circuit to generate uniform random number based on residue method.In the design, it is assumed that b=0.The circuit consist of a multiplexer, a multiplier, two AND gate, a buffer (required clear) and two buffers (required enable).The circuit requires initial value seed given from outside.Input A_in is used to provide a multiplication factor.Random numbers are produced serially through port named Output.Port seed is used for initial value and only given one at the beginning.Port A_in is used to pass multiplication value into the circuit.
The circuit also equipped with two control signals which are enable and reset.Signal enable control the start operation of the circuit.Initially signal reset have to be HIGH (enable=LOW) to clear all previous stored values in the buffers.Pre-defined value of seed and A_in have to be available at the input ports before enable goes HIGH (reset=LOW).After this, every times clock goes HIGH, a random number produced at the output port.

IV. results and dIscussIons
The implementation of the designed circuit is targeted to various Xilinx FPGA chips.Four chips have been selected for this purpose; Spartan 3, Spartan 6, Virtex 4 and Virtex 7.
Figs. 3 and 4 show behavior simulation results of uniform random number generator using 4 bit and 8 bit respectively.Both of the implementations using seed=3 and a=2.The numbers resulted from these implementations are not repeated, also they produced few numbers only.
Another simulation (Fig. 5) has been done of 8 bit generator using seed=7 and a=3.It produced more random numbers compare than the previous simulations.Moreover, the numbers are repeated after a very long period.Therefore, the randomness and the amount of number produced are depend on seed and initial multiplication factor a.
Table 1 shows speed comparisons in terms of maximum frequency that might be achieved for Spartan 3, Spartan 6, Virtex 4 and Virtex 7. It can be seen that the maximum frequency decreased as the wordlengths increased.The fastest random number produced is when it is implemented into Virtex 7, it would be reached over 700 MHz (wordlengths = 4 bit).Conversely, Spartan 3 is the slowest chip of the designed random numbers implementations.
In term of occupied area that is represented by the amount of required slices, it is varied.For wordlengths = 4 bit, Spartan 3 chip requires only 6 slices which is around a half of the slices required when the circuit implemented into Spartan 6 and Virtex 7.However, in this case, Virtex 4 is the best chip for random number implementation.All of these can be seen in the Table 2.
Figs. 6 and 7 show other views of speed representation.The graphs provide a more clear figures of speed variation.For implementation into Virtex 7, it can be seen that the speed reduces significantly when wordlengths increased from 4 bit to 8 bit.Changing wordlengths from 8 bit to 16 bit did not have significant impact to the speed.Figs. 8 and 9 provide information about area occupies in different ways.For Virtex 4 implementation using wordlengths 4 bit and 8 bit, the area required is equal.As stated before, Virtex 4 is the best chip for random number

Fig. 5 .Fig. 6 .Fig. 7 .Fig. 8 . 9 .
Fig. 5. Behavior simulation of the designed 8-bit uniform random number generator (seed = 7, a = 3) period: 3.710ns (Maximum Frequency: 269.513MHz)Minimum input arrival time before clock: 1.189ns Maximum output required time after clock: 0.575ns Maximum combinational path delay: No path found ====================================== It can be seen from the synthesis result into Virtex 4, the designed circuit requires only use some part of logic cells (LCs).The chip has (digital signal processing) DSP, but the designed circuit do not require any DSP at all.V. conclusIons FPGA implementation of uniform random number based on residue method has been demonstrated on various Xilinx chips.The circuit for FPGA implementation has been proposed using a multiplexer, a multiplier, two AND gates, and three buffers.The randomness and repetition of produced uniform numbers vary depending on selection values of seed and multiplication factor a. The implementations have been done over four different wordlengths (4 bit, 8 bit, 16 bit and 31 bit).Virtex 7 achieved highest maximum frequency 737 MHz using wordlengths = 4 bit.In terms of area occupation, Virtex 4 the best choice except for wordlengths = 4. references

Table 1 .
Speed comparisons of various Xilinx chips implemented overrent wordlengths

Table 2 .
Occupied area (slice) comparisons of various Xilinx chips