Skip to main content

Emulator for the PIO Blocks within the RP2 Microcontroller Series (Python Edition)

Build Status Coverage PyPI

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:

  1. TDD example for the Pimoroni Blinkt!

  2. Tool to create Fast Signal Trace (FST) files suitable for analysis by GTKWave

  3. 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:

  1. Not all of the available instructions are supported - please refer to the table above.

  2. No support for pin-sets associated with IN; all pin numbers are with respect to GPIO 0.

  3. Pin-sets do not wrap after GPIO 31.

  4. PULL IFEMPTY and PUSH IFFULL do not respect the pull and push thresholds.

  5. 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rp2040_pio_emulator-0.88.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rp2040_pio_emulator-0.88.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file rp2040_pio_emulator-0.88.0.tar.gz.

File metadata

  • Download URL: rp2040_pio_emulator-0.88.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.7 Linux/7.1.9-arch1-2

File hashes

Hashes for rp2040_pio_emulator-0.88.0.tar.gz
Algorithm Hash digest
SHA256 cd8d779e08b55c8949597b5993baf256797e7d0e52661a4cb6f6850f83803087
MD5 d031a678db366d74aa11dd7249c31077
BLAKE2b-256 5f45d8ce545f8b10ef91e7128b68ff3c23afdd6f7789194e49c5b1f85a2df009

See more details on using hashes here.

File details

Details for the file rp2040_pio_emulator-0.88.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rp2040_pio_emulator-0.88.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47c73c1727fa86e4a47cf130af7e6a246b8185db7a761095871de0e0eb5b5cc0
MD5 5b879f30ce0b6e398114e6c3dd2bb9a2
BLAKE2b-256 89e44995348d549f21ce7ad5d0eb372abf27c2f8b82a708e89126c7fe2138688

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.88.0 This release

2 files

0.87.0

2 files

0.86.0

2 files

0.85.0

2 files

0.84.0

2 files

0.83.0

2 files

0.82.0

2 files

0.81.0

2 files

0.80.0

2 files

0.79.0

1 file

0.78.0

2 files

0.77.0

2 files

0.76.0

2 files

0.75.1

2 files

0.70.0

2 files

0.26.0

2 files

0.22.0

2 files

0.21.0

2 files

0.20.0

2 files

0.19.0

2 files

0.16.0

2 files

0.15.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page