Sie sind auf Seite 1von 5

Causal and Non-causal Entropy quantifiers

implemented in FPGA
M. Antonelli† , L. De Micco†∗ and H. Larrondo†∗
† ICYTE (Instituto de Investigaciones Cientı́ficas y Tecnológicas en Electrónica)
J. B. Justo 4302, Mar del Plata, Argentina
∗ CONICET (Consejo Nacional de Investigaciones Cientı́ficas y Técnicas)

{maxanto, ldemicco, larrondo}@fi.mdp.edu.ar

Abstract—This paper describes the implementation of a mensions;


system for measuring entropy. The design was optimized • Perron-Frobenius operator, quantifiers of recurrent
to be implemented in a simple and small microcontroller, plots;
achieving acceptable accuracy. The system allows measuring
the entropy of internally code-generated signals, and also, • Statistical tests proposed in standardized banks for
sampled external analog signals. The development board studying random number generators (Marsaglia, NIST,
used M1AFS-embedded kit of Actel. In the FPGA (Field etc.).
Programmable Gate Array) a microcontroller 8051 was
instantiated and programmed in C language. The hardware At the moment, there is no much literature on hardware
and software design are described and also the obtained results. implementations of these tools [1].
In the particular case of entropy, it is used in various
Resumen—En este trabajo se describe la implementación de applications, such as in the anomaly detection of IP data
un sistema de medición de entropı́as. El diseño fue optimizado
para ser implementado en un microcotrolador simple y
flows [2], [3]. In [4] an FPGA design and simulation of an
pequeño, conservando una precisión aceptable. El sistema entropy quantifier is introduced, however currently there are
permite medir entropı́as a señales generadas internamente no available hardware implementations of this quantifier.
por código y a señales externas analógicas muestreadas. Se Within the project mentioned in this paper a system that
utilizó la placa de desarrollo M1AFS-embedded kit de ACTEL.
calculates the entropy of a particular probability distribution
En la FPGA (Field Programmable Gate Array) se instanció
un microcontrolador 8051 al que se programó en lenguaje C. (PDF) associated with a data set is implemented. Causal
Se detalla el diseño del hardware y software y los resultados and non-causal PDFs are analyzed. Data can have a digital
obtenidos. source (generated by code) or can come from sampling
external analog signals. The development board used the
I. I NTRODUCTION M1AFS-embedded kit, based on the M1AFS1500 chip that
In the development of new electronic realizations of is known for having an analog block embedded in the same
NonLinear Systems, specially Multiatractor chaotic Systems package of the FPGA.
it is critical to be able to know and monitor the system’s Then, the numerical accuracy of the implemented quan-
properties. Always a thorough analysis of the systems is tifier is verified by comparing their results with a standard
required to meet the objectives, mainly the changes in program. The maximum error detected determines the sta-
the statistical properties induced by discretization of the tistical accuracy of the system.
system. Then it is necessary to check that the system The organization of this paper is as follows: Section II
still satisfies the application’s requirements, this demands both normalized entropies are presented for their considera-
further analysis. Tools coming from the nonlinear analysis tion; Section III describes the hardware implementation and
like Lyapunov exponents, cross, and autocorrelation, Perron- interfaces; in IV the software is described in detail; Section
Frobenius operator, Correlation Dimension are employed, V shows the obtained results of the system validation and in
and also statistical tools like the Shannon Entropy, Com- the measurement of the signals. In section VI, experimental
plexity, Bandt and Pompe embedding. results are interpreted and discussed. Finally, we present our
This work is part of a more ambitious project, which is conclusions in Section VII.
the hardware development and implementation of tools for
the analysis of nonlinear systems. These tools will mean a II. C AUSAL AND N ON CAUSAL E NTROPY
significant advance in the field of implementation of non-
linear systems. It will allow to more accurately understand Let X = {xi , i = 1, ..., N } of length N the output of a
and describe the behavior of the digital version of this type given source symbol, with alphabet A = {ai , i = 1, ...M }.
of systems. The complete package of tools that we intend Each element of X is xi ∈ A.
to implement consists of: The most commonly used PDF is the normalized his-
• functional of the probability distribution: Shannon En- togram of the N values of X between the M symbols of
tropy, Statistical Disequilibrium, and Statistical Com- A; it is defined as P DFhist = {pi , i = 1, ...M }, where pi
plexity; is the probability of occurrence of the symbol ai ∈ A. Its
• time series’s quantifiers, especially Lyapunov expo- normalized Shannon entropy is referred to as Hhist and is
nents, autocorrelation, cross-correlation and fractal di- defined:
PM
pi log pi Development Kit
i=1
Hhist = (1) FPGA
logM Calculation Logic
The standard entropy Hhist quantifies the distribution of
Logic SRAM
the elements of the series among all possible symbols.
If the source is a Pseudo Random Number Generator
(PRNG), then all the symbols of the alphabet should appear
Acquisition
the same number of times and its (optimal) value will be Presentation
Hhist = 1. Analog
P DFhist is non-causal since it does not consider the Interface USB-to-UART
temporal order of time series’ elements. This fact means that
the X vector could be rearranged to generate other vector Y ,
which would have the same histogram as X, and, therefore
identical P DFhist and the same value for Hhist . PC
Analog signal
For quantifying statistical independence between consec- (Matlab)
utive elements, in this paper the causal PDF proposed by
Bandt & Pompe in [5] is used. This PDF is obtained by Fig. 1. Scheme of the complete system.
assigning patterns of order to overlapped segments of length
D of the time series.
The process for its calculation is the following: first which converts the incoming analog signals into digital
D consecutive elements are grouped {xi , xi+1 , ..., xi+D }. words. The next step is the Calculation logic stage, it
Then the (ascending or descending) order of the D values uses the SRAM to perform calculations and coordinate
of each group is compared to the order of the vector the interfaces, and the last stage is the Presentation which
{1, 2, ..., D}. There are D! Possible ways to sort the num- sends the results to a computer through the USB-to-UART
bers {1, 2, ..., D}. If two values of xi within the same group interface.
are identical, it is considered that the first is lower, to obtain
a unique result. Each permutation is called ordering pattern A. Acquisition Stage
[6].
The normalized histogram of the order patterns is the The analog data to be evaluated is entered into the
causal Bandt & Pompe’s PDF P DFBP . The normalized system by using the voltage input AV 2 of the analog block
Shannon entropy of that P DFBP is HBP where the sub- Analog Quad 2. This input is mapped to channel seven of
script BP means “Bandt & Pompe”. the analog multiplexer, and it was configured with an input
Bandt and Pompe suggest 3 ≤ D ≤ 7. For this work, we voltage of 0 V to 4 V. The analog-digital converter was
adopted D = 6. configured with a 12-bit resolution. In this first prototype
the maximum sample rate achieved was 16 ks/s, limited
In the HBP vs. Hhist plane [7], a higher value in any
by the processing logic delay. This speed was enough for
of the entropy values implies an increase in the uniformity
the required measurements. However, in a next stage an
of the involved P DF . The point (1, 1) represents an ideal
optimization of the design will be developed by increasing
case were both distributions, distribution of values and
the operating frequency, among other improvements.
distribution of order patterns, are uniform.
A complete discussion about the convenience of using
B. Calculation logic
these quantifiers is beyond the scope of this work. A broad
study can be found in [7]–[11]. The calculations and synchronization between peripherals
are made at this stage. Figure 2 shows the main blocks that
III. I MPLEMENTED H ARDWARE compose it.
The hardware design was based on ACTEL’s con- The heart of implementation is an 8051 Core that provides
figuration on the 8051 microcontroller, and peripheral Actel in its library catalog. It is a microcontroller containing
interfaces. It was developed using the software pack- the central logic of the Intel 8051 microprocessor, without
age Libero Soc v11.3 c
. The development board used its peripherals. This micro has a Harvard architecture with a
was M1AFS-EMBEDDED-KIT that contains an FPGA 16 bits address bus, limiting our design to 64 KB of memory
M1AFS1500 and peripherals [13]. code and 64 KB of data memory.
The M1AFS1500 embedded chip contains an analog block The application that performs the calculations presented in
consisting of nine addressable adapters of four inputs each, section II runs over this microcontroller. It is responsible for
a 32 inputs analog multiplexer and a configurable analog- obtaining the PDFs (BP and hist) and to perform the calcu-
digital converter. lations to get the entropies from the input data, according to
For handling this block, a system also provided by Eq. 1. Section IV describes in detail the developed software.
ACTEL is used. This system is based on an 8051 microcon- In this particular FPGA, the code memory is a non-volatile
troller, and it also contains drivers of the peripheral among memory (NVM) and is implemented in the internal flash
other things [12], [14]. of the FPGA blocks. It is mapped onto the addresses from
The developed system can be divided into three main 0x0000 to 0xFFFF and is written during compilation with
stages as shown in Fig. 1: the first phase is the Acquisition, the contents of a hexadecimal format file.
Logic
addresses
SRAM
μC 8051
data
NVM
APB_Master data
SRAM

