Skip to main content

reading and writing MIF files

Project description

mif

mif is a Python module to read and write Memory Initialization Files, used by Quartus to interact with memory blocks on Intel FPGAs. They are similar to Intel HEX files, except they support arbitrary memory widths as first-class citizens.

Install via pip:

pip install mif

Use with load / loads and dump / dumps, similar to the json module:

with open('memory.mif') as f:
    mem = mif.load(f)

print(mif.dumps(mem))

The resulting mem is a numpy array of unpacked bits, where the first dimension is the address in memory, and the second are the bits in little-endian order. For example, to access the least significant bit at address 0x12:

mem[0x12][0]

Of course, unpacked bits are sometimes convenient, but very memory ineffecient. To instead load packed bytes (still in little-endian order):

with open('memory.mif') as f:
    width, mem = mif.load(f, packed=True)

print(mif.dumps(mem, width=width))

Note that load now returns an extra width value, since there is otherwise no way to know the exact width of the returned memory if it is not divisible by 8. This can also be provided to dump to force an output width; normally, it is inferred.

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

mif-0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

mif-0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file mif-0.2.tar.gz.

File metadata

  • Download URL: mif-0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for mif-0.2.tar.gz
Algorithm Hash digest
SHA256 f2b88936cdf4e9108fecf3e8229abc6f71d8a7e08e44d841a056229bee5b980b
MD5 51bdd23b376157f70e482aae3c3b4c7e
BLAKE2b-256 5558f8e6813e234f9d7aad22ce48d125150d34506189772f40cc4809c5cb167a

See more details on using hashes here.

File details

Details for the file mif-0.2-py3-none-any.whl.

File metadata

  • Download URL: mif-0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for mif-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45dc82b96f573efe8fd5b360988f3cac884b925eaa07a9caf7a9b37133666d3c
MD5 d96e391be9d809ea1187b49df283e632
BLAKE2b-256 fcf28842d475468c021aa258fe13ff78708130bbbaf87c88b4785fd6edc64e54

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