Created
July 30, 2018 15:16
-
-
Save ajoydas/990b8f485e95e381ea388515971bd044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ins_count = 0 | |
tstate_count = 0 | |
df = pd.DataFrame() | |
position= [] | |
address = [] | |
is_first = False | |
with open('in.txt') as infile: | |
for line in infile: | |
if(line[0]!='.'): | |
print(line) | |
if(line[0]=='-'): | |
tstate_count +=1 | |
line = line[1:] | |
if(is_first): | |
address.append(tstate_count-1) | |
is_first = False | |
signals = [x.strip() for x in line.split(',')] | |
# print(signals) | |
for signal in signals: | |
if len(df.columns) ==0 or signal not in df.columns: | |
if '_BAR' not in signal: | |
df[signal] = 0 | |
else: | |
df[signal] = 1 | |
# print('after adding columns') | |
# print(df) | |
# print(df.columns) | |
# row = [0]* len(df.columns) | |
row = [] | |
for col in df.columns: | |
if '_BAR' not in col: | |
row.append(0) | |
else: | |
row.append(1) | |
print(row) | |
df.append(row) | |
df.loc[len(df)] = row | |
for signal in signals: | |
if '_BAR' not in signal: | |
df.loc[tstate_count-1,signal] = 1 | |
else: | |
df.loc[tstate_count-1,signal] = 0 | |
else: | |
ins_count +=1 | |
is_first = True | |
line = line.strip() | |
print(line[1:len(line)-1]) | |
pos = int(line[1:len(line)-1], 16) | |
print(pos) | |
position.append(pos) | |
# print('after adding values') | |
# print(df) | |
# print() | |
rest = 8 - len(df.columns)%8 | |
print(rest) | |
if(rest !=8): | |
for i in range (rest): | |
df['NULL'+str(i)] = 0 | |
print(df) | |
print() | |
print(len(df.columns)) | |
print(ins_count) | |
print(df.columns) | |
print(len(position)) | |
print(position) | |
print(len(address)) | |
print(address) | |
num_of_file = int(len(df.columns)/8) | |
for i in range(num_of_file): | |
with open('crom'+str(i)+'.BIN', 'w') as outfile: | |
# outfile.write('created') | |
rows = df.shape[0] | |
for j in range(rows): | |
byte = df.loc[j][i*8:(i+1)*8] | |
# print(byte) | |
bstr='' | |
for k in byte: | |
bstr += str(k) | |
hstr = '%0*X' % ((len(bstr) + 3) // 4, int(bstr, 2)) | |
# print(bstr) | |
# print(hstr) | |
outfile.write(hstr+'\n') | |
with open('adrom.BIN', 'w') as addfile: | |
add_list = [0]*32 | |
for i in range(len(position)): | |
add_list[position[i]] = address[i] | |
for addr in add_list: | |
hexs = "%X" % addr | |
addfile.write(hexs+"\n") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-LM_BAR,EP_BAR,EM_BAR | |
-CP, LDR_BAR,R_BAR, EM_BAR | |
-EDB_BAR,LIR_BAR | |
-LOAD | |
.00H | |
-LM_BAR, EP_BAR,EM_BAR | |
-CP, LDR_BAR, R_BAR, EM_BAR | |
-LM_BAR , EDB_BAR, EM_BAR | |
-LDR_BAR, R_BAR,EM_BAR | |
-LA_BAR, EDB_BAR, RESET | |
.01H | |
-LM_BAR, EP_BAR,EM_BAR | |
-CP, LDR_BAR,R_BAR, EM_BAR | |
-LM_BAR,EDB_BAR,EM_BAR | |
-LDR_BAR,EA_BAR,MEM_BUS,EM_BAR, RESET | |
.02H | |
-RCR, SSO | |
-RCR | |
-RCR, RESET | |
.03H | |
-LO_BAR, EA_BAR, RESET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment