Commit ccf490ad by Dinple

fix netlist parser

parent 93752bef
...@@ -159,7 +159,6 @@ class PlacementCost(object): ...@@ -159,7 +159,6 @@ class PlacementCost(object):
# node found # node found
if line_item[0] == 'node': if line_item[0] == 'node':
node_cnt += 1
node_name = '' node_name = ''
input_list = [] input_list = []
...@@ -169,8 +168,14 @@ class PlacementCost(object): ...@@ -169,8 +168,14 @@ class PlacementCost(object):
# retrieve node name # retrieve node name
if line_item[0] == 'name': if line_item[0] == 'name':
node_name = line_item[1] node_name = line_item[1]
if node_name == "__metadata__":
print("skipping __metadata__")
else:
# print(node_name)
node_cnt += 1
else: else:
node_name = 'N/A name' node_name = 'N/A name'
# advance ptr # advance ptr
line = fp.readline() line = fp.readline()
...@@ -198,23 +203,42 @@ class PlacementCost(object): ...@@ -198,23 +203,42 @@ class PlacementCost(object):
line_item = re.findall(r'\w+', line) line_item = re.findall(r'\w+', line)
key = line_item[1] key = line_item[1]
# advance, expect value if key == "macro_name":
line = fp.readline() # advance, expect value
line_item = re.findall(r'\w+', line) line = fp.readline()
line_item = re.findall(r'\w+', line)
# advance, expect value item # advance, expect value item
line = fp.readline() line = fp.readline()
line_item = re.findall(r'\-*\w+\.*\/{0,1}\w*[\w+\/{0,1}\w*]*', line) line_item = re.findall(r'\w+[^\:\n\\{\}\s"]*', line)
attr_dict[key] = line_item attr_dict[key] = line_item
line = fp.readline() line = fp.readline()
line = fp.readline() line = fp.readline()
line = fp.readline() line = fp.readline()
line_item = re.findall(r'\w+', line) line_item = re.findall(r'\w+', line)
else:
# advance, expect value
line = fp.readline()
line_item = re.findall(r'\w+', line)
if attr_dict['type'][1] == 'macro': # advance, expect value item
line = fp.readline()
line_item = re.findall(r'\-*\w+\.*\/{0,1}\w*[\w+\/{0,1}\w*]*', line)
attr_dict[key] = line_item
line = fp.readline()
line = fp.readline()
line = fp.readline()
line_item = re.findall(r'\w+', line)
if node_name == "__metadata__":
logging.info('[NETLIST PARSER INFO] skipping invalid net input')
elif attr_dict['type'][1] == 'macro':
# soft macro # soft macro
# check if all required information is obtained # check if all required information is obtained
try: try:
...@@ -301,6 +325,7 @@ class PlacementCost(object): ...@@ -301,6 +325,7 @@ class PlacementCost(object):
x_offset = attr_dict['x_offset'][1], x_offset = attr_dict['x_offset'][1],
y_offset = attr_dict['y_offset'][1], y_offset = attr_dict['y_offset'][1],
macro_name = attr_dict['macro_name'][1]) macro_name = attr_dict['macro_name'][1])
if 'weight' in attr_dict.keys(): if 'weight' in attr_dict.keys():
hard_macro_pin.set_weight(float(attr_dict['weight'][1])) hard_macro_pin.set_weight(float(attr_dict['weight'][1]))
...@@ -1677,19 +1702,15 @@ class PlacementCost(object): ...@@ -1677,19 +1702,15 @@ class PlacementCost(object):
return mod.get_width(), mod.get_height() return mod.get_width(), mod.get_height()
def make_soft_macros_square(self): def make_soft_macros_square(self):
""" pass
update soft macro width/height base on its square area
"""
def update_soft_macros_position(self, coord_dict): def update_soft_macros_position(self, coord_dict):
""" """
For sync-up with Google's plc_client after FD placer For sync-up with Google's plc_client after FD placer
""" """
for mod_idx in coord_dict.keys(): for mod_idx in coord_dict.keys():
self.modules_w_pins[mod_idx].set_pos(coord_dict[mod_idx]) self.modules_w_pins[mod_idx].set_pos(coord_dict[mod_idx])
def set_soft_macro_position(self, node_idx, x_pos, y_pos): def set_soft_macro_position(self, node_idx, x_pos, y_pos):
""" """
used for updating soft macro position used for updating soft macro position
...@@ -2688,7 +2709,7 @@ class PlacementCost(object): ...@@ -2688,7 +2709,7 @@ class PlacementCost(object):
def main(): def main():
test_netlist_dir = './Plc_client/test/'+\ test_netlist_dir = './Plc_client/test/'+\
'ariane133' 'ariane_68_1.3'
netlist_file = os.path.join(test_netlist_dir, netlist_file = os.path.join(test_netlist_dir,
'netlist.pb.txt') 'netlist.pb.txt')
plc = PlacementCost(netlist_file) plc = PlacementCost(netlist_file)
......
...@@ -44,8 +44,8 @@ Example: ...@@ -44,8 +44,8 @@ Example:
--marv 51.790\ --marv 51.790\
--smooth 2 --smooth 2
$ python3 -m Plc_client.plc_client_os_test --netlist ./Plc_client/test/ariane133/netlist.pb.txt\ $ python3 -m Plc_client.plc_client_os_test --netlist ./Plc_client/test/ariane_68_1.3/netlist.pb.txt\
--plc ./Plc_client/test/ariane133/initial.plc\ --plc ./Plc_client/test/ariane_68_1.3//initial.plc\
--width 1599\ --width 1599\
--height 1600.06\ --height 1600.06\
--col 24\ --col 24\
...@@ -347,7 +347,7 @@ class PlacementCostTest(): ...@@ -347,7 +347,7 @@ class PlacementCostTest():
self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW) self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW)
self.plc_os.display_canvas() self.plc_os.display_canvas()
self.unplace_node() self.plc_os.unplace_all_nodes()
print(np.flip(np.array(self.plc_util.get_node_mask(0)).reshape(35, 33), axis=0)) print(np.flip(np.array(self.plc_util.get_node_mask(0)).reshape(35, 33), axis=0))
print(np.flip(np.array(self.plc.get_node_mask(0)).reshape(35, 33), axis=0)) print(np.flip(np.array(self.plc.get_node_mask(0)).reshape(35, 33), axis=0))
...@@ -800,11 +800,11 @@ def main(args): ...@@ -800,11 +800,11 @@ def main(args):
# PCT.test_proxy_cost() # PCT.test_proxy_cost()
# PCT.test_placement_util(keep_save_file=False) # PCT.test_placement_util(keep_save_file=False)
# PCT.test_place_node() # PCT.test_place_node()
PCT.test_miscellaneous() # PCT.test_miscellaneous()
# PCT.test_observation_extractor() # PCT.test_observation_extractor()
# PCT.view_canvas() # PCT.view_canvas()
# PCT.test_proxy_congestion() # PCT.test_proxy_congestion()
# PCT.test_environment() PCT.test_environment()
if __name__ == '__main__': if __name__ == '__main__':
......
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