Model Preparation
Discretization
To execute deterministically within NI VeriStand’s real-time framework, MATLAB/Simulink models must run in discrete time steps governed by a fixed-step real-time engine clock. Real-time operating systems cannot utilize continuous, variable-step differential equation solvers because dynamic sub-stepping creates unpredictable execution durations that lead to time-step overruns. Consequently, any Simulink model compiled for deployment on a VeriStand CPU target must consist entirely of discrete blocks operating at a fixed sample rate.
Preparing a continuous or hybrid model for VeriStand deployment requires a comprehensive discretization process. Continuous elements—such as Laplace-domain transfer functions, continuous integrators, dynamic state-space systems, and physical domain components—must be converted into discrete equivalents using fixed-step solver algorithms (such as Forward Euler, Backward Euler, or Tustin/Bilinear transformation methods). Engineers must audit the model using MathWorks Model Advisor to verify that all continuous-time states are replaced with discrete sample-and-hold mechanisms and z-domain discrete equations. Converting every block into a discrete representation ensures that computational execution time per step remains strictly bounded, repeatable, and compatible with VeriStand’s real-time C/C++ model execution framework.
The discretization can be done directly in Simulink using the ”Model Discretizer” that will automatically detect the continuous blocks and allow the user to convert them to their discrete versions.

After selecting the appropriate transformation method, trigger the process by clicking S->Z; all continuous blocks will be replaced with appropriate discrete versions.

NOTE: given that the discretization process might alter the way the model is executed is advice to revalidate the model to make sure the accuracy of the simulation is maintained.
3rd Party Components
Although NI VeriStand Model Generation Support automates the compilation of Simulink models for real-time deployment, it does not guarantee native support for third-party libraries, proprietary blocksets, or hardware-bound driver blocks. Vendor-specific hardware access blocks—such as those created for dSPACE, Speedgoat, or specific microcontroller targets—will cause build failures and must be systematically identified and removed during a pre-deployment model assessment. This removal is architecturally required because NI VeriStand decouples model mathematics from hardware interfacing, managing physical I/O driver configuration, signal scaling, and channel routing independently within the VeriStand System Definition file rather than through inline Simulink driver blocks.
Conversely, while hardware-dependent blocks must be stripped, custom algorithmic libraries or C-MEX S-functions are not strictly prohibited; however, they require evaluation to verify that they do not rely on non-portable host APIs or precompiled host-architecture binaries. Any unsupported or non-portable elements must be replaced with native discrete Simulink blocks, re-implemented using standard C-code wrappers compatible with the NI Linux Real-Time cross-compiler, or offloaded to VeriStand Custom Devices to guarantee a successful compilation and error-free real-time execution.
Partitioning
To deploy a customer’s MATLAB/Simulink model onto a Hardware-in-the-Loop (HIL) simulator, the original simulation model must undergo structural partitioning. Simulation models delivered by development teams are typically monolithic files containing three distinct domains integrated together: the physical Plant Model (e.g., vehicle dynamics, engine, power electronics), the Controller Model (e.g., control logic, ECU algorithms), and the Environment/Interface Model (e.g., driver inputs, GUI sliders, virtual signal generators, and visualization scopes). In an automotive HIL testing environment, the physical Device Under Test (DUT)—the real ECU hardware—replaces the internal Controller Model, while NI VeriStand Workspace controls, stimulus profiles, and physical PXI/cRIO I/O channels replace the internal Environment/Interface blocks. Consequently, the monolithic model cannot be compiled or integrated as-is; it must be decoupled and reorganized into distinct subsystems so that only the mathematical plant dynamics are compiled for real-time execution.
Isolation of the Plant Model
The internal ECU control logic and virtual stimulus generators must be removed or bypassed. The Plant Model is isolated into its own top-level subsystem (or set of subsystems). Internal signal connections previously feeding the controller are routed to top-level Simulink Outport. Conversely, controller commands previously coming from the internal ECU logic are routed to top-level Simulink Inports.
Decoupling User Interfaces and Test Stimuli
Simulink blocks such as Manual Switches, GUI Sliders, Signal Builder blocks, Scope sinks, and Display monitors must be stripped out. In a VeriStand real-time environment, interactive signal monitoring, manual parameter tuning, and automated test execution are handled externally via VeriStand. Removing these desktop-specific interactive blocks prevents build errors during code generation and eliminates unnecessary computational overhead.
Multi-Rate Subsystem Partitioning for Execution Optimization
Large automotive plant models often contain physical domains operating at vastly different dynamic speeds—such as high-speed electric motor switching (microseconds), mechanical driveline dynamics (milliseconds), and slow thermal/HVAC fluid networks (tens of milliseconds). Partitioning the model into modular, single-rate or explicitly multi-rate subsystems allows engineers to optimize hardware resource allocation:
-
Fast Subsystems: Ultra-fast dynamics (e.g., power electronics, e-motor inverters, resolver emulation) are decoupled into dedicated subsystems targeted for FPGA execution or ultra-fast CPU loops.
- Slow Subsystems: Slower dynamics (e.g., vehicle body mechanics, ambient thermal systems, battery cell balancing) are isolated into separate subsystems running on multicore CPU tasks at lower loop rates (e.g., 1ms to 10ms).
- Explicit Rate Transitions: Explicit Rate Transition blocks and boundary buffers are inserted between subsystems to enforce deterministic data exchange and prevent thread contention or priority inversion during concurrent real-time execution.
Harnessing
Plant Model Harnessing for HIL The HIL implementation model will also need to be harnessed for the HIL system. Model harnessing is about making available in the real-time platform desired model signals and parameters for reading and writing purposes.