VHDL Descriptions for the FPGA Implementation of PWL-Function-Based Multi-Scroll Chaotic Oscillators

Nowadays, chaos generators are an attractive field for research and the challenge is their realization for the development of engineering applications. From more than three decades ago, chaotic oscillators have been designed using discrete electronic devices, very few with integrated circuit technology, and in this work we propose the use of field-programmable gate arrays (FPGAs) for fast prototyping. FPGA-based applications require that one be expert on programming with very-high-speed integrated circuits hardware description language (VHDL). In this manner, we detail the VHDL descriptions of chaos generators for fast prototyping from high-level programming using Python. The cases of study are three kinds of chaos generators based on piecewise-linear (PWL) functions that can be systematically augmented to generate even and odd number of scrolls. We introduce new algorithms for the VHDL description of PWL functions like saturated functions series, negative slopes and sawtooth. The generated VHDL-code is portable, reusable and open source to be synthesized in an FPGA. Finally, we show experimental results for observing 2, 10 and 30-scroll attractors.


Introduction
Chaos theory deals with nonlinear and complex dynamic behavior that is associated to unpredictable phenomena. The main characteristic is that small changes in the initial conditions lead to drastic changes in the results. It is deterministic because one knows its model parameters and it is unpredictable because one does not know the evolution of the trajectories, and then one cannot predict its behavior.
Three decades ago, the author in [1] introduced an extremely simple autonomous circuit that generates chaotic behavior. It was known as Chua's circuit with the advantage of including only one nonlinear element composed of a piecewise-linear (PWL) resistor. If it has 3-segments, it can generate the double-scroll attractor, as confirmed in [2]. Ten years later, the popularity of Chua's circuit was summarized in [3], where it is mentioned that more than 200 a1111111111 a1111111111 a1111111111 a1111111111 a1111111111 number of scrolls. The following subsections show new ways to model PWL functions like saturated function series, negative slopes and sawtooth one. All these PWL functions can be implemented using comparators, which will be useful for the VHDL descriptions of chaos generators, as shown in Sect. 4.

Chaotic oscillator based on saturated function series
Eq (1) describes the 3-dimensional multi-scroll chaotic oscillator based on the PWL function f(x) described by Eq (2). The state variables are x, y and z, and they are multiplied by four coefficients: a, b, c and d 1 . Those coefficient values can be in the range [0, 1], and one must decide how many places to use for the integer and fractional parts [4,21]. The PWL function can be associated to comparators, since it is a saturated function series. From Fig 1, one can identify the parameters: saturation levels k i , break points B j and slope m. These three parameters can be augmented according to the number of scrolls n being generated. The PWL function in continuous lines shown in Fig 1(a) can be described by Eq (2), which can be augmented as sketched by the dashed lines to generate even number of scrolls. In a similar manner, Fig 1(b) has parameters k i , B j and m, but the continuous line has 3 saturation levels (k 1 , k 2 , k 3 ) to generate 3-scrolls, then the PWL function can be augmented as sketched by the dashed lines to generate odd number of scrolls, and the mathematical description is like in Eq (3), where the PWL . . .

Chua's circuit based on negative slopes
and slopes m e . These three parameters can be augmented according to the number of scrolls n being generated. The PWL function in continuous lines shown in Fig 2(a) can be described by Eq (5), which can be augmented as sketched by the dashed lines to generate even number of scrolls. Fig 2(b) has also parameters k i , B j and m e , but the continuous line has more segments than Fig 2(a) to generate 3-scrolls, then the PWL function can be augmented as sketched by the dashed lines to generate odd number of scrolls, and the mathematical description is like in Eq (6).

Chua's circuit based on sawtooth function
Chua's circuit can also be implemented using a sawtooth function, and described by the three state variables x, y and z, given in Eq (7), and it also has three coefficients: α, β and γ. From  Fig 3, one can identify the parameters: amplitude k i , break points B j and slopes m. These three parameters can be augmented according to the number of scrolls n being generated. The PWL function in continuous lines shown in Fig 3(a) can be described by Eq (8), which can be augmented as sketched by the dashed lines to generate even number of scrolls. Fig 3(b) has 3 continuous lines to generate 3-scrolls, then the PWL function can be augmented as sketched by the dashed lines to generate odd number of scrolls, and the mathematical description is like in Eq (9). The PWL function will always have n − 1 number of break points B i , n number of slopes m, and amplitude ±k.

