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 < 0)
for before, after in generator:
print(f"X register: {before.x_register} -> {after.x_register}")
Additional Examples
Some additional examples include:
-
Visualisation of square wave program using Jupyter Notebooks within the
examples/
directory. -
TDD example for the Pimoroni Blinkt! within the
examples/
directory.
Supported Instructions
Instruction | Supported | Notes |
---|---|---|
JMP | :heavy_check_mark: :construction: | PIN and !OSRE variants not implemented |
WAIT | :heavy_check_mark: :warning: | IRQ variant is not supported |
IN | :heavy_multiplication_x: | |
OUT | :heavy_check_mark: :construction: | PC, ISR and EXEC destinations not implemented |
PUSH | :heavy_check_mark: :construction: | IfEmpty variant not implemented |
PULL | :heavy_check_mark: :construction: | IfEmpty variant not implemented |
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:
-
Only supports a sub-set of the available instructions - please refer to the table above.
-
No support for OUT, SET or IN pin-sets; all pin numbers are with respect to Pin 0.
-
Pin-sets do not wrap after GPIO 31.
-
No direct support for the concurrent running of multiple PIO programs; a single State Machine is emulated and not an entire PIO block.
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
Hashes for rp2040-pio-emulator-0.70.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bd07fe5a91ca65a18f2207b389c0cad32a77d37ae76eac2b94024af9c706946 |
|
MD5 | 7cb05e83a3d8a5650ea4f4eed627ff7b |
|
BLAKE2b-256 | 92bcd38ead9493cb514cd6a7a82a842faa2ff16d129640f4b9d9fda9670b2610 |
Hashes for rp2040_pio_emulator-0.70.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3815e86ff64ac0710205ecfa51405d2146fceee01c125551a439d0b11d141e1 |
|
MD5 | c85f333b744f50d861d365735898f69c |
|
BLAKE2b-256 | 3e513ee82096c6e4cea35bcdde5292ac376f0c1cc49664e0c609207f009863bb |