Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [zmac/] [] - Rev 8

Compare with Previous | Blame | View Log

#!/usr/bin/env python3
# This script reads a binary file and writes it out in the ASCII format
# that lists each 8-bit word in a hex format without 0x.
# This format can be read by SystemVerilog function $readmemh()
# Usage:  python <input-file> [<output-file>]
# If the output file is not given, "out.hex" will be created.
import sys
if len(sys.argv)<2:
    print ("Usage:  python <input-file> [<output-file>]")
filename = sys.argv[1]
outfile = "out.hex"
col = 0;
if len(sys.argv)==3:
    outfile = sys.argv[2]
with open(filename, "rb") as f, open(outfile, "w") as o:
    block =
    for ch in block:
        #print ('{0:02X}'.format(ch))
        o.write('{0:02X} '.format(ch))
        col = col + 1
        if col==16:
            col = 0;
print ("Created", outfile)

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.