I am trying to create a simulation of a power stage of a boost converter in ModelSim to further create a PID controller on FPGA. I have written differential equations that describe a boost converter and created a testbench for simulation. Unfortunately output signals (inductor current and output voltage) does not match those from adequate model from Simulink, for example inductor current reaches large negative values. Can you help me find mistakes in my files? I manually set simulation time in ModelSim (typically 50ms). Below I attach screens from ModelSim and Simulink (inductor current) and simulation files. Thanks in advance.
You are apparently makin a time discrete behavioral model of the converter hardware in SV. That's of course possible, but there's no guarantee that the model is physical plausible.
Do you mind to show a circuit of the modelled hardware?
Without looking into the details. I don't see a diode modelled in power_stage.sv. There should be a current sign dependent resistance respectively voltage drop.
OK, I added that voltage drop but it has pretty much no impact on the results, due to the way my model is created. Commutation is implemented as changes between equations, there are no changes of diode resistance.