blob: 583fe0dfdd2629bf39b27a81e85b152f5f3850c7 [file] [log] [blame] [edit]
#!/usr/bin/env python3
# takes a lef file and a y position => obstructs everything above
import re
import os
import sys
ARGV = sys.argv
if len(ARGV) < 2:
print("Usage " + ARGV[0] + " threshold_y_pos")
sys.exit(-1)
MAX_Y = float(ARGV[1])
LAYERS = ["li1", "met1", "met2", "met3", "met4", "met5"]
SIZE_REGEX = r"^\s*SIZE\s+(-?\d+\.?\d*)\s+BY\s+(-?\d+\.?\d*)\s+;$"
def print_obs_section(size_x, size_y):
for layer in LAYERS:
print(" LAYER %s ;" %(layer))
print(" RECT %f %f %s %s ;" % (0, MAX_Y, size_x, size_y))
obs_section = False
for line in sys.stdin:
if line.isspace():
continue
size_match = re.search(SIZE_REGEX, line)
if size_match:
size_x, size_y = size_match.group(1), size_match.group(2)
elif line.find("OBS") != -1:
obs_section = True
elif obs_section and line.find("END") != -1:
obs_section = False
# print all except RECTs inside OBS
if line.find("OBS") != -1:
print(line, end='')
print_obs_section(size_x, size_y)
elif not obs_section:
print(line, end='')