2.1. Software Design and Implementation
Neural entrainment plays a critical role in coordinating oscillatory activity across brain regions. In epileptic seizures, abnormal neural synchronization often manifests as excessive, uncontrolled oscillatory coupling. By introducing controlled rhythmic stimulation, digitally generated precise frequencies, it may be possible to guide pathological brain rhythms back into stable, physiologically coherent states [
17,
18,
19]. In this framework, a digital frequency-generation chip developed with open-source tools can deliver phase-controlled signals that interact with cortical oscillations, promoting adaptive entrainment rather than pathological suppression or synchronization. Such interventions could restore balance within neural networks, mitigating seizure onset and propagation through frequency-aligned entrainment of cortical rhythms [
20]. To illustrate the principle,
Figure 2 shows the high-level description of neural signal entrainment using digitally generated oscillatory waveforms through custom designed chip. The concept models how an external periodic signal, produced by a custom-designed frequency-generation chip, can influence and synchronize dysregulated brain activity. To illustrate this principle, the top plot in
Figure 3 shows two independent oscillatory signals at 11 Hz (blue) and 13 Hz (red), representing neural populations operating at different intrinsic frequencies. These unsynchronized rhythms where oscillatory pools are not phase or frequency-aligned and therefore exhibit low coherence. In such a state, the peaks and troughs of the signals appear at different times, reflecting the chaotic nature of uncoordinated neural activity often observed in pathological conditions such as epilepsy [
21,
22,
23,
24]. Meanwhile, the bottom plot shows two oscillatory signals with the same frequency (11 Hz) but a constant phase offset. This represents a phase-locked, entrained state in which the formerly independent oscillations have aligned under the influence of an external rhythmic drive. The constant phase difference indicates that the two signals are now coherently coupled, oscillating in a stable, synchronized relationship. In the neural context, this state models the successful entrainment of chaotic brain rhythms to an externally applied digital signal, restoring a balanced and regulated oscillatory pattern.
Similar to the brain’s electrical rhythms, signal entrainment involves the synchronization of an oscillatory system to an external periodic signal. In the context of brain waves, entrainment describes how an external rhythm generated by an external device could influence and synchronize with the brain’s native rhythms, potentially bringing the brain wave activity closer to a desired frequency. In the context of this research paper, the brain’s chaotic signal is not in sync with its expected reference rhythm and is hence classified as neural dysregulation. When a frequency with a specific rhythm generated by a custom-designed chip is introduced after the chaotic activity is detected, it works to entrain the chaotic signal by forcing it to align with the chip’s generated frequency, thus bringing the brain signal back to a more regulated rhythm. The entrainment process can be modeled mathematically as a forced oscillator system [
25]. The dysregulated signal, before the entrainment, is analogous to a free oscillator. Upon application of the pre-defined chip signal, the system is forced to adjust its phase and frequency to synchronize with the external stimulus. The chaotic signal can be modeled as random fluctuations with no inherent periodicity, and its frequency spectrum is spread across a wide range of values. The dysregulated signal could be represented by Equation (1):
where
represents a random process. This signal fluctuates between positive and negative values without a defined frequency, making it irregular and unpredictable. Once the chaotic signal is detected, a trigger pulse is generated, and the external chip introduces a periodic forcing signal at a specific frequency, which could be modeled as Equation (2):
As shown in Equation (2), the pulse function represents a digital periodic pulse with frequency, fchip, and A as an amplitude, between 0 and 1, and t is the time.
The entrainment of the dysregulated signal with the chip signal can be modeled using a coupled system of equations. As the neural chaotic signal is being forced by the periodic chip signal, a general form for the entrainment equation is given by Equation (3), and by substituting Equation (2), the final expression is shown in Equation (4):
As shown in Equation (3), θ(t) is the phase of the signal, ω0 is the natural frequency of the brain signal prior to entrainment, ζ is the damping coefficient described as the internal resistance to entrainment, F(t) is the external forcing term, the chip signal, where ω0 and ζ are chosen based on the system’s natural properties and the chaotic signal’s behaviour. In order to achieve the signal entrainment, the phase synchronization and locking happen when the phase θ(t) of the chaotic signal locks onto the phase of the periodic forcing chip signal, which corresponds to the system’s response reaching a steady state, where the chaotic signal oscillates with the same frequency as the external signal. This phenomenon can be quantified by measuring the phase difference between the chaotic signal and the external signal. As the system entrains, the phase difference decreases, and both signals oscillate together with the same period.
2.2. Dataset Pre-Processing and Analysis
The dataset used in this study consists of EEG recordings from 500 individual subjects, organized into five groups, each corresponding to a different EEG recording condition [
26]. Each subject’s EEG data spans 23.6 s and is sampled at a rate of 173.3 Hz, resulting in 4097 data points per subject. These signals are divided into 23 chunks, each representing 1 s of data containing 178 data points. The EEG signals are stored in columns labelled X1 to X178, and the associated response variable, y, is represented in column 179. The y variable indicates the condition under which the EEG was recorded, with five labels ranging from 1 to 5. Label 1 corresponds to seizure activity, label 2 to the tumour region of the brain, label 3 to a healthy brain region, label 4 to eyes closed, and label 5 to eyes open. The goal of this dataset was to investigate and analyze the differences in EEG signals across these conditions, particularly the distinction between seizure and non-seizure activities. In the pre-processing step, the data is extracted from rows where the label ‘1’ indicates seizure events. The dataset can be represented as a matrix X of size M × N, where M is the number of seizure events, and N is the number of time points. After extracting the dataset for seizure events, the plot for both superimposed and average signals is shown in
Figure 4, where X
i(t) could be represented as the EEG signal at time t for the
ith seizure, and
I = 1, 2, …,
M represents each seizure event, and
t = 1,2,…,
N represents the time points. In order to compute the average EEG signal across all seizure events, the mean of the signals was taken from all seizures at each time point. Mathematically, the average EEG signal S
avg (t) at time
t is given by Equation (5):
In Equation (5), M is the total number of seizure events, and Xi(t) is the EEG signal at time t for the ith seizure. The averaging process smooths out individual fluctuations and reveals the general trend of brain activity during a seizure, highlighting common features across different seizure events. It is particularly useful in identifying consistent patterns in the brain’s electrical activity during seizures.
To analyze seizure signals, all the EEG segments that were labelled as seizure activity were extracted from the dataset. Each segment contains 178 samples of the EEG activity, as shown in
Figure 4. For the purposes of assessing the variability across seizure events and to determine any shared structural features, all waveforms for the seizure were plotted on the same axes, yielding a superimposition of the signals. This graphical representation highlights the diversity of seizure morphologies, reflected in differences in amplitude, shape, and timing, as well as recurring patterns that appear as darker regions where many signals overlap. In the middle plot, an average seizure waveform was computed by taking the mean across all seizure segments at each sample point. This yields a smooth, representative waveform that captures the dominant temporal structure commonly exhibited during seizure activity in this dataset.
To complement these qualitative observations, Shannon entropy was calculated for each seizure segment as a numerical measure of signal irregularity and complexity. Entropy was chosen because seizure EEG can vary widely in structure: some events exhibit highly rhythmic spikewave discharges, while others are more chaotic or irregular. Entropy, therefore, provides an objective way to quantify this variability. The amplitude values were first normalized into a probability distribution for each seizure segment using a normalized histogram. Then, the Shannon entropy of this distribution was calculated using Equation (6):
where
pi represents the probability associated with the ith amplitude bin. Segments with high entropy correspond to more irregular and less predictable seizure waveforms, whereas low entropy values indicate more structured, stereotyped activity. Plotting entropy across all seizure events reveals how the complexity of seizure dynamics varies from one event to another and provides a quantitative interpretation of the variability observed in the superimposed waveforms.
Taken together, the superimposed seizure plots, the average waveform, and the entropy distribution offer a comprehensive view of both the common underlying structure of seizure EEG activity and the substantial intrinsic variability that exists across individual seizure occurrences.
As EEG signals include noise hence to isolate the relevant brainwave frequencies, a bandpass filter was applied. The filter selectively allowed signals within a specific frequency range to pass while attenuating signals outside this range. For this study, the frequency range from 0.5 Hz to 40.0 Hz was selected, corresponding to the typical physiological brain rhythms delta, theta, alpha, beta and gamma. A Butterworth filter was used to select the desired frequency components, maximizing its flat frequency response in the passband, while minimizing distortion in the filtered signal.
The mathematical representation of a Butterworth filter can be represented by Equation (7):
As shown in Equation (7),
H(
f) is the frequency response,
f is the frequency,
fc is the cutoff frequency, and
n is the order of the filter. The filter’s transfer function allows frequencies between the lower and upper cutoff frequencies to pass through while attenuating others. After filtering the EEG signals, the power was analyzed in specific frequency bands. The FFT was applied to convert the signal from the time domain to the frequency domain, as shown in expression 8, where the FFT of a signal
x(
t) is defined as follows:
where
X(
f) is the frequency-domain representation of the signal
x(
t). The squared magnitude of the FFT gives the power spectrum of the signal, as shown in Equation (9):
To calculate the band power by summing the squared magnitudes of the FFT coefficients within each frequency band of interest. The power within a specific frequency band is computed as Equation (10), where
Pband is the band power for the frequency range:
The visualization of the EEG signals and band power is shown in
Figure 5.
As shown in
Figure 5, the bar plots present the power in the different frequency bands for each class (y = 1 to 5). The
x-axis represents the frequency bands, and the
y-axis represents the power in microvolts squared (µV
2), which is the typical unit for EEG power. The right-hand side plot shows the average EEG signal for each class.
EEG signals were filtered using a zero-phase 4th-order Butterworth bandpass filter with a lower cutoff frequency of 0.5 Hz and an upper cutoff frequency of 40 Hz, selected to isolate physiologically relevant EEG rhythms while attenuating slow baseline drift and high-frequency noise. Filtering was implemented using a forward-backward filtering approach to eliminate phase distortion.
Frequency-domain analysis was performed using the discrete Fourier transform. For each EEG segment, the FFT was computed using 178 samples. The power spectrum was defined as the squared magnitude of the FFT coefficients, and band-specific power was calculated by summing spectral power within standard EEG frequency bands: delta (0.5–4 Hz), theta (4–8 Hz), alpha (8–13 Hz), beta (13–30 Hz), and low gamma (30–40 Hz). For seizure events, Shannon entropy was computed to quantify signal complexity. Entropy was calculated from normalized amplitude histograms with 50 bins for each EEG segment using the standard Shannon entropy formulation.
The analysis performed on the EEG dataset provides important insights into the characteristics of the signals across the five clinical conditions represented by the labels y = 1 to y = 5. Separating the data according to class and then filtering it with a physiologically meaningful bandpass filter, 0.5–40 Hz, isolates the dominant brain rhythms, delta, theta, alpha, beta, and low gamma, removing high-frequency noise and slow drift often seen in raw EEG recordings. Computing the average waveform for each class provides a visual representation of the typical shape of the signals in time and reduces subject-specific variability, emphasizing characteristic signatures of seizure versus non-seizure activity. Running in parallel, the spectral analysis performed through the FFT and band-power computation quantifies the distribution of energy across the major EEG frequency bands.
Seizure activity is not defined by high-frequency content alone but rather by abnormal synchronization, amplitude changes, and shifts in spectral energy. These distinctions are evident in the band-power bar plots: class 1 (seizure) signals show elevated power in the delta–theta range and broader spectral spread, consistent with paroxysmal discharges and hypersynchrony commonly seen during pre- and post-ictal events. In contrast, the non-seizure classes display more stable and band-specific power distributions. Hence, this combination of temporal averaging and frequency-domain analysis establishes that this dataset captures meaningful physiological differences between classes and further confirms that the extracted class-1 signals reflect seizure patterns even when the dominant frequency falls within a traditionally ‘normal’ frequency band. This establishes a reliable baseline against which the biological seizure dynamics will be compared to the behaviour of the hardware rhythm-generation chip used later for signal entrainment.
Before evaluating the hardware-level entrainment behaviour of the proposed custom-designed chip, it was necessary to construct a benchmark signal that correctly represents the characteristic dynamics of seizure activity. Each raw EEG trace contains 4097 samples over a duration of 23.6 s, yielding an effective sampling frequency of approximately 173.3 Hz. Three transformations of this benchmark signal were then generated as shown in
Figure 6. The top plot shows the analog seizure waveform derived from the dataset. The middle plot presents a digitized version of this signal, produced by applying a mean-based threshold which mimics the comparator circuits used within digital custom-designed hardware, as shown below. The bottom subplot presents the logarithmic power spectrum of the averaged EEG signal, computed using a Fast Fourier Transform (FFT):
The ‘Average Frequency’ reported in
Figure 6 was calculated from the digitized average EEG waveform shown in the top subplot. First, all seizure segments were aligned and averaged sample by sample to produce a representative time-domain waveform. The FFT was then applied to this averaged waveform to compute the power spectrum, shown in the bottom subplot. The average frequency was determined as the power-weighted mean across all frequency components in this spectrum, providing a single value that summarizes the dominant oscillatory activity in the signal.
In this study, digitization was simplified to reflect the design constraints of ultra-low-power digital neuromodulation hardware. The EEG signals were sampled at the dataset’s native sampling frequency of 173.3 Hz, which exceeds the Nyquist requirement for the targeted physiological frequency range (0.5–40 Hz). A binary thresholding operation was used to emulate a comparator-based front-end, a common design choice in event-driven neuromorphic systems. Although the hardware operates internally using 8-bit digital registers for control and timing, the comparator stage reduces the analog input to a 1-bit event stream. This abstraction prioritizes frequency-domain behavior over amplitude fidelity, consistent with demonstrating digital rhythm entrainment rather than high-resolution signal reconstruction.
This illustrates how the biological signal would appear once converted into the binary event domain used by the chip. The third plot shows the logarithmic power spectrum of the seizure waveform, demonstrating its dominant energy distribution across low-frequency bands (4–8 Hz), consistent with rhythmic seizure discharges reported in clinical EEG literature. This frequency-domain characterization is essential because signal entrainment in the hardware is fundamentally a frequency-selection and frequency-stabilization problem.
These three representations, analog, binary, and spectral, form the software benchmark against which the behaviour of the neural chip is evaluated. The subsequent simulations in the hardware section of the paper demonstrate how a chaotic seizure signal can be stabilized through an externally generated trigger pulse, after which the system entrains to a target reference rhythm. Together, this validates the system-level concept: seizure activity can be digitally suppressed and replaced with a stable, reference oscillatory pattern through hardware-based frequency entrainment. A flowchart of the system-level implementation is shown in
Figure 7.
2.3. Hardware Design and Implementation
To illustrate the principle of signal entrainment, a pseudo-chaotic signal scenario has been created for hardware emulation, as depicted in
Figure 8. The top subplot illustrates the reference brain rhythm at 6 Hz, digitized into a binary pulse. The 6 Hz oscillation was selected as a representative low-frequency rhythm for validating the entrainment mechanism and hence does not imply clinical optimality for all seizure phenotypes. The chaotic second subplot is created from high-frequency random noise to emulate the irregular and unpredictable activity found during epileptic seizures. The third subplot presents the trigger pulse, indicative of the detection of abnormal activity by the seizure detection device, which initiates the entrainment process.
After the trigger pulse, the digital chip generates a controlled 6 Hz rhythm. The recovered signal post-entrainment, shown in the bottom subplot, transitions smoothly from pseudo-chaotic activity to the stable rhythm. The proposed paradigm validates the signal detection and processing logic but also strengthens the scientific principle of chaotic-to-ordered neural entrainment. By emulating both irregular seizure-like activity and controlled rhythmic stimulation, the system shows how focused intervention can be used to reinstate stable brain oscillations principle underpinning the subsequent hardware implementation by means of open-source synthesis tools. The digital representation of pulses allows for the use of digital logic to create a real-world, real-time neurostimulation experiment.
The simulation outlined here serves a critical role in the design and validation of an open-source hardware platform that processes real-time signals, especially in contexts of neurotechnology. In a real-world scenario, a device would be monitoring brain activity continuously. When the system detects seizure activity, it activates the trigger signal, causing the seizure detection paradigm to process the incoming signals. An open-source hardware synthesis tool, Yosys, was used to implement the design in hardware [
27]. It serves as the foundation for synthesizing the design into a physical hardware implementation. Yosys is an open-source synthesis tool that takes high-level Verilog designs and translates them into a gate-level netlist that can be used to generate a hardware circuit. By providing this Verilog code in the Yosys format, the system could be implemented on hardware platforms where the chaotic signal detection and synchronization could be applied in real-time. Therefore, the Yosys code is critical for bridging the gap between simulation and physical implementation, ensuring that the design can be validated in both a simulated environment and on actual hardware.
The hardware design synthesis activity diagram is shown in
Figure 9, where the trigger pulse is controlled externally through the trigger_pulse input, and when this signal is asserted, the system switches from chaotic to a stable periodic signal that approximates a reference brain rhythm. The chaotic signal is continuously updated based on random noise. When the signal exceeds a certain threshold, which is set to 8′b01111111 in the simulations, the system outputs a pulse, signalling that the chaotic activity has reached a level where intervention is needed. This pulse, once detected, sets the reference signal, called normal_signal in the simulations, to a predefined value that represents the normal brain activity, and the chaotic signal is cleared. The testbench created provides a stimulus to the design by generating a clock signal and controlling the reset and trigger pulse inputs. The testbench simulates the behaviour of the system, applying a reset at the beginning and then allowing the chaotic signal to evolve. After a short period, the trigger pulse is asserted, causing the system to transition to the normal brain rhythm. The detailed output waveform activity is shown in
Figure 9.
For this open-source emulation platform, the activity diagram demonstrates how a system can detect chaotic signals and synchronize to a desired known rhythm. The chaotic signal represents an epileptic or irregular brain state, and the normal rhythm represents the target brain activity. The triggering mechanism simulates a medical intervention, such as a neural implant or brain stimulation device, that can restore the brain’s activity to a stable, predictable state, analogous to a known reference 6 Hz rhythm. To further validate the paradigm, utilizing an open-source simulation environment such as Icarus Verilog, we can prototype and test signal correction mechanisms that could be deployed in embedded devices for brainwave monitoring, seizure detection, and entrainment. The open-source nature of the tool allows for flexibility in experimentation and optimization, making it an ideal choice for prototyping before moving to more complex hardware implementations. The goal is to develop a custom-designed embedded platform that can detect irregular brain activity and correct it in real time, helping to manage neurological disorders. The RTL synthesis output waveform is shown in
Figure 10.
The main output from Yosys is the synthesized netlist, which details how the different components of the design are interconnected. This netlist contains information about the logic gates and their connections, showing how the chaotic signal generation, pulse detection, and filtering mechanisms work together. The netlist allows designers to verify that the intended logic and functionality have been preserved through the synthesis process. In the context of the brain rhythm generator, the symbols in the Yosys output can be directly related to the various components defined in the design. The rectangles in the output represent the combinational logic used to generate the chaotic signal. Each rectangle corresponds to a specific logical operation defined in the code, helping to visualize how these operations combine to produce the chaotic behaviour.
The D flip-flops (DFFs) shown in the output represent the storage elements used to hold values at each clock cycle. For instance, the chaotic signal and restored signal are all stored in D flip-flops. These components capture the state of their respective signals on the rising edge of the clock, ensuring that the circuit behaves synchronously. Rhombuses, which signify decision points, relate to the logic that determines when the pulse signal is activated. The pulse signal logic checks if the chaotic signal exceeds a certain threshold. This decision-making process is crucial for detecting chaotic behaviour, and the corresponding rhombus in the Yosys output visually represents this conditional logic. The lines connecting these symbols illustrate the flow of signals, such as from the chaotic signal to the pulse signal logic. These connections are critical for understanding how data flows through the circuit and how the different components interact with each other. Overall, the Yosys outputs facilitate a comprehensive understanding of the design, enabling designers to verify correctness, optimize performance, and prepare the design for further stages such as implementation on an ASIC.
To emulate actual hardware behavior, hardware simulations were performed in System Verilog using a 100 MHz clock, where reset initializes all signals, and the simulation tracks the evolution of chaotic, filtered, and restored signals over time, as shown in
Figure 10. This setup shows chaotic_signal fluctuating unpredictably, low_pass_filter smoothing these fluctuations, when the chaotic signal crosses the threshold, and restored_signal aligning with the chip_signal, illustrating how chaotic dynamics can be guided by a regular reference through strong entrainment.
The waveform generated by the simulation in
Figure 10 provides a complementary view of the system’s behaviour over time, illustrating how the input signals and output signals evolve during the simulation. The waveform allows for the observation of signal transitions, which is crucial for verifying that the FSM is triggering the expected actions and that the output signals correspond to the correct state at any given moment. The waveform can also provide insights into the timing of various signals, helping to ensure that all transitions occur in the correct sequence and at the right times, which is particularly important in real-time signal processing applications where precise timing can be a matter of critical importance.