Metadata-Version: 2.1
Name: mif
Version: 0.1
Summary: reading and writing MIF files
Home-page: https://github.com/agrif/mif/
Author: Aaron Griffith
Author-email: aargri@gmail.com
License: MIT
Project-URL: Source, https://github.com/agrif/mif/
Keywords: memory mif quartus
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.3
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: lark-parser

mif
---

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

 [spec]: https://www.intel.com/content/www/us/en/programmable/quartushelp/13.0/mergedProjects/reference/glossary/def_mif.htm
 [hex]: https://en.wikipedia.org/wiki/Intel_HEX

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.