Simulating multi-scroll chaotic oscillators based on PWL functions
This section details the pseudocode for the three multi-scroll chaotic oscillators shown above. We describe the PWL functions with the main purpose of transforming the mathematical model to VHDL-code, as highlighted in the next section. For instance, as already shown in [4,21], the mathematical descriptions in Eqs (1), (4) and (7) can be solved by numerical methods like Forward Euler, Runge-Kutta, and so on. The discretized equations from Eqs (1), (4) and (7), by applying Forward Euler, are given by Eqs (10), (11) and (12), respectively.
The oscillators and their associated PWL functions can be programmed from the following pseudocodes to generate double-scroll attractors using Eqs (2), (5) and (8).

Oscillator based on saturated function series
To generate even and odd number of scrolls from Eq (1), f(x) is sketched in Fig 1(a) and 1(b), respectively. As one can infer, the PWL descriptions based on saturated function series and modeled in Eqs (2) and (3) can be extended according to the number of scrolls being generated. Algorithm 1 highlights the form in which the double-scroll chaotic attractor is simulated using Eq (2). The steps are executed as follows:

Oscillator based on negative slopes
For Chua's circuit based on negative slopes, to generate even and odd number of scrolls from Eq (4), f(x) must be described as shown in Eqs (5) and (6), respectively. Algorithm 2 highlights the form in which the double-scroll chaotic attractor is simulated using Eq (5). The steps are executed as follows:  (5) and (6) 16. Verifies if x is higher than B[2Ãn -3]. If it is satisfied then (4), x and y are initial conditions, and h is the step size (4) and z is the initial condition 20. State variable z[n] is updated to z+hÃ(-betaÃy), where beta is coefficient β in Eq (4) 21. State variable x is updated to the next iteration 22. State variable y is updated to the next iteration 23. State variable z is updated to the next iteration 24. Index i from step 1 is incremented to the next iteration, until st is accomplished.

Oscillator based on sawtooth function
For Chua's circuit based on sawtooth function, to generate even and odd number of scrolls from Eq (7), f(x) must be described as shown in Eqs (8) and (9), respectively. Algorithm 3 highlights the form in which the double-scroll chaotic attractor is simulated using Eq (8). The steps are executed as follows: where n is the number of scrolls being generated. If it is satisfied then

VHDL descriptions for the FPGA implementation of multi-scroll chaotic oscillators
From the pseudocodes listed above, one can infer the kind of digital hardware for generating chaotic behavior. For instance, to generate more than 2-scrolls or odd scrolls, one just needs to extend the PWL descriptions from Eqs (2), (3), (5), (6), (8) and (9), and all of them can be evaluated using comparators, as sketched in Algorithms 1, 2 and 3. This section shows the distribution of the digital word to establish the fixed-point format from high-level simulation using Python. Afterwards, our approach generates VHDL-code for the three multi-scroll chaotic oscillators detailed above. At the end, the generated VHDL-code is ready to be synthesized into an FPGA.

Fixed-point format for generating 2 and 30 scrolls
To compute the fixed-point format being used for the VHDL descriptions, one needs to simulate the chaotic oscillator to know parameters like coefficient values and PWL characteristics, namely: break points, amplitudes, and slopes. Those parameter values for generating 2-scroll attractors for the three chaotic oscillators are the following: Other simulation results for generating 30-scrolls are shown in Figs 7-9. From the simulation results, one can identify the ranges of the state variables and parameters that will serve to define the computer arithmetic to translate simulation parameters to VHDL-code. The binary digits will have integer and fractional parts and our algorithm converts real numbers to their 2's complement. Basically, the integer part is converted through successive divisions and the fractional part with multiplications. From the 2's complement numbers, one can generate VHDL code by interconnecting the required blocks that solve a discretized system of equations, e.g. Eqs (10), (11) and (12), as shown in the following subsections.
For example: Using 32 bits, the ranges of the state variables for generating 2-scrolls in  Fig 9 ±0.6 and ±30. Now, the number of bits for the integer part will be 5, so that the fixed-point format can be established as 6.26. Sometimes, this task on establishing the format also requires estimating the maximum value when multiplying 2 numbers.

