<commit_before>#!/usr/bin/env python3

import re
import os

from prjxray.segmaker import Segmaker
from prjxray.bitfilter import get_bitfilter

segmk = Segmaker("design.bits")

tiledata = dict()
pipdata = dict()
ignpip = set()

print("Loading tags from design.txt.")
with open("design.txt", "r") as f:
    for line in f:
        tile, pip, src, dst, pnum, pdir = line.split()

        if not tile.startswith('INT_'):
            continue

        _, pip = pip.split(".")
        _, src = src.split("/")
        _, dst = dst.split("/")
        pnum = int(pnum)
        pdir = int(pdir)

        if tile not in tiledata:
            tiledata[tile] = {"pips": set(), "srcs": set(), "dsts": set()}

        if pip in pipdata:
            assert pipdata[pip] == (src, dst)
        else:
            pipdata[pip] = (src, dst)

        tiledata[tile]["pips"].add(pip)
        tiledata[tile]["srcs"].add(src)
        tiledata[tile]["dsts"].add(dst)

        if pdir == 0:
            tiledata[tile]["srcs"].add(dst)
            tiledata[tile]["dsts"].add(src)

        gfan_src = re.match('^GFAN', src) is not None

        # Okay: BYP_ALT0.VCC_WIRE
        # Skip: INT.IMUX13.VCC_WIRE, INT.IMUX_L43.VCC_WIRE
        if pnum == 1 or pdir == 0 or \
                src == "VCC_WIRE" or \
                re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", src) or \
                re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", dst) or \
                gfan_src or \
                re.match(r"^(CTRL|GFAN)(_L)?[0-9]", dst):
            ignpip.add(pip)

for tile, pips_srcs_dsts in tiledata.items():
    pips = pips_srcs_dsts["pips"]
    srcs = pips_srcs_dsts["srcs"]
    dsts = pips_srcs_dsts["dsts"]

    for pip, src_dst in pipdata.items():
        src, dst = src_dst
        if pip in ignpip:
            pass
        elif pip in pips:
            segmk.add_tile_tag(tile, "%s.%s" % (dst, src), 1)
        elif src_dst[1] not in dsts:<commit_msg>050-pip-seed: Don't solve FAN_ALT.BYP_BOUNCE bits<commit_after>#!/usr/bin/env python3

import re
import os

from prjxray.segmaker import Segmaker
from prjxray.bitfilter import get_bitfilter

segmk = Segmaker("design.bits")

tiledata = dict()
pipdata = dict()
ignpip = set()

print("Loading tags from design.txt.")
with open("design.txt", "r") as f:
    for line in f:
        tile, pip, src, dst, pnum, pdir = line.split()

        if not tile.startswith('INT_'):
            continue

        _, pip = pip.split(".")
        _, src = src.split("/")
        _, dst = dst.split("/")
        pnum = int(pnum)
        pdir = int(pdir)

        if tile not in tiledata:
            tiledata[tile] = {"pips": set(), "srcs": set(), "dsts": set()}

        if pip in pipdata:
            assert pipdata[pip] == (src, dst)
        else:
            pipdata[pip] = (src, dst)

        tiledata[tile]["pips"].add(pip)
        tiledata[tile]["srcs"].add(src)
        tiledata[tile]["dsts"].add(dst)

        if pdir == 0:
            tiledata[tile]["srcs"].add(dst)
            tiledata[tile]["dsts"].add(src)

        gfan_src = re.match('^GFAN', src) is not None
        fan_alt_byp_bounce = re.match('^FAN_ALT[0-9]',
                                      dst) is not None and re.match(
                                          '^BYP_BOUNCE.*', src) is not None

        # Okay: BYP_ALT0.VCC_WIRE
        # Skip: INT.IMUX13.VCC_WIRE, INT.IMUX_L43.VCC_WIRE
        if pnum == 1 or pdir == 0 or \
                src == "VCC_WIRE" or \
                re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", src) or \
                re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", dst) or \
                gfan_src or \
                fan_alt_byp_bounce or \
                re.match(r"^(CTRL|GFAN)(_L)?[0-9]", dst):
            ignpip.add(pip)

for tile, pips_srcs_dsts in tiledata.items():
    pips = pips_srcs_dsts["pips"]
    srcs = pips_srcs_dsts["srcs"]
    dsts = pips_srcs_dsts["dsts"]

    for pip, src_dst in pipdata.items():
        src, dst = src_dst
        if pip in ignpip:
            pass
        elif pip in pips:
            segmk.add_tile_tag(tile, "%s.%s" % (dst, src), 1)
        elif src_dst[1] not in dsts:
{'fraction_non_alphanumeric': 0.15837759536455817, 'fraction_numerical': 0.009415741187831965, 'mean_word_length': 1.9592857142857143, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7464690', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1535, 'n_words': 334}