SOFA/SCRIPT/merge_caravel_klayout.py

32 lines
860 B
Python
Raw Normal View History

2020-12-08 14:32:26 -06:00
import pya
import sys
CARAVEL_GDS_PATH = "./gds/caravel.gds"
USER_GDS_PATH = "./gds/user_project_wrapper.gds"
# ly = pya.CellView.active().cell.layout
ly = pya.Layout()
ly.read(CARAVEL_GDS_PATH)
2020-12-20 18:04:56 -06:00
TOP = ly.cell("caravel")
2020-12-08 14:32:26 -06:00
2020-12-20 18:04:56 -06:00
# x, y = 326.38500, 1382.01000
for each in TOP.each_inst():
2020-12-08 14:32:26 -06:00
if "user_project_wrapper" in (each.cell.name):
x, y = each.dtrans.disp.x, each.dtrans.disp.y
print("Placing module at (%f,%f)" % (x, y))
2020-12-20 18:04:56 -06:00
ly.delete_cell(ly.cell_by_name("user_project_wrapper"))
2020-12-08 14:32:26 -06:00
ly.read(USER_GDS_PATH)
tiles = ly.cell('user_project_wrapper')
TOP.insert(pya.DCellInstArray(tiles.cell_index(),
pya.DTrans(pya.DTrans.R0, pya.DPoint(x, y))))
2020-12-20 18:04:56 -06:00
for c in ly.top_cells():
if c.name != "caravel":
print("removing cell " + c.name)
ly.delete_cell(c.cell_index())
2020-12-08 14:32:26 -06:00
ly.write("./gds/caravel_merged.gds")