On numerical methods, computer arithmetic and MLE
As one can infer, an important issue when implementing a dynamical system using fixedpoint arithmetic is related to the necessary number of bits for the fractional part. The required number of bits can be estimated by trial and error techniques until observing the number of scrolls in the phase-space portrait, as already shown in [4, ch. 8]. So that one can reduce the number of bits for the fractional part until chaotic behavior remains. For instance, this subsection shows the reduction of bits for the fractional part to implement Chua's chaotic oscillator with fixed-point arithmetic. It is obvious that one needs a metric to quantify chaotic behavior, therefore the three Lyapunov exponents are computed for different number of bits in the fractional part. The Lyapunov exponents give the most characteristic description of the presence of a deterministic non-periodic flow. They are asymptotic measures characterizing the average rate of growth (or shrinking) of small perturbations to the solutions of a dynamical system, and they provide quantitative measures of response sensitivity of a dynamical system to small changes in initial conditions [28]. That way, the goal is determining the minimum number of bits in the fractional part, when still the maximum Lyapunov exponent (MLE) remains in a similar value.
To measure the Lyapunov exponents, the initial state of the chaotic oscillator is set to where [e 1 , e 2 , e 3 ] = I, and I is the identity matrix of size 3 × 3. Thus, e i , for i = 1, 2, 3, are each unitary column vector of the identity matrix I. (4) is observed by expanding it with other three systems. If x ¼ ½ _

The original system described by Eq
x; _ y; _ z T represent one state of the original dynamical system at any t > 0, then the states in the three new observational systems will be y = [x, x 1 , x 2 , x 3 ] T . The observational system is integrated by several steps until an orthonormalization period T O is reached. After this, the state of the variational system is orthonormalized by using the standard Gram-Schmidt method. The next integration is carried out by using the new orthonormalized vectors as initial conditions [28]. The Lyapunov exponents measure the long time sensitivity of the flow in x with respect to the initial data x 0 at the directions of every orthogonalized vector. This measure is taken when the variational system is orthonormalized. In this manner, if y = [x, p 1 , p 2 , p 3 ] T is the state after the matrix [x 1 , x 2 , x 3 ] is orthonormalized, then the Lyapunov exponent λ i , for i = 1, 2, 3 is evaluated by In this work the simulation of the expanded system was carried on with fixed integer arithmetic, using Forward Euler method with a time-step of 0.001. T O was set to 5 seconds and the period T to 2000 seconds, respectively. The number of bits for the integer part was established by looking at the phase-space portraits of the expanded system, so that 8-bits are good enough for the integer part. For the fractional part, we test the behavior by using from 10 to 30 bits, therefore, Table 1 lists the values of the Lyapunov exponents computed with formats of 9.10 to 9.30.
The computation of the Lyapunov exponents using Eq (13) was performed using floating point numbers, by applying the fourth-order Runge-Kutta method with a time step of 0.01, and whose result are listed in the first row of Table 1. The remaining values in that Table were computed using fixed integer arithmetic and Forward Euler with a time-step of 0.001. Fig 10 shows the maximum Lyapunov exponent (MLE) against the number of bits for the fractional part. The value computed by applying the fourth-order Runge-Kutta method is shown by the horizontal line at 0.061775, so that from these results, it is clear that by applying Forward Euler and fourth-order Runge-Kutta one gets similar values of the MLE. In addition, discretizing the ordinary differential equations with Forward Euler will require the lowest number of FPGA resources. Finally, one can conclude that for a hardware realization, at least 14 bits for the fractional part are required to keep the chaotic oscillator under a similar MLE value.

