A real-time FPGA-based power system simulation platform developed as part of a diploma thesis. The platform integrates automation techniques and adaptive architecture selection, following a multi-stage workflow. It builds upon an existing framework for power system design and network analysis, leveraging integer fixed-point representation and using two distinct fraction lengths to achieve both high precision and resource efficiency. The platform categorizes the system in one of three input-based archtectures, depending on the type of sources (current, voltage, or both), and in one of three sized-based architectures, depending on its size (number of nodes).
- MATLAB R2017a
- Vitis HLS 2020.2
- Vivado 2020.2
- Vitis 2020.2
Newer versions of the software may be compatible, but the platform has been tested and validated with the versions listed above.
-
Open the
power_systemdirectory. -
Copy one of the
.slxfiles into thepower_systemdirectory, open it, and clickRunin the Simulink GUI to run the simulation.
- Double-click
Algorithm 1in the Simulink GUI.Algorithm 1performs simulation, network analysis, and decides the fraction lengthsf1andf2for integer data representation. The fraction lengths are stored in the workspace and represent the maximum limits of each fraction length. Typeyin the prompt window for error estimation between Simulink and the NIS method (suggested). Otherwise, pressn.
- (Optional) Alternatively, run the
Fixed-Point Converterapp manually if a deeper look into the fixed-point analysis is desired. Selectfun1Ibr.m,fun1Ihistory.m,fun1Ihs.m,fun2Ibr.m,fun2Ihistory.m,fun2Ihs.m, andVnodal.mas entry-point functions. If the network does not include transformers, omitfun1Ibr.m,fun1Ihs.m, andfun2Ihistory.m. Addempts_app.mas the script and clickAutodefine Input Types. In the Settings, selectPropose fraction lengths for specified word lengthand set the default word length to 32. SetSignedin the Signedness option and analyze.
- Double-click
Algorithm 2in the Simulink GUI. In the prompt window, specifyf1andf2and type1to generate the text files for the HLS implementation.
- Custom power networks can consist of passive elements (any combination of resistors, inductors, and capacitors), linear transformers, and voltage and current sources. The compatible components are from the Simscape Specialized Technology library.
- In the Simulink GUI, go to Simulation -> Model Configuration Parameters -> Solver -> Solver Options**. The Solver must be set to
discreteand the Type toFixed-stepfor correct error estimation. Similarly, the Simulation Type in thepowerguiblock must be set toDiscrete.
- For the error estimation in
Algorithm 1and the simulation error inAlgorithm 2to work correctly, the.slxfile must be named eitherSphase.slxfor single-phase networks orTphase.slxfor three-phase networks. Additionally, theMultimetermust have exactly one selected voltage measurement and one selected current measurement each time. The selected voltage and current measurements do not necessarily need to be from the same load or branch. For three-phase networks, 'one measurement' refers to a three-phase measurement.
-
In some cases, running
Algorithm 1orAlgorithm 2multiple times may result in different nodes assignment. To preserve the assignment used when exporting the text files,Algorithm 1stores it in theOutputs_Info.mfile. Since this file is later used to compute the simulation error between Simulink and HLS or FPGA results, it is recommended to save it separately to avoid accidentally overriding it in subsequent runs. -
Six Simulink models are included as test cases: three simple single-phase models demonstrating the input-based architectures, and three three-phase IEEE models, each corresponding to the size-based architectures. The chosen IEEE models did not require modifications to the models themselves.
-
The MATLAB/Simulink framework is based on an existing work. Modifications were made to adapt it to the specific requirements of this implementation.
-
Open the
scriptdirectory. -
Copy all the MATLAB-generated text files into the directory.
-
Compile and run the
generate_headers.cppscript. The script generates four header files:constants.h,initial_state.h,input_sources.h, andps_sim_host.h.
The target FPGA used for implementation and testing is the Zynq UltraScale+ ZCU104 Evaluation Board and the C/C++ script is designed to work without modifications unless targeting a board with significantly different requirements or if maximum performance is not the goal. The script also provides a brief explanation of the available architectures and the criteria for choosing among them. In this case, the user may modify the following parts inside the script:
buswidthlimit_full_unrolllimit_partial_unrollunroll_factor
-
Open the
power_system_simulatordirectory. -
Copy the
constants.h,initial_state.h, andinput_sources.hfiles into the directory. -
Open Vitis HLS and create a new project. In the Design Files section, add all
.cppfiles included in thepower_system_simulatordirectory, except for thepower_system_simulator_test.cpp. In the Testbench Files section, add thepower_system_simulator_test.cppfile. In the Solution Configuration section, select the target FPGA board in the part selection andVivado IP Flow Targetin the Flow Target.
- Once the project is open, navigate to Project -> Project Settings -> Synthesis -> Top Function and select
power_system_simulator.cpp.
- Navigate to Solution -> Solution Settings -> General -> config_interface and set the following :
- m_axi_max_bitwidth =
128 - m_axi_max_widen_bitwidth =
128 - m_axi_alignment_byte_size =
16
- m_axi_max_bitwidth =
- Run the steps: C Simulation, C Synthesis, Co-Simulation, and Export RTL, all with the default settings.
-
If memory requirements are different, the general settings for config_interface in Vitis HLS are as follows:
- m_axi_max_bitwidth =
buswidth - m_axi_max_widen_bitwidth =
buswidth - m_axi_alignment_byte_size =
buswidth/8
- m_axi_max_bitwidth =
-
Regarding the HLS implementation, in the modules
history_currents,branch_currents, andnodal_voltages, there is an option to use the#pragma HLS allocationdirective. Its purpose is to limit DSP utilization. While it works for relatively small reductions, larger reductions often lead to congestion. To use these directives, uncomment and set the desired number. -
The testbench in Vitis HLS stores the C-Simulation and Co-Simulation results by default in the project directory: project directory -> solution -> csim -> build. Similarly, when exporting the RTL as an IP, the default directory is: project directory -> solution -> impl -> ip.
-
When exporting the RTL as an IP,
Vivado SynthesisorVivado synthesis, place and routemust not be checked if the IP is intended for subsequent use in Vivado. However,Vivado SynthesisorVivado synthesis, place and routecan be used to obtain real results about resource utilization of the IP as a standalone module.
-
Copy the
HLS_VandHLS_Idirectories that HLS Simulation created into thepower_systemdirectory. -
Open the
.slxfile and clickRunin the Simulink GUI to run the simulation. -
Double-click
Algorithm 2in the Simulink GUI. In the prompt window, specifyf1andf2and type2to compare the HLS results with the Simulink results.
- Open Vivado and create a new project. In the Project Type section, leave the settings at default. In the Default Part section, choose the target FPGA board.
- Once the project is open, navigate to Tools -> Settings -> Project Settings -> IP -> Repository and add the HLS-generated IP.
- Navigate to IP INTEGRATOR and click
Create Block Design.
- In the Diagram section, add the
ZYNQ Ultrascale+ MPSoCblock. ClickRun Block Automationand apply the board preset. Then, double-click theZYNQ Ultrascale+ MPSoCblock and navigate to PS-PL Configuration -> PS-PL Interfaces. In the Master Interface section, selectAXI HPM0 FPD. In the Slave Interface section, selectAXI HP0 FPD,AXI HP1 FPD, andAXI HP2 FPD. If the network has both voltage and current sources, select additionallyAXI HP3 FPD.
- In the Diagram section, add these IP blocks:
Processor System Reset,AXI Interconnect,AXI SmartConnect, andPower_system_simulator. Set the appropriate masters and slaves, and connect all blocks accordingly.
- Navigate to the Address Editor section and click
Assign All. Then, navigate to the Diagram section and clickValidate Design.
- Navigate to Sources -> Design Sources. Under Design Sources, right-click and select
Generate Output Products. In the Synthesis Options section, selectGlobaland clickGenerate. Right-click again and selectCreate HDL Wrapper. ChooseLet Vivado manage wrapper and auto-update.
- Navigate to PROGRAM AND DEBUG and click
Generate Bitstream. Let Vivado handle the intermediate steps.
- Once finished, navigate to File -> Export -> Export Hardware. In the Output section, choose
Include Bitstreamand export the.xsafile.
-
Open the
ps_sim_hostdirectory. -
Copy the
ps_sim_host.handinput_sources.hfiles into the directory. -
Open Vitis and create a new application project. In the Platform section select
Choose a new platform from hardware (XSA)and browse to the Vivado-generated.xsafile. In the following sections, leave settings at default. In the Templates section, selectEmpty Application.
- Navigate to the Explorer, and click on the
platform.sprfile (in the platform section of the project). Then, navigate to standalone_psu_cortexa53_0 -> Board Support Package and selectModify BSP Settings. In the Supported Libraries section check thexilffslibrary.
- Navigate to the Explorer, and right-click on the
srcdirectory (in the application section of the project). SelectImport Sourcesand add all files included in theps_sim_hostdirectory (includinglscript.ld).
- Navigate to the Explorer, right-click on the system, and click on
Build Project.
-
Copy the
HLS_VandHLS_Idirectories into the SD card. -
Insert the SD card into the SD card slot on the target board and make the appropriate connections for the JTAG debugger and serial monitor. Then, right-click on the system, select Debug As, and then click on
Launch Hardware.
- Once the execution is over, retrieve the
FPGA_VandFPFA_Idirectories containing the output text files from the SD card.
-
Copy the
FPGA_VandFPFA_Idirectories into thepower_systemdirectory. -
Open the
.slxfile and clickRunin the Simulink GUI to run the simulation. -
Double-click
Algorithm 2in the Simulink GUI. In the prompt window, specifyf1andf2and type '3' to compare the Simulink results with the final results.
-
Original MATLAB/Simulink Framework: E. Mylonas, "Auto Power System Simulator," GitHub, 2021, [Online]. Available: https://github.com/lefmylonas/auto_power_system_simulator.
-
Original IEEE 5 Model: R. Tan, IEEE 5-Bus System Model, MATLAB Central File Exchange, MathWorks, 2018, [Online]. Available: https://www.mathworks.com/matlabcentral/fileexchange/66555-ieee-5-bus-system-model.
-
Original IEEE 14 Model: B. Y.K., IEEE 14 Bus System Simulink Model, MATLAB Central File Exchange, MathWorks, 2016, [Online]. Available: https://www.mathworks.com/matlabcentral/fileexchange/46067-ieee-14-bus-system-simulink-model.
-
Original IEEE 69 Model: A. Lal, IEEE 69 Bus System, MATLAB Central File Exchange, MathWorks, 2021, [Online]. Available: https://www.mathworks.com/matlabcentral/fileexchange/88111-ieee-69-bus-system.


































