## 1 Introduction  
HIL (hardware-in-the-loop) techniques are being increasingly used for testing and simulation of complex systems, such as power electronics [1, 2, 3, 4] and mechanical elements [5, 6, 7, 8]. These techniques consist in replacing an element of the real system with a model. For instance, in [4], a photovoltaic panel with a DC-DC boost converter is modeled. The HIL model usually operates in real time and provides feedback to the rest of the system as close as possible to that of the real element, including extreme cases. This serves to identify malfunctions or bugs in the controller without causing accidents, including bodily harm or damage to equipment. A typical use in power electronic converters is testing a real implementation of the controller with a simulated plant. In case the controller putsthe plant in a forbidden or dangerous state, there are no catastrophic results for the test. As an example, ref. [9] models a three-phase converter for electric vehicles along with its controller. Although first HIL systems were implemented by using computers [10], reaching simulation steps of tens of microseconds, most of the current HIL systems use field-programmable gate arrays (FPGAs) [11; 12; 13], including commercial systems such as Opal-RT, dSPACE, and Typhoon HIL, among others. In the literature, it is also common to find FPGA-based HIL systems based on platforms that were not designed explicitly for HIL purposes, such s NI LabView, but reached good results [4; 14]. The main advantage of FPGAs is that they have a parallel architecture, where many complex operations can be performed simultaneously. Consequently, FPGA-based systems can reach simulation steps around hundreds of ns. For instance, HIL602 system by Typhoon HIL reaches 500 ns, and even the simple model like a boost converter using a basic ODE (Ordinary Differential Equation) solver reached a simulation step of 14 ns in [15]. The HIL model usually must operate in real time and must provide acceptable accuracy. The former implies that calculation of the state variables is performed with integration times between a few microseconds and tens of nanoseconds, in order to provide a very small calculation delay and be able to emulate medium- to high-frequency converters. The latter means that the algorithms must describe with high detail the behavior of the replaced system, and the state variables must be able to encode with high accuracy the values of the physical magnitudes they represent. These are two conflicting conditions (high-speed calculation versus accurate algorithms and solvers) that lead to trade-offs in the design. Most real-time HIL systems use linear numerical methods, such as first-order forward Euler, because of their simplicity [15; 16]. However, some proposals introduce higher-order methods such as the second-order Adams-Bashforth [17; 18; 19] or Runge-Kutta methods [20; 21]. If a model is to be integrated into a commercial system with a simulation step of around 1 us, the Euler method could be impractical for some applications, so more accurate methods are usually utilized. High-order methods improve drastically the accuracy with the drawback of increasing the complexity and the simulation step. As the accuracy of the simulation is improved by reducing the simulation step or using an accurate method, other sources of error become visible and limit the accuracy of the system. Some examples of these sources are small electrical losses [22] and resolution issues in the calculation of variables [23]. Another issue is found in [24], where a synchronous buck converter model does not benefit from 4 th-order methods when the current reaches zero during the switching deadtime. This problem arises for any power converter using half-bridge modules, not only synchronous buck converters, because the problem comes from the fact that deadtimes are included. This paper proposes a method to solve this issue, reaching high accuracy even in those situations.