import binascii
import array
import struct

# output data array
romData = bytearray()

# add ROM
romFile = open('demo-cart.bin', 'rb')
rom = romFile.read()
romData += bytearray(rom)

# save as Lattice memory file
mem = open('test.mem', 'w')
mem.write('#Format=Hex\n')
mem.write('#Depth=4096\n')
mem.write('#Width=8\n')
mem.write('#AddrRadix=3\n')
mem.write('#DataRadix=3\n')
mem.write('#Data\n')
for b in romData:
	mem.write("%0.2X\n" % b)
mem.close()
