Emulator for the PIO Blocks within the RP2 Microcontroller Series (Python Edition)
Introduction
An emulator for the Programmable Input/Output (PIO) blocks that are present within the Raspberry Pi Foundation's RP2040 and RP2350 Microcontrollers. It is designed to assist in the analysis of PIO programs and to help you by:
- Enabling unit tests to be written.
- Answering questions such as: How many clock cycles are being consumed?
- Supporting the visualization of GPIO outputs over time.
- Providing alternatives to debugging on real hardware, which can be time consuming.
Quick Start
Below is a slight variation of the example used within the Quick Start Guide.
from pioemu import emulate
program = [0xE029, 0x0041, 0x2080] # Count down from 9 using X register
generator = emulate(program, stop_when=lambda _, state: state.x_register == (2 ** 32) - 1)
for before, after in generator:
print(f"X register: {before.x_register} -> {after.x_register}")
Documentation
A Tour of pioemu provides a more detailed explanation than the Quick Start Guide offers. In addition, there is a FAQ available that might contain an answer to your question. However, if none of these provides you with the necessary information then please consider creating a new issue - thanks!
Additional Examples
Some additional examples are available within the rp2040-pio-emulator-examples repository, including:
-
TDD example for the Pimoroni Blinkt!
-
Tool to create Fast Signal Trace (FST) files suitable for analysis by GTKWave
-
Visualisation of square wave program using a Jupyter Notebook
Supported Instructions
| Instruction | Supported | Notes |
|---|---|---|
| JMP | ✔️ | |
| WAIT | ✔️ ⚠️ | IRQ variant is not supported |
| IN | ✔️ | |
| OUT | ✔️ 🚧 | EXEC destination not implemented |
| PUSH | ✔️ | |
| PULL | ✔️ | |
| MOV | ✔️ 🚧 | Some variants and operations not implemented |
| IRQ | ✖️ | |
| SET | ✔️ |
Known Limitations
This software is under development and currently has limitations - the notable ones are:
-
Not all of the available instructions are supported - please refer to the table above.
-
No support for pin-sets associated with
IN; all pin numbers are with respect to GPIO 0. -
Pin-sets do not wrap after GPIO 31.
-
PULL IFEMPTYandPUSH IFFULLdo not respect the pull and push thresholds. -
No direct support for the concurrent running of multiple PIO programs; a single State Machine is emulated and not an entire PIO block.
Thanks To
- aaronjamt for contributing features and fixes.
- Josverl for contributing features.
- winnylourson for contributing a bug fix.
- kamocat for reporting issues, contributing examples and ideas.
- Lerc for reporting a bug.
- bikeNomad for contributing a bug fix.
- martinhansdk for adding a missing feature.
Metadata
Release files for rp2040-pio-emulator 0.88.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rp2040_pio_emulator-0.88.0.tar.gz | 16.3 kB | Without provenance | Details for rp2040_pio_emulator-0.88.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rp2040_pio_emulator-0.88.0-py3-none-any.whl | Python 3 | none | any | Details for rp2040_pio_emulator-0.88.0-py3-none-any.whl |
Total release size: 40.0 kB
Release files / rp2040_pio_emulator-0.88.0.tar.gz
| Download URL | rp2040_pio_emulator-0.88.0.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd8d779e08b55c8949597b5993baf256797e7d0e52661a4cb6f6850f83803087
|
|
BLAKE2b-256 checksum How to use checksums |
5f45d8ce545f8b10ef91e7128b68ff3c23afdd6f7789194e49c5b1f85a2df009
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.7 Linux/7.1.9-arch1-2
|
Release files / rp2040_pio_emulator-0.88.0-py3-none-any.whl
| Download URL | rp2040_pio_emulator-0.88.0-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47c73c1727fa86e4a47cf130af7e6a246b8185db7a761095871de0e0eb5b5cc0
|
|
BLAKE2b-256 checksum How to use checksums |
89e44995348d549f21ce7ad5d0eb372abf27c2f8b82a708e89126c7fe2138688
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.7 Linux/7.1.9-arch1-2
|
Security for rp2040-pio-emulator 0.88.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.