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

LevelWhat is realWhat is simulatedRuns on
MIL, model-in-the-loopThe controller model, such as a Simulink modelThe plant: engine, vehicle, sensorsA PC, in simulation time
SIL, software-in-the-loopThe controller code, compiled for the PCThe plant and the ECU's surroundingsA PC, as fast as possible
PIL, processor-in-the-loopThe code compiled for, and running on, the target processorThe plant, on a PC connected to the processorAn evaluation board or the ECU's microcontroller
HIL, hardware-in-the-loopThe finished ECU: hardware, software, connectorsSensors, actuators and the rest of the vehicle, in real timeA 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

LevelFindsMisses
MILWrong control logic, wrong requirements interpretation, unstable control loopsAnything about code, timing or hardware
SILErrors introduced by code generation or hand coding, integer overflow, wrong state machinesCompiler and processor effects, real-time behaviour
PILEffects of the target compiler and processor: fixed-point arithmetic, stack use, execution timeI/O circuits, electrical faults, real bus timing
HILI/O and electrical behaviour, diagnostics and DTCs, real CAN, LIN and Ethernet timing, fault reactions, start-up and shutdownReal 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 vcan interface behaves like a real SocketCAN interface without hardware:
Terminal
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

PartJob
Real-time simulatorRuns the plant model and restbus with fixed, guaranteed timing
I/O boardsGenerate sensor signals (analog, digital, PWM, frequency) and measure actuator outputs
Bus interfacesCAN, CAN FD, LIN, FlexRay or Ethernet ports for the restbus and for observing traffic
LoadsReal actuators, or substitute loads that draw the same current
Fault injection unitOpens wires, shorts signals to ground or battery, connects pins together
Programmable power supplyVaries the supply voltage, including drops and cranking profiles such as those in ISO 16750-2
Test automationRuns 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