| 11 | :return: lef_dict {cell_name:{pin:{pin_name:pin_rect}, 'size':[unit*w,unit*h]}} |
| 12 | """ |
| 13 | def read_lef(path, lef_dict, unit): |
| 14 | with open(path, 'r') as read_file: |
| 15 | cell_name = '' |
| 16 | pin_name = '' |
| 17 | rect_list_left = [] |
| 18 | rect_list_lower = [] |
| 19 | rect_list_right = [] |
| 20 | rect_list_upper = [] |
| 21 | READ_MACRO = False |
| 22 | for line in read_file: |
| 23 | if line.lstrip().startswith('MACRO'): |
| 24 | READ_MACRO = True |
| 25 | cell_name = line.split()[1] |
| 26 | lef_dict[cell_name] = {} |
| 27 | lef_dict[cell_name]['pin'] = {} |
| 28 | |
| 29 | |
| 30 | if READ_MACRO: |
| 31 | if line.lstrip().startswith('SIZE'): |
| 32 | l = re.findall(r'-?\d+\.?\d*e?-?\d*?', line) |
| 33 | lef_dict[cell_name]['size'] = [unit * float(l[0]), unit * float(l[1])] # size [unit*w,unit*h] |
| 34 | |
| 35 | elif line.lstrip().startswith('PIN'): |
| 36 | pin_name = line.split()[1] |
| 37 | |
| 38 | |
| 39 | elif line.lstrip().startswith('RECT'): |
| 40 | l = line.split() |
| 41 | rect_list_left.append(float(l[1])) |
| 42 | rect_list_lower.append(float(l[2])) |
| 43 | rect_list_right.append(float(l[3])) |
| 44 | rect_list_upper.append(float(l[4])) |
| 45 | |
| 46 | elif line.lstrip().startswith('END %s\n' % pin_name): |
| 47 | rect_left = min(rect_list_left) * unit |
| 48 | rect_lower = min(rect_list_lower) * unit |
| 49 | rect_right = max(rect_list_right) * unit |
| 50 | rect_upper = max(rect_list_upper) * unit |
| 51 | lef_dict[cell_name]['pin'][pin_name] = [rect_left, rect_lower, rect_right, rect_upper] # pin_rect |
| 52 | rect_list_left = [] |
| 53 | rect_list_lower = [] |
| 54 | rect_list_right = [] |
| 55 | rect_list_upper = [] |
| 56 | |
| 57 | return lef_dict |
| 58 | |
| 59 | |
| 60 | def read_lef_pin_map(path, lef_dic, unit): |