Embedded system simulation is a way of testing a device's software on an ordinary computer that pretends to be the device. The computer runs the device's own software, unchanged, before the hardware exists or without it. It is also called a virtual prototype, or virtual hardware.
Why is it needed? Embedded software runs on one particular chip, on one particular circuit board. A new board often arrives months after the software work begins. The first boards are few and expensive, and many engineers must share them. And some tests are dangerous or impossible on real hardware, such as a sensor failing while a machine runs at full speed.
A simulator copies the parts of the device that the software can see. It imitates the processor, so that it can run the same compiled program that will later run on the chip. It also imitates the memory, the timers and the connections to sensors and to other units. So the software cannot tell that it is not running on the real board.
Imagine a team in Chennai that writes the software for the door controller of a metro train. The rules are simple and strict. The train must not move while any door is open. A door must open again if something blocks it. The real controller boards will arrive in four months. Meanwhile, the team runs its software on a simulated controller, under the same real-time operating system that the real board will use.
A test script plays the part of the train. It tells the software that the train is at the platform, and tells the doors to close. Then it reports that an obstacle is blocking door 3. The test checks two things: that the software opens door 3 again within 100 milliseconds, and that it keeps the 'ready to move' signal off. The team writes 2,000 such tests. Each night, the CI/CD pipeline runs all of them on 20 simulated controllers at once, and the results are ready by morning. When the real boards arrive, most of the bugs have already been found and fixed.
This is a kind of automated testing, applied to hardware that does not exist yet. It sits between several neighbours. A model-based design tool simulates the control logic as a drawing, before any code is written. Embedded system simulation runs the real code. Chip makers use hardware emulation, special machines that imitate a whole chip that is still being designed. And for self-driving cars, autonomous vehicle simulation builds a whole virtual world of roads, so that the car's software can drive millions of kilometres.
Simulation does not replace tests on the real device. The timing on a simulator can differ from the timing on the real chip. So the final approval of a railway or car system still needs tests on the actual hardware.