Tech, ExplainedCloud platforms and developer tools
Part

Embedded system simulation

Testing device software before the device exists.

INSIDE: REAL-TIME OPERATING SYSTEM (RTOS)HOW IT WORKS · A METRO DOOR CONTROLLER TESTED BEFORE ITS BOARD EXISTSA simulatedcontroller runs theteam's unchangedsoftware and RTOSA test scriptreports: trainat platform,doors closingIt then reports anobstacle at door 3The test checksthat door 3 opensagain within 100ms and 'ready tomove' stays offEvery night, 2,000such tests run on 20simulated controllersat onceALSO TALKS TOModel-based designHardware emulation↗ SEMICONDUCTORSAutonomous vehicle simulation↗ AUTOMOTIVE TECHNOLOGYINSIDE: REAL-TIME OPERATING SYSTEM (RTOS)HOW IT WORKS · A METRO DOOR CONTROLLER TESTEDBEFORE ITS BOARD EXISTSA simulated controllerruns the team's unchangedsoftware and RTOSA test script reports:train at platform,doors closingIt then reports anobstacle at door 3The test checks that door3 opens again within 100ms and 'ready to move'stays offEvery night, 2,000 suchtests run on 20 simulatedcontrollers at onceALSO TALKS TOModel-based designHardware emulation↗ SEMICONDUCTORSAutonomousvehicle simulation↗ AUTOMOTIVE TECHNOLOGYINSIDE: REAL-TIME OPERATING SYSTEM(RTOS) · A METRO DOOR CONTROLLERTESTED BEFORE ITS BOARD EXISTSA simulated controller runs the team'sunchanged software and RTOS↓A test script reports: train at platform,doors closing↓It then reports an obstacle at door 3↓The test checks that door3 opens again within 100 msand 'ready to move' stays off↓Every night, 2,000 such tests run on 20simulated controllers at onceALSO TALKS TOModel-based designHardware emulation↗ SEMICONDUCTORSAutonomous vehicle simulation↗ AUTOMOTIVE TECHNOLOGY
A simulated metro door controller runs the Chennai team's unchanged software, while a test script reports an obstacle at door 3 and checks that the door opens again and the train stays put.
opens a page inside this one a page in the same scene a page in another scene a concept page a label only, with no page

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.

Tech, Explained is a part of ingrid.fyi. Every page explains one piece of technology in plain words.