mirror of https://github.com/openXC7/prjxray.git
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:
parent
df1d33cd9f
commit
79df0e2b2b
|
|
@ -3,6 +3,28 @@
|
|||
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
|
||||
|
||||
|
|
@ -70,7 +92,7 @@ with open("%s/index.html" % os.getenv("XRAY_DATABASE"), "w") as f:
|
|||
grid_range[2] = max(grid_range[2], grid_x)
|
||||
grid_range[3] = max(grid_range[3], grid_y)
|
||||
|
||||
print("<table border>", file =f)
|
||||
print("<table border>", file=f)
|
||||
|
||||
for grid_y in range(grid_range[1], grid_range[3]+1):
|
||||
print("<tr>", file=f)
|
||||
|
|
@ -110,7 +132,7 @@ with open("%s/index.html" % os.getenv("XRAY_DATABASE"), "w") as f:
|
|||
|
||||
print("</tr>", file=f)
|
||||
|
||||
print("</table>", file =f)
|
||||
print("</table>", file=f)
|
||||
print("</body></html>", file=f)
|
||||
|
||||
|
||||
|
|
@ -122,17 +144,17 @@ for segtype in segbits.keys():
|
|||
with open("%s/seg_%s.html" % (os.getenv("XRAY_DATABASE"), segtype), "w") as f:
|
||||
print("<html><title>X-Ray %s Database: %s</title><body>" % (os.getenv("XRAY_DATABASE").upper(), segtype.upper()), file=f)
|
||||
print("<h3>X-Ray %s Database: %s</h3>" % (os.getenv("XRAY_DATABASE").upper(), segtype.upper()), file=f)
|
||||
print("<table border>", file =f)
|
||||
print("<table border>", file=f)
|
||||
|
||||
print("<tr>", file =f)
|
||||
print("<th width=\"30\"></th>", file =f)
|
||||
print("<tr>", file=f)
|
||||
print("<th width=\"30\"></th>", file=f)
|
||||
for frameidx in range(segframes[segtype]):
|
||||
print("<th width=\"30\"><span style=\"font-size:10px\">%d</span></th>" % frameidx, file =f)
|
||||
print("</tr>", file =f)
|
||||
print("<th width=\"30\"><span style=\"font-size:10px\">%d</span></th>" % frameidx, file=f)
|
||||
print("</tr>", file=f)
|
||||
|
||||
for bitidx in range(63, -1, -1):
|
||||
print("<tr>", file =f)
|
||||
print("<th align=\"right\"><span style=\"font-size:10px\">%d</span></th>" % bitidx, file =f)
|
||||
print("<tr>", file=f)
|
||||
print("<th align=\"right\"><span style=\"font-size:10px\">%d</span></th>" % bitidx, file=f)
|
||||
for frameidx in range(segframes[segtype]):
|
||||
bit_pos = "%02d_%02d" % (frameidx, bitidx)
|
||||
bit_name = segbits_r[segtype][bit_pos] if bit_pos in segbits_r[segtype] else None
|
||||
|
|
@ -176,8 +198,8 @@ for segtype in segbits.keys():
|
|||
label = "R"
|
||||
|
||||
print("<td bgcolor=\"%s\" title=\"%s\"><span style=\"font-size:10px\">%s</span></td>" % (bgcolor, "\n".join(title), label), file=f)
|
||||
print("</tr>", file =f)
|
||||
print("</table>", file =f)
|
||||
print("</tr>", file=f)
|
||||
print("</table>", file=f)
|
||||
|
||||
|
||||
bits_by_prefix = dict()
|
||||
|
|
@ -191,17 +213,70 @@ for segtype in segbits.keys():
|
|||
bits_by_prefix[prefix].add((bit_name, bit_pos))
|
||||
|
||||
for prefix, bits in sorted(bits_by_prefix.items()):
|
||||
print("<p/>", file =f)
|
||||
print("<h4>%s</h4>" % prefix, 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("<p/>", file=f)
|
||||
print("<h4>%s</h4>" % prefix, file=f)
|
||||
print("<table cellspacing=0>", file=f)
|
||||
print("<tr><th width=\"400\" align=\"left\">Bit Name</th><th>Position</th></tr>", file=f)
|
||||
|
||||
trstyle = ""
|
||||
for bit_name, bit_pos in sorted(bits):
|
||||
trstyle = " bgcolor=\"#dddddd\"" if trstyle == "" else ""
|
||||
print("<tr%s><td>%s</td><td>%s</td></tr>" % (trstyle, bit_name, bit_pos), file=f)
|
||||
|
||||
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> %s </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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue