Skip to main content

Loading from and dumping to Verilog Hex files

Project description

VerilogHex

A Python package for reading and writing Verilog hex files.

This package supports the Verilog hex format that is used to initialise simulation memories using the Verilog $readmemh system task. This format is supported by srec_cat which provides comprehensive conversion from/to multiple common binary formats. Details on the format can be found here: https://linux.die.net/man/5/srec_vmem

The motivation for this package was to provide a pure Python implementation to convert between VMEM and a bytearray for sending and receiving memory data over a socket.

Installation

pip install veriloghex

Usage

from pathlib import Path
from veriloghex import VerilogHex

# Open a hex file and parse the contents to a bytearray
vmem = VerilogHex(filename_or_io_obj)
bytes = vmem.tobytes()

# Write out a VMEM file using any byte width
with Path('mem.8.vmem').open('w') as f:
	f.write(vmem.tovmem(width_bytes=1)
    
with Path('mem.16.vmem').open('w') as f:
	f.write(vmem.tovmem(width_bytes=2)
    
with Path('mem.32.vmem').open('w') as f:
	f.write(vmem.tovmem(width_bytes=4)

# Initialise from a list of bytes and write out as VMEM
vmem = VerilogHex([0xde, 0xad, 0xbe, 0xef])
print(vmem.tovmem())

Status

This package is in development and may change considerably during that time. The API takes inspiration from intelhex and bincopy, both of which perform similar tasks but don't support the Verilog hex format.

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

veriloghex-0.1.2.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

veriloghex-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file veriloghex-0.1.2.tar.gz.

File metadata

  • Download URL: veriloghex-0.1.2.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for veriloghex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7c1d4b5ef2c6bcf35cfdb055bb4c4cbd205af962f31bf961d922d3e83daa1c37
MD5 22352fa8447ba7aabc7bdd01387bcbb9
BLAKE2b-256 01682122adb9ccc7f06a33bdf08cd128fedd8121bd6a790f7aa90bdfbbf0c19b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: veriloghex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for veriloghex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f5f6fb1c1af331616f1d7dffc74cc0faf13fabf7fd73cbd94e5d34d0c274dcf
MD5 28b9b48e48c3b42327f01f69da31e19d
BLAKE2b-256 852dd0224943521b133237eccb7f35c43cbdb4a620e5be1ca942899c9c09200a

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