From e66234a10cba81757f218e54aa737d1bd57a4410 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 29 Oct 2021 14:28:29 +0200 Subject: [PATCH] python3 support and compile fixes --- scripts/valtab.py | 19 ++++++++++--------- scripts/verilator_tb.h | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/valtab.py b/scripts/valtab.py index 77c4867..c6b20ad 100644 --- a/scripts/valtab.py +++ b/scripts/valtab.py @@ -3,6 +3,7 @@ import re import sys import getopt +from functools import cmp_to_key opts, args = getopt.getopt(sys.argv, "", []) args.pop(0) @@ -94,7 +95,7 @@ def binary2decimal(bits, signed): if len(bitpartitions) != 0: for part in bitpartitions: vars_found_diff = False - ref_lst = data[idx]['split_outputs'].keys()[0] + ref_lst = list(data[idx]['split_outputs'].keys())[0] for lst in data[idx]['split_outputs'].keys(): if data[idx]['split_outputs'][lst][part[2]] != data[idx]['split_outputs'][ref_lst][part[2]]: vars_found_diff = True @@ -135,22 +136,22 @@ def pretty_list(txt): for idx in sorted(data.keys()): d = data[idx] if len(d['split_outputs']) > 1: - print ''.format(idx) + print('
Pattern #{}binarydecimal
'.format(idx)) first_var = True for key in sorted(d['inputs'].keys()): if first_var: - print ''.format(len(d['inputs']), key, d['inputs'][key][0], d['inputs'][key][1]) + print(''.format(len(d['inputs']), key, d['inputs'][key][0], d['inputs'][key][1])) else: - print ''.format(key, d['inputs'][key][0], d['inputs'][key][1]) + print(''.format(key, d['inputs'][key][0], d['inputs'][key][1])) first_var = False for lst in sorted(d['split_outputs'].keys()): first_var = True - for var in sorted(d['split_outputs'][lst].keys(), cmp=outvar_compare): + for var in sorted(d['split_outputs'][lst].keys(), key=cmp_to_key(outvar_compare)): if first_var: - print ''.format( - len(d['split_outputs'][lst].keys()), pretty_list(lst), var, d['split_outputs'][lst][var][0], d['split_outputs'][lst][var][1]) + print(''.format( + len(d['split_outputs'][lst].keys()), pretty_list(lst), var, d['split_outputs'][lst][var][0], d['split_outputs'][lst][var][1])) else: - print ''.format(var, d['split_outputs'][lst][var][0], d['split_outputs'][lst][var][1]) + print(''.format(var, d['split_outputs'][lst][var][0], d['split_outputs'][lst][var][1])) first_var = False - print '
Pattern #{}binarydecimal
input signals{}{}{}
input signals{}{}{}
{}{}{}
{}{}{}
{}{}{}{}
{}{}{}{}
{}{}{}
{}{}{}
' + print('') diff --git a/scripts/verilator_tb.h b/scripts/verilator_tb.h index 1079089..07bedb9 100644 --- a/scripts/verilator_tb.h +++ b/scripts/verilator_tb.h @@ -14,7 +14,7 @@ bool pattern_bits[PATTERN_BITS_N]; int pattern_cursor, pattern_idx; std::string input_pat_list; -std::vector input_patterns_buf; +std::vector input_patterns_buf; std::set undef_bits; static inline void set_pattern(const char *pattern)