API Reference
Loading
mif.loads
(s, packed=False)Load MIF data from a string. See mif.load
for a description of
arguments and return value.
mif.load
(fp, packed=False)Load MIF data from a file, and return it. If you want to load data
directly from a string, not a file, see mif.loads
.
Arguments
-
fp - The file-like object to read from.
-
packed - If True, return an array of packed bytes, rather than unpacked bits.
Returns
If packed is False, this function returns the data as unpacked
bits in a 2D numpy array. If packed is True, this function
returns a tuple (width, data)
, where width
is the width of the
words stored in the file in bits, and data
is the loaded data in
a packed 2D numpy array of bytes.
In either case, the first dimension of the data array is the address space, and the second dimension is the data in little-endian order.
Dumping
mif.dumps
(mem, packed=False, width=None, address_radix=’HEX’, data_radix=’BIN’)Save MIF data to a string, and return it. See mif.dump
for a
description of arguments.
mif.dump
(mem, fp, packed=False, width=None, address_radix=’HEX’, data_radix=’BIN’)Save MIF data to a file. If you instead want to store the data in a
string, see mif.dumps
.
Arguments
-
mem - The memory to dump, either as a packed array of bytes or an unpacked bit array. In either case, the first dimension is the address space, and the second is the data in little-endian order. This must be a 2D numpy array with
dtype=numpy.uint8
. -
fp - The file-like object to dump into.
-
packed - If True, then mem must be a packed array of bytes. If False, it must be an unpacked array of bits. If True, you may also be interested in setting the width parameter.
-
width - Override the default output width. Normally the width is inferred from mem, but you can set this to override it, which is especially useful with packed byte arrays.
-
address_radix - The address format to use. Can be one of:
BIN
,HEX
,OCT
,DEC
,UNS
. -
data_radix - The address format to use. Can be one of:
BIN
,HEX
,OCT
,DEC
,UNS
.