mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
Improving script comments
This commit is contained in:
parent
9e9d323025
commit
927b31a811
47
scripts/elf2hex
Executable file
47
scripts/elf2hex
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
#############################################################################
|
||||
# elf2hex <inputfile> <outputfile> <memory-width> [-emf] [-offset]
|
||||
#
|
||||
# Script uses objcopy to dump a a
|
||||
#
|
||||
# The script assumes the hex file has max 16 byte entries per line
|
||||
#
|
||||
# Script also supports creating EMF transactions with one address per data
|
||||
#
|
||||
#############################################################################
|
||||
import sys
|
||||
import re
|
||||
|
||||
hexin = sys.argv[1]
|
||||
hexout = sys.argv[2]
|
||||
width = int(int(sys.argv[3])/8) #needed for both
|
||||
emf = 0 # emf
|
||||
offset = 0 #TODO: specify as hex offset, only for emf
|
||||
|
||||
#1. Read file into list and strip off trail junk
|
||||
list = [line.rstrip(' \n') for line in open(hexin)]
|
||||
|
||||
#2. Loop through byte list and print to output file
|
||||
fileout=open(hexout,"w")
|
||||
for line in list:
|
||||
if (~line.find('@')): #detects new memory section
|
||||
address = offset + int(line.replace('@','',1),16)
|
||||
if(emf):
|
||||
print ("Not Implemented")
|
||||
else:
|
||||
file.write("@"+format(address, 'x'))
|
||||
else:
|
||||
bytes=line.split(' ')
|
||||
length=len(bytes)
|
||||
for i in range(0,(16-length)): # zero extend buffer for simplicity
|
||||
bytes.append("00")
|
||||
for i in range(0,16,width):
|
||||
sublist=bytes[i:i+width]
|
||||
sublist.reverse()
|
||||
word=""
|
||||
word=word.join(sublist)
|
||||
if(emf):
|
||||
print ("Not Implemented")
|
||||
else :
|
||||
file.write(word)
|
||||
file.close()
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
#############################################################################
|
||||
# elf2hex <inputfile> <outputfile> <memory-width> [-emf] [-offset]
|
||||
# hex2hex <inputfile> <outputfile> <memory-width> [-emf] [-offset]
|
||||
#
|
||||
# Script uses objcopy to dump a a
|
||||
# Script uses objcopy to dump a Verilog comptatible hex file
|
||||
#
|
||||
# The script assumes the hex file has max 16 byte entries per line
|
||||
#
|
||||
@ -18,10 +18,12 @@ width = int(int(sys.argv[3])/8) #needed for both
|
||||
emf = 0 # emf
|
||||
offset = 0 #TODO: specify as hex offset, only for emf
|
||||
|
||||
#1. Read file into list and strip off trail junk
|
||||
###################################################
|
||||
# Read file into list and strip off trail junk
|
||||
list = [line.rstrip(' \n') for line in open(hexin)]
|
||||
|
||||
#2. Loop through byte list and print to output file
|
||||
###################################################
|
||||
# Loop through byte list and print to output file
|
||||
fileout=open(hexout,"w")
|
||||
for line in list:
|
||||
if (~line.find('@')): #detects new memory section
|
||||
|
Loading…
x
Reference in New Issue
Block a user