mirror of https://github.com/efabless/caravel.git
Move Rectify To Caravel
This commit is contained in:
parent
e938b7dcf3
commit
641096e4ed
|
@ -39,11 +39,11 @@ run_magic
|
||||||
run_magic_drc
|
run_magic_drc
|
||||||
|
|
||||||
save_views -lef_path $::env(magic_result_file_tag).lef \
|
save_views -lef_path $::env(magic_result_file_tag).lef \
|
||||||
-def_path $::env(CURRENT_DEF) \
|
-def_path $::env(CURRENT_DEF) \
|
||||||
-gds_path $::env(magic_result_file_tag).gds \
|
-gds_path $::env(magic_result_file_tag).gds \
|
||||||
-mag_path $::env(magic_result_file_tag).mag \
|
-mag_path $::env(magic_result_file_tag).mag \
|
||||||
-save_path $save_path \
|
-save_path $save_path \
|
||||||
-tag $::env(RUN_TAG)
|
-tag $::env(RUN_TAG)
|
||||||
|
|
||||||
# make pin labels visible in the magview
|
# make pin labels visible in the magview
|
||||||
exec /bin/bash $script_dir/../../utils/export_pin_labels.sh $script_dir/../../mag/$::env(RUN_TAG).mag 0 3498 2920 3520 0 -20 2920 4 >@stdout 2>@stderr
|
exec /bin/bash $script_dir/../../utils/export_pin_labels.sh $script_dir/../../mag/$::env(RUN_TAG).mag 0 3498 2920 3520 0 -20 2920 4 >@stdout 2>@stderr
|
||||||
|
@ -57,9 +57,9 @@ set llx [expr [lindex $::env(DIE_AREA) 0]-$gap]
|
||||||
set lly [expr [lindex $::env(DIE_AREA) 1]-$gap]
|
set lly [expr [lindex $::env(DIE_AREA) 1]-$gap]
|
||||||
set urx [expr [lindex $::env(DIE_AREA) 2]+$gap]
|
set urx [expr [lindex $::env(DIE_AREA) 2]+$gap]
|
||||||
set ury [expr [lindex $::env(DIE_AREA) 3]+$gap]
|
set ury [expr [lindex $::env(DIE_AREA) 3]+$gap]
|
||||||
exec python3 $::env(OPENLANE_ROOT)/scripts/rectify.py $llx $lly $urx $ury \
|
exec python3 $script_dir/rectify.py $llx $lly $urx $ury \
|
||||||
< $::env(magic_result_file_tag).lef \
|
< $::env(magic_result_file_tag).lef \
|
||||||
| python3 $::env(OPENLANE_ROOT)/scripts/obs.py {*}$::env(DIE_AREA) li1 met1 met2 met3 \
|
| python3 $::env(OPENLANE_ROOT)/scripts/obs.py {*}$::env(DIE_AREA) li1 met1 met2 met3 \
|
||||||
| python3 $::env(OPENLANE_ROOT)/scripts/obs.py -42.88 -37.53 2962.50 3557.21 met4 met5 \
|
| python3 $::env(OPENLANE_ROOT)/scripts/obs.py -42.88 -37.53 2962.50 3557.21 met4 met5 \
|
||||||
> $::env(magic_result_file_tag).obstructed.lef
|
> $::env(magic_result_file_tag).obstructed.lef
|
||||||
file copy -force $::env(magic_result_file_tag).obstructed.lef $save_path/lef
|
file copy -force $::env(magic_result_file_tag).obstructed.lef $save_path/lef
|
|
@ -0,0 +1,148 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2020 Efabless Corporation
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
"""
|
||||||
|
takes a lef file and a rectangle => trims all RECT statements within the area
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
ARGV = sys.argv
|
||||||
|
if len(ARGV) < 5:
|
||||||
|
print("Usage " + ARGV[0] + " llx lly urx ury")
|
||||||
|
sys.exit(-1)
|
||||||
|
LLX = float(ARGV[1])
|
||||||
|
LLY = float(ARGV[2])
|
||||||
|
URX = float(ARGV[3])
|
||||||
|
URY = float(ARGV[4])
|
||||||
|
LAYERS = ["li1", "met1", "met2", "met3", "met4", "met5"]
|
||||||
|
RECT_REGEX = (
|
||||||
|
r"^\s*RECT\s+(-?\d+\.?\d*)\s+(-?\d+\.?\d*)\s+(-?\d+\.?\d*)\s+(-?\d+\.?\d*)\s+;$"
|
||||||
|
)
|
||||||
|
# SIZE_REGEX = r"^\s*SIZE\s+(-?\d+\.?\d*)\s+BY\s+\s+(-?\d+\.?\d*);$"
|
||||||
|
|
||||||
|
|
||||||
|
def get_cut_rect_x(rect, axis):
|
||||||
|
"""
|
||||||
|
cuts one rect about an x axis
|
||||||
|
"""
|
||||||
|
rects = [rect]
|
||||||
|
llx, lly, urx, ury = rect
|
||||||
|
if llx < axis and urx > axis:
|
||||||
|
rects = [(llx, lly, axis, ury), (axis, lly, urx, ury)]
|
||||||
|
return rects
|
||||||
|
|
||||||
|
|
||||||
|
def get_cut_rect_y(rect, axis):
|
||||||
|
"""
|
||||||
|
cuts one rect about an y axis
|
||||||
|
"""
|
||||||
|
rects = [rect]
|
||||||
|
llx, lly, urx, ury = rect
|
||||||
|
if lly < axis and ury > axis:
|
||||||
|
rects = [(llx, lly, urx, axis), (llx, axis, urx, ury)]
|
||||||
|
return rects
|
||||||
|
|
||||||
|
|
||||||
|
def rects2cutrects(rects, axis, direction):
|
||||||
|
"""
|
||||||
|
cut a list of rects (4-tuple) and returns another list of of rects (4-tuple)
|
||||||
|
cut by an x or y axis
|
||||||
|
|
||||||
|
axix is a position
|
||||||
|
|
||||||
|
direction is either 'x' or 'y'
|
||||||
|
"""
|
||||||
|
rects_cut = []
|
||||||
|
if direction == "x":
|
||||||
|
for rect in rects:
|
||||||
|
rects_cut += get_cut_rect_x(rect, axis)
|
||||||
|
else:
|
||||||
|
for rect in rects:
|
||||||
|
rects_cut += get_cut_rect_y(rect, axis)
|
||||||
|
return rects_cut
|
||||||
|
|
||||||
|
|
||||||
|
def get_all_cut_rects(rect):
|
||||||
|
"""
|
||||||
|
cut a rect about the 4 axis LLX, LLY, URX, URY
|
||||||
|
"""
|
||||||
|
rects = [rect]
|
||||||
|
rects = rects2cutrects(rects, LLX, "x")
|
||||||
|
rects = rects2cutrects(rects, URX, "x")
|
||||||
|
rects = rects2cutrects(rects, LLY, "y")
|
||||||
|
rects = rects2cutrects(rects, URY, "y")
|
||||||
|
return rects
|
||||||
|
|
||||||
|
|
||||||
|
def rectify(rects):
|
||||||
|
"""
|
||||||
|
gets a list of already cut rects (4-tuple) and returns another list of of
|
||||||
|
rects (4-tuple) that are not within LLX, LLY, URX, URY
|
||||||
|
"""
|
||||||
|
rect_outside = []
|
||||||
|
for rect in rects:
|
||||||
|
llx, lly, urx, ury = rect
|
||||||
|
if (
|
||||||
|
llx < LLX
|
||||||
|
or llx > URX
|
||||||
|
or urx > URX
|
||||||
|
or urx < LLX
|
||||||
|
or lly < LLY
|
||||||
|
or lly > URY
|
||||||
|
or ury > URY
|
||||||
|
or ury < LLY
|
||||||
|
):
|
||||||
|
rect_outside += [rect]
|
||||||
|
return rect_outside
|
||||||
|
|
||||||
|
|
||||||
|
def print_rects(prefix, rects):
|
||||||
|
for rect in rects:
|
||||||
|
llx, lly, urx, ury = rect
|
||||||
|
print(prefix + "RECT %f %f %f %f ;" % (llx, lly, urx, ury))
|
||||||
|
|
||||||
|
|
||||||
|
layer = ""
|
||||||
|
for line in sys.stdin:
|
||||||
|
if line.isspace():
|
||||||
|
continue
|
||||||
|
rect_match = re.search(RECT_REGEX, line)
|
||||||
|
if rect_match:
|
||||||
|
llx, lly, urx, ury = (
|
||||||
|
float(rect_match.group(1)),
|
||||||
|
float(rect_match.group(2)),
|
||||||
|
float(rect_match.group(3)),
|
||||||
|
float(rect_match.group(4)),
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
(lly < LLY and ury < LLY)
|
||||||
|
or (lly > URY and ury > URY)
|
||||||
|
or (llx < LLX and urx < LLX)
|
||||||
|
or (llx > URX and urx > URX)
|
||||||
|
): # outside the whole thing
|
||||||
|
rects = [(llx, lly, urx, ury)]
|
||||||
|
else:
|
||||||
|
rects = rectify(get_all_cut_rects((llx, lly, urx, ury)))
|
||||||
|
if len(rects) > 0:
|
||||||
|
print(layer)
|
||||||
|
if layer != "": # LAYER printed, clear it
|
||||||
|
layer = ""
|
||||||
|
print_rects(line[: line.find("R")], rects)
|
||||||
|
else:
|
||||||
|
if line.find("LAYER") != -1: # print it only if there're RECTs
|
||||||
|
layer = line
|
||||||
|
else:
|
||||||
|
print(line, end="")
|
Loading…
Reference in New Issue