Block description to generate the hardware associated to discretized equations
As detailed in [4,21], the solution to the system of differential equations modeling a chaotic oscillator like Eqs (1), (4) and (7), needs the application of a numerical method to obtain their discretized descriptions like in Eqs (10)-(12), respectively. From those equations one can identify digital blocks like comparators for implementing the PWL functions, adders, subtractors and multipliers. Each block will process bits according to the selected format. For instance, Fig 11 shows the description of the adder, subtractor and multiplier. They are synchronous to take control on the iterative process and have associated a delay of a clock pulse CLK. In this manner, the time propagation from the input to the output in the chaotic oscillator unit shown in Fig 12, equals the maximum number of series-connected blocks. In Fig 12 one can identify the block Iterations control, which embeds a timer and a multiplexer to control the   (10), the state variables x and y are easy to implement as shown in Fig 13. However, z needs more hardware, as shown in Fig 14. In this manner, its propagation time is the largest and it controls the iteration loop in Fig 12. For this chaotic oscillator, the number of building blocks required in the Chaotic Oscillator Unit from Fig 12, can be calculated as given in Table 2, where n is the number of scrolls being generated.
Chua's chaotic oscillators have similar equations, the main difference is the evaluation of state variable x and their corresponding PWL functions for negative slopes and sawtooth. As  state variables y and z have the same description from Eqs (11) and (12), Fig 15 shows their implementations. For x, the hardware realization using negative slopes is shown in Fig 16, and using sawtooth function is shown in Fig 17. Again, for both Chua's chaotic oscillators based on negative slopes and sawtooth function, the number of building blocks required in the Chaotic Oscillator Unit from Fig 12, can be calculated as given by Table 2. These resources estimations are just the ones required to solve the discretized equations, and they can be incremented according to the length of the digital word that depends on the selected format.

VHDL-code generation
VHDL is the acronym of Very High-Speed Integrated Circuit Hardware Description Language, it was developed around 1980 at the request of the U.S. Department of Defense. At the beginning, the main goal of VHDL was the electric circuit simulation; however, tools for synthesis and implementation in hardware based on VHDL behavior or structure description files were developed later. With the increasing use of VHDL, the need for standardized was generated. In 1986, the Institute of Electrical and Electronics Engineers (IEEE) standardized the first hardware description language through the 1076 and 1164 standards. Nowadays, VHDL is technology/vendor independent, then VHDL codes are portable and reusable.
In Subsection 4.1 one can see the main parameters of a 2-scroll chaotic oscillator, like: coefficient values, break points, amplitudes, and slopes. They are used to perform a high-level simulation to identify the ranges of the state variables and iteration parameters that serve to define the computer arithmetic to translate simulation parameters to VHDL-code. Our approach can automatically generate VHDL code by interconnecting the required blocks that solve a discretized system of equations, e.g. Eqs (10)- (12), as already shown in Subsection 4.3. In this manner, this subsection shows the VHDL-code associated to the blocks required to synthesize the three multi-scroll chaotic oscillators detailed in Sect. 2. For instance, the main steps in generating VHDL-code can be summarized as follows: Step 1: Select the number of scrolls being generated, coefficient values and characteristics of the PWL function of the desired multi-scroll chaotic oscillator. The break points are directly related to the number of scrolls and must be provided from the left (the most negative) to the  Step 2: The high-level simulation is performed and our approach verifies the number of desired scrolls. From simulation data, the fixed-point format is established, as discussed in Subsection 4.1, where the ranges in Figs 4-6, leads us to use format 3.29 (using 32 bits), and from Figs 7-9, the ranges require a format 6.26. After the format is established, our approach connects the required blocks as detailed in subsection 4.3.
Step 3: Our approach creates a file containing the libraries and code for the blocks implementing Fig 12, where the block Iterations Control embeds a counter and a multiplexer to take control on the iterative process. In our examples, the counter provides a delay of 8 clock cycles CLK to process all signals at each iteration. The block Chaotic Oscillator Unit embeds all blocks implementing the desired multi-scroll chaotic oscillator.
The VHDL-codes for all the required blocks are shown in the following Algorithms. As one sees, they are described using 28 bits as the word length. This is not an issue, since our approach can generate the codes automatically. The signals are also described for each case.
The blocks multiplier, adder and subtractor have the following signal descriptions: • CLK: This is the master clock of the FPGA. All the operations are performed based on the clock frequency.
• RST: Reset of the system, puts the outputs to zero. Restarts the system.
• sena1: Internal signal with the double of bits from the word length to perform the multiplication. Iterations control block (Algorithm 7) has the signals:

