Commit d690cd79 by Dinple

initial cluster port adj

parent 8d03aea7
...@@ -676,7 +676,7 @@ class PlacementCost(object): ...@@ -676,7 +676,7 @@ class PlacementCost(object):
def get_macro_adjacency(self) -> list: def get_macro_adjacency(self) -> list:
""" """
Compute Adjacency Matrix (Unclustered PORTs) Compute Adjacency Matrix
""" """
# NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted # NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted
#[MACRO][macro] #[MACRO][macro]
...@@ -745,12 +745,8 @@ class PlacementCost(object): ...@@ -745,12 +745,8 @@ class PlacementCost(object):
""" """
Compute Adjacency Matrix (Unclustered PORTs) Compute Adjacency Matrix (Unclustered PORTs)
""" """
# NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted
macro_adj = [0] * self.module_cnt * self.module_cnt
assert len(macro_adj) == self.module_cnt * self.module_cnt
#[MACRO][macro][PORT] #[MACRO][macro][PORT]
module_indices = self.hard_macro_indices + self.soft_macro_indices + self.port_indices module_indices = self.hard_macro_indices + self.soft_macro_indices
#[Grid Cell] => [PORT] #[Grid Cell] => [PORT]
clustered_ports = {} clustered_ports = {}
...@@ -764,8 +760,61 @@ class PlacementCost(object): ...@@ -764,8 +760,61 @@ class PlacementCost(object):
clustered_ports[(row, col)].append(port) clustered_ports[(row, col)].append(port)
else: else:
clustered_ports[(row, col)] = [port] clustered_ports[(row, col)] = [port]
# NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted
macro_adj = [0] * (len(module_indices) + len(clustered_ports)) * (len(module_indices) + len(clustered_ports))
# instantiate macros
for row_idx, module_idx in enumerate(module_indices):
# row index
# store temp module
curr_module = self.modules_w_pins[module_idx]
# get module name
curr_module_name = curr_module.get_name()
for col_idx, h_module_idx in enumerate(module_indices):
# col index
entry = 0
# store connected module
h_module = self.modules_w_pins[h_module_idx]
# get connected module name
h_module_name = h_module.get_name()
if curr_module_name in h_module.get_connection():
entry += h_module.get_connection()[curr_module_name]
return clustered_ports if h_module_name in curr_module.get_connection():
entry += curr_module.get_connection()[h_module_name]
macro_adj[row_idx * (self.hard_macro_cnt + self.soft_macro_cnt) + col_idx] = entry
macro_adj[col_idx * (self.hard_macro_cnt + self.soft_macro_cnt) + row_idx] = entry
# instantiate clustered ports
for cluster_idx, cluster_cell in enumerate(clustered_ports):
for port in clustered_ports[cluster_cell]:
# get module name
curr_port_name = port.get_name()
# assuming ports only connects to macros
for col_idx, h_module_idx in enumerate(module_indices):
# col index
entry = 0
# store connected module
h_module = self.modules_w_pins[h_module_idx]
# get connected module name
h_module_name = h_module.get_name()
if curr_module_name in h_module.get_connection():
entry += h_module.get_connection()[curr_port_name]
if h_module_name in curr_module.get_connection():
entry += curr_module.get_connection()[h_module_name]
macro_adj[row_idx * (self.hard_macro_cnt + self.soft_macro_cnt + cluster_idx) + col_idx] = entry
macro_adj[col_idx * (self.hard_macro_cnt + self.soft_macro_cnt + cluster_idx) + row_idx] = entry
return macro_adj
def get_node_location(self): def get_node_location(self):
pass pass
...@@ -1183,12 +1232,5 @@ def main(): ...@@ -1183,12 +1232,5 @@ def main():
print(plc.get_grid_cells_density()) print(plc.get_grid_cells_density())
print(plc.get_density_cost()) print(plc.get_density_cost())
temppins = plc.soft_macros_to_inpins[plc.modules_w_pins[plc.soft_macro_indices[0]].get_name()]
print(plc.modules_w_pins[plc.mod_name_to_indices[temppins[17]]].get_name())
print(plc.modules_w_pins[plc.mod_name_to_indices[temppins[17]]].get_sink())
print(plc.modules_w_pins[plc.soft_macro_indices[54]].get_name())
temppins2 = plc.soft_macros_to_inpins[plc.modules_w_pins[plc.soft_macro_indices[54]].get_name()]
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -16,6 +16,24 @@ class CircuitDataBaseTest(): ...@@ -16,6 +16,24 @@ class CircuitDataBaseTest():
NETLIST_PATH = "./Plc_client/test/ariane/netlist.pb.txt" NETLIST_PATH = "./Plc_client/test/ariane/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt"
# Google's Ariane
CANVAS_WIDTH = 356.592
CANVAS_HEIGHT = 356.640
GRID_COL = 35
GRID_ROW = 33
# Ariane133
# CANVAS_WIDTH = 1599.99
# CANVAS_HEIGHT = 1598.8
# GRID_COL = 50
# GRID_ROW = 50
# Sample clustered
# CANVAS_WIDTH = 80
# CANVAS_HEIGHT = 80
# GRID_COL = 5
# GRID_ROW = 5
def test_proxy_cost(self): def test_proxy_cost(self):
# Google's Binary Executable # Google's Binary Executable
self.plc = plc_client.PlacementCost(self.NETLIST_PATH) self.plc = plc_client.PlacementCost(self.NETLIST_PATH)
...@@ -24,28 +42,11 @@ class CircuitDataBaseTest(): ...@@ -24,28 +42,11 @@ class CircuitDataBaseTest():
self.plc_os = plc_client_os.PlacementCost(netlist_file=self.NETLIST_PATH, self.plc_os = plc_client_os.PlacementCost(netlist_file=self.NETLIST_PATH,
macro_macro_x_spacing = 50, macro_macro_x_spacing = 50,
macro_macro_y_spacing = 50) macro_macro_y_spacing = 50)
# Google's Ariane
CANVAS_WIDTH = 356.592
CANVAS_HEIGHT = 356.640
GRID_COL = 35
GRID_ROW = 33
# Ariane133 self.plc.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
# CANVAS_WIDTH = 1599.99 self.plc.set_placement_grid(self.GRID_COL, self.GRID_ROW)
# CANVAS_HEIGHT = 1598.8 self.plc_os.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
# GRID_COL = 50 self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW)
# GRID_ROW = 50
# Sample clustered
# CANVAS_WIDTH = 80
# CANVAS_HEIGHT = 80
# GRID_COL = 5
# GRID_ROW = 5
self.plc.set_canvas_size(CANVAS_WIDTH, CANVAS_HEIGHT)
self.plc.set_placement_grid(GRID_COL, GRID_ROW)
self.plc_os.set_canvas_size(CANVAS_WIDTH, CANVAS_HEIGHT)
self.plc_os.set_placement_grid(GRID_COL, GRID_ROW)
assert int(self.plc_os.get_wirelength()) == int(self.plc.get_wirelength()) assert int(self.plc_os.get_wirelength()) == int(self.plc.get_wirelength())
assert int(sum(self.plc_os.get_grid_cells_density())) == int(sum(self.plc.get_grid_cells_density())) assert int(sum(self.plc_os.get_grid_cells_density())) == int(sum(self.plc.get_grid_cells_density()))
...@@ -58,7 +59,13 @@ class CircuitDataBaseTest(): ...@@ -58,7 +59,13 @@ class CircuitDataBaseTest():
self.plc_os = plc_client_os.PlacementCost(netlist_file=self.NETLIST_PATH, self.plc_os = plc_client_os.PlacementCost(netlist_file=self.NETLIST_PATH,
macro_macro_x_spacing = 50, macro_macro_x_spacing = 50,
macro_macro_y_spacing = 50) macro_macro_y_spacing = 50)
self.plc.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
self.plc.set_placement_grid(self.GRID_COL, self.GRID_ROW)
self.plc_os.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW)
self.plc_os.get_grid_cells_density()
assert int(self.plc_os.get_area()) == int(self.plc.get_area()) assert int(self.plc_os.get_area()) == int(self.plc.get_area())
...@@ -79,6 +86,7 @@ class CircuitDataBaseTest(): ...@@ -79,6 +86,7 @@ class CircuitDataBaseTest():
assert self.plc.get_macro_routing_allocation() == self.plc_os.get_macro_routing_allocation() assert self.plc.get_macro_routing_allocation() == self.plc_os.get_macro_routing_allocation()
assert sum(self.plc.get_macro_adjacency()) == sum(self.plc_os.get_macro_adjacency()) assert sum(self.plc.get_macro_adjacency()) == sum(self.plc_os.get_macro_adjacency())
assert sum(self.plc.get_macro_and_clustered_port_adjacency()[0]) == sum(self.plc_os.get_macro_and_clustered_port_adjacency())
def test_miscellaneous(self): def test_miscellaneous(self):
# Google's Binary Executable # Google's Binary Executable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment