mirror of https://github.com/openXC7/prjxray.git
dbfixup: move parse_db_line() to util
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
parent
cfb1a2e696
commit
5c3083d1a4
|
|
@ -71,3 +71,23 @@ def db_root_arg(parser):
|
|||
db_root_kwargs['required'] = False
|
||||
db_root_kwargs['default'] = os.path.join(database_dir, database)
|
||||
parser.add_argument('--db-root', help="Database root.", **db_root_kwargs)
|
||||
|
||||
|
||||
def parse_db_line(line):
|
||||
parts = line.split()
|
||||
# Ex: CLBLL_L.SLICEL_X0.AMUX.A5Q
|
||||
assert len(parts), "Empty line"
|
||||
tag = parts[0]
|
||||
assert re.match(r'[A-Z0-9_.]+',
|
||||
tag), "Invalid tag name: %s, line: %s" % (tag, line)
|
||||
orig_bits = line.replace(tag + " ", "")
|
||||
# <0 candidates> etc
|
||||
if "<" in orig_bits:
|
||||
return tag, set(), orig_bits
|
||||
|
||||
# Ex: !30_06 !30_08 !30_11 30_07
|
||||
bits = frozenset(parts[1:])
|
||||
for bit in bits:
|
||||
assert re.match(
|
||||
r'[!]*[0-9][0-9]_[0-9][0-9]', bit), "Invalid bit: %s" % bit
|
||||
return tag, bits, None
|
||||
|
|
|
|||
|
|
@ -17,20 +17,6 @@ clb_int_zero_db = [
|
|||
]
|
||||
|
||||
|
||||
def parse_line(line):
|
||||
parts = line.split()
|
||||
# Ex: CLBLL_L.SLICEL_X0.AMUX.A5Q
|
||||
tag = parts[0]
|
||||
orig_bits = line.replace(tag + " ", "")
|
||||
# <0 candidates> etc
|
||||
if "<" in orig_bits:
|
||||
return tag, set(), orig_bits
|
||||
|
||||
# Ex: !30_06 !30_08 !30_11 30_07
|
||||
bits = set(parts[1:])
|
||||
return tag, bits, None
|
||||
|
||||
|
||||
def zero_range(bits, wordmin, wordmax):
|
||||
"""
|
||||
If any bits occur wordmin <= word <= wordmax,
|
||||
|
|
@ -134,7 +120,7 @@ def add_zero_bits(fn_in, fn_out, zero_db, clb_int=False, verbose=False):
|
|||
if line == llast:
|
||||
continue
|
||||
|
||||
tag, bits, mode = parse_line(line)
|
||||
tag, bits, mode = util.parse_db_line(line)
|
||||
assert mode not in (
|
||||
"<const0>",
|
||||
"<const1>"), "Entries must be resolved. line: %s" % (line, )
|
||||
|
|
|
|||
Loading…
Reference in New Issue