Study and implementation project for Digital Predistortion (DPD) to compensate for nonlinearities in power amplifiers. This repository brings together the Python/Octave modeling flow, coefficient generation, VHDL implementation, and simulation-based validation.
The main project flow is:
- Read the measured power amplifier data.
- Model the behavior using a memory polynomial.
- Calculate and normalize the DPD coefficients.
- Validate the model in floating-point and fixed-point formats.
- Generate or adjust constants for VHDL.
- Simulate the VHDL architecture and compare the output against references.
- Optionally run post-synthesis/post-place-and-route simulation in Questa/ModelSim.
DPD/
├── INPUT/ Input data in .mat format
├── OUTPUT/ Generated results: coefficients, validations, and simulation outputs
├── Master/ Main Python notebooks and helper functions
├── TCC/ TCC activity/experiment notebooks
├── OCTAVE/ Octave/MATLAB scripts used in the initial activities
├── VHDL/ VHDL implementation, testbench, and simulation/synthesis scripts
├── questa_sim/ Files and instructions for timing simulation in Questa/ModelSim
├── diagramas/ Project process and calculation-flow diagrams
├── requirements.txt
└── README.md
Contains the measured or prepared data files used for training and validation:
IN_OUT_PA.matdata_LDMOS_formatted_4500p.matin_out_SBRT2_direto.mat
These files are used by the notebooks to extract the power amplifier input/output signals and calculate the models.
Contains artifacts generated during the flow:
- NumPy coefficient files (
.npy), such ascoefficients_norm_DPD.npyandcoefficients_norm_pa.npy; - validation data in CSV format;
- VHDL/FPGA simulation outputs in
.txtformat; - intermediate comparisons and metrics.
This directory works as the results area shared by Python, VHDL, and the simulation flows.
This is the main Python development directory. It contains:
- notebooks from
M1.ipynbtoM8.ipynb, organizing the project steps; separar_dados_pa.ipynb, used for data preparation/separation;M7 Coeficientes vhdl.ipynb, used in the coefficient generation/adaptation flow for VHDL;functions.py, with helper functions for memory polynomials, fixed-point processing, NMSE, simulation-output loading, and complex-vector comparison;.npyvectors used to compare calculated and simulated models.
Contains auxiliary activity or experiment notebooks:
at1.ipynbtoat5.ipynb.
Use this directory as an experimentation history and support material for the main development flow.
Contains Octave/MATLAB scripts:
atividade_m1.matividade_m2.matividade_m3.mexemplo_plot_PSD.txt
These files record early analysis and calculation steps outside the main Python flow.
Contains the hardware implementation:
DPD.vhd: main DPD module;functions.vhd: helper functions and types used by the VHDL code;complex_constants.vhd: complex constants used by the architecture;tb_main.vhd: testbench;simular.sh: compiles and simulates with GHDL;sintetizar.sh: runs logic synthesis with Yosys + GHDL plugin;- reports, compilation objects, and
output.vcdgenerated by the tools.
Contains files and documentation for post-place-and-route timing simulation using Questa/ModelSim:
DPD_timesim.vDPD_timesim.sdfglbl.vsetup.doREADME.md
See questa_sim/README.md for the specific step-by-step instructions for this simulation.
Contains editable Draw.io diagrams:
diagrama_process.drawiofluxo_de_calculo.drawioprocess_2.drawio
Use these files to understand or update the visual documentation of the flow.
- Python 3.8 or newer
- Dependencies listed in
requirements.txt:numpyscipymatplotlibsympy
To open the notebooks, installing Jupyter is also recommended:
pip install notebookRequired only to run the scripts in OCTAVE/.
The scripts in VHDL/ assume OSS CAD Suite is available at:
/opt/oss-cad-suite
Tools used:
- GHDL, for behavioral simulation;
- Yosys with the GHDL plugin, for logic synthesis;
- GTKWave, optional, to inspect
output.vcd.
For timing simulation in questa_sim/, the flow uses Xilinx ISE 14.7, Netgen, and Questa/ModelSim. See questa_sim/README.md.
Clone the project and enter the directory:
git clone https://github.com/Je-Leo-AS/DPD.git
cd DPDCreate and activate a Python virtual environment:
python -m venv .venv
source .venv/bin/activateInstall the dependencies:
pip install -r requirements.txt
pip install notebookOpen the notebooks:
jupyter notebookStart with the Master/ directory. A suggested order is:
Master/separar_dados_pa.ipynbMaster/M1.ipynbtoMaster/M6-Avaliacao-mp .ipynbMaster/M7 Coeficientes vhdl.ipynbMaster/M8.ipynb
This sequence follows data preparation, modeling, evaluation, coefficient generation, and validation.
Enter the VHDL/ directory:
cd VHDLRun the behavioral simulation:
./simular.shThe script compiles functions.vhd, DPD.vhd, and tb_main.vhd, elaborates the tb testbench, and generates:
VHDL/output.vcd
For logic synthesis with Yosys + GHDL:
./sintetizar.shThe report is saved at:
VHDL/relatorio_sintese.txt
The functions in Master/functions.py include utilities to:
- load simulation outputs;
- align signals by delay;
- calculate mean error, maximum error, and NMSE;
- compare complex vectors generated by Python and VHDL.
The results used in these comparisons are mainly stored in OUTPUT/ and in some .npy vectors inside Master/.
- The main README describes the general project flow.
- Post-place-and-route timing simulation has its own instructions in
questa_sim/README.md. - Compilation files, reports, and simulation outputs can be regenerated by running the corresponding notebooks and scripts.