How it works
How does a SIL test run?
Instead of compiling the firmware for the device’s microcontroller, the same source code is compiled for the PC. Everything that would normally come from outside the device is provided by a simulation:
- Prepare the code. The application logic is compiled for the PC together with a substitute hardware layer. Drivers, sensors and interfaces are replaced by stand-ins that behave like the real hardware.
- Simulate the environment. An environment model feeds in the inputs, for example sensor readings, button presses or messages from other devices.
- Evaluate the response. The software’s outputs are recorded and automatically compared with the expected values.
- Open or closed loop. In an open-loop test, fixed input sequences are played back. In a closed loop, the environment model reacts to the software’s outputs and calculates the next inputs from them.
Because no real-time hardware is needed, a SIL test can run faster than real time. Hours of device operation can be simulated in minutes.
Prerequisites
What you need for SIL testing
A clean software architecture
Application logic and hardware-specific parts must be clearly separated. Only then can the hardware layer be swapped for the PC without changing the actual logic.
A model of the environment
Depending on the product, a simple sequence of input values is enough, or you need a physical model that simulates a motor, a pump or a patient, for example.
A test framework
Test cases are written as code or in a test tool, executed and evaluated automatically. The results end up in a traceable report.
A build pipeline
SIL really pays off when the tests run automatically in the CI/CD pipeline on every code change and report defects immediately.
Strengths and limits
What SIL finds and what it misses
What SIL reliably uncovers
Logic errors in algorithms and state machines, wrong calculations, missing handling of error cases and boundary values, and new defects caused by changes elsewhere.
What SIL cannot see
Anything that depends on the real hardware: exact timing, interrupts, drivers, electrical properties and numerical differences on the target processor. That requires a HIL test.
A SIL test is only as good as the simulation behind it. If the model does not reflect reality accurately, defects can go undetected. That is why SIL does not replace testing on the real device, it prepares for it.
Use cases
When SIL pays off most
- Before hardware exists. The software can be tested while the circuit board is still being developed. This shortens development time considerably.
- On every change. SIL tests run in seconds to minutes and are ideal for automated regression testing after every commit.
- For error cases and edge conditions. Sensor failures, implausible values or extreme operating conditions can be played through safely and as often as needed.
- For many variants. Different configurations and parameter sets are tested in parallel on several machines without building a separate test bench for each variant.
- For component and integration testing. SIL mainly covers the lower test levels and creates a solid foundation before the complete system is tested.
Benefits
SIL at a glance
Early
Defects are found before prototypes are built, when fixing them still costs little.
Affordable and scalable
A PC or server is all you need. Tests can run as often as you like and in parallel, without tying up expensive test benches.
Safe
Even critical situations can be tested without damaging a device or putting people at risk.
Reusable
Well-written SIL test cases can be reused later in the HIL test. This lets you check directly whether the software behaves the same way on the real hardware.
Frequently asked questions about Software-in-the-Loop
What is Software-in-the-Loop (SIL) in simple terms?
A test method in which the real program code of an embedded device runs on a PC instead of on the device. A simulation provides the inputs that would otherwise come from sensors and interfaces, and the software's responses are checked automatically.
Do I need the real hardware for SIL tests?
No. That is exactly the advantage: SIL tests run on an ordinary PC or server. The hardware is replaced by a substitute layer. Only hardware-dependent behaviour such as timing and drivers requires a HIL test later on.
What is a virtual controller?
A virtual controller is a device's software running on the PC together with a substitute hardware layer. To the outside it behaves like the real device and forms the basis for SIL testing.
Can I test existing software with SIL retroactively?
Usually yes, but the effort depends on the architecture. If the application logic is tightly interwoven with the hardware, it first has to be cleanly separated. This is often a good opportunity to improve the testability of the software as a whole.
How does SIL fit into a CI/CD pipeline?
SIL tests need no hardware and run quickly. They can therefore be executed automatically on every commit. Defects show up within minutes instead of at the next test on the device.
SIL testing for your software
We help you make your embedded software testable, set up SIL tests and integrate them into your pipeline. And when it is time for the real hardware, we continue your tests in HIL.