Skip to content

Commit

Permalink
matched block types with original rrgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshgore committed Jan 6, 2025
1 parent c586048 commit eb83118
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ examples/**/_*
FM_WORK*
*.lck
runOpenFPGA
docs/source/_SDN_DOC_SOURCE
docs/source/_SDN_DOC_SOURCE

# Debug Directory
_test
38 changes: 23 additions & 15 deletions spydrnet_physical/util/rrgraph_uncompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,26 @@
"segmentId": "segment_id",
}

default_values = ["0", "0.0", "uxsdInvalid"]
skip_if_default = [
"cin",
"cinternal",
"r",
"c",
"cout",
"tdel",
"cPerMeter",
"rPerMeter",
]


def update_attr(element, attribs, skip_keys=(), upper_case_fields=()):
for k, v in attribs.items():
if (str(k) in skip_if_default) and (v in default_values):
continue
if (str(k) in skip_if_default) and isinstance(v, float):
if float(v) <= 0:
continue
if str(v) != "uxsdInvalid":
if not k in skip_keys:
element.attrib[attrib_map.get(k, k)] = (
Expand Down Expand Up @@ -99,11 +116,11 @@ def _segments_bin2xml(segments, xml_root=None):
segment_root = Element(
"segment",
id=str(segment_bin.id),
name=str(segment_bin.name),
length=str(segment_bin.length),
name=str(segment_bin.name),
)
if not segment_bin.resType == "uxsdInvalid":
segment_root.attrib["res_type"] = str(segment_bin.resType)
segment_root.attrib["res_type"] = str(segment_bin.resType).upper()

timing = update_attr(Element("timing"), segment_bin.timing.to_dict())
segment_root.append(timing)
Expand All @@ -117,10 +134,10 @@ def _block_types_bin2xml(block_types, xml_root=None):
for block_type in block_types:
block_types_root = Element(
"block_type",
height=str(block_type.height),
id=str(block_type.id),
name=str(block_type.name),
width=str(block_type.width),
height=str(block_type.height),
)

for pin_class_ux in block_type.pinClasses:
Expand All @@ -131,9 +148,7 @@ def _block_types_bin2xml(block_types, xml_root=None):
upper_case_fields=("type"),
)
for p in pin_class_ux.pins:
pin = update_attr(
Element("pin"), p.to_dict(), attrib_map, ("value")
)
pin = update_attr(Element("pin"), p.to_dict(), ("value"))
pin.text = p.value
pin_class.append(pin)
block_types_root.append(pin_class)
Expand All @@ -159,19 +174,12 @@ def _nodes_bin2xml(nodes, xml_root=None):
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)
)
node.append(update_attr(Element("timing"), node_ux.timing.to_dict()))
if str(node_ux.type).startswith("chan"):
node.append(
update_attr(
Element("segment"), node_ux.segment.to_dict(), attrib_map
)
)
node.append(update_attr(Element("segment"), node_ux.segment.to_dict()))
xml_root.append(node)
return xml_root

Expand Down
46 changes: 35 additions & 11 deletions spydrnet_physical/util/rrgraph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,47 @@ def enumerate_rrgraph(self, filename):
)

# Adding block types
self.create_block(
"EMPTY",
(),
height=1,
width=1,
)

tile_dim = {}
for tile in root.findall("tiles/tile"):
tile_name = tile.attrib["name"]
tile_dim[tile.attrib["name"]] = {
"width": tile.attrib.get("width", 1),
"height": tile.attrib.get("height", 1),
}

pins = []
for pin in tile.findall("sub_tile/input"):
pin_name = pin.attrib["name"]
pin_number = int(pin.attrib.get("num_pins", 1))
pins.append(("I", f"{pin_name}[0:{pin_number}]"))

for pin in tile.findall("sub_tile/output"):
pin_name = pin.attrib["name"]
pin_number = int(pin.attrib.get("num_pins", 1))
pins.append(("O", f"{pin_name}[0:{pin_number}]"))
block_capacity = int(tile.find("sub_tile").attrib.get("capacity", 1))
for t_idx in range(block_capacity):
t_idx = f"[{t_idx}]" if block_capacity > 1 else ""
for pin in tile.findall("sub_tile/input"):
p_name = pin.attrib["name"]
p_num = int(pin.attrib.get("num_pins", 1))
if pin.attrib.get("equivalent", "none") == "full":
pins.append(("I", f"{tile_name}{t_idx}.{p_name}[0:{p_num}]"))
else:
for p_num in range(p_num):
pins.append(("I", f"{tile_name}{t_idx}.{p_name}[{p_num}]"))

for pin in tile.findall("sub_tile/output"):
p_name = pin.attrib["name"]
p_num = int(pin.attrib.get("num_pins", 1))
if pin.attrib.get("equivalent", "none") == "full":
pins.append(("O", f"{tile_name}{t_idx}.{p_name}[0:{p_num}]"))
else:
for p_num in range(p_num):
pins.append(("O", f"{tile_name}{t_idx}.{p_name}[{p_num}]"))

for pin in tile.findall("sub_tile/clock"):
p_name = pin.attrib["name"]
for p_num in range(int(pin.attrib.get("num_pins", 1))):
pins.append(("I", f"{tile_name}{t_idx}.{p_name}[{p_num}]"))

self.create_block(
tile.attrib["name"],
Expand Down Expand Up @@ -233,8 +257,8 @@ def create_segment(

segment_ux = rr_capnp.Segment.new_message(
id=len(self.segments),
name=name,
length=int(length),
name=name,
resType=res_type,
timing=rr_capnp.SegmentTiming.new_message(
cPerMeter=c_per_meter, rPerMeter=r_per_meter
Expand All @@ -252,7 +276,7 @@ def create_channels(self):
xMin=min(self.channels["X"]),
yMax=max(self.channels["Y"]),
yMin=min(self.channels["Y"]),
chanWidthMax=max(rr.channels.channel.xMax, rr.channels.channel.yMax),
chanWidthMax=max(self.channels["X"] + self.channels["Y"]),
)
x_lists, y_lists = [], []
for indx, chan in enumerate(self.channels["X"]):
Expand Down

0 comments on commit eb83118

Please sign in to comment.