Simulating Low-Level Hardware Devices in Cpp
summary
Claims that C++ can simulate memory-mapped device registers so the same register-level code runs on desktop and target hardware. Uses operator overloading, user-defined conversion operators, class-specific operator new/delete, volatile uint32_t, std::map and std::thread to attach per-address read/write handlers. Implements a UART plus seven‑segment display (UART has six device registers) where reads clear RDR and a background thread injects an 'a' every second. The simulator reproduces the hardware side‑effects and the example runs as described.
AI-written summary · about
chapters (13)
- 0:00Simulating hardware in C++
- 1:03Why simulate hardware devices
- 5:37Memory-mapped hardware registers
- 8:28Constructing UART objects
- 11:44Positioning UART objects
- 17:04Running on target hardware
- 18:35Benefits of simulated environments
- 22:09Side effects of register access
- 29:00Device register classes
- 34:40Simulating UART with operators
- 40:09Side effect handlers
- 46:15Finalizing UART implementation
- 48:03Q&A
related talks
26mUnit Testing Memory Mapped Device Drivers
26mUnit Testing Memory Mapped Device Drivers
20mHow to Mock in the 21st Century
01h 01mAdvanced Unit Testing in C & C++
46mTestability and C++ API Design
16mSoftware Development for 64-Bit RISC-V Processor Verification
47mThe Native Simulator and Zephyr
01h 22mTest-Driven Development of C++ Embedded and System-Level Software
