diff --git a/prjxray/util.py b/prjxray/util.py index 35603fc9..09377c83 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -74,19 +74,23 @@ def db_root_arg(parser): def parse_db_line(line): + '''Return tag name, bit values (if any), mode (if any)''' parts = line.split() # Ex: CLBLL_L.SLICEL_X0.AMUX.A5Q assert len(parts), "Empty line" tag = parts[0] + if tag == 'bit': + raise ValueError("Wanted bits db but got mask db") assert re.match(r'[A-Z0-9_.]+', tag), "Invalid tag name: %s, line: %s" % (tag, line) orig_bits = line.replace(tag + " ", "") # <0 candidates> etc - if "<" in orig_bits: - return tag, set(), orig_bits + # Ex: INT_L.BYP_BOUNCE5.BYP_ALT5 always + if "<" in orig_bits or "always" == orig_bits: + return tag, None, orig_bits - # Ex: !30_06 !30_08 !30_11 30_07 bits = frozenset(parts[1:]) + # Ex: CLBLL_L.SLICEL_X0.AOUTMUX.A5Q !30_06 !30_08 !30_11 30_07 for bit in bits: # 19_39 # 100_319 diff --git a/utils/dbfixup.py b/utils/dbfixup.py index 758d5592..094629aa 100755 --- a/utils/dbfixup.py +++ b/utils/dbfixup.py @@ -124,19 +124,24 @@ def add_zero_bits(fn_in, fn_out, zero_db, clb_int=False, verbose=False): assert mode not in ( "", ""), "Entries must be resolved. line: %s" % (line, ) - if mode: - assert mode == "<0 candidates>" - """ - This appears to be a large range of one hot interconnect bits - They are immediately before the first CLB real bits - """ - if clb_int: - zero_range(bits, 22, 25) - bits = set(bits) - zero_groups( - tag, bits, zero_db, strict=not clb_int, verbose=verbose) - new_line = " ".join([tag] + sorted(bits)) + if mode == "always": + new_line = line + elif mode == "<0 candidates>": + """ + This appears to be a large range of one hot interconnect bits + They are immediately before the first CLB real bits + """ + if clb_int: + zero_range(bits, 22, 25) + bits = set(bits) + zero_groups( + tag, bits, zero_db, strict=not clb_int, verbose=verbose) + + new_line = " ".join([tag] + sorted(bits)) + else: + assert 0, line + if new_line != line: changes += 1 new_lines.add(new_line) diff --git a/utils/mergedb.sh b/utils/mergedb.sh index 848d50f3..90aca2b0 100755 --- a/utils/mergedb.sh +++ b/utils/mergedb.sh @@ -10,6 +10,13 @@ test -e "$2" tmp1=`mktemp -p .` tmp2=`mktemp -p .` +function finish { + echo "Cleaning up temp files" + rm -f "$tmp1" + rm -f "$tmp2" +} +trap finish EXIT + db=$XRAY_DATABASE_DIR/$XRAY_DATABASE/segbits_$1.db # Fuzzers verify L/R data is equivilent @@ -72,5 +79,4 @@ esac touch "$db" sort -u "$tmp1" "$db" | grep -v '<.*>' > "$tmp2" || true ${XRAY_PARSEDB} --strict "$tmp2" "$db" -rm -f "$tmp1" diff --git a/utils/parsedb.py b/utils/parsedb.py index e3837798..b24ad42f 100755 --- a/utils/parsedb.py +++ b/utils/parsedb.py @@ -5,21 +5,28 @@ from prjxray import util def run(fnin, fnout=None, strict=False, verbose=False): lines = open(fnin, 'r').read().split('\n') - tags = set() + tags = dict() bitss = set() for line in lines: line = line.strip() if line == '': continue + # TODO: figure out what to do with masks + if line.startswith("bit "): + continue tag, bits, mode = util.parse_db_line(line) if strict: - assert not mode, "strict: got ill defined line: %s" % (line, ) - assert tag not in tags, "strict: got duplicate tag %s (ex: %s)" % ( - tag, line) + if mode != "always": + assert not mode, "strict: got ill defined line: %s" % (line, ) + if tag in tags: + print("Original line: %s" % tags[tag]) + print("New line: %s" % line) + assert 0, "strict: got duplicate tag %s" % (tag, ) assert bits not in bitss, "strict: got duplicate bits %s (ex: %s)" % ( bits, line) - tags.add(tag) - bitss.add(bits) + tags[tag] = line + if bits != None: + bitss.add(bits) if fnout: with open(fnout, "w") as fout: