You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
microwatt/litedram/gen-src/sdram_init/bin2hex.py

15 lines
341 B
Python

#!/usr/bin/python3
import sys
import subprocess
import struct
with open(sys.argv[1], "rb") as f:
while True:
word = f.read(8)
if len(word) == 0:
exit(0);
if len(word) != 8:
word = word + bytes(8 - len(word))
print("%016x" % struct.unpack('Q', word));