mirror of https://github.com/openXC7/prjxray.git
checkdb.py: using db and grid
Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
This commit is contained in:
parent
1f6054ae0d
commit
d18a6df1f8
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from .roi import Roi
|
from .roi import Roi
|
||||||
|
from prjxray.grid import BlockType
|
||||||
|
|
||||||
def get_db_root():
|
def get_db_root():
|
||||||
# Used during tilegrid db bootstrap
|
# Used during tilegrid db bootstrap
|
||||||
|
|
@ -172,7 +172,7 @@ def addr2btype(base_addr):
|
||||||
return block_type_i2s[block_type_i]
|
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
|
For given tile and corresponding db_file structure yield
|
||||||
(absolute address, absolute FDRI bit offset, tag)
|
(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 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)
|
for block_type in tile_segbits:
|
||||||
bitbase = 32 * blockj["offset"]
|
assert block_type.value in tile["bits"], "block type %s is not present in current tile" % block_type.value
|
||||||
frames = tilej["bits"][block_type]["frames"]
|
|
||||||
|
|
||||||
for line, (tag, bits, mode) in db_file[block_type]:
|
block = tile["bits"][block_type.value]
|
||||||
assert mode is None
|
|
||||||
for bitstr in bits:
|
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
|
# 31_06
|
||||||
_bit_inv, (bit_addroff, bit_bitoff) = parse_tagbit(bitstr)
|
word_column, word_bit, isset = bit
|
||||||
assert bit_addroff <= frames, "ERROR: bit out of bound"
|
assert word_column <= frames, "ERROR: bit out of bound --> word_column = %s; frames = %s" % (word_column, frames)
|
||||||
yield (baseaddr + bit_addroff, bitbase + bit_bitoff, tag)
|
yield word_column + baseaddr, word_bit + bitbase, tag
|
||||||
|
|
||||||
|
|
||||||
def specn():
|
def specn():
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import parsedb
|
||||||
import glob
|
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
|
Return dict
|
||||||
key: (address, bit index)
|
key: (address, bit index)
|
||||||
|
|
@ -30,7 +30,7 @@ def make_tile_mask(db_file, tile_name, tilej, strict=False, verbose=False):
|
||||||
|
|
||||||
ret = dict()
|
ret = dict()
|
||||||
for absaddr, bitaddr, tag in util.gen_tile_bits(
|
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)
|
name = "%s.%s" % (tile_name, tag)
|
||||||
ret.setdefault((absaddr, bitaddr), name)
|
ret.setdefault((absaddr, bitaddr), name)
|
||||||
return ret
|
return ret
|
||||||
|
|
@ -54,33 +54,6 @@ def parsedb_all(db_root, verbose=False):
|
||||||
print("mask_*.db: %d okay" % files)
|
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):
|
def check_tile_overlap(db, db_root, strict=False, verbose=False):
|
||||||
'''
|
'''
|
||||||
Verifies that no two tiles use the same bit
|
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
|
Throw an exception if two tiles share an address
|
||||||
'''
|
'''
|
||||||
mall = dict()
|
mall = dict()
|
||||||
tiles_type_done = set()
|
tiles_type_done = dict()
|
||||||
db_files = dict()
|
tile_segbits = dict()
|
||||||
|
|
||||||
tiles_checked = 0
|
tiles_checked = 0
|
||||||
|
|
||||||
|
|
@ -100,15 +73,22 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False):
|
||||||
tile_type = tilej["type"]
|
tile_type = tilej["type"]
|
||||||
|
|
||||||
if tile_type not in tiles_type_done:
|
if tile_type not in tiles_type_done:
|
||||||
db_files = parsedb_file(db_root, db_files, tilej)
|
segbits = db.get_tile_segbits(tile_type).segbits
|
||||||
tiles_type_done.add(tile_type)
|
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] = {}
|
mall[tile_type] = {}
|
||||||
|
|
||||||
|
if tiles_type_done[tile_type]:
|
||||||
|
continue
|
||||||
|
|
||||||
mtile = make_tile_mask(
|
mtile = make_tile_mask(
|
||||||
db_files[tile_type],
|
tile_segbits[tile_type],
|
||||||
tile_name,
|
tile_name,
|
||||||
tilej,
|
tilej,
|
||||||
strict=strict,
|
strict=strict,
|
||||||
|
|
@ -119,8 +99,11 @@ def check_tile_overlap(db, db_root, strict=False, verbose=False):
|
||||||
if len(mtile) == 0:
|
if len(mtile) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
collisions = set(mall[tile_type].keys()).intersection(
|
collisions = set()
|
||||||
set(mtile.keys()))
|
for bits in mtile.keys():
|
||||||
|
if bits in mall[tile_type].keys():
|
||||||
|
collisions.add(bits)
|
||||||
|
|
||||||
if collisions:
|
if collisions:
|
||||||
print("ERROR: %s collisions" % len(collisions))
|
print("ERROR: %s collisions" % len(collisions))
|
||||||
for ck in sorted(collisions):
|
for ck in sorted(collisions):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue