Skip to content

Commit

Permalink
Merge pull request f4pga#1797 from litghost/remove_connection_box
Browse files Browse the repository at this point in the history
Remove connection box from rr-graph patching.
  • Loading branch information
acomodi committed Nov 24, 2020
2 parents d5f8ce8 + 2cd6394 commit 8c499dc
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 359 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ channels:
dependencies:
- symbiflow::symbiflow-yosys=0.8_6021_gd8b2d1a2=20200708_083630
- symbiflow::symbiflow-yosys-plugins=1.0.0.7_0174_g5e6370a=20201012_171341
- symbiflow::symbiflow-vtr=8.0.0.rc2_5097_gf1a3bcc2a=20200916_072439
- symbiflow::symbiflow-vtr=8.0.0.rc2_5415_gd6d69ff92=20201120_180018
- symbiflow::zachjs-sv2v=0.0.5_0018_ga170536
- symbiflow::openocd
- symbiflow::iverilog
Expand Down
1 change: 0 additions & 1 deletion testarch/utils/testarch_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ def rebuild_graph(fn, fn_out, rcw=6, verbose=False):

xml_graph.serialize_to_xml(
channels_obj=channels_obj,
connection_box_obj=None,
nodes_obj=graph.nodes,
edges_obj=graph.edges
)
Expand Down
85 changes: 1 addition & 84 deletions utils/lib/rr_graph/graph2.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,54 +143,8 @@ class NodeSegment(namedtuple('NodeSegment', 'segment_id')):
"""


class CanonicalLoc(namedtuple('CanonicalLoc', 'x y')):
""" Canonical location of channel node.
The canonical location of the node is an unambigous location for the given
node in the "canonical grid". For example, on an L-shaped wire, the
canonical location is the location of the input edge.
"""
pass


class ConnectionBox(namedtuple('ConnectionBox', 'x y id site_pin_delay')):
""" Connection box location and definition.
The connection box location is the place in the "canonical grid" where
a IPIN is connected too. This allows lookahead from a routing channel
to the IPIN connection box, which uses the regular interconnect fabric.
Attributes
----------
x, y : int
Canonical location of connection box for IPIN.
id : int
0-based index into ConnectionBoxes.boxes vector of connection box names.
site_pin_delay : float
"""
pass


class ConnectionBoxes(namedtuple('ConnectionBoxes', 'x_dim y_dim boxes')):
""" Definition of the canonical routing grid.
Attributes
----------
x_dim, y_dim : int
Dimensions of the canonical grid. All ConnectionBox and CanonicalLoc
coordinates should be [0, x_dim), [0, y_dim).
boxes : list of str
List of names for connection boxes.
"""
pass


class Node(namedtuple(
'Node',
'id type direction capacity loc timing metadata segment canonical_loc connection_box'
)):
'Node', 'id type direction capacity loc timing metadata segment')):
"""https://vtr-verilog-to-routing.readthedocs.io/en/latest/vpr/file_formats.html#tag-nodes-node
"""

Expand Down Expand Up @@ -262,9 +216,6 @@ def __init__(
self.nodes.sort(key=lambda node: node.id)
self.edges = edges if edges is not None else []

self.connection_boxes = []
self.connection_box_map = {}

# Map of (x, y) to GridLoc definitions.
self.loc_map = {}

Expand Down Expand Up @@ -354,32 +305,6 @@ def __init__(
else:
assert False, (loc, pin_class)

def maybe_add_connection_box(self, box):
""" Get id for connection box name.
If connection box was not declared previously, assign an id for it.
Arugments
---------
box : str
Name of connection box.
"""
if box not in self.connection_box_map:
idx = len(self.connection_boxes)
self.connection_boxes.append(box)
self.connection_box_map[box] = idx
return idx
else:
return self.connection_box_map[box]

def create_connection_box_object(self, x_dim, y_dim):
""" Create ConnectionBoxes object defining canonical grid. """
return ConnectionBoxes(
x_dim=x_dim,
y_dim=y_dim,
boxes=tuple(self.connection_boxes),
)

def _create_node(
self,
type,
Expand All @@ -389,8 +314,6 @@ def _create_node(
timing,
capacity=1,
metadata=None,
canonical_loc=None,
connection_box=None,
):

if timing is None:
Expand All @@ -409,8 +332,6 @@ def _create_node(
timing=timing,
metadata=metadata,
segment=segment,
canonical_loc=canonical_loc,
connection_box=connection_box,
)
)

Expand All @@ -431,8 +352,6 @@ def add_track(
name=None,
ptc=None,
direction=NodeDirection.BI_DIR,
canonical_loc=None,
connection_box=None,
):
"""Take a Track and add node to the graph with supplimental data"""

Expand Down Expand Up @@ -472,8 +391,6 @@ def add_track(
timing=timing,
segment=NodeSegment(segment_id=segment_id),
metadata=metadata,
canonical_loc=canonical_loc,
connection_box=connection_box,
)
)

Expand Down
16 changes: 0 additions & 16 deletions utils/lib/rr_graph/tests/test_graph2.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def test_init(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=1,
Expand All @@ -103,8 +101,6 @@ def test_init(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=2,
Expand All @@ -122,8 +118,6 @@ def test_init(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=3,
Expand All @@ -141,8 +135,6 @@ def test_init(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
]

Expand Down Expand Up @@ -307,8 +299,6 @@ def setUp(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=1,
Expand All @@ -326,8 +316,6 @@ def setUp(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=2,
Expand All @@ -345,8 +333,6 @@ def setUp(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
Node(
id=3,
Expand All @@ -364,8 +350,6 @@ def setUp(self):
timing=node_timing,
metadata=None,
segment=NodeSegment(segment_id=0),
canonical_loc=None,
connection_box=None,
),
]

Expand Down
34 changes: 0 additions & 34 deletions utils/lib/rr_graph_capnp/graph2.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ def read_node(node, new_node_id=None):
timing=graph2.NodeTiming(r=node_timing.r, c=node_timing.c),
metadata=None,
segment=graph2.NodeSegment(segment_id=node.segment.segmentId),
canonical_loc=None,
connection_box=None
)


Expand Down Expand Up @@ -335,24 +333,6 @@ def _write_channels(self, rr_graph, channels):
out_y_list.index = y_list.index
out_y_list.info = y_list.info

def _write_connection_box(self, rr_graph, connection_box):
"""
Writes the RR graph connection box.
"""

rr_graph.connectionBoxes.xDim = connection_box.x_dim
rr_graph.connectionBoxes.yDim = connection_box.y_dim
rr_graph.connectionBoxes.numBoxes = len(connection_box.boxes)

connection_boxes = rr_graph.connectionBoxes.init(
'connectionBoxes', len(connection_box.boxes)
)

for idx, (out_box, box) in enumerate(zip(connection_boxes,
connection_box.boxes)):
out_box.id = idx
out_box.name = box

def _write_nodes(self, rr_graph, num_nodes, nodes, node_remap):
""" Serialize list of Node objects to capnp.
Expand Down Expand Up @@ -409,18 +389,6 @@ def _write_nodes(self, rr_graph, num_nodes, nodes, node_remap):
out_meta.name = meta.name
out_meta.value = meta.value

