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.3.tar.gz (6.4 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.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mif-0.3.tar.gz
  • Upload date:
  • Size: 6.4 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.3.tar.gz
Algorithm Hash digest
SHA256 2100c5f84df44e1257287c90626ff3c915e161a43ed84df82aa18f3b97607775
MD5 36b9c1d39f0746ce6c406da00750071e
BLAKE2b-256 6675e9e49ed4fb7e55e025893e2853d9d327690cecba35006f32dd38463f8f1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mif-0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 845b0a74388d3187c3bc3feea72615410f699a842b1fd70e29e15ad8e41fdede
MD5 6e5ddba1b9ec81352d0dae61c2f911c9
BLAKE2b-256 180bee4e950d8133e3961351957760bc89e98bd804cc4c6b66749438b55e2925

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