Skip to content

Commit

Permalink
Added option to create nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshgore committed Jan 6, 2025
1 parent 24287f8 commit 5f57c61
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
33 changes: 33 additions & 0 deletions spydrnet_physical/util/rrgraph_uncompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,36 @@ def _block_types_bin2xml(block_types, xml_root=None):
block_types_root.append(pin_class)
xml_root.append(block_types_root)
return xml_root

@staticmethod
def _nodes_bin2xml(nodes, xml_root=None):
if xml_root is None:
xml_root = XML("<rr_nodes></rr_nodes>")

for node_ux in nodes:
node = update_attr(
Element("node"),
node_ux.to_dict(),
("loc", "timing", "segment"),
upper_case_fields=("type"),
)
if node.attrib.get("direction", None):
node.attrib["direction"] = node.attrib["direction"].upper().replace("DIR","_DIR")
loc = update_attr(
Element("loc"),
node_ux.loc.to_dict(),
attrib_map,
upper_case_fields=("side"),
)
node.append(loc)
node.append(
update_attr(Element("timing"), node_ux.timing.to_dict(), attrib_map)
)
if str(node_ux.type).startswith("chan"):
node.append(
update_attr(
Element("segment"), node_ux.segment.to_dict(), attrib_map
)
)
xml_root.append(node)
return xml_root
11 changes: 6 additions & 5 deletions spydrnet_physical/util/rrgraph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,17 @@ def _gen_rrgraph_xml(
segments = self._segments_bin2xml(self.segments)
block_types = self._block_types_bin2xml(self.rrgraph_bin.blockTypes.blockTypes)
grids = self._grid_bin2xml(self.rrgraph_bin.grid.gridLocs)
# rrgraph_segments_bin2xml(self.rrgraph_bin.channels, etree.Element("channels"))
# rrgraph_block_types_bin2xml(self.rrgraph_bin.channels, etree.Element("channels"))
# rrgraph_grid_bin2xml(self.rrgraph_bin.channels, etree.Element("channels"))
# rrgraph_rr_nodes_bin2xml(self.rrgraph_bin.channels, etree.Element("channels"))
# rrgraph_rr_edges_bin2xml(self.rrgraph_bin.channels, etree.Element("channels"))

# Add nodes datastructure
self.rrgraph_bin.rrNodes.nodes = [n for col in self.node_lookup for row in col for n in row]
rr_nodes = self._nodes_bin2xml(self.rrgraph_bin.rrNodes.nodes)

root.append(channels)
root.append(switches)
root.append(segments)
root.append(block_types)
root.append(grids)
root.append(rr_nodes)
return root

def write_rrgraph_xml(
Expand Down

0 comments on commit 5f57c61

Please sign in to comment.