Merge pull request #183 from shawnanastasio/addpcis
[microwatt.git] / scripts / bin2hex.py
1 #!/usr/bin/python3
2
3 import sys
4 import subprocess
5 import struct
6
7 with open(sys.argv[1], "rb") as f:
8 while True:
9 word = f.read(8)
10 if len(word) == 8:
11 print("%016x" % struct.unpack('<Q', word));
12 elif len(word) == 4:
13 print("00000000%08x" % struct.unpack('<I', word));
14 elif len(word) == 0:
15 exit(0);
16 else:
17 raise Exception("Bad length")