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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file veriloghex-0.1.1.tar.gz
.
File metadata
- Download URL: veriloghex-0.1.1.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14871cda3c9745180885d92119517d7d126556bbceea34b10044c045fcba6c6a |
|
MD5 | 8d368cd0241623aee34b6de89009dd7f |
|
BLAKE2b-256 | 4f57c046721ad879d70061ceb507ca858bbe445411693b28047aeb94a2ccc1be |
File details
Details for the file veriloghex-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: veriloghex-0.1.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb7f39e89d148400b4ce31533cd37fb4eeda5ef3c16c4014c761d4b884981878 |
|
MD5 | 4f788d2ad49754e07050188475130c9f |
|
BLAKE2b-256 | 616e393e75440384555c88540c87d7dce47094d7dfd0536f11bba2d633f6211c |