mirror of https://github.com/openXC7/prjxray.git
fuzzers: 007: add timings_fixup script
Signed-off-by: Karol Gugala <kgugala@antmicro.com>
This commit is contained in:
parent
8366e324af
commit
91e7f3910e
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
def fix_line(line, site, filetype):
|
||||
line = line.split()
|
||||
newline = list()
|
||||
sites_count = int(line[1])
|
||||
newline.append(line[0])
|
||||
# we'll emit only one site
|
||||
newline.append("1")
|
||||
newline.append(site)
|
||||
newline.append("1")
|
||||
newline.append(site)
|
||||
entries = list()
|
||||
all_entries = 0
|
||||
loc = 2
|
||||
for site in range(0, sites_count):
|
||||
bels_count = int(line[loc + 1])
|
||||
loc += 2
|
||||
for bel in range(0, bels_count):
|
||||
entries_count = int(line[loc + 1])
|
||||
loc += 2
|
||||
all_entries += entries_count
|
||||
for entry in range(0, entries_count):
|
||||
if filetype == 'timings':
|
||||
for delay_word in range(0, 6):
|
||||
entries.append(line[loc])
|
||||
loc += 1
|
||||
elif filetype == 'pins':
|
||||
for pin_word in range(0, 3):
|
||||
entries.append(line[loc])
|
||||
loc += 1
|
||||
elif filetype == 'properties':
|
||||
entries.append(line[loc])
|
||||
loc += 1
|
||||
values_count = int(line[loc])
|
||||
entries.append(line[loc])
|
||||
loc += 1
|
||||
for value in range(0, values_count):
|
||||
entries.append(line[loc])
|
||||
loc += 1
|
||||
newline.append(str(all_entries))
|
||||
newline.extend(entries)
|
||||
return " ".join(newline) + "\n"
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--txtin', type=str, help='Input text file')
|
||||
parser.add_argument('--txtout', type=str, help='Output text file')
|
||||
parser.add_argument('--site', type=str, help='Site to which the entries should be squashed')
|
||||
parser.add_argument('--slice', type=str, help='Slice for which the entries shall be fixed')
|
||||
parser.add_argument('--type', type=str, choices=['timings', 'pins', 'properties'])
|
||||
|
||||
args = parser.parse_args()
|
||||
lines = list()
|
||||
|
||||
with open(args.txtin, 'r') as fp:
|
||||
for line in fp:
|
||||
if line.startswith(args.slice):
|
||||
line = fix_line(line, args.site, args.type)
|
||||
lines.append(line)
|
||||
|
||||
with open(args.txtout, 'w') as fp:
|
||||
for line in lines:
|
||||
fp.write(line)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue