Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#1959 from The-OpenROAD-Projec…
Browse files Browse the repository at this point in the history
…t-staging/rule-table-format

genRuleFile.py: make the text table prettier for the commit
  • Loading branch information
maliberty authored Apr 22, 2024
2 parents b992704 + c32c00b commit 470955d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions flow/util/genRuleFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def gen_rule_file(design_dir, update, tighten, failing, variant, golden_metrics=
if len(period_list) != 1:
print(f'[WARNING] Multiple clocks not supported. Will use first clock: {period_list[0]}.')

format_str = '| {:45} | {:8} | {:8} | {:8} |\n'
change_str = ''
for field, option in rules_dict.items():
if field not in metrics.keys():
Expand Down Expand Up @@ -269,27 +270,27 @@ def gen_rule_file(design_dir, update, tighten, failing, variant, golden_metrics=
and rule_value != old_rule['value'] \
and compare(rule_value, old_rule['value']):
UPDATE = True
change_str += f"| {field} | {old_rule['value']} | "\
f"{rule_value} | Tighten |\n"
change_str += format_str.format(field, old_rule['value'],
rule_value, 'Tighten')

if failing and not compare(metrics[field], old_rule['value']):
UPDATE = True
change_str += f"| {field} | {old_rule['value']} | " \
f"{rule_value} | Failing |\n"
change_str += format_str.format(field, old_rule['value'],
rule_value, 'Failing')

if update and old_rule['value'] != rule_value:
UPDATE = True
change_str += f"| {field} | {old_rule['value']} | "\
f"{rule_value} | Updating |\n"
change_str += format.format_str.format(field, old_rule['value'],
rule_value, 'Updating')

if not UPDATE:
rule_value = old_rule['value']

rules[field] = dict(value=rule_value, compare=option['compare'])

if len(change_str) > 0:
print("| Metric | Old | New | Type |")
print("| ------ | --- | --- | ---- |")
print(format_str.format('Metric', 'Old', 'New', 'Type'))
print(format_str.format('------', '---', '---', '----'))
print(change_str)

with open(rules_file, 'w') as f:
Expand Down

0 comments on commit 470955d

Please sign in to comment.