-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathfoo.py
More file actions
executable file
·109 lines (88 loc) · 4.29 KB
/
Copy pathfoo.py
File metadata and controls
executable file
·109 lines (88 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/python
#Copyright (C) 2019 Jon Pry
#
#This file is part of Pill.
#
#Pill is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 2 of the License, or
#(at your option) any later version.
#
#Pill is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with Pill. If not, see <http://www.gnu.org/licenses/>.
import klayout.db as db
import klayout.lib
layout = db.Layout()
layout.dbu = .001
top = layout.create_cell("nch")
f = open("tsmcN65.layermap").read().split("\n")
layermap = {}
for l in f:
if len(l) < 1:
continue
if l[0] == "#":
continue
l = l.split()
if len(l) != 4:
continue
layermap[ (l[0],l[1]) ] = [int(l[2]),int(l[3])]
#print layermap
def dbCreateLabel(cell,layer,origin,text,justification,orientation,font,height):
l1 = layermap[ (layer[0],layer[1]) ]
l1 = layout.layer(l1[0], l1[1])
t = db.DText.new(text,origin[0],origin[1])
t.halign = 1 #center
t.valign = 1 #center
top.shapes(l1).insert(t)
def rodCreateRect(name,layer,width,length,origin,elementsX=1,spaceX=0):
print layer
l1 = layermap[ (layer[0],layer[1]) ]
l1 = layout.layer(l1[0], l1[1])
r = db.DBox.new(origin[0],origin[1],origin[0]+width,origin[1]+length)
top.shapes(l1).insert(r)
return { "lL" : [origin[0],origin[1]],
"uL" : [origin[0],origin[1]+length],
'lR' : [origin[0]+width,origin[1]],
'uR' : [origin[0]+width,origin[1]+length],
'lC' : [origin[0],origin[1]+length/2],
'uC' : [origin[0]+width/2,origin[1]+length],
'dbId' : {'pin' : None}}
def dbCreateRect(name,layer,coord):
l1 = layermap[ (layer[0],layer[1]) ]
l1 = layout.layer(l1[0], l1[1])
r = db.DBox.new(coord[0][0],coord[0][1],coord[1][0],coord[1][1])
top.shapes(l1).insert(r)
def addPoint(a,b):
return [a[0]+b[0],a[1]+b[1]]
def rodFillBBoxWithRects(layer,fillBBox,width,length,spaceX,spaceY,gap="distribute"):
assert(gap=="distribute")
boxWidth = fillBBox[1][0] - fillBBox[0][0]
boxHeight = fillBBox[1][1] - fillBBox[0][1]
p = addPoint(fillBBox[0],[boxWidth/2,boxHeight/2])
p = addPoint(p,[-width/2,-length/2])
rodCreateRect("",layer,width,length,p)
dbCreateLabel(None,["IP","drawing"],[0,0], "& Distributor TSMC",
"centerCenter","R0","stick",0.0)
rodCreateRect("gate",['PO', 'drawing'],0.060000000000000005,0.2,[0,0])
rodCreateRect('gatePinU_0', ['PO', 'drawing'], 0.060000000000000005, 0.14, [0, 0.2], 1, 0)
rodCreateRect('gatePinD_0', ['PO', 'drawing'], 0.060000000000000005, 0.14, [0, -0.14], 1, 0)
rodCreateRect('diffPinL_Gate', ['OD', 'drawing'], 0.060000000000000005, 0.2, [0.0, 0], 1, 0)
rodCreateRect('diffPinLS', ['OD', 'drawing'], 0.175, 0.2, [-0.175, 0], 1, 0)
rodCreateRect('metal_0', ['M1', 'drawing'], 0.09, 0.22000000000000003, [-0.145, -0.01], 1, 0)
dbCreateLabel(None, ['text', 'drawing'], [-0.09999999999999999, 0.10000000000000002], 'S', 'centerCenter', 'R0', 'stick', 0.05)
rodFillBBoxWithRects(layer=['CO', 'drawing'], fillBBox=[[-0.145, 0.03], [-0.05499999999999999, 0.17]], width= 0.09, length=0.09, spaceX= 0.11, spaceY=0.11)
rodCreateRect('diffPinRD', ['OD', 'drawing'], 0.175, 0.2, [0.060000000000000005, 0], 1, 0)
rodCreateRect('metal_1', ['M1', 'drawing'], 0.09, 0.22000000000000003, [0.115, -0.01], 1, 0)
dbCreateLabel(None,['text', 'drawing'], [-0.09999999999999999, 0.10000000000000002], 'S', 'centerCenter', 'R0', 'stick', 0.05)
rodFillBBoxWithRects(layer=['CO', 'drawing'], fillBBox=[[0.115, 0.03], [0.20500000000000002, 0.17]], width=0.09, length= 0.09, spaceX= 0.11, spaceY= 0.11)
dbCreateRect(None,['NP', 'drawing'], [[-0.305, -0.34], [0.36500000000000005, 0.54]])
rodCreateRect('body', ['PDK', 'drawing'], 0.8500000000000001, 0.64, [-0.395, -0.22], 1, 0)
dbCreateRect(None,['LVSDMY', 'dummy1'], [[-0.395, -0.22], [0.45500000000000007, 0.42000000000000004]])
dbCreateRect(None,['VTL_N', 'drawing'], [[-0.185, -0.16], [0.245, 0.36]])
#dbCreateRect(None,['instance', 'drawing'], [[-0.175, 0], [0.23500000000000001, 0.2]])
layout.write("foo.gds")