diff --git a/litedram/gen-src/sdram_init/bin2hex.py b/litedram/gen-src/sdram_init/bin2hex.py index af278bc..b53b2c9 100755 --- a/litedram/gen-src/sdram_init/bin2hex.py +++ b/litedram/gen-src/sdram_init/bin2hex.py @@ -7,11 +7,8 @@ import struct with open(sys.argv[1], "rb") as f: while True: word = f.read(8) - if len(word) == 8: - print("%016x" % struct.unpack('Q', word)); - elif len(word) == 4: - print("00000000%08x" % struct.unpack('I', word)); - elif len(word) == 0: + if len(word) == 0: exit(0); - else: - raise Exception("Bad length") + if len(word) != 8: + word = word + bytes(8 - len(word)) + print("%016x" % struct.unpack('Q', word));