Skip to content

Instantly share code, notes, and snippets.

@hktechn0
Created February 28, 2012 20:22
Show Gist options
  • Save hktechn0/1934876 to your computer and use it in GitHub Desktop.
Save hktechn0/1934876 to your computer and use it in GitHub Desktop.
#!/bin/sh
ld-mist32 -Tdata=0x0400 -Ttext=0x0000 -o reloc.o $1
objcopy-mist32 -j .text -O binary reloc.o text.bin
objcopy-mist32 -j .data -O binary reloc.o data.bin
od -t xC -w4 -v text.bin | cut -s -d ' ' -f 2- | sed -e 's/ //g' > text.hex
od -t xC -w4 -v data.bin | cut -s -d ' ' -f 2- | sed -e 's/ //g' > data.hex
echo "=== .text"
python verilog_out_text.py < text.hex
echo "=== .data"
python verilog_out_data.py < data.hex
if __name__ == "__main__":
i = 0
eof = False
while not eof:
try:
lo = 0
lo = int(raw_input(), 16)
except:
eof = True
print """memory[%d] <= 32'h%08x;""" % (
i, lo)
i += 1
if __name__ == "__main__":
i = 0
eof = False
while not eof:
try:
lo = 0
hi = 0
lo = int(raw_input(), 16)
hi = int(raw_input(), 16)
except:
eof = True
print """32'h%08x : func_inst_rom = 64'h%08x%08x;""" % (
i, hi, lo)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment