1import pytrellis
2
3"""
4Database fix utility
5
6Run at the end of fuzzing to "finalise" the database and remove problems that may occur during fuzzing
7"""
8
9
10def dbfixup(family, device, tiletype):
11    db = pytrellis.get_tile_bitdata(
12        pytrellis.TileLocator(family, device, tiletype))
13
14    fc = db.get_fixed_conns()
15    # Where a wire is driven by both a mux and fixed connections, replace those fixed connections
16    # with a mux arc with no config bits
17    for mux in db.get_sinks():
18        deleteFc = False
19        for conn in fc:
20            if conn.sink == mux:
21                ad = pytrellis.ArcData()
22                ad.source = conn.source
23                ad.sink = conn.sink
24                db.add_mux_arc(ad)
25                deleteFc = True
26        if deleteFc:
27            db.remove_fixed_sink(mux)
28    db.save()
29