Improve htmlgen routing table

Signed-off-by: Clifford Wolf <clifford@clifford.at>
Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
This commit is contained in:
Clifford Wolf 2017-11-12 21:05:51 +01:00 committed by Tim 'mithro' Ansell
parent df1d33cd9f
commit 79df0e2b2b
1 changed files with 91 additions and 16 deletions

View File

@ -3,6 +3,28 @@
import os, sys, json, re import os, sys, json, re
class UnionFind:
def __init__(self):
self.parents = dict()
def make(self, value):
if value not in self.parents:
self.parents[value] = value
def find(self, value):
self.make(value)
if self.parents[value] != value:
retval = self.find(self.parents[value])
self.parents[value] = retval
return self.parents[value]
def union(self, v1, v2):
a = self.find(v1)
b = self.find(v2)
if a != b:
self.parents[a] = b
################################################# #################################################
# Loading Raw Source Data # Loading Raw Source Data
@ -194,7 +216,7 @@ for segtype in segbits.keys():
print("<p/>", file=f) print("<p/>", file=f)
print("<h4>%s</h4>" % prefix, file=f) print("<h4>%s</h4>" % prefix, file=f)
print("<table cellspacing=0>", file=f) print("<table cellspacing=0>", file=f)
print("<tr><th width=\"500\" align=\"left\">Bit Name</th><th>Position</th></tr>", file=f) print("<tr><th width=\"400\" align=\"left\">Bit Name</th><th>Position</th></tr>", file=f)
trstyle = "" trstyle = ""
for bit_name, bit_pos in sorted(bits): for bit_name, bit_pos in sorted(bits):
@ -203,5 +225,58 @@ for segtype in segbits.keys():
print("</table>", file=f) print("</table>", file=f)
ruf = UnionFind()
for bit, pips in routebits[segtype].items():
for pip in pips:
grp = pip.split('.')[1]
ruf.union(grp, bit)
rgroups = dict()
rgroup_names = dict()
for bit, pips in routebits[segtype].items():
for pip in pips:
grp_name = pip.split('.')[1]
grp = ruf.find(grp_name)
if grp not in rgroup_names:
rgroup_names[grp] = set()
rgroup_names[grp].add(grp_name)
if grp not in rgroups:
rgroups[grp] = dict()
if pip not in rgroups[grp]:
rgroups[grp][pip] = set()
rgroups[grp][pip].add(bit)
for grp, gdata in sorted(rgroups.items()):
print("<p/>", file=f)
print("<h4>%s</h4>" % ", ".join(sorted(rgroup_names[grp])), file=f)
print("<table cellspacing=0>", file=f)
print("<tr><th width=\"400\" align=\"left\">PIP</th>", file=f)
grp_bits = set()
for pip, bits in gdata.items():
grp_bits |= bits
grp_bits = sorted(grp_bits)
for bit in grp_bits:
print("<th>&nbsp;%s&nbsp;</th>" % bit, file=f)
print("</tr>", file=f)
lines = list()
for pip, bits in sorted(gdata.items()):
line = " --><td>%s</td>" % (pip)
for bit in grp_bits:
c = "1" if bit in bits else "-"
line = "%s%s<td align=\"center\">%s</td>" % (c, line, c)
lines.append(line)
trstyle = ""
for line in sorted(lines):
trstyle = " bgcolor=\"#dddddd\"" if trstyle == "" else ""
print("<tr%s><!-- %s</tr>" % (trstyle, line), file=f)
print("</table>", file=f)
print("</body></html>", file=f) print("</body></html>", file=f)