From ad1877f9e5020439e1495c8ac34b161e07ea6826 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Fri, 8 Feb 2019 15:35:49 +0100 Subject: [PATCH 1/8] checkdb: added out of bound bits check and optimized Signed-off-by: Alessandro Comodi --- prjxray/util.py | 7 ++++++- utils/checkdb.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/prjxray/util.py b/prjxray/util.py index 0b4cf689..7cde6a0c 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -189,15 +189,19 @@ def gen_tile_bits(db_root, tilej, strict=False, verbose=False): for block_type, blockj in tilej["bits"].items(): baseaddr = int(blockj["baseaddr"], 0) bitbase = 32 * blockj["offset"] + frames = tilej["bits"][block_type]["frames"] if block_type == "CLB_IO_CLK": fn = "%s/segbits_%s.db" % (db_root, tilej["type"].lower()) else: - fn = "%s/segbits_%s.db.%s" % ( + fn = "%s/segbits_%s.%s.db" % ( db_root, tilej["type"].lower(), block_type.lower()) # tilegrid runs a lot earlier than fuzzers # may not have been created yet verbose and print("Check %s: %s" % (fn, os.path.exists(fn))) + + # FIXME: some segbits files are not present and the strict check produces assertion errors + # e.g. segbits_cmt_top_r_lower_b.db if strict: assert os.path.exists(fn) elif not os.path.exists(fn): @@ -208,6 +212,7 @@ def gen_tile_bits(db_root, tilej, strict=False, verbose=False): for bitstr in bits: # 31_06 _bit_inv, (bit_addroff, bit_bitoff) = parse_tagbit(bitstr) + assert bit_addroff <= frames, "ERROR: bit out of bound" yield (baseaddr + bit_addroff, bitbase + bit_bitoff, tag) diff --git a/utils/checkdb.py b/utils/checkdb.py index 425cf4d6..df1d8090 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -64,6 +64,7 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): Throw an exception if two tiles share an address ''' mall = dict() + tiles_type_done = set() tiles_checked = 0 @@ -74,6 +75,10 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): for tile_name, tilej in db.tilegrid.items(): # for tile_name, tilej in subtiles(["CLBLL_L_X14Y112", "INT_L_X14Y112"]): + if tilej['type'] in tiles_type_done or not tilej["bits"]: + continue + tiles_type_done.add(tilej['type']) + mtile = make_tile_mask( db_root, tile_name, tilej, strict=strict, verbose=verbose) verbose and print( From 530bb1f2436a390497e8ec2230bd2ac99b0fa3d3 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Mon, 11 Feb 2019 14:18:27 +0100 Subject: [PATCH 2/8] checkdb.py: added some optimizations to script I have restored the check on every single tile while also adding some optimizations to the algorithm. It still is pretty slow, mainly during the INT_[LR] tiles checking, but compared to the previous solution there is a good improvement. Signed-off-by: Alessandro Comodi --- prjxray/util.py | 34 +++++++--------------------- utils/checkdb.py | 58 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/prjxray/util.py b/prjxray/util.py index 7cde6a0c..9494ca19 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -172,42 +172,24 @@ def addr2btype(base_addr): return block_type_i2s[block_type_i] -def gen_tile_bits(db_root, tilej, strict=False, verbose=False): +def gen_tile_bits(db_file, tilej, strict=False, verbose=False): ''' - For given tile yield + For given tile and corresponding db_file structure yield (absolute address, absolute FDRI bit offset, tag) - For each address space - Find applicable files - For each tag bit in those files, calculate absolute address and bit offsets + db_file: + {'': [], '': [], ...} - Sample file names: - segbits_clbll_l.db - segbits_int_l.db - segbits_bram_l.block_ram.db + For each tag bit in the corresponding block_type entry, calculate absolute address and bit offsets ''' for block_type, blockj in tilej["bits"].items(): + assert block_type in db_file, "Block type is not in current tile" + baseaddr = int(blockj["baseaddr"], 0) bitbase = 32 * blockj["offset"] frames = tilej["bits"][block_type]["frames"] - if block_type == "CLB_IO_CLK": - fn = "%s/segbits_%s.db" % (db_root, tilej["type"].lower()) - else: - fn = "%s/segbits_%s.%s.db" % ( - db_root, tilej["type"].lower(), block_type.lower()) - # tilegrid runs a lot earlier than fuzzers - # may not have been created yet - verbose and print("Check %s: %s" % (fn, os.path.exists(fn))) - - # FIXME: some segbits files are not present and the strict check produces assertion errors - # e.g. segbits_cmt_top_r_lower_b.db - if strict: - assert os.path.exists(fn) - elif not os.path.exists(fn): - continue - - for line, (tag, bits, mode) in parse_db_lines(fn): + for line, (tag, bits, mode) in db_file[block_type]: assert mode is None for bitstr in bits: # 31_06 diff --git a/utils/checkdb.py b/utils/checkdb.py index df1d8090..d9e36a51 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -15,9 +15,9 @@ import os import parsedb #from prjxray import db as prjxraydb import glob +import json - -def make_tile_mask(db_root, tile_name, tilej, strict=False, verbose=False): +def make_tile_mask(db_file, tile_name, tilej, strict=False, verbose=False): ''' Return dict key: (address, bit index) @@ -30,7 +30,7 @@ def make_tile_mask(db_root, tile_name, tilej, strict=False, verbose=False): ret = dict() for absaddr, bitaddr, tag in util.gen_tile_bits( - db_root, tilej, strict=strict, verbose=verbose): + db_file, tilej, strict=strict, verbose=verbose): name = "%s.%s" % (tile_name, tag) ret.setdefault((absaddr, bitaddr), name) return ret @@ -54,6 +54,33 @@ def parsedb_all(db_root, verbose=False): print("mask_*.db: %d okay" % files) +def parsedb_file(db_root, db_files, tile, strict=False, verbose=False): + tile_type = tile["type"] + db_files[tile_type] = {} + + for block_type, blockj in tile["bits"].items(): + db_files[tile_type][block_type] = [] + if block_type == "CLB_IO_CLK": + fn = "%s/segbits_%s.db" % (db_root, tile_type.lower()) + else: + fn = "%s/segbits_%s.%s.db" % ( + db_root, tile_type.lower(), block_type.lower()) + # tilegrid runs a lot earlier than fuzzers + # may not have been created yet + verbose and print("Check %s: %s" % (fn, os.path.exists(fn))) + + # FIXME: some segbits files are not present and the strict check produces assertion errors + # e.g. segbits_cmt_top_r_lower_b.db + if strict: + assert os.path.exists(fn) + elif not os.path.exists(fn): + continue + + for line in util.parse_db_lines(fn): + db_files[tile_type][block_type].append(line) + return db_files + + def check_tile_overlap(db, db_root, strict=False, verbose=False): ''' Verifies that no two tiles use the same bit @@ -65,29 +92,30 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): ''' mall = dict() tiles_type_done = set() + db_files = 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"]): + tile_type = tilej["type"] - if tilej['type'] in tiles_type_done or not tilej["bits"]: - continue - tiles_type_done.add(tilej['type']) + if tile_type not in tiles_type_done: + db_files = parsedb_file(db_root, db_files, tilej) + tiles_type_done.add(tile_type) + + if tile_type not in mall: + verbose and print("Adding tile type: %s" % tile_type) + mall[tile_type] = {} mtile = make_tile_mask( - db_root, tile_name, tilej, strict=strict, verbose=verbose) + db_files[tile_type], 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())) + collisions = set(mall[tile_type].keys()).intersection(set(mtile.keys())) if collisions: print("ERROR: %s collisions" % len(collisions)) for ck in sorted(collisions): @@ -95,9 +123,9 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): word, bit = util.addr_bit2word(bitaddr) print( " %s: had %s, got %s" % - (util.addr2str(addr, word, bit), mall[ck], mtile[ck])) + (util.addr2str(addr, word, bit), mall[tile_type][ck], mtile[ck])) raise ValueError("%s collisions" % len(collisions)) - mall.update(mtile) + mall[tile_type].update(mtile) tiles_checked += 1 print("Checked %s tiles, %s bits" % (tiles_checked, len(mall))) From 1f6054ae0d0e45c363c401bef3f82479774cf4fb Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Mon, 11 Feb 2019 17:17:28 +0100 Subject: [PATCH 3/8] Run make format. Signed-off-by: Alessandro Comodi --- utils/checkdb.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/utils/checkdb.py b/utils/checkdb.py index d9e36a51..aafc62fb 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -15,7 +15,7 @@ import os import parsedb #from prjxray import db as prjxraydb import glob -import json + def make_tile_mask(db_file, tile_name, tilej, strict=False, verbose=False): ''' @@ -108,22 +108,28 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): mall[tile_type] = {} mtile = make_tile_mask( - db_files[tile_type], tile_name, tilej, strict=strict, verbose=verbose) + db_files[tile_type], + 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[tile_type].keys()).intersection(set(mtile.keys())) + collisions = set(mall[tile_type].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[tile_type][ck], mtile[ck])) + " %s: had %s, got %s" % ( + util.addr2str(addr, word, bit), mall[tile_type][ck], + mtile[ck])) raise ValueError("%s collisions" % len(collisions)) mall[tile_type].update(mtile) tiles_checked += 1 From d18a6df1f8e23a5faeb2e3d8ec963f71c52f6ab5 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 12 Feb 2019 14:02:42 +0100 Subject: [PATCH 4/8] checkdb.py: using db and grid Signed-off-by: Alessandro Comodi --- prjxray/util.py | 28 ++++++++++++----------- utils/checkdb.py | 59 +++++++++++++++++------------------------------- 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/prjxray/util.py b/prjxray/util.py index 9494ca19..4ff8b54a 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -1,7 +1,7 @@ import os import re from .roi import Roi - +from prjxray.grid import BlockType def get_db_root(): # Used during tilegrid db bootstrap @@ -172,7 +172,7 @@ def addr2btype(base_addr): return block_type_i2s[block_type_i] -def gen_tile_bits(db_file, tilej, strict=False, verbose=False): +def gen_tile_bits(tile_segbits, tile, strict=False, verbose=False): ''' For given tile and corresponding db_file structure yield (absolute address, absolute FDRI bit offset, tag) @@ -182,20 +182,22 @@ def gen_tile_bits(db_file, tilej, strict=False, verbose=False): For each tag bit in the corresponding block_type entry, calculate absolute address and bit offsets ''' - for block_type, blockj in tilej["bits"].items(): - assert block_type in db_file, "Block type is not in current tile" - baseaddr = int(blockj["baseaddr"], 0) - bitbase = 32 * blockj["offset"] - frames = tilej["bits"][block_type]["frames"] + for block_type in tile_segbits: + assert block_type.value in tile["bits"], "block type %s is not present in current tile" % block_type.value - for line, (tag, bits, mode) in db_file[block_type]: - assert mode is None - for bitstr in bits: + block = tile["bits"][block_type.value] + + baseaddr = int(block["baseaddr"], 0) + bitbase = 32 * block["offset"] + frames = block["frames"] + + for tag in tile_segbits[block_type]: + for bit in tile_segbits[block_type][tag]: # 31_06 - _bit_inv, (bit_addroff, bit_bitoff) = parse_tagbit(bitstr) - assert bit_addroff <= frames, "ERROR: bit out of bound" - yield (baseaddr + bit_addroff, bitbase + bit_bitoff, tag) + word_column, word_bit, isset = bit + assert word_column <= frames, "ERROR: bit out of bound --> word_column = %s; frames = %s" % (word_column, frames) + yield word_column + baseaddr, word_bit + bitbase, tag def specn(): diff --git a/utils/checkdb.py b/utils/checkdb.py index aafc62fb..a4959356 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -17,7 +17,7 @@ import parsedb import glob -def make_tile_mask(db_file, tile_name, tilej, strict=False, verbose=False): +def make_tile_mask(tile_segbits, tile_name, tilej, strict=False, verbose=False): ''' Return dict key: (address, bit index) @@ -30,7 +30,7 @@ def make_tile_mask(db_file, tile_name, tilej, strict=False, verbose=False): ret = dict() for absaddr, bitaddr, tag in util.gen_tile_bits( - db_file, tilej, strict=strict, verbose=verbose): + tile_segbits, tilej, strict=strict, verbose=verbose): name = "%s.%s" % (tile_name, tag) ret.setdefault((absaddr, bitaddr), name) return ret @@ -54,33 +54,6 @@ def parsedb_all(db_root, verbose=False): print("mask_*.db: %d okay" % files) -def parsedb_file(db_root, db_files, tile, strict=False, verbose=False): - tile_type = tile["type"] - db_files[tile_type] = {} - - for block_type, blockj in tile["bits"].items(): - db_files[tile_type][block_type] = [] - if block_type == "CLB_IO_CLK": - fn = "%s/segbits_%s.db" % (db_root, tile_type.lower()) - else: - fn = "%s/segbits_%s.%s.db" % ( - db_root, tile_type.lower(), block_type.lower()) - # tilegrid runs a lot earlier than fuzzers - # may not have been created yet - verbose and print("Check %s: %s" % (fn, os.path.exists(fn))) - - # FIXME: some segbits files are not present and the strict check produces assertion errors - # e.g. segbits_cmt_top_r_lower_b.db - if strict: - assert os.path.exists(fn) - elif not os.path.exists(fn): - continue - - for line in util.parse_db_lines(fn): - db_files[tile_type][block_type].append(line) - return db_files - - def check_tile_overlap(db, db_root, strict=False, verbose=False): ''' Verifies that no two tiles use the same bit @@ -91,8 +64,8 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): Throw an exception if two tiles share an address ''' mall = dict() - tiles_type_done = set() - db_files = dict() + tiles_type_done = dict() + tile_segbits = dict() tiles_checked = 0 @@ -100,15 +73,22 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): tile_type = tilej["type"] if tile_type not in tiles_type_done: - db_files = parsedb_file(db_root, db_files, tilej) - tiles_type_done.add(tile_type) + 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 tile_type not in mall: - verbose and print("Adding tile type: %s" % tile_type) mall[tile_type] = {} + if tiles_type_done[tile_type]: + continue + mtile = make_tile_mask( - db_files[tile_type], + tile_segbits[tile_type], tile_name, tilej, strict=strict, @@ -119,8 +99,11 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): if len(mtile) == 0: continue - collisions = set(mall[tile_type].keys()).intersection( - set(mtile.keys())) + collisions = set() + for bits in mtile.keys(): + if bits in mall[tile_type].keys(): + collisions.add(bits) + if collisions: print("ERROR: %s collisions" % len(collisions)) for ck in sorted(collisions): From e87d6c603f07e37adce35a194e65e474108764eb Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 12 Feb 2019 14:03:53 +0100 Subject: [PATCH 5/8] Run make format. Signed-off-by: Alessandro Comodi --- prjxray/util.py | 7 +++++-- utils/checkdb.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/prjxray/util.py b/prjxray/util.py index 4ff8b54a..a3316bff 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -3,6 +3,7 @@ import re from .roi import Roi from prjxray.grid import BlockType + def get_db_root(): # Used during tilegrid db bootstrap ret = os.getenv("XRAY_DATABASE_ROOT", None) @@ -184,7 +185,8 @@ def gen_tile_bits(tile_segbits, tile, strict=False, verbose=False): ''' for block_type in tile_segbits: - assert block_type.value in tile["bits"], "block type %s is not present in current tile" % block_type.value + assert block_type.value in tile[ + "bits"], "block type %s is not present in current tile" % block_type.value block = tile["bits"][block_type.value] @@ -196,7 +198,8 @@ def gen_tile_bits(tile_segbits, tile, strict=False, verbose=False): for bit in tile_segbits[block_type][tag]: # 31_06 word_column, word_bit, isset = bit - assert word_column <= frames, "ERROR: bit out of bound --> word_column = %s; frames = %s" % (word_column, frames) + assert word_column <= frames, "ERROR: bit out of bound --> word_column = %s; frames = %s" % ( + word_column, frames) yield word_column + baseaddr, word_bit + bitbase, tag diff --git a/utils/checkdb.py b/utils/checkdb.py index a4959356..20cb4944 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -17,7 +17,8 @@ import parsedb import glob -def make_tile_mask(tile_segbits, tile_name, tilej, strict=False, verbose=False): +def make_tile_mask( + tile_segbits, tile_name, tilej, strict=False, verbose=False): ''' Return dict key: (address, bit index) From 256ae2d1d96ba441cef57d8bb84f81fc1395f67f Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 12 Feb 2019 15:56:24 +0100 Subject: [PATCH 6/8] prjxray/util: better assertion message Signed-off-by: Alessandro Comodi --- prjxray/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/prjxray/util.py b/prjxray/util.py index a3316bff..0bad38a9 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -1,7 +1,6 @@ import os import re from .roi import Roi -from prjxray.grid import BlockType def get_db_root(): @@ -198,8 +197,8 @@ def gen_tile_bits(tile_segbits, tile, strict=False, verbose=False): for bit in tile_segbits[block_type][tag]: # 31_06 word_column, word_bit, isset = bit - assert word_column <= frames, "ERROR: bit out of bound --> word_column = %s; frames = %s" % ( - word_column, frames) + assert word_column <= frames, "ERROR: bit out of bound --> tag: %s; word_column = %s; frames = %s" % ( + tag, word_column, frames) yield word_column + baseaddr, word_bit + bitbase, tag From 2a8587772d0f31c2ef67d3dd59c397d920a107aa Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 12 Feb 2019 17:00:16 +0100 Subject: [PATCH 7/8] checkdb.py: now correctly using db and grid datastructures Signed-off-by: Alessandro Comodi --- prjxray/util.py | 30 ------------------------------ utils/checkdb.py | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/prjxray/util.py b/prjxray/util.py index 0bad38a9..35f9939f 100644 --- a/prjxray/util.py +++ b/prjxray/util.py @@ -172,36 +172,6 @@ def addr2btype(base_addr): return block_type_i2s[block_type_i] -def gen_tile_bits(tile_segbits, tile, strict=False, verbose=False): - ''' - For given tile and corresponding db_file structure yield - (absolute address, absolute FDRI bit offset, tag) - - db_file: - {'': [], '': [], ...} - - For each tag bit in the corresponding block_type entry, calculate absolute address and bit offsets - ''' - - for block_type in tile_segbits: - assert block_type.value in tile[ - "bits"], "block type %s is not present in current tile" % block_type.value - - block = tile["bits"][block_type.value] - - baseaddr = int(block["baseaddr"], 0) - bitbase = 32 * block["offset"] - frames = block["frames"] - - for tag in tile_segbits[block_type]: - for bit in tile_segbits[block_type][tag]: - # 31_06 - word_column, word_bit, isset = bit - assert word_column <= frames, "ERROR: bit out of bound --> tag: %s; word_column = %s; frames = %s" % ( - tag, word_column, frames) - yield word_column + baseaddr, word_bit + bitbase, tag - - def specn(): # ex: build/specimen_001 specdir = os.getenv("SPECDIR") diff --git a/utils/checkdb.py b/utils/checkdb.py index 20cb4944..85e5f912 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -17,8 +17,35 @@ import parsedb import glob +def gen_tile_bits(tile_segbits, tile_bits, strict=False, verbose=False): + ''' + For given tile and corresponding db_file structure yield + (absolute address, absolute FDRI bit offset, tag) + + For each tag bit in the corresponding block_type entry, calculate absolute address and bit offsets + ''' + + for block_type in tile_segbits: + assert block_type in tile_bits, "block type %s is not present in current tile" % block_type + + block = tile_bits[block_type] + + baseaddr = block.base_address + bitbase = 32 * block.offset + frames = block.frames + + for tag in tile_segbits[block_type]: + for bit in tile_segbits[block_type][tag]: + # 31_06 + word_column = bit.word_column + word_bit = bit.word_bit + assert word_column <= frames, "ERROR: bit out of bound --> tag: %s; word_column = %s; frames = %s" % ( + tag, word_column, frames) + yield word_column + baseaddr, word_bit + bitbase, tag + + def make_tile_mask( - tile_segbits, tile_name, tilej, strict=False, verbose=False): + tile_segbits, tile_name, tile_bits, strict=False, verbose=False): ''' Return dict key: (address, bit index) @@ -30,8 +57,8 @@ def make_tile_mask( # We may want this to build them anyway ret = dict() - for absaddr, bitaddr, tag in util.gen_tile_bits( - tile_segbits, tilej, strict=strict, verbose=verbose): + for absaddr, bitaddr, tag in gen_tile_bits(tile_segbits, tile_bits, + strict=strict, verbose=verbose): name = "%s.%s" % (tile_name, tag) ret.setdefault((absaddr, bitaddr), name) return ret @@ -67,11 +94,13 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): mall = dict() tiles_type_done = dict() tile_segbits = dict() - + grid = db.grid() tiles_checked = 0 - for tile_name, tilej in db.tilegrid.items(): - tile_type = tilej["type"] + 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 @@ -91,7 +120,7 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): mtile = make_tile_mask( tile_segbits[tile_type], tile_name, - tilej, + tile_bits, strict=strict, verbose=verbose) verbose and print( From 987cf47df9331307a82bb6d2442181bf25d43dd6 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 12 Feb 2019 18:50:08 +0100 Subject: [PATCH 8/8] checkdb.py: remove not needed arguments Signed-off-by: Alessandro Comodi --- utils/checkdb.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/utils/checkdb.py b/utils/checkdb.py index 85e5f912..d788e3b3 100755 --- a/utils/checkdb.py +++ b/utils/checkdb.py @@ -17,7 +17,7 @@ import parsedb import glob -def gen_tile_bits(tile_segbits, tile_bits, strict=False, verbose=False): +def gen_tile_bits(tile_segbits, tile_bits): ''' For given tile and corresponding db_file structure yield (absolute address, absolute FDRI bit offset, tag) @@ -44,8 +44,7 @@ def gen_tile_bits(tile_segbits, tile_bits, strict=False, verbose=False): yield word_column + baseaddr, word_bit + bitbase, tag -def make_tile_mask( - tile_segbits, tile_name, tile_bits, strict=False, verbose=False): +def make_tile_mask(tile_segbits, tile_name, tile_bits): ''' Return dict key: (address, bit index) @@ -57,8 +56,7 @@ def make_tile_mask( # We may want this to build them anyway ret = dict() - for absaddr, bitaddr, tag in gen_tile_bits(tile_segbits, tile_bits, - strict=strict, verbose=verbose): + for absaddr, bitaddr, tag in gen_tile_bits(tile_segbits, tile_bits): name = "%s.%s" % (tile_name, tag) ret.setdefault((absaddr, bitaddr), name) return ret @@ -82,7 +80,7 @@ def parsedb_all(db_root, verbose=False): print("mask_*.db: %d okay" % files) -def check_tile_overlap(db, db_root, strict=False, verbose=False): +def check_tile_overlap(db, verbose=False): ''' Verifies that no two tiles use the same bit @@ -117,15 +115,10 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): if tiles_type_done[tile_type]: continue - mtile = make_tile_mask( - tile_segbits[tile_type], - tile_name, - tile_bits, - strict=strict, - verbose=verbose) + mtile = make_tile_mask(tile_segbits[tile_type], tile_name, tile_bits) verbose and print( "Checking %s, type %s, bits: %s" % - (tile_name, tilej["type"], len(mtile))) + (tile_name, tile_type, len(mtile))) if len(mtile) == 0: continue @@ -149,7 +142,7 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False): print("Checked %s tiles, %s bits" % (tiles_checked, len(mall))) -def run(db_root, strict=False, verbose=False): +def run(db_root, verbose=False): # Start by running a basic check on db files print("Checking individual .db...") parsedb_all(db_root, verbose=verbose) @@ -167,7 +160,7 @@ def run(db_root, strict=False, verbose=False): verbose and print("") print("Checking aggregate dir...") - check_tile_overlap(db, db_root, strict=strict, verbose=verbose) + check_tile_overlap(db, verbose=verbose) def main(): @@ -177,11 +170,10 @@ def main(): description="Parse a db repository, checking for consistency") util.db_root_arg(parser) - parser.add_argument('--strict', action='store_true', help='') parser.add_argument('--verbose', action='store_true', help='') args = parser.parse_args() - run(args.db_root, strict=args.strict, verbose=args.verbose) + run(args.db_root, verbose=args.verbose) if __name__ == '__main__':