python-klayout

python-klayout

create layout

ly = db.Layout()
ly.dbu = 0.001

define layer

AA = ly.layer(1, 1,“AA”)

Create a cell

BitCell_Unit= ly.create_cell(“BitCell_Unit”)

setup CT060 instance and insert CT as instance

CT060 = ly.create_cell(“CT060”)

width = CD_CT060
height = CD_CT060
pt = db.DPoint(0, 0)
box_CT060 = db.DBox(pt, pt + db.DVector(width, height))
CT060.shapes(CT).insert(box_CT060)

xPosition= (Len_AA_BL - CD_CT040)/2
yPosition= CD_CT040/2*-1

xPitch=0
yPitch=Width_AA_BL

CTBL = db.DCellInstArray(
CT040.cell_index(),
db.DTrans(db.DTrans.R0, xPosition, yPosition),
db.DVector(0, yPitch),
db.DVector(xPitch, 0),
2,
2
)
BitCell_Unit.insert(CTBL)

Insert a layer

width = 0.1
length = 10
xPosition=0
yPosition=0
pt = db.DPoint(xPosition,yPosition)

box_M1_BL = db.DBox(pt, pt + db.DVector(length, width))
BitCell_Unit.shapes(M1).insert(box_M1_BL)

copy an instance

BitCell1_Unit= ly.create_cell(“BitCell1_Unit”)
BitCell1_Unit.copy_tree(BitCell_Unit)

flatten an instance and delete a layer

BitCell1_Unit.flatten(-1)
BitCell1_Unit.clear(CT)

write to a GDS

ly.write(“TEST.gds”)

boolean

structure= ly.create_cell(“test”)
structure.shapes(M1).insert(box_CT040)
structure.shapes(M2).insert(box_CT060)

r1=db.Region.new(structure.shapes(M1))
r2=db.Region.new(structure.shapes(M2))

r3=r2-r1

structure.shapes(NW).insert(r3)

read a gds

ly.read(“xxx.gds”)

Operation for all top cell in a gds

topnames = list()
for cell in ly.top_cells():

name_cell = cell.name
pattern = r"Main"
if re.findall(pattern, name_cell):
    topnames.append(name_cell)

Delete a layer from all the cells

for cell in ly.each_cell():
cell.shapes(DummyLOTA1).clear()

clear a cell

ly.cell(‘xxx’).clear

delete a cell

ly.cell(‘xxx’).delete

Copy and replace

ly.read(“MTP_Merged_Vcm_ForDRC_Modify.gds”)

ly1.read(“a.gds”)

ly1.read(“b.gds”)

for cell in ly.each_cell():
name_cell = str(cell.name)
pattern = r"Main"
if re.findall(pattern, name_cell):

    cell.prune_subcells()
    cell.clear()
    exec ('cell .copy_tree( ly1.cell("' +  str(name_cell ) + '"))')

Path

path_layer = db.DPath([(-1,1),(0,1),(3,4),(5,4)],1)

Top.shapes(AA).insert(path_layer)

for cells in ly.top_cells():
for index in cells.each_child_cell():
for ii in ly.cell(index).each_child_cell():
for shape in ly.cell(ii).each_shape(AA):
print(shape)

  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值