Skip to main content

UART modules for cocotb

Project description

UART interface modules for Cocotb

Build Status codecov PyPI version

GitHub repository: https://github.com/alexforencich/cocotbext-uart

Introduction

UART simulation models for cocotb.

Installation

Installation from pip (release version, stable):

$ pip install cocotbext-uart

Installation from git (latest development version, potentially unstable):

$ pip install https://github.com/alexforencich/cocotbext-uart/archive/master.zip

Installation for active development:

$ git clone https://github.com/alexforencich/cocotbext-uart
$ pip install -e cocotbext-uart

Documentation and usage examples

See the tests directory and verilog-uart for complete testbenches using these modules.

UART

The UartSource and UartSink classes can be used to drive, receive, and monitor asynchronous serial data.

To use these modules, import the one you need and connect it to the DUT:

from cocotbext.uart import UartSource, UartSink

uart_source = UartSource(dut.rxd, baud=115200, bits=8)
uart_sink = UartSink(dut.rxd, baud=115200, bits=8)

To send data into a design with a UartSource, call write() or write_nowait(). Accepted data types are iterables of ints, including lists, bytes, bytearrays, etc. Optionally, call wait() to wait for the transmit operation to complete. Example:

await uart_source.send(b'test data')
# wait for operation to complete (optional)
await uart_source.wait()

To receive data with a UartSink, call read() or read_nowait(). Optionally call wait() to wait for new receive data. read() will block until at least 1 data byte is available. Both read() and read_nowait() will return up to count bytes from the receive queue, or the entire contents of the receive queue if not specified.

data = await uart_sink.recv()

Constructor parameters:

  • data: data signal
  • baud: baud rate in bits per second (optional, default 9600)
  • bits: bits per byte (optional, default 8)
  • stop_bits: length of stop bit in bit times (optional, default 1)

Attributes:

  • baud: baud rate in bits per second
  • bits: bits per byte
  • stop_bits: length of stop bit in bit times

Methods

  • write(data): send data (blocking) (source)
  • write_nowait(data): send data (non-blocking) (source)
  • read(count): read count bytes from buffer (blocking) (sink)
  • read_nowait(count): read count bytes from buffer (non-blocking) (sink)
  • count(): returns the number of items in the queue (all)
  • empty(): returns True if the queue is empty (all)
  • idle(): returns True if no transfer is in progress (all) or if the queue is not empty (source)
  • clear(): drop all data in queue (all)
  • wait(): wait for idle (source)
  • wait(timeout=0, timeout_unit='ns'): wait for data received (sink)

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

cocotbext-uart-0.1.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

cocotbext_uart-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file cocotbext-uart-0.1.2.tar.gz.

File metadata

  • Download URL: cocotbext-uart-0.1.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for cocotbext-uart-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a0ed20db731d492e34d3b8dddb0a0a5688df73fe6d5a8b833564a59584672313
MD5 43cdd0fe65c1f96b6e08c084d26c30c2
BLAKE2b-256 6901a74369cf2bc98473e0ea1641ff9cc24730223a3205a67339ac9fea4b461c

See more details on using hashes here.

File details

Details for the file cocotbext_uart-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cocotbext_uart-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for cocotbext_uart-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 806d05eb59dc2805f8499a9045ad4f972a4f1bbeb164e3dbd9174cddc2f3f4d7
MD5 a9f54ae45af854d5a7ea6a0cbd942059
BLAKE2b-256 719cf648ef59b2d8298acd37267d74170f5a3f369dd4037392c9554616a063ef

See more details on using hashes here.

Supported by

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