1. Introduction
The generation of random and pseudorandom sequences is of importance to areas such as science and technology [
1,
2,
3]. Therefore, the design of RNG or PRNG generators that can produce this type of sequence in hardware or software must give it good enough statistical properties to be used for different purposes such as biological systems [
4,
5]. The RNG (
Random Number Generator) is a random number generator that uses sources such as noise from electronic circuits, the quantum effect of semiconductors, and the combination of temperature and time, among others [
1,
6,
7]. The TRNG
True Random Number Generator is widely used in cryptographic systems and is capable of generating truly random sequences [
8,
9] and the PRNG uses an RNG as a seed, i.e., initial data [
1,
5]. Furthermore, it produces pseudorandom or perfectly pseudorandom sequences [
5]. Pseudorandom sequences are those that are deterministic, but appear to be random [
10,
11]. Some applications include areas such as cryptography for use in key encryption, electronic circuit testing, simulation processes, financial models, etc. [
1,
4,
5,
8,
10].
One method to generate pseudorandom numbers is the LFSR
Linear Feedback Shift Register, as seen in
Figure 1. This is a PRNG generator that can generate binary sequences. Its simplicity and favorable statistical qualities make the generator an important element for processes such as stream encryption [
8,
9]. The LFSR uses a mathematical model to produce the sequence of maximum length using Equation (1) [
2]. This is obtained when the feedback is characterized by a primitive polynomial of degree
m [
4,
8,
9]. Xilinx provided in its document in [
12] a table of the recommended pins to use for feedback according to the length of the LFSR and obtain the maximum sequence that can be generated [
12].
Some designs of PRNGs use a LFSR as a part of the circuit to generate pseudorandom sequences with good statistical characteristics. For example, Fibonacci and Galois ring generators are limited by the length of the LFSR, generating a periodic pattern. Therefore, the sequences that are created are pseudorandom. The FiRO
Fibonacci Ring Oscillator generator, which is derived from its eponymous LFSR architecture, replaces the D flip-flops with inverters, as described in [
13,
14]. This produces an asynchronous circuit that introduces randomness due to the linear dependence of the inverter delay on temperature and supply voltage [
14]. On the other hand, the GaRO (
Galois Ring Oscillator) generator derives its structure in Galois LFSR, which as the FiRO generator, replaces the D flip-flops with inverters, as shown in [
14]. Each output of the cascade inverters is connected to the input of an Xor gate to form the input of the next inverter [
14].
There is also the UFPRNG (
Ultra-Fast Pseudorandom Number Generator), which is based on 4D-TBMHM and ALFSR and is validated by the NIST statistical test and TestU01 [
15]. In addition to those mentioned, there are PRNG generators that use ANNs (
Artificial Neural Networks) such as the one proposed in [
16]. This generator imitates the properties of the PUCS (
Pehlivan-Uyaroglu Chaotic System) and the shape of the attractor. It is used for implementation in a simple image encryption system with a maximum frequency of 12.553 MHz [
16].
To validate that the sequences are random, pseudorandom or perfectly pseudorandom, there are different types of statistical tests that are included in a set. One is the Diehard test, which is made up of 14 statistical tests [
17,
18]. These are the Birthday spacings, Overlapping permutations, Ranks of matrices, Monkey tests, 20-bit word stream, Count de ones in a byte sequence, Count of ones in a specific byte, Parking lot test, Minimum distance, Random spheres test, Reduction test, Overlapping sums test, Runs test and the Craps test [
17,
18,
19]. Another set of tests to evaluate and validate random sequences is TestU01, which is a library implemented in ANSI C [
20], and the 15 statistical tests proposed by NIST. The fifteen tests are the Frequency (Monobit) test, the Frequency test within a Block, the Runs test, the Longest-Run-of-Ones in a Block test, Binary Matrix Rank test, the Discrete Fourier Transform (Spectral) Test, the Non-overlapping Template Matching test, the Overlapping Template Matching test, the Maurer’s Universal Statistical test, the Linear Complexity test, the Serial test, the Approximate Entropy test, the Cumulative Sums (Cusums) test, the Random Excursions test and the Random Excursions Variant test [
5,
17].
This work presents the design of a new pseudorandom number neuro-generator that produces sequences with good statistical properties, as is shown by the results of the NIST tests. In contrast to other generators PRNG as mentioned above, this neuro-generator consists of two LFSR shift registers. These are loaded with initial data called seed or external data, with the option of loading the external data in on LFSR and the seed data in the other. The circuit has a neuronal module connected to the clk signal of one of the LFSRs to produce pulses aperiodically, while the other LFSR maintains periodicity in the pulses clk. The parallel output of the registers is connected to a logic block to process the data and decides through a multiplexer which one passes to the output of the neuro-generator. To evaluate the sequences that the neuro-generator produces, a series of tests were performed. The first is with the neuronal module disabled to maintain the clock pulses of the LFSR constants. Hence, the frequency of the first LFSR varies, while the frequency of the second one remains at a certain frequency. The seed data were loaded into the first test series without a neuronal module, and the external data were in the second series. Tests were also conducted with the neuronal module connected, while keeping the LFSRs at the same frequency as the impulse neurons. In this case, the frequency was changed from 4 kHz to 100 MHz. The sequences produced by the neuro-generator with different frequencies pass approximately ten statistical tests. Some of these produced results where the conclusion of the sequence was perfectly random, such as the Frequency (Monobit) test. This test is the first of the fifteen statistical tests of the NIST and one of the most important of the entire set [
5].
2. Statistical Tests Proposed by NIST for Validation of RNG and PRNG Generators
Each of the statistical tests proposed by NIST must conclude whether or not the sequence being validated is random, perfectly random, pseudorandom or perfectly pseudorandom [
1,
5]. For each one, a statistical value called a
p-value is calculated, which has to be greater than 0.01 for sequences of 100 and greater than 0.001 for sequences of 1000 [
1,
5,
6,
10]. The
p-value is a probabilistic value that uses a statistical test to give strength of evidence against the null hypothesis
[
1,
5,
6]. The purpose of the null hypothesis is to prove that the sequence is random. However, when the sequence is not random, we have the alternative hypothesis
[
5,
6,
21].
Table 1 shows the different cases of hypothesis and the type of error corresponding to each one. Error type I indicates that
has been rejected when true and error type II accepts
when false [
5,
6,
21].
Table 2 shows the description and equation to obtain the
p-value of each of the statistical tests proposed by NIST in [
5]. It is important to highlight that each of the tests has a different methodology to evaluate the sequences [
5].
3. Design of the PRNG Pseudorandom Number Neuro-Generator
The design of a new neuro-generator type PRNG was carried out, as shown in
Figure 2. The neuro-generator circuit consists of two Data In blocks that determine if the data that is loaded to the LFSR is external data or seed data only if LOAD is enabled. It must be considered that the Data In control signal can be different for each one, that is, for LFSR 1 the external data can be loaded while for LFSR 2 the seed data are loaded, causing the sequence on both sides to be different.
The data already loaded in both registers, for each pulse that generates the clock signal clk, are moved one position to the right. This allows a new feedback bit to enter the missing position, while at the same time new parallel output data are generated. The output values of the LFSRs are processed by logical blocks to obtain a new sequence, that will be part of the output sequence. To select the bits that pass to the output of the neuro-generator, the processed data from LFSR1 or LFSR2 pass to a MUX multiplexer. The XOR module connected to the controller determines the source of the data that are passed to the output. When the output of this module is 0, the bits that are passed to the output are those of Logic Channel 1. On the other hand, if the value is 1, the bits of Logic Channel 2 are passed to the output.
The neuronal module connected to the neuro-generator was designed with impulse neurons, each with different behaviors based on Izhikevich’s model. In contrast to other random number generators that use artificial neural networks, as in [
16], these are not trained, so their original behavior is taken to produce a pulse-based signal. In
Figure 2, it is seen that the output of the module is connected to register LFSR1. The module decides through a multiplexer the pulses that pass to the clk signal to generate an aperiodic signal, while, in the LFSR2, the clock signal clk remains periodic. A clear advantage of this neuro-generator is that the neural module can be disconnected to produce a periodic frequency in both parts of the circuit if required by the user.
Neuro-Generator Neuronal Module
The neuronal module of the neuro-generator uses six impulse neurons with different behaviors, which base their behavior on impulses from mammalian cortical neurons [
10,
28,
29,
30,
31,
32]. The simple Izhikevich model of Equations (2) and (3) is used to simulate the 20 behaviors of impulse neurons. These consist of two ordinary differential equations to represent the membrane potential and Equation (4) is the recovery variable that uses a reset condition when the impulse is generated [
10,
28,
29,
30,
31,
32]. The variables are
v the membrane potential, the derivative concerning time,
u the recovery variable,
a the time scale of the recovery variable
u,
b the sensitivity of recovery variable
u to subthreshold fluctuations of the membrane potential,
c the reset value that the membrane potential adopts after the impulse, and
d the reset after the recovery variable
u [
10,
28,
29,
30,
31,
32].
Modifying the values of parameters
a,
b,
c and
d lead to different behaviors [
28,
29,
30,
31,
32]. On the official website of Dr. Izhikevich [
32], it is possible to find the relevant information on impulse neurons and the MATLAB code provided by the author himself. In this case, frequency adaptation, phasic impulse, mixed mode, phasic bursts, tonic bursts and tonic impulse were used for the neuronal module.
Table 3 shows the values that correspond to each behavior used. The description in hardware of the neuron block as the one seen in
Figure 3 was made using VHDL hardware description. This block has a clock signal clk, reset and a stimulus input called x. For each neuron, it is necessary to enter a pulse to stimulate it and begin to produce a series of pulses corresponding to the type of behavior.
For each neuron used in the neuronal module, a state machine was designed. Each one has an input variable x, which must be in a high state to stimulate the neuron, without needing to remain in this state. The counter is the variable that represents each of the iterations to generate the start and end of the pulse, which is reflected in the output of the neuron in “y” and the * represents an indeterminate value, which causes it to be cycled in the same state until the counter has the value corresponding to the pulse.
The number of pulses shown at the output of the neuron depends on its behavior and the reset variable is used to restart the neuron.
When the input stimulus is presented, the neuron with frequency adaptation behavior can produce a series of seven pulses [
28,
29,
30,
31,
32].
Figure 4 shows the state machine that describes this behavior to represent it, where for every two states, starting with state one, they correspond to the start and end of the first pulse. This continues until the five pulses have been completed. If the condition is not met in any of the states, then it remains in the same state until all the conditions are completed and the cycle can continue [
28,
29,
30,
31,
32].
The estate machine of phasic impulse behavior in (a) of
Figure 5 only has two states to produce a single output pulse when the neuron is stimulated. On the other hand, the tonic impulse neuron in (b) consists of nine states to produce five output pulses. In the mixed-mode neuron in its state machine in
Figure 6, a total of ten states are observed to produce five pulses [
28,
29,
30,
31,
32].
Lastly, the state machines of the neuron’s phasic burst behavior in
Figure 7, need a total of 13 states to produce six pulses and tonic bursts in
Figure 8, and require 33 states for a series of sixteen pulses [
10,
28,
29,
30,
31,
32].
4. Simulation and Implementation of the Neuro-Generator in the FPGA Virtex 7 xc7vx485t-2ffg1761
The circuit design of the neuro-generator was described in VHDL hardware description language. The simulation results of
Figure 9 and
Figure 10 were carried out with different frequencies and times to appreciate the difference in the pulses generated by the neurons of the neuronal module and the outputs of this (out_m). In this, the signals in_af, in_fa, in_mm, in_rf, in_rt and in_to correspond to the input stimulus of the neurons and their outputs are shown as yaf (frequency adaptation), yfa (phasic pulse), ymm (mixed mode), yrf (tonic bursts) and yto (tonic pulse). Each of these pulses passes to the output of the neuronal module, which is the one connected to LFSR 1 to produce a non-periodic signal.
The simulation of the neuro-generator was carried out with a frequency of 4 kHz in a time of 8 s to appreciate the output pulses of the neural module. As shown in
Figure 9, this signal does not maintain periodicity compared to the clk signal that is the LFSR 2 clock signal. It is also shown that the output pulse of the mixed-mode neuron (ymm) is the one that passes at the output of the neuronal module. This demonstrates that the pulse that passes to the output will only be the decided by the neuronal module controller (sel_m). On the other hand, in
Figure 10a, the complete simulation of the neuro-generator can be seen together with the neuron pulses at a frequency of 100 MHz to obtain a greater number of pulses at the output of the neuronal module and a longer response time simulation of 500 us.
Figure 10b shows two different pulses that pass to the output of the neuronal module and some binary results from the output of the neuro-generator.
Increasing the frequency in the neural module is to obtain a greater number of bits that will serve as masking within the sequence of bits generated in the LFSR 2. This means that while the LFSR 2 produces sequences at a constant frequency of 100 MHz, in LFSR 1 the output data are produced at different frequencies that depend on the output pulses of the neural module. That is, the frequency in this part of the circuit is random. In
Figure 9, it is observed that the pulses occur with a frequency at 4 kHz with a simulation time of 8 s and 100 MHz in a simulation of 500 us in
Figure 10, both in a non-periodic manner compared to the clk signal that corresponds to that of LFSR 2, which is consistent. The output data of the neuro-generator are shown in the out_rn signal of both figures.
The neuro-generator circuit was implemented in the
Virtex 7 xc7vx485t-2ffg1761 reconfigurable device due to its large numbers of resources, which has available 607,200 slice registers, 303,600 LUT’S, 429 LUT-FF, 700 IOBs and 32 BUFG/BUFGCTRLS. This FPGA is adequate to implement circuits without affecting their performance.
Table 4 shows the percentages of resources used by the neuro-generator circuit, where the lowest is 0.025% of slice registers and the highest is 31.701% of LUT-FF pairs. These percentages indicate that the neuro-generator can be implemented without affecting its performance, generating a total of approximately 10 million bits at a speed of 100 MHz per clock cycle.
5. Results and Discussion
NIST statistical tests were used to evaluate the sequences produced by the new neuro-generator with different frequencies and demonstrated that they met the statistical testing requirements, which conclude whether the sequence being evaluated is pseudorandom or perfectly pseudorandom. The first eight tests involved disabling the neuronal module of the neuro-generator, varying the frequency of the LFSR1 to 50 MHz, 25 MHz, 12.5 MHz and 6.25 MHz, and keeping the frequency of the LFSR2 fixed at 50 MHz for each half-clock cycle, which is equivalent to 100 MHz, 50 MHz, 25 MHz and 12.5 MHz of the full cycle. The seed data were loaded for four of the cases, while external data were loaded for the other four.
5.1. NIST Test Results of the Neuro-Generator with the Neuronal Module Disable
The
p-value results with the neuronal module disabled and with the data seed loaded to the LFSR are shown in
Table 5, in which the results are divided according to the output sequence of the neuro-generator with different frequencies. In all cases from the Frequency (Monobit) test to the Runs test, the
p-value was greater than 0.01. On the other hand, for the Binary Matrix Range test,
p-value = 0.000000 when the neuro-generator was at 50 MHz. The same situation occurred with the Non-overlapping Template Matching test, where the test was divided into 148 templates. To identify the number of templates that determined the sequence to be satisfactory, they were marked with 1/1 and those that did not were marked with 0/1. For the Random Excursion test and Random Excursion Variant test, the results corresponding to each state were observed, that is, each one calculated an independent value of the
p-value. These ranged from −4 to +4 for the Random Excursion test and −9 to +9 for the Random Excursion Variant. Nonetheless, the dotted line at 25 MHz for this test indicates that it was not executed due to the insufficient number of cycles [
5].
The results of the Non-overlapping Template Matching test in this case are shown in
Table 6 and
Figure 11, where the percentages of the
p-value results of the sequences obtained at different frequencies are observed. These show that at a frequency of 50 MHz, 100% of the data were concluded as pseudorandom, while this percentage decreased for the lower frequencies.
The
p-values of this test were also classified into different ranges, as shown in
Table 7 and the graph of
Figure 12. According to the results, when the neuro-generator had a frequency of 50 MHz, the percentage of data in rank 2 was 74.32%, while for a low frequency like 6.25 MHz, 80.40% of the data were in rank 1, which had low
p-values, including the results that did not pass the test for a specific template. This demonstrates a relationship with the results in
Table 5, where the percentage of
p-value < 0.01 is included in the percentages of rank 1.
In addition, the results of the neuro-generator with the external data loaded to the LFSRs are shown in
Table 8, where the
p-value was greater than 0.01 in most cases. The only exception was the Approximate Entropy test, which had a perfectly pseudorandom
p-value when the frequency of the neuro-generator was at 50 MHz. However, when the frequency was less than this frequency, the
p-value result for this test suggests that the output sequence of the neuro-generator was completely non-pseudorandom. In the Random Excursion and Randon Excursion Variant test (
Table 5), there were a total of eight states ranging from −4 to +4 and 18 states from −9 to +9. Each state calculated a probabilistic
p-value to ascertain whether the sequence being validated was pseudorandom or not in the specific state.
The Non-overlapping Template Matching test in
Table 8 shows with 1/1 the number of templates with a
p-value > 0.01 and with 0/1 those with a
p-value < 0.01. The percentage of these data is shown in
Table 9 and the graph in
Figure 13. It can be observed that in the case where the neuro-generator had a frequency of 50 MHz, 98.6% of the templates concluded it to be pseudorandom. Additionally, 99.32% of the templates concluded the data to be pseudorandom when the neuro-generator had a frequency of 25 MHz. The percentage of the templates with a
p-value < 0.01 with the frequencies at 12.5 MHz and 6.25 MHz increased to 27.02%. These percentages are included in
Table 10, where the
p-value results were divided into range 1 ranging from 0.000000 to 0.500000, and range 2 with values from 0.500001 to 1.000000. A total of 50% of the
p-value data were in range 1 and the remaining 50% were in range 2. This means that 1.35% belonged to results with a
p-value < 0.01, as indicated in
Table 9, and 98.6% was divided between rank 1 and rank 2. To better visualize these results, the percentages from
Table 10 were graphed in
Figure 14. The results obtained with the seed data and the external data loaded into the neuro-generator indicate that the initial data that enters the LFSR does not matter. Despite this, the working frequency of the neuro-generator does influence whether it passes more or fewer NIST statistical tests.
5.2. NIST Test Results of Neuro-Generator with Neuronal Module Enabled
With the neuronal module of the neuro-generator enabled, the output sequence was obtained with the LFSR2 at a periodic frequency of 4 kHz, while that of LFSR1 depended on the pulses of impulse neurons, which generated an aperiodic signal. This sequence was validated by NIST statistical tests with the loaded seed data as the first case and with the external data as the second case. With the seed data loaded into the neuro-generator, the sequence passed only the Linear Complexity test. On the other hand, with the external data as initial data,
Figure 15 shows the tests that determined the sequence to be pseudorandom. These were the Frequency (Monobit) test with a result of a
p-value = 0.184754, the Runs test with a
p-value = 0.014435, and the Linear Complexity test with a
p-value = 0.346706.
The frequency of the neuronal module was modified to 100 MHz per clock cycle to produce a greater number of pulses at the output of this module. In this way, a higher frequency was generated in the LFSR1. The sequence obtained from the neuro-generator under these conditions and with the external data as initial data passed three more tests than with a frequency of 4 kHz in the neuronal module.
Table 11 shows the
p-value results for these tests, which are the Frequency (Monobit) test, all states of the Random Excursion test and Random Excursion Random Variant test and the Linear Complexity test. However, when the initial seed value was loaded to the neuro-generator, under the same frequency conditions the results yield a satisfactory conclusion only for the Linear Complexity test, with a
p-value = 0.640503.
According to the validation results of the neuro-generator with different frequencies, it was shown that it can generate pseudorandom or perfectly pseudorandom sequences, regardless of the data entered into the design’s LFSR registers as the initial value. Furthermore, it was observed that in all the situations to which the neuro-generator was subjected, the Linear Complexity test always concluded as pseudorandom all the output sequences that were generated under different conditions in the design of the neuro-generator. This means that the test considers the entire sequence to be sufficiently complex and with an adequate bit distribution.
6. Conclusions
The neuro-generator circuit design can be implemented in the FPGA Virtex 7 xcvx85t-2ffg1761 device without affecting its performance, due to the few percentages of the device’s resources used. The highest percentage was 31.701%, which corresponded to the number of LUT-FF used.
In addition, the neuro-generator can generate complex sequences with an adequate bit distribution, regardless of the conditions in which it is found. In other words, the frequency can be modified to a higher frequency than 100 MHz or reach a lower frequency such as the original frequency of the neurons of the neuronal module, which is 4 kHz per clock cycle. This module that is connected to the clk of LFSR1 can generate a non-periodic frequency, which depends entirely on the output pulses that the neurons produce. Therefore, until that moment, the register generates a new series of bits that are processed by the rest of the circuit blocks together with the data from LFSR2. If the frequency of the neuronal module increases, as shown in the circuit simulation results, it is possible to generate a greater number of pulses. This means increasing the frequency of the LFSR1.
In the frequency range of 100 MHz–4 kHz, a good response is guaranteed in the validation by the NIST statistical test of the entire sequence, as demonstrated in the p-value results obtained in the different cases. The results of most tests showed that a sequence of approximately 10 million bits is pseudorandom and perfectly pseudorandom for some of these. For example, the Approximate Entropy test and some states of the Random Excursion and Random Excursion Variant test had a p-value = 1.000000.
Finally, considering all of the above and the different conditions that the neuro-generator has, it was concluded that it can be used for different areas of interest as required. Some of these are in biological systems, where the properties that impulse neurons have can be taken advantage of to manipulate themselves and modify their output response. As in this case, the frequencies were modified from a very low to a higher one to have a better response in the output sequence of the neuro-generator.
The characteristics of this neuro-generator will be used as future work in the study of algae and microalgae, which are a pest problem in different aquifer systems of Jalisco, Mexico [
33,
34]. This would imply a variation in the frequencies of the neuro-generator to adapt to the growth speed that this type of biological system can present; that is, their growth depends on the conditions in which it is found, so it can be given in a very slow or speedy way. Therefore, using the neuro-generator at different frequencies, taking into account that the frequency of LFSR 1 is kept random by the pulses of the neuronal module, the different sequences generated can be used to simulate the growth of this type of algae. Other applications are in different types of simulations in electronic circuits to test their operation, among others.