Changeset c123609 in mainline
- Timestamp:
- 2009-10-09T14:18:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0772aff, f307f12
- Parents:
- 8e21512e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
r8e21512e rc123609 554 554 return result 555 555 556 def merge_ subarch(prefix, arch, outdir):556 def merge_arch(prefix, arch, outdir): 557 557 "Merge subarchitecture into architecture" 558 558 … … 566 566 subarch = get_arch(inst['type']) 567 567 if (not subarch is None): 568 (subinsts, subbinds, subdelegates, subsubsumes) = merge_ subarch("%s_%s" % (prefix, subarch['name']), subarch, outdir)568 (subinsts, subbinds, subdelegates, subsubsumes) = merge_arch("%s_%s" % (prefix, subarch['name']), subarch, outdir) 569 569 insts.extend(subinsts) 570 570 binds.extend(subbinds) … … 613 613 subarch = get_arch(inst['type']) 614 614 if (not subarch is None): 615 (subinsts, subbinds, subdelegates, subsubsumes) = merge_ subarch(subarch['name'], subarch, outdir)615 (subinsts, subbinds, subdelegates, subsubsumes) = merge_arch(subarch['name'], subarch, outdir) 616 616 insts.extend(subinsts) 617 617 binds.extend(subbinds) … … 1585 1585 recursion(base, canon, output, level + 1) 1586 1586 1587 def merge_bind(subarchs, delegates, subsumes, prefix, bfrom, bto, outf, indent): 1588 "Update binding according to bound object types" 1589 1590 pfrom = "%s%s" % (prefix, bfrom[0]) 1591 pto = "%s%s" % (prefix, bto[0]) 1592 attrs = [] 1593 1594 if (bfrom[0] in subarchs): 1595 sfrom = subsumes[pfrom][bfrom[1]] 1596 attrs.append("ltail=cluster_%s" % pfrom) 1597 else: 1598 sfrom = pfrom 1599 1600 if (bto[0] in subarchs): 1601 sto = delegates[pto][bto[1]] 1602 attrs.append("lhead=cluster_%s" % pto) 1603 else: 1604 sto = pto 1605 1606 outf.write("%s\t%s -> %s" % (tabs(indent), sfrom, sto)) 1607 if (len(attrs) > 0): 1608 outf.write(" [%s]" % ", ".join(attrs)) 1609 outf.write(";\n") 1610 1611 def merge_dot_subarch(prefix, name, arch, outf, indent): 1587 def merge_dot_frame(prefix, name, frame, outf, indent): 1588 "Dump Dot frame" 1589 1590 outf.write("%ssubgraph cluster_%s {\n" % (tabs(indent), prefix)) 1591 outf.write("%s\tlabel=\"%s\";\n" % (tabs(indent), name)) 1592 outf.write("%s\tstyle=filled;\n" % tabs(indent)) 1593 outf.write("%s\tcolor=red;\n" % tabs(indent)) 1594 outf.write("%s\tfillcolor=yellow;\n" % tabs(indent)) 1595 outf.write("%s\t\n" % tabs(indent)) 1596 1597 if ('provides' in frame): 1598 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, style=filled, color=green, fillcolor=yellow];\n" % (tabs(indent), prefix)) 1599 1600 if ('requires' in frame): 1601 outf.write("%s\t%s__requires [label=\"\", shape=circle, style=filled, color=red, fillcolor=yellow];\n" % (tabs(indent), prefix)) 1602 1603 outf.write("%s}\n" % tabs(indent)) 1604 outf.write("%s\n" % tabs(indent)) 1605 1606 def merge_dot_arch(prefix, name, arch, outf, indent): 1612 1607 "Dump Dot subarchitecture" 1613 1608 … … 1617 1612 outf.write("%s\t\n" % tabs(indent)) 1618 1613 1619 subarchs = set()1620 delegates = {}1621 subsumes = {}1622 1623 delegates[prefix] = {}1624 subsumes[prefix] = {}1625 1626 1614 if ('inst' in arch): 1627 1615 for inst in arch['inst']: 1628 1616 subarch = get_arch(inst['type']) 1629 1617 if (not subarch is None): 1630 (subdelegates, subsubsumes) = merge_dot_subarch("%s_%s" % (prefix, inst['var']), inst['var'], subarch, outf, indent + 1) 1631 subarchs.add(inst['var']) 1632 delegates.update(subdelegates) 1633 subsumes.update(subsubsumes) 1618 merge_dot_arch("%s_%s" % (prefix, inst['var']), inst['var'], subarch, outf, indent + 1) 1634 1619 else: 1635 1620 subframe = get_frame(inst['type']) 1636 1621 if (not subframe is None): 1637 outf.write("%s\t%s_%s [label=\"%s\", shape=component, style=filled, color=red, fillcolor=yellow];\n" % (tabs(indent), prefix, inst['var'], inst['var']))1622 merge_dot_frame("%s_%s" % (prefix, inst['var']), inst['var'], subframe, outf, indent + 1) 1638 1623 else: 1639 1624 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']) 1640 1625 1641 1626 if ('bind' in arch): 1627 labels = {} 1642 1628 for bind in arch['bind']: 1643 merge_bind(subarchs, delegates, subsumes, "%s_" % prefix, bind['from'], bind['to'], outf, indent) 1629 if (bind['from'][1] != bind['to'][1]): 1630 label = "%s:%s" % (bind['from'][1], bind['to'][1]) 1631 else: 1632 label = bind['from'][1] 1633 1634 if (not (bind['from'][0], bind['to'][0]) in labels): 1635 labels[(bind['from'][0], bind['to'][0])] = [] 1636 1637 labels[(bind['from'][0], bind['to'][0])].append(label) 1638 1639 for bind in arch['bind']: 1640 if (not (bind['from'][0], bind['to'][0]) in labels): 1641 continue 1642 1643 attrs = [] 1644 1645 if (bind['from'][0] != bind['to'][0]): 1646 attrs.append("ltail=cluster_%s_%s" % (prefix, bind['from'][0])) 1647 attrs.append("lhead=cluster_%s_%s" % (prefix, bind['to'][0])) 1648 1649 attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])])) 1650 del labels[(bind['from'][0], bind['to'][0])] 1651 1652 outf.write("%s\t%s_%s__requires -> %s_%s__provides [%s];\n" % (tabs(indent), prefix, bind['from'][0], prefix, bind['to'][0], ", ".join(attrs))) 1644 1653 1645 1654 if ('delegate' in arch): 1655 outf.write("%s\t%s__provides [label=\"\", shape=doublecircle, color=green];\n" % (tabs(indent), prefix)) 1656 1657 labels = {} 1646 1658 for delegate in arch['delegate']: 1647 delegates[prefix][delegate['from']] = "%s_%s" % (prefix, delegate['to'][0]) 1659 if (delegate['from'] != delegate['to'][1]): 1660 label = "%s:%s" % (delegate['from'], delegate['to'][1]) 1661 else: 1662 label = delegate['from'] 1663 1664 if (not delegate['to'][0] in labels): 1665 labels[delegate['to'][0]] = [] 1666 1667 labels[delegate['to'][0]].append(label) 1668 1669 for delegate in arch['delegate']: 1670 if (not delegate['to'][0] in labels): 1671 continue 1672 1673 attrs = [] 1674 attrs.append("color=gray") 1675 attrs.append("lhead=cluster_%s_%s" % (prefix, delegate['to'][0])) 1676 attrs.append("label=\"%s\"" % "\\n".join(labels[delegate['to'][0]])) 1677 del labels[delegate['to'][0]] 1678 1679 outf.write("%s\t%s__provides -> %s_%s__provides [%s];\n" % (tabs(indent), prefix, prefix, delegate['to'][0], ", ".join(attrs))) 1648 1680 1649 1681 if ('subsume' in arch): 1682 outf.write("%s\t%s__requires [label=\"\", shape=circle, color=red];\n" % (tabs(indent), prefix)) 1683 1684 labels = {} 1650 1685 for subsume in arch['subsume']: 1651 subsumes[prefix][subsume['to']] = "%s_%s" % (prefix, subsume['from'][0]) 1686 if (subsume['from'][1] != subsume['to']): 1687 label = "%s:%s" % (subsume['from'][1], subsume['to']) 1688 else: 1689 label = subsume['to'] 1690 1691 if (not subsume['from'][0] in labels): 1692 labels[subsume['from'][0]] = [] 1693 1694 labels[subsume['from'][0]].append(label) 1695 1696 for subsume in arch['subsume']: 1697 if (not subsume['from'][0] in labels): 1698 continue 1699 1700 attrs = [] 1701 attrs.append("color=gray") 1702 attrs.append("ltail=cluster_%s_%s" % (prefix, subsume['from'][0])) 1703 attrs.append("label=\"%s\"" % "\\n".join(labels[subsume['from'][0]])) 1704 del labels[subsume['from'][0]] 1705 1706 outf.write("%s\t%s_%s__requires -> %s__requires [%s];\n" % (tabs(indent), prefix, subsume['from'][0], prefix, ", ".join(attrs))) 1652 1707 1653 1708 outf.write("%s}\n" % tabs(indent)) 1654 1709 outf.write("%s\n" % tabs(indent)) 1655 1656 return (delegates, subsumes)1657 1710 1658 1711 def dump_dot(outdir): … … 1674 1727 outf.write("\tlabel=\"%s\";\n" % arch['name']) 1675 1728 outf.write("\tcompound=true;\n") 1729 outf.write("\tedge [fontsize=8];\n") 1676 1730 outf.write("\t\n") 1677 1678 subarchs = set()1679 delegates = {}1680 subsumes = {}1681 1731 1682 1732 if ('inst' in arch): … … 1684 1734 subarch = get_arch(inst['type']) 1685 1735 if (not subarch is None): 1686 (subdelegates, subsubsumes) = merge_dot_subarch(inst['var'], inst['var'], subarch, outf, 1) 1687 subarchs.add(inst['var']) 1688 delegates.update(subdelegates) 1689 subsumes.update(subsubsumes) 1736 merge_dot_arch(inst['var'], inst['var'], subarch, outf, 1) 1690 1737 else: 1691 1738 subframe = get_frame(inst['type']) 1692 1739 if (not subframe is None): 1693 outf.write("\t%s [shape=component, style=filled, color=red, fillcolor=yellow];\n" % inst['var'])1740 merge_dot_frame("%s" % inst['var'], inst['var'], subframe, outf, 1) 1694 1741 else: 1695 1742 print "%s: '%s' is neither an architecture nor a frame" % (arch['name'], inst['type']) 1696 1743 1697 1744 if ('bind' in arch): 1745 labels = {} 1698 1746 for bind in arch['bind']: 1699 merge_bind(subarchs, delegates, subsumes, "", bind['from'], bind['to'], outf, 0) 1747 if (bind['from'][1] != bind['to'][1]): 1748 label = "%s:%s" % (bind['from'][1], bind['to'][1]) 1749 else: 1750 label = bind['from'][1] 1751 1752 if (not (bind['from'][0], bind['to'][0]) in labels): 1753 labels[(bind['from'][0], bind['to'][0])] = [] 1754 1755 labels[(bind['from'][0], bind['to'][0])].append(label) 1756 1757 for bind in arch['bind']: 1758 if (not (bind['from'][0], bind['to'][0]) in labels): 1759 continue 1760 1761 attrs = [] 1762 1763 if (bind['from'][0] != bind['to'][0]): 1764 attrs.append("ltail=cluster_%s" % bind['from'][0]) 1765 attrs.append("lhead=cluster_%s" % bind['to'][0]) 1766 1767 attrs.append("label=\"%s\"" % "\\n".join(labels[(bind['from'][0], bind['to'][0])])) 1768 del labels[(bind['from'][0], bind['to'][0])] 1769 1770 outf.write("\t%s__requires -> %s__provides [%s];\n" % (bind['from'][0], bind['to'][0], ", ".join(attrs))) 1700 1771 1701 1772 if ('delegate' in arch):
Note:
See TracChangeset
for help on using the changeset viewer.