if node.canonical_loc is not None:
canonical_loc = out_node.canonicalLoc
canonical_loc.x = node.canonical_loc.x
canonical_loc.y = node.canonical_loc.y

if node.connection_box is not None:
connection_box = out_node.connectionBox
connection_box.id = node.connection_box.id
connection_box.x = node.connection_box.x
connection_box.y = node.connection_box.y
connection_box.sitePinDelay = node.connection_box.site_pin_delay

assert nodes_written == num_nodes, 'Unwritten nodes!'

try:
Expand Down Expand Up @@ -553,7 +521,6 @@ def _write_grid(self, rr_graph):
def serialize_to_capnp(
self,
channels_obj,
connection_box_obj,
num_nodes,
nodes_obj,
num_edges,
Expand All @@ -576,7 +543,6 @@ def serialize_to_capnp(
self._write_segments(rr_graph)
self._write_block_types(rr_graph)
self._write_grid(rr_graph)
self._write_connection_box(rr_graph, connection_box_obj)
self._write_nodes(rr_graph, num_nodes, nodes_obj, node_remap)
self._write_edges(rr_graph, num_edges, edges_obj, node_remap)

Expand Down
47 changes: 1 addition & 46 deletions utils/lib/rr_graph_xml/graph2.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ def graph_from_xml(
timing=node_timing,
metadata=metadata,
segment=node_segment,
canonical_loc=None,
connection_box=None,
)
)

Expand Down Expand Up @@ -404,25 +402,6 @@ def _write_channels(self, channels):

self._end_xml_tag()

def _write_connection_box(self, connection_box):
"""
Writes the RR graph connection box.
"""
attrib = {
"x_dim": connection_box.x_dim,
"y_dim": connection_box.y_dim,
"num_boxes": len(connection_box.boxes)
}

self._begin_xml_tag("connection_boxes", attrib)

for idx, box in enumerate(connection_box.boxes):
self._write_xml_tag("connection_box", {"id": idx, "name": box})
if DEBUG >= 2:
break

self._end_xml_tag()

def _write_nodes(self, nodes, node_remap):
""" Serialize list of Node objects to XML.
Expand Down Expand Up @@ -478,22 +457,6 @@ def _write_nodes(self, nodes, node_remap):
attrib = {"segment_id": node.segment.segment_id}
self._write_xml_tag("segment", attrib)

if node.connection_box is not None:
attrib = {
"x": node.connection_box.x,
"y": node.connection_box.y,
"id": node.connection_box.id,
"site_pin_delay": node.connection_box.site_pin_delay,
}
self._write_xml_tag("connection_box", attrib)

if node.canonical_loc is not None:
attrib = {
"x": node.canonical_loc.x,
"y": node.canonical_loc.y,
}
self._write_xml_tag("canonical_loc", attrib)

self._end_xml_tag()
if DEBUG >= 2:
break
Expand Down Expand Up @@ -657,12 +620,7 @@ def _write_grid(self):
self._end_xml_tag()

def serialize_to_xml(
self,
channels_obj,
connection_box_obj,
nodes_obj,
edges_obj,
node_remap=lambda x: x
self, channels_obj, nodes_obj, edges_obj, node_remap=lambda x: x
):
"""
Writes the routing graph to the XML file.
Expand All @@ -680,9 +638,6 @@ def serialize_to_xml(

self._write_channels(channels_obj)

if connection_box_obj is not None:
self._write_connection_box(connection_box_obj)

self._write_switches()
self._write_segments()
self._write_block_types()
Expand Down

0 comments on commit 8c499dc

Please sign in to comment.