Commit 9256f51a by Dinple

More testcases

parent 1d8d3713
......@@ -6,8 +6,6 @@ from typing import Text, Tuple
from absl import logging
from collections import namedtuple
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from matplotlib.collections import LineCollection
from matplotlib.patches import Rectangle
import numpy as np
......@@ -509,14 +507,12 @@ class PlacementCost(object):
x_min= c_i * self.grid_width,
y_min= r_i * self.grid_height
)
print("grid_cell_block", grid_cell_block)
print(self.grid_row * r_i + c_i)
self.grid_occupied[self.grid_row * r_i + c_i] += \
self.grid_occupied[self.grid_col * r_i + c_i] += \
self.__overlap_area(grid_cell_block, module_block)
if abs(self.grid_occupied[self.grid_row * r_i + c_i] - 1) < 1e-6:
self.grid_occupied[self.grid_row * r_i + c_i] = 1
# if abs(self.grid_occupied[self.grid_row * r_i + c_i] - 1) < 1e-6:
# self.grid_occupied[self.grid_row * r_i + c_i] = 1
print("module_block", module_block)
......@@ -531,6 +527,7 @@ class PlacementCost(object):
self.grid_cells = [0] * (self.grid_col * self.grid_row)
for module_idx in (self.soft_macro_indices + self.hard_macro_indices):
# extract module information
module = self.modules_w_pins[module_idx]
module_h = module.get_height()
module_w = module.get_width()
......@@ -549,7 +546,6 @@ class PlacementCost(object):
return self.grid_cells
def get_density_cost(self) -> float:
# run get_grid_cells_density first
occupied_cells = sorted([gc for gc in self.grid_cells if gc != 0.0], reverse=True)
density_cost = 0.0
......@@ -810,9 +806,9 @@ class PlacementCost(object):
def save_placement(self):
pass
def display_canvas(self):
def display_canvas(self, annotate=True):
#define Matplotlib figure and axis
fig, ax = plt.subplots(figsize=(8,8), dpi=80)
fig, ax = plt.subplots(figsize=(8,8), dpi=50)
# Plt config
ax.margins(x=0.05, y=0.05)
......@@ -825,6 +821,7 @@ class PlacementCost(object):
ax.plot(x, y, c='b', alpha=0.1) # use plot, not scatter
ax.plot(np.transpose(x), np.transpose(y), c='b', alpha=0.1) # add this here
# Construct module blocks
for mod in self.modules_w_pins:
if mod.get_type() == 'PORT':
plt.plot(*mod.get_pos(),'ro', markersize=1)
......@@ -832,13 +829,19 @@ class PlacementCost(object):
ax.add_patch(Rectangle((mod.get_pos()[0] - mod.get_width()/2, mod.get_pos()[1] - mod.get_height()/2),\
mod.get_width(), mod.get_height(),\
alpha=0.5, zorder=1000, facecolor='b', edgecolor='darkblue'))
ax.annotate(mod.get_name().rsplit('/', 1)[1], mod.get_pos(), color='r', weight='bold', fontsize=3, ha='center', va='center')
if annotate:
ax.annotate(mod.get_name(), mod.get_pos(), color='r', weight='bold', fontsize=7, ha='center', va='center')
elif mod.get_type() == 'MACRO_PIN':
plt.plot(*mod.get_pos(),'bo', markersize=1)
elif mod.get_type() == 'macro':
ax.add_patch(Rectangle((mod.get_pos()[0] - mod.get_width()/2, mod.get_pos()[1] - mod.get_height()/2),\
mod.get_width(), mod.get_height(),\
alpha=0.5, zorder=1000, facecolor='y'))
if annotate:
ax.annotate(mod.get_name(), mod.get_pos(), wrap=True,color='r', weight='bold', fontsize=7, ha='center', va='center')
plt.show()
plt.close('all')
# Board Entity Definition
......@@ -1159,7 +1162,7 @@ class PlacementCost(object):
return "MACRO_PIN"
def main():
test_netlist_dir = '/home/yuw/Desktop/Github/CT_runnable/circuit_training/circuit_training/environment/test_data/'+\
test_netlist_dir = './Plc_client/test/'+\
'ariane'
netlist_file = os.path.join(test_netlist_dir,
'netlist.pb.txt')
......
......@@ -11,6 +11,7 @@ class CircuitDataBaseTest(unittest.TestCase):
# NETLIST_PATH = "./Plc_client/test/sample_clustered_nomacro/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/sample_clustered_macroxy/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt"
def test_proxy_cost(self):
# Google's Binary Executable
......@@ -19,8 +20,24 @@ class CircuitDataBaseTest(unittest.TestCase):
self.plc_os = plc_client_os.PlacementCost(netlist_file=self.NETLIST_PATH,
macro_macro_x_spacing = 50,
macro_macro_y_spacing = 50)
# Google's Ariane
CANVAS_HEIGHT =
CANVAS_WIDTH =
GRID_COL = 35
GRID_ROW = 33
# Ariane133
CANVAS_HEIGHT =
CANVAS_WIDTH =
GRID_COL = 35
GRID_ROW = 33
print(self.plc.set_canvas_size(CANVAS_WIDTH, CANVAS_HEIGHT))
print(self.plc.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_density_cost()) == int(self.plc.get_density_cost())
def test_metadata(self):
# Google's Binary Executable
......
This source diff could not be displayed because it is too large. You can view the blob instead.
# proto-file: tensorflow/core/framework/graph.proto
# proto-message: tensorflow.GraphDef
node {
name: "i_ariane/i_frontend/i_icache/sram_block_1__tag_sram/mem/mem_inst_mem_256x45_256x16_0x0"
attr {
key: "height"
value {
f: 19.26
}
}
attr {
key: "orientation"
value {
placeholder: "N"
}
}
attr {
key: "type"
value {
placeholder: "MACRO"
}
}
attr {
key: "width"
value {
f: 29.355
}
}
attr {
key: "x"
value {
f: 341.9145
}
}
attr {
key: "y"
value {
f: 25.804
}
}
}
node {
name: "i_ariane/i_frontend/i_icache/sram_block_3__tag_sram/mem/mem_inst_mem_256x45_256x16_0x0"
attr {
key: "height"
value {
f: 19.26
}
}
attr {
key: "orientation"
value {
placeholder: "N"
}
}
attr {
key: "type"
value {
placeholder: "MACRO"
}
}
attr {
key: "width"
value {
f: 29.355
}
}
attr {
key: "x"
value {
f: 341.75
}
}
attr {
key: "y"
value {
f: 8.8835
}
}
}
\ No newline at end of file
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