BUS APB
YES

AI controller UART
Controller

Analog Interface USB-to-UART


Fig. 2. Details of the Calculation Logic stage.

The system functionality is extended by connecting pe-


ripherals through the APB interface.
For handling communication with the PC, the UART
controller is used. The output of this block is directed out
of the FPGA and is connected to a USB-to-UART chip that
is soldered to the board. The analog block is controlled by
the AI controller, which routes and synchronizes its inputs.
C. Presentation
The stage of data presentation involves the USB-to-UART
chip adapter that is on the development board and is driven Fig. 3. Flowchart of the implemented software.
both by the program running on the FPGA as well as by
the software that runs on the PC.
The USB-to-UART chip is responsible for adapting the V. R ESULTS
input-output UART logic to an input-output USB standard
by which is possible to interact with the PC. Moreover, the As said, to test the system, the obtained results were
program running on the PC handles the user interface and compared with the results achieved by a pattern program
is described in detail in the next section. running on the PC. For this, 10000 samples of different
waveforms were generated by both external (analog) and
IV. I MPLEMENTED S OFTWARE internal (digital) signals.
The system operation is achieved by the interaction of Two digital signals were produced by the code in the
two programs. One running on the PC and another on the microcontroller, one corresponds to the rand() C function
microcontroller instantiated in the FPGA. It can be seen a and the other to the chaotic Logistic map with parameter
flow chart of the two programs and the interaction between r = 4.
them in Fig. 3. On the PC runs a Matlab’s script that is Analog signals were generated with the HP33120A wave-
responsible for opening the serial port where the USB is form generator. With a range of 4 V pp and 2 V of direct
mapped, requesting data, taking the results of the port, then current to take advantage of the full spectrum of the analog-
plotting them in a plane HBP vs. Hhist and finally closing digital converter and increase the signal to noise ratio. In
the port. all four cases, the signal frequency was 100 Hz and the
Over the microcontroller instantiated in the FPGA runs a sampling rate of 16 ks/s.
program written in C language and compiled for the 8051 Table I shows the absolute error between the calculated
microcontroller using the SoftConsole IDE v3.4 c
tool. The results of the quantifiers in the FPGA compared with the
firmware used is a modification of [14]. When a request results calculated with the standard program running on the
for data from the UART port occurs, the data sampled in PC, over the same samples.
the analog input are stored. Then, P DFhist y P DFBP Fig. 4 shows in the HBP vs. Hhist plane the results
are calculated, and with this information, their respective calculated by the FPGA.
entropies Hhist and HBP are also calculated. These results Compilation results show the FPGA resources needed by
are sent to the PC through the same port. the entire system and also the amount of memory occupied
To validate the system, and verify how accurate the by the software running on the microcontroller. It is impor-
results are, the incoming sampled vector data is forwarded tant to highlight that this is a rigid hardware implementation,
to the PC, so that it can calculate their entropies with PC i.e. the first circuit in the FPGA (microcontroller, peripheral,
using Matlab c
and compare them with the results of the etc.) are configured and then the software is loaded on it.
implemented system. The report returned after running the “Place and Route” tool
TABLE I
Q UANTIFIERS ERROR EVALUATED IN THE FPGA WITH RESPECT TO THE to be able to implement it in the microcontroller that was
RESULTS CALCULATED BY THE PATTERN PROGRAM . instantiated in the FPGA, we had to reduce the number
of bits employed. We used 32-bit floating point arithmetic
Generator Source Error HBP Error Hhist
Rand Digital 1, 7421E −6 2, 6977E −6 (IEEE754-32 bits standard). The calculation of the logarithm
Logistic Digital 0, 4256E −6 94, 693E −6 function was also required, so it was implemented using the
Triangular Analogic 6, 3445E −6 2, 0028E −6 CORDIC algorithm. These differences make the output of
Sinusoidal Analogic 6, 3151E −6 5, 6506E −6 the implemented system not to be equal to that of a program
Square Analogic 0, 1797E −6 1, 9930E −6
Ramp Analogic 245, 00E −6 1, 0876E −6
running on the PC, which we take as pattern program. Thus,
these differences were measured, to have a dimension and
determine whether the results are correct.
Table I shows that the absolute error never exceeds the
value 245E −6 . This boundary indicates that there is a
difference from the fifth decimal digit.
It can be seen in Fig. 4 that HBP and Hhist quantifiers
can clearly difference between the statistical properties of
the analyzed data. Sinusoidal, Ramp and triangular signals
have the highest values for Hhist because the present all
the possible values that the Analog-digital converter can
Logistic Map generate.
Rand function of C
However, the mixing of these signals are not good because
Triangular
they are periodic signals, so they are totally predictable, this
Sinusoidal
Square
is reflected by the small values of HBP . An interesting case
Ramp to be analyzed is the square signal. The additive noise effect
is specially marked in the areas where the value of the signal
should be constant.
Two very narrow Gaussian curves appear around the ideal
Fig. 4. Measurement results.
values of the P DFhist , this does not affect too much the
calculated value of Hhist , however for P DFBP , the order
pattern is derived directly from the noise, with a particular
is shown in Fig. 5. It can be seen that the implementation
mean value, so the value of HBP will be higher than
uses 19% of the FPGA logic resources, 21% of the input-
expected.
output cells and 28% of the memory blocks.
The signal generated by rand function of C has the best
The compilation report of the software part of the system
statistical properties being located at the point ∼ (1, 1).
is shown in Fig. 6. We can see that the non-volatile flash
memory is 15.4% occupied.
On the other hand, of the 65536 addresses the SRAM VII. C ONCLUSIONS AND FUTURE WORK
have available just 61440 because some of this addresses It was developed and implemented a system that allows
are used by the APB bus, so the 76.7% of the available a measurement with the proper precision of the causal
memory is used. and non-causal entropy of external analog signals from
the outside of the FPGA and internal signals generated
by code. It was possible to measure signals and perform
complex calculations with a small microcontroller as the
8051 instantiated in ACTEL AFS1500 FPGA. This first
prototype meets the required specifications of accuracy and
Fig. 5. Resources used by the system hardware.
the quantity of resources established in the design. The
following step will be to optimize the system regarding
operating frequency and noise immunity. It is expected that
the system will allow modifying, at runtime, the sampling
rate, so it would be adaptable to the input signal, with the
upper limit of 500 Ks/s set by the ADC.
A threshold level should be added from which a value
will be considered different from another, thus, the problem
Fig. 6. Resources used by the system software. with the additive noise in the calculation of HBP will be
solved. The code for this system occupies 15.4% of the
total flash memory of the instantiated micro, so it will be
VI. D ISCUSSION possible to add software to implement other quantifiers and
The software had to be adapted to the microcontroller functionalities. As for the issue of the resources available
instantiated in the FPGA. The pattern program uses 64-bit in the FPGA, the logic cells used is 7349, leaving almost
floating point arithmetic (IEEE754-64 bits standard ) and 80% of the available hardware resources to implement the
uses the math.h library [15]. For adapting the algorithm systems under test, concurrently with the quantifiers.
ACKNOWLEDGMENT
This work was partially supported by the Con-
sejo Nacional de Investigaciones Cientı́ficas y Técnicas
(CONICET), Argentina (PIP 112-200801-01420), ANPCyT
(PICT-2013-2066), UNMDP and the International Centre for
Theoretical Physics (ICTP) Associateship Scheme.
The Actel Development Kit used in this work was kindly
donated by the Multidisciplinary Laboratory (ICTP).
R EFERENCES
[1] L. De Micco, M. Antonelli, C. Gonzalez, and H. Larrondo. Hardware
implementation of maximum lyapunov exponent. In Embedded
Systems (SASE/CASE), 2013 Fourth Argentine Symposium and Con-
ference on, pages 1–4, Aug 2013.
[2] Y. Gu, A. McCallum, and D. Towsley. Detecting anomalies in network
traffic using maximum entropy estimation. In Proceedings of the
5th ACM SIGCOMM Conference on Internet Measurement, IMC ’05,
pages 32–32, Berkeley, CA, USA, 2005. USENIX Association.
[3] A. Wagner and B. Plattner. Entropy Based Worm and Anomaly
Detection in Fast IP Networks. In Proceedings of the 14th IEEE
International Workshops on Enabling Technologies Infrastructure for
Collaborative Enterprise, 2005.
[4] S. Nagalakshmi. Study of FPGA implementation of entropy norm
computation for IP data streams. PhD thesis, University of South
Florida Scholar Commons, 2008.
[5] C. Bandt and B. Pompe. Permutation entropy: a natural complexity
measure for time series. Phys. Rev. Lett., 88:174102–1, 2002.
[6] J. M. Amigó, L. Kocarev, and J. Szczepanski. Order patterns and
chaos. Physics Letters A, 355:27–31, 2006.
[7] L. De Micco, C. M. González, H. A. Larrondo, M. T. Martin,
A. Plastino, and O. A. Rosso. Randomizing nonlinear maps via
symbolic dynamics. Physica A, 387:3373–3383, 2008.
[8] R. Wackerbauer, A. Witt, H. Atmanspacher, J. Kurths, and H. Schein-
graber. A comparative classification of complexity measures. Chaos,
Solitons, Fractals, 4:133–173, 1994.
[9] R. López-Ruiz, H. L. Mancini, and X. Calbet. A statistical measure
of complexity. Phys. Lett. A, 209:321–326, 1995.
[10] O. A. Rosso, H. A. Larrondo, M. T. Martin, A. Plastino, and
M. A. Fuentes. Distinguishing noise from chaos. Physs. Rev. Lett.,
pp154102-154106, 99, 2007.
[11] O. A. Rosso, L. De Micco, H. A. Larrondo, M. T. Martin, and
A. Plastino. Generalized statistical complexity measure: a new tool for
dynamical systems. International Journal of Bifurcation and Chaos,
Vol. , No. 3 (2010) ., 20(3):775–785.
[12] Actel Corporation. Core8051s Embedded Processor Hardware De-
velopment Tutorial, for Fusion Mixed-Signal FPGAs, 2009.
[13] Actel Corporation. Fusion Embedded Development Kit, 2009.
[14] Actel Corporation. Core8051s Embedded Processor Software Devel-
opment Tutorial, for Fusion Mixed-Signal FPGAs, 2009.
[15] I. . The Open Group Base Specifications. math.h: mathematical
declarations, base definitions reference.

Das könnte Ihnen auch gefallen