int_maketodo.py: Replace assertion with warning if PIP can't be balanced

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
This commit is contained in:
Tomasz Michalak 2019-06-19 11:07:24 +02:00
parent 5831cf604f
commit 8c059c627b
1 changed files with 10 additions and 6 deletions

View File

@ -34,6 +34,7 @@ def load_pipfile(pipfile, verbose=False):
def balance_todo_list( def balance_todo_list(
pipfile,
todos, todos,
balance_wire_re, balance_wire_re,
balance_wire_direction, balance_wire_direction,
@ -52,6 +53,7 @@ def balance_todo_list(
specified with the --balance-wire-direction switch) will have at least the number specified with the --balance-wire-direction switch) will have at least the number
of entries specified with the --balance-wire-cnt switch in the final todo list. of entries specified with the --balance-wire-cnt switch in the final todo list.
""" """
orig_todos, tile_type = load_pipfile(pipfile, verbose=verbose)
if balance_wire_re is not None: if balance_wire_re is not None:
todo_wires = {} todo_wires = {}
verbose and print("Start balancing the TODO list") verbose and print("Start balancing the TODO list")
@ -83,8 +85,10 @@ def balance_todo_list(
if len(todo_wires[wire]) == balance_wire_cnt: if len(todo_wires[wire]) == balance_wire_cnt:
break break
for wire, other_wires in todo_wires.items(): for wire, other_wires in todo_wires.items():
assert len(other_wires) >= balance_wire_cnt, "Len is " + str( if len(other_wires) < balance_wire_cnt:
len(other_wires)) verbose and print(
"Warning: failed to balance the todo list for wire {}, there are only {} PIPs which meet the requirement: {}"
.format(wire, len(other_wires), other_wires))
for other_wire in other_wires: for other_wire in other_wires:
line = tile_type + "." line = tile_type + "."
if balance_wire_direction in "src": if balance_wire_direction in "src":
@ -112,7 +116,6 @@ def maketodo(
050-intpips doesn't care about contents, but most fuzzers use the tile type prefix 050-intpips doesn't care about contents, but most fuzzers use the tile type prefix
''' '''
orig_todos, tile_type = load_pipfile(pipfile, verbose=verbose)
todos, tile_type = load_pipfile(pipfile, verbose=verbose) todos, tile_type = load_pipfile(pipfile, verbose=verbose)
verbose and print('%s: %u entries' % (pipfile, len(todos))) verbose and print('%s: %u entries' % (pipfile, len(todos)))
verbose and print("pipfile todo sample: %s" % list(todos)[0]) verbose and print("pipfile todo sample: %s" % list(todos)[0])
@ -141,7 +144,8 @@ def maketodo(
todos.remove(tag) todos.remove(tag)
else: else:
verbose and print( verbose and print(
"WARNING: couldnt remove %s (line %s)" % (tag, line)) "WARNING: couldnt remove %s (line %s)" %
(tag, line.strip()))
else: else:
verbose and print("WARNING: dbfile doesnt exist: %s" % dbfile) verbose and print("WARNING: dbfile doesnt exist: %s" % dbfile)
verbose and print('Post db %s: %u entries' % (dbfile, len(todos))) verbose and print('Post db %s: %u entries' % (dbfile, len(todos)))
@ -166,8 +170,8 @@ def maketodo(
verbose and print('Print %u entries w/ %u drops' % (lines, drops)) verbose and print('Print %u entries w/ %u drops' % (lines, drops))
balance_todo_list( balance_todo_list(
filtered_todos, balance_wire_re, balance_wire_direction, pipfile, filtered_todos, balance_wire_re, balance_wire_direction,
balance_wire_cnt) balance_wire_cnt, verbose)
for todo in filtered_todos: for todo in filtered_todos:
print(todo) print(todo)