In short
Each level replaces less of the real system with simulation. MIL tests the model, SIL the compiled code on a PC, PIL the code on the real processor, and HIL the finished ECU with its real inputs, outputs and buses. Earlier levels are fast and cheap and catch logic errors; HIL catches what only real hardware and real bus timing reveal.
Best for: Engineers starting in ECU testing, and CAN or embedded engineers who need to understand what a test bench does with their software
An ECU function goes through several test levels before it reaches a vehicle. The names all follow one pattern, X-in-the-loop: something real (X) runs in a closed loop with a simulated environment that reacts to its outputs. What changes from level to level is how much is real.
The four levels
| Level | What is real | What is simulated | Runs on |
|---|---|---|---|
| MIL, model-in-the-loop | The controller model, such as a Simulink model | The plant: engine, vehicle, sensors | A PC, in simulation time |
| SIL, software-in-the-loop | The controller code, compiled for the PC | The plant and the ECU's surroundings | A PC, as fast as possible |
| PIL, processor-in-the-loop | The code compiled for, and running on, the target processor | The plant, on a PC connected to the processor | An evaluation board or the ECU's microcontroller |
| HIL, hardware-in-the-loop | The finished ECU: hardware, software, connectors | Sensors, actuators and the rest of the vehicle, in real time | A real-time simulator wired to the ECU |
The loop is closed at every level: the controller's output goes into the plant model, and the plant's reaction comes back as the next input. That is the difference from a unit test, which feeds fixed inputs and checks fixed outputs.
What each level finds
| Level | Finds | Misses |
|---|---|---|
| MIL | Wrong control logic, wrong requirements interpretation, unstable control loops | Anything about code, timing or hardware |
| SIL | Errors introduced by code generation or hand coding, integer overflow, wrong state machines | Compiler and processor effects, real-time behaviour |
| PIL | Effects of the target compiler and processor: fixed-point arithmetic, stack use, execution time | I/O circuits, electrical faults, real bus timing |
| HIL | I/O and electrical behaviour, diagnostics and DTCs, real CAN, LIN and Ethernet timing, fault reactions, start-up and shutdown | Real vehicle dynamics and environment, which only vehicle tests show |
A common technique between levels is back-to-back testing: run the same test inputs through MIL, SIL and PIL and compare the outputs. Differences point at code generation, numeric precision or compiler problems, long before a HIL bench is involved.
Where CAN comes in
From SIL upwards, the ECU's software expects to send and receive messages. At each level the bus is simulated differently:
- SIL: a virtual bus. On Linux, a
vcaninterface behaves like a real SocketCAN interface without hardware:
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
- PIL: often the real CAN controller of the evaluation board, connected to a PC interface.
- HIL: real CAN, LIN or Ethernet, with the simulator playing every other ECU on the bus.
That last part is the restbus simulation: the bench sends every message the ECU expects from the rest of the vehicle, with the right IDs, cycle times, counters and CRCs, so the ECU behaves as if it were in a car. The DBC is the source for all of it. The restbus simulation guide builds one from a DBC with Python.
What a HIL bench is made of
| Part | Job |
|---|---|
| Real-time simulator | Runs the plant model and restbus with fixed, guaranteed timing |
| I/O boards | Generate sensor signals (analog, digital, PWM, frequency) and measure actuator outputs |
| Bus interfaces | CAN, CAN FD, LIN, FlexRay or Ethernet ports for the restbus and for observing traffic |
| Loads | Real actuators, or substitute loads that draw the same current |
| Fault injection unit | Opens wires, shorts signals to ground or battery, connects pins together |
| Programmable power supply | Varies the supply voltage, including drops and cranking profiles such as those in ISO 16750-2 |
| Test automation | Runs test cases, sets inputs, checks outputs and writes reports |
The test automation talks to the simulator through an API. ASAM XIL standardises that API, so test cases can be moved between MIL, SIL and HIL systems and between bench vendors. Its current version, 3.0.0, was released in September 2024.
A test strategy across the levels
- Run MIL and SIL on every change. They are fast, need no hardware, and fit in continuous integration.
- Run PIL when the code or compiler changes, and for timing and resource checks.
- Reserve HIL time for integration, I/O, diagnostics, network behaviour and fault reactions. Benches are expensive and shared, so automate the tests and run them overnight.
- Keep one set of requirements and trace each test case to them, at whichever level it runs.
- Use the same DBC everywhere. A message definition that differs between the SIL bus and the HIL restbus produces failures that have nothing to do with the software under test. Comparing DBC versions before each release keeps them aligned.
Frequently asked questions
What is the difference between HIL and SIL testing?
In SIL, the ECU's software is compiled for a PC and runs against simulated surroundings, without any ECU hardware. In HIL, the real ECU with its hardware and software is connected to a real-time simulator that emulates sensors, actuators and the rest of the vehicle.
What is processor-in-the-loop testing?
The production code is compiled with the target compiler and runs on the real microcontroller or an evaluation board, while the plant model runs on a PC. It reveals effects of the processor and compiler that a PC build hides, such as fixed-point behaviour and execution time.
What is a restbus simulation?
Simulating all the other ECUs on a network so the ECU under test receives every message it expects, with correct timing, counters and checksums. It is normally generated from the network's DBC, ARXML or LDF.
What is ASAM XIL?
An ASAM standard API between test automation software and test benches. It covers MIL, SIL and HIL systems, so the same test cases can run on different simulators. Version 3.0.0 was released in September 2024.
References
DBC Utility
One desktop app for DBC files and CAN recordings.
One-time $34 · Windows & Linux · Files stay on your computer