From e0642ba06eac0c057a05c7c7f46b4f22b90a4c76 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Fri, 7 Jun 2019 23:50:11 +0200 Subject: icebox_html: Use cached re functions --- icebox/icebox_html.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'icebox/icebox_html.py') diff --git a/icebox/icebox_html.py b/icebox/icebox_html.py index 6415230..b710f61 100755 --- a/icebox/icebox_html.py +++ b/icebox/icebox_html.py @@ -16,6 +16,7 @@ # import icebox +from icebox import re_match_cached, re_sub_cached import getopt, sys, os, re chipname = "iCE40 HX1K" @@ -252,7 +253,7 @@ configuration bits it has and how it is connected to its neighbourhood.

""" % if not ic.tile_has_entry(tx, ty, entry): continue for bit in [bit.replace("!", "") for bit in entry[0]]: - match = re.match(r"B(\d+)\[(\d+)\]$", bit) + match = re_match_cached(r"B(\d+)\[(\d+)\]$", bit) idx1 = int(match.group(1)) idx2 = int(match.group(2)) if entry[1] == "routing": @@ -324,7 +325,7 @@ nets are connected with nets from cells in its neighbourhood.

""") for s in segs: if s[0] == tx and s[1] == ty: this_segs.append(s[2]) - match = re.match(r"(.*?_)(\d+)(.*)", s[2]) + match = re_match_cached(r"(.*?_)(\d+)(.*)", s[2]) if match: this_tile_nets.setdefault(match.group(1) + "*" + match.group(3), set()).add(int(match.group(2))) else: @@ -444,7 +445,7 @@ in the all-zeros configuration.

""") for cfggrp in sorted(grpgrp[cat]): grp = config_groups[cfggrp] for bit in cfggrp.split(",")[1:]: - match = re.match(r"B(\d+)\[(\d+)\]", bit) + match = re_match_cached(r"B(\d+)\[(\d+)\]", bit) bits_in_cat.add((int(match.group(1)), int(match.group(2)))) print('') @@ -520,7 +521,7 @@ in the all-zeros configuration.

""") bits = cfggrp.split(",")[1:] print('

') for bit in bits: - print('' % (re.sub(r"B(\d+)\[(\d+)\]", r"B.\1.\2", bit), bit)) + print('' % (re_sub_cached(r"B(\d+)\[(\d+)\]", r"B.\1.\2", bit), bit)) group_lines = list() is_buffer = True for entry in grp: @@ -569,7 +570,7 @@ in the all-zeros configuration.

""") print('

%s%s
') for cfggrp in sorted(other_config_groups): - bits = " ".join(['%s' % (re.sub(r"B(\d+)\[(\d+)\]", r"B.\1.\2", bit), bit) for bit in sorted(other_config_groups[cfggrp])]) + bits = " ".join(['%s' % (re_sub_cached(r"B(\d+)\[(\d+)\]", r"B.\1.\2", bit), bit) for bit in sorted(other_config_groups[cfggrp])]) cfggrp = cfggrp.replace(" " + list(other_config_groups[cfggrp])[0], "") print('' % (cfggrp, bits)) print('
FunctionBits
%s%s

') -- cgit v1.2.3