add vss/vdd as pins, gets the net into the VST
[soclayout.git] / experiments9 / pll.py
1 # Autogenerated file. Changes will be overwritten.
2
3 import CRL, Hurricane, Viewer, Cfg
4 from Hurricane import (
5 Technology, DataBase, DbU, Library,
6 Layer, BasicLayer,
7 Cell, Net, Vertical, Rectilinear, Box, Point,
8 Instance, Transformation,
9 NetExternalComponents,
10 )
11 from common.colors import toRGB
12 from common.patterns import toHexa
13 from helpers import u, l
14 from helpers.technology import setEnclosures
15 from helpers.overlay import CfgCache, UpdateSession
16
17 __all__ = ["setup"]
18
19 def createRL(tech, net, layer, coords):
20 return
21 coords = [Point(u(x), u(y)) for x,y in coords]
22 Rectilinear.create(net, tech.getLayer(layer), coords)
23
24 def _routing():
25 return # all commented-out for now
26 af = CRL.AllianceFramework.get()
27 db = DataBase.getDB()
28 tech = db.getTechnology()
29
30 rg = CRL.RoutingGauge.create('pll')
31 rg.setSymbolic(False)
32 metal = tech.getLayer('metal1')
33 via = tech.getLayer('metal1_via1_metal2')
34 setEnclosures(via, metal, (u(0.0), u(0.035)))
35 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
36 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.PinOnly, 0, 0.0,
37 u(0.0), u(0.21), u(0.065), u(0.065), u(0.065), u(0.065),
38 ))
39 metal = tech.getLayer('metal2')
40 via = tech.getLayer('metal1_via1_metal2')
41 setEnclosures(via, metal, (u(0.0), u(0.035)))
42 via = tech.getLayer('metal2_via2_metal3')
43 setEnclosures(via, metal, (u(0.0), u(0.035)))
44 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
45 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.Default, 1, 0.0,
46 u(0.0), u(0.21), u(0.14), u(0.07), u(0.07), u(0.07),
47 ))
48 metal = tech.getLayer('metal3')
49 via = tech.getLayer('metal2_via2_metal3')
50 setEnclosures(via, metal, (u(0.035), u(0.0)))
51 via = tech.getLayer('metal3_via3_metal4')
52 setEnclosures(via, metal, (u(0.035), u(0.0)))
53 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
54 metal, CRL.RoutingLayerGauge.Vertical, CRL.RoutingLayerGauge.Default, 2, 0.0,
55 u(0.0), u(0.21), u(0.14), u(0.07), u(0.07), u(0.07),
56 ))
57 metal = tech.getLayer('metal4')
58 via = tech.getLayer('metal3_via3_metal4')
59 setEnclosures(via, metal, (u(0.0), u(0.0)))
60 via = tech.getLayer('metal4_via4_metal5')
61 setEnclosures(via, metal, (u(0.0), u(0.0)))
62 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
63 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.Default, 3, 0.0,
64 u(0.0), u(0.28), u(0.14), u(0.14), u(0.14), u(0.14),
65 ))
66 metal = tech.getLayer('metal5')
67 via = tech.getLayer('metal4_via4_metal5')
68 setEnclosures(via, metal, (u(0.0), u(0.0)))
69 via = tech.getLayer('metal5_via5_metal6')
70 setEnclosures(via, metal, (u(0.0), u(0.0)))
71 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
72 metal, CRL.RoutingLayerGauge.Vertical, CRL.RoutingLayerGauge.Default, 4, 0.0,
73 u(0.0), u(0.28), u(0.14), u(0.14), u(0.14), u(0.14),
74 ))
75 metal = tech.getLayer('metal6')
76 via = tech.getLayer('metal5_via5_metal6')
77 setEnclosures(via, metal, (u(0.0), u(0.0)))
78 via = tech.getLayer('metal6_via6_metal7')
79 setEnclosures(via, metal, (u(0.0), u(0.0)))
80 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
81 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.Default, 5, 0.0,
82 u(0.0), u(0.28), u(0.14), u(0.14), u(0.14), u(0.14),
83 ))
84 metal = tech.getLayer('metal7')
85 via = tech.getLayer('metal6_via6_metal7')
86 setEnclosures(via, metal, (u(0.0), u(0.0)))
87 via = tech.getLayer('metal7_via7_metal8')
88 setEnclosures(via, metal, (u(0.0), u(0.0)))
89 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
90 metal, CRL.RoutingLayerGauge.Vertical, CRL.RoutingLayerGauge.Default, 6, 0.0,
91 u(0.0), u(0.8), u(0.4), u(0.4), u(0.4), u(0.4),
92 ))
93 metal = tech.getLayer('metal8')
94 via = tech.getLayer('metal7_via7_metal8')
95 setEnclosures(via, metal, (u(0.0), u(0.0)))
96 via = tech.getLayer('metal8_via8_metal9')
97 setEnclosures(via, metal, (u(0.0), u(0.0)))
98 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
99 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.Default, 7, 0.0,
100 u(0.0), u(0.8), u(0.4), u(0.4), u(0.4), u(0.4),
101 ))
102 metal = tech.getLayer('metal9')
103 via = tech.getLayer('metal8_via8_metal9')
104 setEnclosures(via, metal, (u(0.0), u(0.0)))
105 via = tech.getLayer('metal9_via9_metal10')
106 setEnclosures(via, metal, (u(0.0), u(0.0)))
107 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
108 metal, CRL.RoutingLayerGauge.Vertical, CRL.RoutingLayerGauge.Default, 8, 0.0,
109 u(0.0), u(1.6), u(0.8), u(0.8), u(0.8), u(0.8),
110 ))
111 metal = tech.getLayer('metal10')
112 via = tech.getLayer('metal9_via9_metal10')
113 setEnclosures(via, metal, (u(0.0), u(0.0)))
114 rg.addLayerGauge(CRL.RoutingLayerGauge.create(
115 metal, CRL.RoutingLayerGauge.Horizontal, CRL.RoutingLayerGauge.Default, 9, 0.0,
116 u(0.0), u(1.6), u(0.8), u(0.8), u(0.8), u(0.8),
117 ))
118 af.addRoutingGauge(rg)
119 af.setRoutingGauge('LibreSOCMem')
120
121 cg = CRL.CellGauge.create(
122 'LibreSOCMem', 'metal2',
123 u(0.4), u(4.0), u(0.4),
124 )
125 af.addCellGauge(cg)
126 af.setCellGauge('LibreSOCMem')
127
128 # Place & Route setup
129 with CfgCache(priority=Cfg.Parameter.Priority.ConfigurationFile) as cfg:
130 cfg.lefImport.minTerminalWidth = 0.0
131 cfg.crlcore.groundName = 'vss'
132 cfg.crlcore.powerName = 'vdd'
133 cfg.etesian.aspectRatio = 1.00
134 cfg.etesian.aspectRatio = [10, 1000]
135 cfg.etesian.spaceMargin = 0.10
136 cfg.etesian.uniformDensity = False
137 cfg.etesian.routingDriven = False
138 cfg.etesian.feedNames = 'tie_x0,fill_x0'
139 cfg.etesian.cell.zero = 'zero_x0'
140 cfg.etesian.cell.one = 'one_x0'
141 cfg.etesian.bloat = 'disabled'
142 cfg.etesian.effort = 2
143 cfg.etesian.effort = (
144 ('Fast', 1),
145 ('Standard', 2),
146 ('High', 3 ),
147 ('Extreme', 4 ),
148 )
149 cfg.etesian.graphics = 2
150 cfg.etesian.graphics = (
151 ('Show every step', 1),
152 ('Show lower bound', 2),
153 ('Show result only', 3),
154 )
155 cfg.anabatic.routingGauge = 'LibreSOCMem'
156 cfg.anabatic.globalLengthThreshold = 1450
157 cfg.anabatic.saturateRatio = 90
158 cfg.anabatic.saturateRp = 10
159 cfg.anabatic.topRoutingLayer = 'metal10'
160 cfg.anabatic.edgeLength = 48
161 cfg.anabatic.edgeWidth = 8
162 cfg.anabatic.edgeCostH = 9.0
163 cfg.anabatic.edgeCostK = -10.0
164 cfg.anabatic.edgeHInc = 1.0
165 cfg.anabatic.edgeHScaling = 1.0
166 cfg.anabatic.globalIterations = 10
167 cfg.anabatic.globalIterations = [ 1, 100 ]
168 cfg.anabatic.gcell.displayMode = 1
169 cfg.anabatic.gcell.displayMode = (("Boundary", 1), ("Density", 2))
170 cfg.katana.hTracksReservedLocal = 4
171 cfg.katana.hTracksReservedLocal = [0, 20]
172 cfg.katana.vTracksReservedLocal = 3
173 cfg.katana.vTracksReservedLocal = [0, 20]
174 cfg.katana.termSatReservedLocal = 8
175 cfg.katana.termSatThreshold = 9
176 cfg.katana.eventsLimit = 4000002
177 cfg.katana.ripupCost = 3
178 cfg.katana.ripupCost = [0, None]
179 cfg.katana.strapRipupLimit = 16
180 cfg.katana.strapRipupLimit = [1, None]
181 cfg.katana.localRipupLimit = 9
182 cfg.katana.localRipupLimit = [1, None]
183 cfg.katana.globalRipupLimit = 5
184 cfg.katana.globalRipupLimit = [1, None]
185 cfg.katana.longGlobalRipupLimit = 5
186 cfg.chip.padCoreSide = 'South'
187
188 # Plugins setup
189 with CfgCache(priority=Cfg.Parameter.Priority.ConfigurationFile) as cfg:
190 cfg.chip.block.rails.count = 5
191 cfg.chip.block.rails.hWidth = u(2.68)
192 cfg.chip.block.rails.vWidth = u(2.68)
193 cfg.chip.block.rails.hSpacing = u(0.7)
194 cfg.chip.block.rails.vSpacing = u(0.7)
195 cfg.clockTree.minimumSide = l(600)
196 cfg.clockTree.buffer = 'buf_x2'
197 cfg.clockTree.placerEngine = 'Etesian'
198 cfg.block.spareSide = 10
199 cfg.spares.buffer = 'buf_x8'
200 cfg.spares.maxSinks = 31
201
202
203 def _load():
204 af = CRL.AllianceFramework.get()
205 db = DataBase.getDB()
206 tech = db.getTechnology()
207 rootlib = db.getRootLibrary()
208
209 lib = Library.create(rootlib, 'pll')
210
211 space = 0.1
212
213 cell = Cell.create(lib, 'pll')
214 with UpdateSession():
215 cell.setAbutmentBox(Box(
216 #u(0.0), u(0.0), u(13.5), u(2.025),
217 u(0.0), u(0.0), u(space*125), u(space*25),
218 ))
219 nets = {
220 #'*': Net.create(cell, '*'),
221 'ref_v': Net.create(cell, 'ref_v'),
222 'div_out_test': Net.create(cell, 'div_out_test'),
223 'a0': Net.create(cell, 'a0'),
224 'a1': Net.create(cell, 'a1'),
225 'vco_test_ana': Net.create(cell, 'vco_test_ana'),
226 'out_v': Net.create(cell, 'out_v'),
227 'vdd': Net.create(cell, 'vdd'),
228 'vss': Net.create(cell, 'vss'),
229 }
230 nets['vdd'].setGlobal(True)
231 nets['vss'].setGlobal(True)
232
233 # set net directions
234 nets['ref_v'].setDirection( Net.Direction.IN )
235 nets['a0'].setDirection( Net.Direction.IN )
236 nets['a1'].setDirection( Net.Direction.IN )
237 nets['div_out_test'].setDirection( Net.Direction.OUT )
238 nets['vco_test_ana'].setDirection( Net.Direction.OUT )
239 nets['out_v'].setDirection( Net.Direction.OUT )
240 nets['vdd'].setType( Net.Type.POWER )
241 nets['vdd'].setDirection( Net.Direction.IN )
242 nets['vss'].setType( Net.Type.GROUND )
243 nets['vss'].setDirection( Net.Direction.IN )
244
245 # create series of stepped pins
246 x = space*20
247 wid = space
248 step = wid*5
249 for cname in ['ref_v', 'div_out_test', 'a0', 'a1', 'vco_test_ana',
250 'out_v', 'vdd', 'vss']:
251 net = nets[cname]
252 pin = Vertical.create(
253 net, tech.getLayer('metal1'),
254 u(x), u(wid), u(0), u(space*15),
255 )
256 x += step
257 net.setExternal(True)
258 NetExternalComponents.setExternal(pin)
259
260 if False:
261 net = nets['*']
262 createRL(
263 tech, net, 'active',
264 ((1.105,1.0),(1.4375,1.0),(1.4375,0.24),(0.9625,0.24),(0.9625,1.0),(1.105,1.0)),
265 )
266 net = nets['*']
267 createRL(
268 tech, net, 'nimplant',
269 ((1.105,0.235),(0.895,0.235),(0.895,0.17),(0.705,0.17),(0.705,0.235),(0.55,0.235),(0.55,0.615),(0.495,0.615),(0.495,0.55),(0.305,0.55),(0.305,0.615),(0.1575,0.615),(0.1575,1.385),(0.305,1.385),(0.305,1.45),(0.495,1.45),(0.495,1.385),(0.65,1.385),(0.65,1.005),(0.705,1.005),(0.705,1.07),(0.895,1.07),(0.895,1.005),(1.105,1.005),(1.105,1.07),(1.295,1.07),(1.295,1.005),(1.4425,1.005),(1.4425,0.235),(1.295,0.235),(1.295,0.17),(1.105,0.17),(1.105,0.235)),
270 )
271 createRL(
272 tech, net, 'nimplant',
273 ((0.515,3.595),(0.515,3.765),(0.685,3.765),(0.685,3.595),(0.515,3.595)),
274 )
275 createRL(
276 tech, net, 'vthg',
277 ((1.105,0.17),(1.105,1.07),(1.295,1.07),(1.295,0.17),(1.105,0.17)),
278 )
279 createRL(
280 tech, net, 'vthg',
281 ((1.105,2.13),(1.105,3.87),(1.295,3.87),(1.295,2.13),(1.105,2.13)),
282 )
283 createRL(
284 tech, net, 'vthg',
285 ((0.305,0.55),(0.305,1.45),(0.495,1.45),(0.495,0.55),(0.305,0.55)),
286 )
287 createRL(
288 tech, net, 'vthg',
289 ((0.305,2.53),(0.305,3.47),(0.495,3.47),(0.495,2.53),(0.305,2.53)),
290 )
291 createRL(
292 tech, net, 'vthg',
293 ((0.705,0.17),(0.705,1.07),(0.895,1.07),(0.895,0.17),(0.705,0.17)),
294 )
295 createRL(
296 tech, net, 'vthg',
297 ((0.705,2.53),(0.705,3.47),(0.895,3.47),(0.895,2.53),(0.705,2.53)),
298 )
299 createRL(
300 tech, net, 'pimplant',
301 ((1.105,2.195),(0.9575,2.195),(0.9575,2.595),(0.895,2.595),(0.895,2.53),(0.705,2.53),(0.705,2.595),(0.7,2.595),(0.495,2.595),(0.495,2.53),(0.305,2.53),(0.305,2.595),(0.15,2.595),(0.15,3.6825),(0.25,3.6825),(0.25,3.405),(0.305,3.405),(0.305,3.47),(0.495,3.47),(0.495,3.405),(0.5,3.405),(0.705,3.405),(0.705,3.47),(0.895,3.47),(0.895,3.405),(0.95,3.405),(0.95,3.7875),(0.9575,3.7875),(0.9575,3.805),(1.105,3.805),(1.105,3.87),(1.295,3.87),(1.295,3.805),(1.4425,3.805),(1.4425,2.195),(1.295,2.195),(1.295,2.13),(1.105,2.13),(1.105,2.195)),
302 )
303 createRL(
304 tech, net, 'pimplant',
305 ((0.115,0.195),(0.115,0.365),(0.285,0.365),(0.285,0.195),(0.115,0.195)),
306 )
307 if False:
308 net = nets['vss']
309 createRL(
310 tech, net, 'pwell',
311 ((-0.12,-0.32),(-0.12,1.92),(1.72,1.92),(1.72,-0.32),(-0.12,-0.32)),
312 )
313 createRL(
314 tech, net, 'metal1',
315 ((0.0,0.0),(0.0,0.48),(1.6,0.48),(1.6,0.0),(0.0,0.0)),
316 )
317 if False:
318 Vertical.create(
319 net, tech.getLayer('metal1.pin'),
320 u(0.8), u(1.6), u(0.0), u(0.48),
321 )
322 pin = Vertical.create(
323 net, tech.getLayer('metal1'),
324 u(0.8), u(1.6), u(0.0), u(0.48),
325 )
326 net.setExternal(True)
327 NetExternalComponents.setExternal(pin)
328 createRL(
329 tech, net, 'active',
330 ((0.12,0.2),(0.12,0.36),(0.28,0.36),(0.28,0.2),(0.12,0.2)),
331 )
332 createRL(
333 tech, net, 'active',
334 ((0.9625,0.3075),(1.0375,0.3075),(1.0375,0.3825),(0.9625,0.3825),(0.9625,0.3075)),
335 )
336 createRL(
337 tech, net, 'contact',
338 ((0.1675,0.2475),(0.2325,0.2475),(0.2325,0.3125),(0.1675,0.3125),(0.1675,0.2475)),
339 )
340 createRL(
341 tech, net, 'contact',
342 ((0.9675,0.3125),(1.0325,0.3125),(1.0325,0.3775),(0.9675,0.3775),(0.9675,0.3125)),
343 )
344 if False:
345 net = nets['*']
346 createRL(
347 tech, net, 'active',
348 ((1.105,3.8),(1.4375,3.8),(1.4375,2.2),(0.9625,2.2),(0.9625,3.8),(1.105,3.8)),
349 )
350 if False:
351 net = nets['vdd']
352 createRL(
353 tech, net, 'nwell',
354 ((-0.12,1.92),(-0.12,4.32),(1.72,4.32),(1.72,1.92),(-0.12,1.92)),
355 )
356 createRL(
357 tech, net, 'metal1',
358 ((0.0,3.52),(0.0,4.0),(1.6,4.0),(1.6,3.52),(0.0,3.52)),
359 )
360 if False:
361 Vertical.create(
362 net, tech.getLayer('metal1.pin'),
363 u(0.8), u(1.6), u(3.52), u(4.0),
364 )
365 pin = Vertical.create(
366 net, tech.getLayer('metal1'),
367 u(0.8), u(1.6), u(3.52), u(4.0),
368 )
369 net.setExternal(True)
370 NetExternalComponents.setExternal(pin)
371 createRL(
372 tech, net, 'active',
373 ((0.52,3.6),(0.52,3.76),(0.68,3.76),(0.68,3.6),(0.52,3.6)),
374 )
375 createRL(
376 tech, net, 'active',
377 ((0.9625,3.5675),(1.0375,3.5675),(1.0375,3.7825),(0.9625,3.7825),(0.9625,3.5675)),
378 )
379 createRL(
380 tech, net, 'active',
381 ((0.1625,3.6025),(0.2375,3.6025),(0.2375,3.6775),(0.1625,3.6775),(0.1625,3.6025)),
382 )
383 createRL(
384 tech, net, 'contact',
385 ((0.5675,3.6475),(0.6325,3.6475),(0.6325,3.7125),(0.5675,3.7125),(0.5675,3.6475)),
386 )
387 createRL(
388 tech, net, 'contact',
389 ((0.9675,3.5725),(1.0325,3.5725),(1.0325,3.6375),(0.9675,3.6375),(0.9675,3.5725)),
390 )
391 createRL(
392 tech, net, 'contact',
393 ((0.9675,3.7125),(1.0325,3.7125),(1.0325,3.7775),(0.9675,3.7775),(0.9675,3.7125)),
394 )
395 createRL(
396 tech, net, 'contact',
397 ((0.1675,3.6075),(0.2325,3.6075),(0.2325,3.6725),(0.1675,3.6725),(0.1675,3.6075)),
398 )
399 if False:
400 net = nets['*']
401 createRL(
402 tech, net, 'active',
403 ((0.305,1.38),(0.495,1.38),(0.495,0.62),(0.1625,0.62),(0.1625,1.38),(0.305,1.38)),
404 )
405 net = nets['*']
406 createRL(
407 tech, net, 'active',
408 ((0.425,2.6),(0.155,2.6),(0.155,3.6775),(0.245,3.6775),(0.245,3.4),(0.705,3.4),(0.705,2.6),(0.425,2.6)),
409 )
410 net = nets['*']
411 createRL(
412 tech, net, 'active',
413 ((0.705,1.0),(1.0375,1.0),(1.0375,0.24),(0.555,0.24),(0.555,1.0),(0.705,1.0)),
414 )
415 createRL(
416 tech, net, 'poly',
417 ((0.775,2.545),(0.775,3.455),(0.825,3.455),(0.825,2.0375),(0.9975,2.0375),(0.9975,1.9625),(0.775,1.9625),(0.775,2.545)),
418 )
419 createRL(
420 tech, net, 'metal1',
421 ((0.9675,1.2675),(0.9675,1.9325),(0.9275,1.9325),(0.9275,2.0675),(0.9675,2.0675),(0.9675,3.455),(1.0325,3.455),(1.0325,0.545),(0.9675,0.545),(0.9675,1.1325),(0.9275,1.1325),(0.9275,1.2675),(0.9675,1.2675)),
422 )
423 if False:
424 Vertical.create(
425 net, tech.getLayer('metal1.pin'),
426 u(1.0), u(0.065), u(0), u(3.455),
427 )
428 pin = Vertical.create(
429 net, tech.getLayer('metal1'),
430 u(1.0), u(0.065), u(0), u(3.455),
431 )
432 net.setExternal(True)
433 NetExternalComponents.setExternal(pin)
434 createRL(
435 tech, net, 'contact',
436 ((0.9275,1.1675),(0.9925,1.1675),(0.9925,1.2325),(0.9275,1.2325),(0.9275,1.1675)),
437 )
438 createRL(
439 tech, net, 'contact',
440 ((0.9275,1.9675),(0.9925,1.9675),(0.9925,2.0325),(0.9275,2.0325),(0.9275,1.9675)),
441 )
442 if False:
443 net = nets['*']
444 createRL(
445 tech, net, 'active',
446 ((0.775,2.6),(0.705,2.6),(0.705,3.4),(0.955,3.4),(0.955,3.7825),(1.045,3.7825),(1.045,2.6),(0.775,2.6)),
447 )
448
449
450 af.wrapLibrary(lib, 0)
451
452 return lib
453
454 def setup():
455 lib = _load()
456 _routing()
457
458 return lib