OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

[/] [tv80/] [branches/] [hpa1/] [scripts/] [ihex2mem.py] - Rev 2

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

#!/usr/bin/env python
 
def ihex2mem (infile, outfile):
    ifh = open (infile, 'r')
    ofh = open (outfile, 'w')
 
    bcount = 0
    line = ifh.readline()
    while (line != ''):
        if (line[0] == ':'):
            rlen = int(line[1:3], 16)
            addr = int(line[3:7], 16)
            rtyp = int(line[7:9], 16)
            ptr = 9
            for i in range (0, rlen):
                val = int(line[9+i*2:9+i*2+2], 16)
                ofh.write ("@%02x %02x\n" % (addr+i, val))
                bcount += 1
 
        line = ifh.readline()
 
    ifh.close()
    ofh.close()
 
    return bcount
 
def cmdline ():
    import sys
 
    infile = sys.argv[1]
    outfile = sys.argv[2]
 
    bc = ihex2mem (infile, outfile)
    print "Converted %d bytes from %s to %s" % (bc, infile, outfile)
 
if __name__ == '__main__':
    cmdline()
 
 

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

powered by: WebSVN 2.1.0

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