RP2040 emulator for the testing and debugging of PIO programs
Project description
Emulator for the PIO Blocks within the RP2040 Microcontroller (Python Edition)
Introduction
An emulator for the Programmable Input/Output (PIO) blocks that are present within the Raspberry Pi Foundation's RP2040 Microcontroller. 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 | :heavy_check_mark: | |
| WAIT | :heavy_check_mark: :warning: | IRQ variant is not supported |
| IN | :heavy_check_mark: | |
| OUT | :heavy_check_mark: :construction: | EXEC destination not implemented |
| PUSH | :heavy_check_mark: | |
| PULL | :heavy_check_mark: | |
| MOV | :heavy_check_mark: :construction: | Some variants and operations not implemented |
| IRQ | :heavy_multiplication_x: | |
| SET | :heavy_check_mark: |
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
SETorIN; 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.
- Lerc for reporting a bug.
- bikeNomad for contributing a bug fix.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rp2040_pio_emulator-0.87.0.tar.gz.
File metadata
- Download URL: rp2040_pio_emulator-0.87.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.2 Linux/6.1.0-43-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15771860fa77d35e96d6fb6a5669890b830efd6e9c2777ff4ee92dadb913205b
|
|
| MD5 |
ea6c171bdcea7ee039981841b6656c67
|
|
| BLAKE2b-256 |
718aa11b26012d4d590e2911a561d421b8143dadceb80f24726c8aa848da7349
|
File details
Details for the file rp2040_pio_emulator-0.87.0-py3-none-any.whl.
File metadata
- Download URL: rp2040_pio_emulator-0.87.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.2 Linux/6.1.0-43-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d3cdbb5709ce795820369924decc4549e30baddfa314e0b38cd7108d4faf0ae
|
|
| MD5 |
fa86f21e14b638ba9a89701c43279d68
|
|
| BLAKE2b-256 |
e133a7c159143feb448e2b7391bcacf2b5d9dec9ae901fbd33dd008ed1385952
|