def check_tile_overlap(db, verbose=False): ''' Verifies that no two tiles use the same bit Assume .db files are individually valid Create a mask for all the bits the tile type uses For each tile, create bitmasks over the entire bitstream for current part Throw an exception if two tiles share an address ''' mall = dict() tiles_type_done = dict() tile_segbits = dict() grid = db.grid() tiles_checked = 0 for tile_name in grid.tiles(): tile_info = grid.gridinfo_at_tilename(tile_name) tile_type = tile_info.tile_type tile_bits = tile_info.bits if tile_type not in tiles_type_done: segbits = db.get_tile_segbits(tile_type).segbits tile_segbits[tile_type] = segbits # If segbits has zero length the tile_type is marked True in order to be skipped if len(segbits) == 0: tiles_type_done[tile_type] = True else: tiles_type_done[tile_type] = False if tiles_type_done[tile_type]: continue mtile = make_tile_mask(tile_segbits[tile_type], tile_name, tile_bits) verbose and print( "Checking %s, type %s, bits: %s" % (tile_name, tile_type, len(mtile))) if len(mtile) == 0: continue collisions = set() for bits in mtile.keys(): if bits in mall.keys(): collisions.add(bits) if collisions: print("ERROR: %s collisions" % len(collisions)) for ck in sorted(collisions): addr, bitaddr = ck word, bit = util.addr_bit2word(bitaddr) print( " %s: had %s, got %s" % (util.addr2str(addr, word, bit), mall[ck], mtile[ck])) raise ValueError("%s collisions" % len(collisions)) mall.update(mtile) tiles_checked += 1 print("Checked %s tiles, %s bits" % (tiles_checked, len(mall)))
def check_tile_overlap(db, db_root, strict=False, verbose=False): ''' Verifies that no two tiles use the same bit Assume .db files are individually valid Create a mask for all the bits the tile type uses For each tile, create bitmasks over the entire bitstream for current part Throw an exception if two tiles share an address ''' mall = dict() tiles_checked = 0 def subtiles(tile_names): for tile_name in tile_names: yield tile_name, db.tilegrid[tile_name] for tile_name, tilej in db.tilegrid.items(): # for tile_name, tilej in subtiles(["CLBLL_L_X14Y112", "INT_L_X14Y112"]): mtile = make_tile_mask(db_root, tile_name, tilej, strict=strict, verbose=verbose) verbose and print("Checking %s, type %s, bits: %s" % (tile_name, tilej["type"], len(mtile))) if len(mtile) == 0: continue collisions = set(mall.keys()).intersection(set(mtile.keys())) if collisions: print("ERROR: %s collisions" % len(collisions)) for ck in sorted(collisions): addr, bitaddr = ck word, bit = util.addr_bit2word(bitaddr) print(" %s: had %s, got %s" % (util.addr2str(addr, word, bit), mall[ck], mtile[ck])) raise ValueError("%s collisions" % len(collisions)) mall.update(mtile) tiles_checked += 1 print("Checked %s tiles, %s bits" % (tiles_checked, len(mall)))