1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-03-02 17:54:29 +00:00
Files
antonblanchard.microwatt/scripts/bin2hex-split.py
Anton Blanchard 9747879643 Add a simple test case
We use 2 32bit RAMs, so we need to split the test case into
two files.
2021-01-05 20:24:33 +11:00

25 lines
658 B
Python
Executable File

#!/usr/bin/python3
import sys
import subprocess
import struct
even = open('even.hex', 'w')
odd = open('odd.hex', 'w')
with open(sys.argv[1], "rb") as f:
while True:
even_word = f.read(4)
if len(even_word) == 0:
exit(0)
if len(even_word) != 4:
raise Exception("Bad length")
even.write("%08x\n" % struct.unpack('<I', even_word));
odd_word = f.read(4)
if len(odd_word) == 0:
exit(0)
if len(odd_word) != 4:
raise Exception("Bad length")
odd.write("%08x\n" % struct.unpack('<I', odd_word));