Algorithm 4. Multiplier in VDHL
• CLK and RST are the same for all blocks.
• Xini, Yini and Zini: Feeds input signals to the Chaotic Oscillator Unit, until accomplishing st iterations as sketched in Sect. 3.
• Xout, Yout and Zout: Output data that will be processed by the Iterations control block to perform st iterations.
• dx, dy and dz: Initial conditions for each iteration. These registers save the output data of the state variables and then feeds them as input signals Xini, Yini and Zini.
• count: Signal to update the initial values to the Chaotic Oscillator Unit at each iteration. This signal is enabled after 8 clock cycles (CLKs), which is the time required by the maximum number of series-connected blocks. The PWL functions are implemented using comparators. If the PWL segments increase, as detailed in Sect. 3, then also the number of comparisons do. The comparator blocks have CLK and RST signals as the previous blocks.

Algorithm 8. Comparator for implementing saturated functions in VHDL
The PWL function for the oscillator based on saturated functions is implemented by Algorithm 8, where: • dato_sat0: Input data for the first level of saturation.
• dato_sat1: Input data for the second level of saturation.
• dato_pen0: Input data for the slope.
• dato_X: Input data of the state variable x to perform comparisons.
• dato_S: Output data that takes the value from one input like dato_sat0, dato_sat1, or dato_pen0.
• B0, B1, B2 and B3: Constants to represent the break points from the left to the right of the PWL functions.
The PWL function for the oscillator based on negative slopes is implemented by Algorithm 9, where: • dato_pen0: Input data for the first slope located on the left of the PWL function.
• dato_pen1: Input data for the last slope, which is the same as the first.
• dato_penm: Input data for the central slope.
• dato_X: Input data of the state variable x to perform comparisons. The PWL function for the oscillator based on sawtooth function is implemented by Algorithm 10, and it is similar as the last two comparators, where: • dato_pen0: Input data for the first slope.
• dato_pen1: Input data for the last slope, which is the same as the first.
• dato_X: Input data of the state variable x to perform comparisons.
• dato_S: Output data that takes the value from one input like dato_pen0, dato_pen1.
• B0: Constant to represent the break point.
The generated VHDL-code is ready to be synthesized into an FPGA, so that the following Section shows experimental results.

Experimental results
The generated VHDL-codes for the synthesis of multi-scroll chaotic oscillators based on PWL functions were implemented in the Altera's FPGA EP4CGX150DF31C7 Cyclone IV GX. The used resources are listed in Table 3, and the experimental attractors are shown in  where one can appreciate the good agreement with simulation results from Sect. 4. In all those figures the state variable x is shown on the top left-side, y on the bottom left-side, and the phase-space portrait x − y on the right-side. One can count the number of scrolls from the phase-space portraits, and from Lyapunov exponents evaluation, one can infer that the more scrolls are generated the more complex behavior. In this manner, and from the experimental results, it is clear that engineering applications like in [4] can be realized in a very short time. This is the advantage of FPGAs for fast prototyping, and we have introduced a Python-based approach for the generation of VHDL-code that is ready for FPGA synthesis.

Conclusions
We have introduced an approach programmed in Python for the generation of VHDL-code associated to multi-scroll chaotic oscillators that are based on PWL functions. The pseudocodes for simulating three kinds of chaotic oscillators were listed to infer the FPGA implementation of the PWL functions based on saturated functions series, negative slopes and sawtooth one. From the high-level simulation, our algorithm determines the fixed-point format to interconnect digital blocks associated to the discretized equations of the chaotic oscillators. The PWL functions are then implemented by using comparator blocks that can increase the number of comparisons according to the number of scrolls being generated. It was highlighted that these tasks are performed from the description of the dynamical equations and PWL functions, to the interconnection of the digital blocks and generation of the VHDL-code, which is portable, reusable and open source to be synthesized in an FPGA of any vendor. It is worthy mentioning that the FPGA resources depend on the discretization approach. For instance, Subsection 4.2 showed that Forward Euler and the fourth-order Runge-Kutta methods computed similar values of the Lyapunov exponents, and also when using floating point and fixed integer arithmetic. However, the number of bits for the fractional part matters. As shown in Table 1, at least 14 bits for the fractional part are required to keep the chaotic oscillator under a similar MLE value.
Finally, it can be concluded that our approach for generating VHDL descriptions can estimate the number of required blocks from the equations listed in Table 2, which depend on the number of scrolls being generated. And, among the three multi-scroll chaotic oscillators that were implemented into an FPGA, we can conclude that the one based on saturated function series requires lower number of hardware resources, as showed by Table 3.