Giter Site home page Giter Site logo

rp2040-pio-emulator's Introduction

Emulator for the PIO Blocks within the RP2040 Microcontroller (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 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:

  1. Visualisation of square wave program using Jupyter Notebooks within the examples/ directory.

  2. TDD example for the Pimoroni Blinkt! within the examples/ directory.

  3. pico-pio-examples

Supported Instructions

Instruction Supported Notes
JMP ✔️
WAIT ✔️ ⚠️ IRQ variant is not supported
IN ✔️
OUT ✔️ 🚧 EXEC destination not implemented
PUSH ✔️ 🚧 IfFull variant not implemented
PULL ✔️ 🚧 IfEmpty variant not implemented
MOV ✔️ 🚧 Some variants and operations not implemented
IRQ ✖️
SET ✔️

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 OUT, SET or IN; all pin numbers are with respect to GPIO 0.

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

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

rp2040-pio-emulator's People

Contributors

nathany3g avatar aaronjamt avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.