OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [zmac/] [bindump.py] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
#!/usr/bin/env python
2
#
3
# This script reads a binary file and writes it out in the ASCII format
4
# that lists each 8-bit word in a hex format without 0x.
5
#
6
# This format can be read by SystemVerilog function $readmemh()
7
#
8
# Usage:  python bindump.py <input-file> [<output-file>]
9
#
10
# If the output file is not given, "out.hex" will be created.
11
#
12
import sys
13
 
14
filename = sys.argv[1]
15
outfile = "out.hex"
16
col = 0;
17
if len(sys.argv) > 2:
18
    outfile  = sys.argv[2]
19
with open(filename, "rb") as f, open(outfile, "w") as o:
20
    block = f.read(65536)
21
    for ch in block:
22
        #print '{0:02X}'.format(ord(ch))
23
        o.write('{0:02X} '.format(ord(ch)))
24
        col = col + 1
25
        if col==16:
26
            o.write("\n")
27
            col = 0;
28
print "Created " + outfile

powered by: WebSVN 2.1.0

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