Skip to main content

A direct substition for PYNQ library, to seamlessly allow simulation of PL region + PS-PL interface

Project description

Use python3 -m cocotbpynq.sample to see sample

cocotbpynq

cocotbpynq is an extension of cocotb that allows for your PYNQ code to be seamlessly used for simulation. This allows you to debug the AXI transactions that occur between the PL and PS. Currently, there is support for the Pynq Z1 board, although it shouldn't be much different, (if at all), to adapt this code to other PYNQ-compatible FPGAs.

Installation

Once Python is installed, install cocotbpynq using the following:

pip install cocotbpynq

Alternatively, clone the repo and use it as an install directory for the most up-to-date version:

https://github.com/watcag/cocotb-pynq

cocotbpynq.sample

How to use cocotbpynq

There is a sample directory, src/cocotbpynq/sample that shows everything needed make use cocotbpynq yourself. It even includes a hardware hand-off file. Specifically, you will want to reference cocotb_runner.py and adapted.py for development of your own tests.

Running the sample

You can run this sample project mentioned above (after installing cocotbpynq) with:

python3 -m cocotbpynq.sample

Note that verilator is used in the sample project, so you will need verilator installed for this to work out of the box.

Adaptation from PYNQ code

The original.py and original_vs_adapted.diff files are there to illustrate how few changes are needed to adapt PYNQ code ALSO be simulation ready. The adaptation should allow you to either run the cocotb_runner.py file to run a simulation, or continue to run the adapted file on a PYNQ-compatible board.

Verilog Description

The sample is meant to illustrate a simple example with one AXI-Lite port(MMIO), one AXI-Stream read port (DMA send), and one AXI-Stream write port (DMA recv). The circuit performs a simple y = ax²+bx+c operation, where a, b, and c are all constants that can be modified/read using the MMIO port at addresses 0x10, 0x18, and 0x20 respectively, and x and y are AXI-Stream write/read ports respectively.

HWH Generation

HWH file can be generated independantly of bitstream using the following Vivado CLI command:

generate_target all <block design file>

This can be used to circumvent the need to ever to bitstream generation. Unlike bitstream generation, this command only needs to be run if the block diagram is updated.

Paper

Our paper was presented at the 35th International Conference on Field-Programmable Logic and Applications(FPL 2025). The conference paper can be found here: < Proceedings not available yet >

Project details


Download files

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

Source Distribution

cocotbpynq-0.0.3.tar.gz (56.9 kB view details)

Uploaded Source

Built Distribution

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

cocotbpynq-0.0.3-py3-none-any.whl (62.5 kB view details)

Uploaded Python 3

File details

Details for the file cocotbpynq-0.0.3.tar.gz.

File metadata

  • Download URL: cocotbpynq-0.0.3.tar.gz
  • Upload date:
  • Size: 56.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for cocotbpynq-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ac02a057cb4127983d0ebdf598b85ba4a580885d569b84ba4b0d36f2d7bb493d
MD5 8ef9cb6cb2e53cad89f2d8a452fe9fac
BLAKE2b-256 bdc9c0d86e4bc249ab45c605b331e1ecf12f0f11c4cf7c98b0344f0541d2b030

See more details on using hashes here.

File details

Details for the file cocotbpynq-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: cocotbpynq-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 62.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for cocotbpynq-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ff4e730eecaf71bda3c4b42e317153cf9093b677780f63f799ce4f6e9e5edcb
MD5 464fdba7e69139242d8ab6fb0d8002a1
BLAKE2b-256 f8e291e8971ca88cb8e5b19130465782c1ea75a4fc329867b7c6cb27e46275a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page