Skip to main content

HDLC encoded Synchronous Serial interface modules for Cocotb

Introduction

Synchronous HDLC simulation models for cocotb.

Installation

Installation from respository:

$ git clone https://github.com/cameronweston/cocotbext-syncserial.git
$ pip install cocotbext-syncserial

Documentation and usage examples

See the tests directory for a testbench using this module.

Synchronous Serial

The SyncSerialSource and SyncSerialSink classes can be used to drive, receive, and monitor HDLC encoded synchronous serial data.

To use these modules, import the module you need and connect it to the DUT.

from cocotbext.syncserial import SyncSerialSource, SyncSerialSink

sync_serial_source = SyncSerialSource(dut.data, dut.clk)

sync_serial_sink = SyncSerialSink(dut.data, dut.clk)

To send data with SyncSerialSource, call write() or write_nowait(). Accepted data types are iterables of 8-bit ints, including lists, bytes, bytearrays, etc.

To receive data with SyncSerialSink, call read() or read_nowait(). read() will block until at least 1 packet is available.

Constructor parameters:

  • data: data signal
  • clock: clock signal
  • clock_rate_mhz: clock rate in megahertz (optional, default = 10)
  • append_crc: appends crc to packet (optional, default = True)
  • crc_polynomial: crc polynomial to use (optional, default = 0x1021)
  • crc_init: crc initial value to use (optional, default = 0xFFFF)
  • crc_final_xor: crc final xor to use (optional, default = 0x0000)
  • validate_crc: validates incoming packet's crc (optional, default = True)
  • strip_crc: Strips off crc after validation on incoming packet (optional, default = True)

Methods

  • write(): send packet of data (blocking) (source)
  • write_nowait(): send packet of data (non-blocking) (source)
  • read(): read one packet of data (blocking) (sink)
  • read_nowait(): read one packet of data (non-blocking) (sink)
  • count(): returns the number of packets in the queue (all)
  • empty(): returns True if the queue is empty (all)
  • clear(): drop all data from the queue (all)
  • wait(timeout=0, timeout_unit='ns'): wait for packet received (sink)

CRC-16

The Crc_16 classes can be used to calculate or validate a 16 bit CRC. To use this module: from cocotbext.syncserial import Crc_16

crc = Crc_16(crc_polynomial, crc_init, crc_final_xor)

To calculate a CRC, call calculate_crc(). Accepted data types are iterables of 8-bit ints, including lists, bytes, bytearrays, etc.

To validate a CRC, call validate_crc(). Accepted data types are iterables of 8-bit ints, including lists, bytes, bytearrays, etc.

Constructor parameters:

  • crc_polynomial: CRC polynomial to use (optional, default = 0x1021)
  • crc_init: CRC initial value to use (optional, default = 0xFFFF)
  • crc_final_xor: CRC final XOR value to use (optional, default = 0x0000)

Methods

  • validate_crc(data, crc): Calculates a CRC for data and compared to crc
  • calculate_crc(data): Calucalates and returns a CRC for data

Metadata

Release files for cocotbext-syncserial 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocotbext-syncserial 0.1.1
File Size Uploaded Provenance Actions
cocotbext-syncserial-0.1.1.tar.gz 26.9 kB Without provenance Details for cocotbext-syncserial-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cocotbext-syncserial 0.1.1
File Interpreter ABI Platform Actions
cocotbext_syncserial-0.1.1-py3-none-any.whl Python 3 none any Details for cocotbext_syncserial-0.1.1-py3-none-any.whl

Total release size: 34.8 kB

Release files / cocotbext-syncserial-0.1.1.tar.gz

Download URL cocotbext-syncserial-0.1.1.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6b580b9dd5cf28be9a758b276122d1c70994e6a0298e9c54dd149d759a8151a0
BLAKE2b-256 checksum
How to use checksums
200b4cee33edfcf6690a4dd35ffbd323da9d8b5813c8dea062ddc473d4c547ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release files / cocotbext_syncserial-0.1.1-py3-none-any.whl

Download URL cocotbext_syncserial-0.1.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
969b9c7e443f1be48467d5ece916a015d6cc69de577c078f907ab820b42a8077
BLAKE2b-256 checksum
How to use checksums
7d3a33cc5fa28435176bf18f030a98aa2d6c5a587ed26722a6e1c5aa80288352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Security for cocotbext-syncserial 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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