来源:IC技能搬用工
如果你是一名模拟IC设计者,如果你曾经或者将要换工艺,那么你一定寻找过原理图迁移工艺的方法,下面介绍的就是可以实现这个功能的脚本。
1/*************************************************************************
2* DISCLAIMER: The following code is provided for Cadence customers *
3* to use at their own risk. The code may require modification to *
4* satisfy the requirements of any user. The code and any modifications *
5* to the code may not be compatible with current or future versions of *
6* Cadence products. THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, *
7* INCLUDING WITHOUT LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED *
8* WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. *
9*************************************************************************/
10
11/*
12USAGE:
13======
14
15This SKILL code runs on all the schematic views of a library and finds if
16instances of a particular device or cell has been used or not. If they are
17found then they need to be replaced with a new cell of a new library.
18List of cell and its mapping to new cell has to be provided via deviceMapList.
19For example:
20deviceMapList='(("nmos1v" ("newRefLib" "nmos2v")) ("pmos1v" ("newRefLib" "pmos2v")))
21
22In above example, nmos1v is supposed to be swapped with newRefLib nmos2v cell.
23pmos1v is supposed to be swapped with newRefLib pmos2v cell.
24
25The code copies old instance transform (placement info) and important properties
26which needs to be paased on to new cell. And then it copies the old property
27values to new properties. The old and new property mapping is supposed to be
28provided via propMapList.
29For example:
30propMapList='(("L" "l") ("W" "w") ("M" "m"))
31
32In the above list, value of property "L" is supposed to be copied to "l".
33value of property "W" is supposed to be copied to "w".
34value of property "M" is supposed to be copied to "m".
35
36Load the SKILL code in CIW:
37load "CCSdelInstCreate.il"
38
39Run in CIW:
40CCSdelInstCreate("MYLIB")
41
42*/
43
44procedure( CCSdelInstCreate(library @optional
45;; Modify device list as per your primitive devices
46( deviceMapList '(("nmos" ("OALIB" "nmos4")) ("pmos" ("OALIB" "pmos4"))))
47;; Modify propMapList as per the properties you want to copy
48 (propMapList '(("l" "L") ("w" "W") ("m" "m")) )
49 "tll")
50let((cv cellname name transform libId instId deviceList deviceTable propTable)
51
52libId=ddGetObj(library)
53unless(libId error("Specified library: %s does not exists, cannot proceed!\n" library))
54
55deviceTable=makeTable("deviceTable")
56foreach(dev deviceMapList
57 deviceTable[car(dev)]=cadr(dev)
58 deviceList=cons(car(dev) deviceList)
59 )
60
61propTable=makeTable("propTable")
62foreach(cellId libId~>cells
63;; Check if the cell has schematic view
64 if(exists(x cellId~>views~>name (x=="schematic"))
65 then
66printf("Operating on Lib: %s Cell:%s View: schematic\n" library cellId~>name )
67 cv=dbOpenCellViewByType(library cellId~>name "schematic" "schematic" "a")
68;; Check if cellview has the instances of given device
69 foreach(inst cv~>instances
70 if(member(inst~>cellName deviceList) then
71 transform=inst~>transform
72 name=inst~>name
73 cellname=inst~>cellName
74
75;; Populate old property values to table
76/*
77 foreach(propList propMapList
78 propTable[car(propList)]=dbFindProp(inst car(propList))~>value
79 ) ;foreach
80*/
81 cdfId=cdfGetInstCDF(inst)
82 foreach(propList propMapList
83 propTable[car(propList)]=cdfFindParamByName(cdfId car(propList))~>value
84 ) ;foreach
85
86;; Delete old instance
87 dbDeleteObject(inst)
88
89;; Create new instance
90 instId=dbCreateInstByMasterName(cv car(deviceTable[cellname])
91 cadr(deviceTable[cellname])
92 "symbol" name
93 car(transform)
94 cadr(transform) )
95
96;; Polpulate the inst parameter values from prop table
97 foreach(propList propMapList
98 dbSet(instId propTable[car(propList)] cadr(propList))
99 )
100 ) ;if member
101 ) ;foreach inst
102
103/* To check and save the cellview uncomment below line */
104 ; if(dbIsCellViewModified(cv) then schCheck(cv) dbSave(cv))
105 ) ;if
106 ) ;foreach
107t
108 );let
109);proc
左右滑动可以查看更多内容哦!
使用上面的脚本可以完成器件替换,但是很可能替换完成之后仿真中依然存在错误,原因是在替换过程中器件的参数虽然填入,但是未触发相应的CDF callbacks函数,所以还需要用下文提供的函数重新触发CDF callbacks.
第一个脚本实现触发CDF callbacks函数,脚本内容比较复杂,具体内容小目同学没有认真看过,这里先做一次“拿来主义”者,内容如下(文件名:CCSinvokeCdfCallbacks.il):
1/* CCSinvokeCdfCallbacks.il
2
3Date Jul 11, 1995
4Modified Dec 23, 2013
5
6Invoke all the CDF callbacks for instances
7
8The main entry point is (CCSinvokeCdfCallbacks cellView)
9which invokes all the CDF callbacks for every instance in
10a cellView. This has some keyword arguments which allow debug
11messages to be displayed, to invoke the formInitProc if needed,
12and to invoke using the instance CDF directly, rather than try
13to create something that looks more like the effective CDF that
14is found when the callbacks are normally invoked from the forms.
15
16You can use the variable CCScallbackPatternsToIgnore so
17that some callbacks can be omitted.
18
19Extended in version 1.16 to allow ?filterFunc to be passed.
20This is a function that gets the cdf, the param name (nil
21for the initProc) and callback string.
22The function should return t if the callback should be called,
23and nil otherwise. For example:
24
25procedure(MYfilterFunc(cdf paramName callback)
26 destructuringBind(
27 (lib @optional cell) CCSgetLibCellFromCDF(cdf)
28 ; t if any other parameter than w for gpdk090/nmos1v
29 !(lib=="gpdk090" && cell=="nmos1v" && param=="w")
30 )
31)
32
33CCSinvokeCdfCallbacks(geGetEditCellView() ?filterFunc 'MYfilterFunc)
34
35***************************************************
36
37SCCS Info: @(#) CCSinvokeCdfCallbacks.il 12/23/13.12:50:52 1.16
38
39*/
40
41/*******************************************************************************
42* DISCLAIMER: The following code is provided for Cadence customers to use at *
43* their own risk. The code may require modification to satisfy the *
44* requirements of any user. The code and any modifications to the code may *
45* not be compatible with current or future versions of Cadence products. *
46* THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT *
47* LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *
48* OR FITNESS FOR A PARTICULAR USE. *
49*******************************************************************************/
50/***************************************************************
51* *
52* The variable CCScallbackPatternsToIgnore is set to be *
53* a list of patterns against which the callbacks are *
54* checked. If any of these patterns are matched then *
55* the callback is not invoked. *
56* *
57***************************************************************/
58
59(unless (boundp 'CCScallbackPatternsToIgnore)
60 (setq CCScallbackPatternsToIgnore
61 '("^MYPDKNot_Allowed.*")))
62
63/***************************************************************
64* *
65* (CCSshouldCallbackBeExecuted callback filterFunc cdf param) *
66* *
67* This checks the callback against all the patterns defined *
68* in the list CCScallbackPatternsToIgnore to determine *
69* whether the callback should be executed or not. *
70* If filterFunc is passed, call with cdf, param name and *
71* callback - this should return t or nil *
72* *
73***************************************************************/
74
75(procedure (CCSshouldCallbackBeExecuted callback filterFunc cdf param)
76 (and
77 (forall pattern CCScallbackPatternsToIgnore
78 (null (rexMatchp pattern callback)))
79 (if filterFunc
80 (funcall filterFunc cdf param callback)
81 t
82 )
83 )
84 )
85
86/***************************************************************
87* *
88* (CCSgetLibCellFromCDF cdf) *
89* *
90* Utility function to retrieve a list of lib and cell name *
91* from the CDF, regardless of whether it is an inst, cell or *
92* lib CDF. For lib CDF it only returns a list of the lib name *
93* *
94***************************************************************/
95
96(procedure (CCSgetLibCellFromCDF cdf)
97 (let (id)
98 (setq id (getq cdf id))
99 (case (type id)
100 (dbobject
101 (list (getq id libName) (getq id cellName))
102 )
103 (ddCellType
104 (list (getq (getq id lib) name) (getq id name))
105 )
106 (ddLibType
107 (list (getq id name))
108 )
109 )
110 )
111 )
112
113/*********************************************************************
114* *
115* (CCScreateEffectiveCDFLookalike cdf [lookalikeParams] *
116* [resetLookalikeParams]) *
117* *
118* Create a structure which looks (sort of) like an effective *
119* CDF. The reason for creating this is to allow the "id" parameter *
120* to be correctly set to the cell, rather than the instance, which *
121* is what happens if we use the cdfGetInstCDF() function to simulate *
122* cdfgData. The lookalikeParams optional parameter allows creation *
123* of the parameters to be "lookalike" as well, so that callbacks can *
124* be called even if there is no actual instance. By default, the *
125* parameters will be reset with using lookalikeParams, unless you *
126* pass nil as the third argument. *
127* *
128*********************************************************************/
129
130(procedure (CCScreateEffectiveCDFLookalike cdf @optional lookalikeParams
131 (resetLookalikeParams t))
132 (let (new cdfFields newParam)
133 (unless (getd 'make_CCSeffCDF)
134 ;---------------------------------------------------------
135 ; Because some slots appear twice in cdf->? have
136 ; to make the list unique
137 ;---------------------------------------------------------
138 (setq cdfFields (makeTable 'cdfFields))
139 (foreach field (getq cdf ?)
140 (setarray cdfFields field t)
141 )
142 (eval `(defstruct CCSeffCDF ,@(getq cdfFields ?))))
143 (setq new (make_CCSeffCDF))
144 (when (and lookalikeParams (null (getd 'make_CCSeffCDFparam)))
145 (setq cdfFields (makeTable 'cdfFields))
146 (foreach field (getq (car (getq cdf parameters)) ?)
147 (setarray cdfFields field t))
148 (eval `(defstruct CCSeffCDFparam ,@(getq cdfFields ?))))
149 ;-----------------------------------------------------------------
150 ; populate the effective cdf with the top level cdf attributes
151 ;-----------------------------------------------------------------
152 (foreach param (getq cdf ?)
153 (putprop new (get cdf param) param))
154 ;-----------------------------------------------------------------
155 ; Set the id and type attributes appropriately
156 ;-----------------------------------------------------------------
157 (when (equal (getq new type) "instData")
158 (putpropq new (dbGetq (dbGetq (getq cdf id) master) cell) id)
159 (putpropq new "cellData" type)
160 )
161 ;-----------------------------------------------------------------
162 ; If we want the parameters to be lookalike too, create those
163 ;-----------------------------------------------------------------
164 (when lookalikeParams
165 (putpropq new
166 (foreach mapcar param (getq cdf parameters)
167 (setq newParam (make_CCSeffCDFparam))
168 (foreach slot (getq param ?)
169 (putprop newParam (get param slot) slot))
170 (when resetLookalikeParams
171 ; reset the value to defValue for safety
172 (putpropq newParam (getq newParam defValue) value)
173 )
174 newParam
175 )
176 parameters)
177 ) ; when
178 ;-----------------------------------------------------------------
179 ; Add the parameters as properties in the effective cdf
180 ;-----------------------------------------------------------------
181 (foreach param (getq new parameters)
182 (putprop new param (getq param name))
183 )
184 new
185 )
186 )
187
188/*******************************************************************
189* *
190* (CCSaddFormFieldsToEffectiveCDFLookalike cdf inst) *
191* *
192* Populate four extra fields - libraryName, cellName, viewName and *
193* instanceName to emulate the forms on the forms - i.e. so that *
194* cdfgForm gets these slots. This is for callbacks which (badly) *
195* use cdfgForm to find out libraryName, cellName and viewName. *
196* *
197*******************************************************************/
198
199(procedure (CCSaddFormFieldsToEffectiveCDFLookalike cdf inst)
200 (let (fieldData value)
201 (unless (getd 'make_CCSeffCDFFormFields)
202 (defstruct CCSeffCDFFormFields value defValue lastValue
203 editable enabled invisible)
204 )
205 (foreach (field attr) '(libraryName cellName viewName instanceName)
206 '(libName cellName viewName name)
207 (setq value (dbGet inst attr))
208 (setq fieldData
209 (make_CCSeffCDFFormFields
210 ?value value
211 ?defValue value
212 ?lastValue value
213 ?editable t
214 ?enabled t
215 ?invisible nil
216 ))
217 (putprop cdf fieldData field)
218 )
219 cdf
220 )
221 )
222
223/********************************************************************
224* *
225* (CCSinvokeObjCdfCallbacks cdf @key (debug nil) order *
226* (callInitProc nil) (setCdfgForm t) (filterFunc nil)) *
227* *
228* Underlying function which does all the real work. This *
229* is separated from the original function CCSinvokeInstCdfCallbacks *
230* so that this can be called with a completely virtual CDF. *
231* See CCSinvokeInstCdfCallbacks for a description of the *
232* arguments - note that there is the ability to control whether *
233* cdfgForm is set or not. *
234* Return nil if any callback failed with a SKILL error, t otherwise*
235* *
236********************************************************************/
237
238(procedure (CCSinvokeObjCdfCallbacks cdf @key (debug nil) order
239 (callInitProc nil) (setCdfgForm t)
240 filterFunc)
241 ;----------------------------------------------------------------------
242 ; Make cdfgData and cdfgForm dynamically scoped, to avoid
243 ; interfering with any global usage of these variables
244 ;----------------------------------------------------------------------
245 (let (callback parameters cdfgData cdfgForm (success t))
246 ;-----------------------------------------------------------------
247 ; Set the cdfgData to be the instance CDF
248 ;-----------------------------------------------------------------
249 (setq cdfgData cdf)
250 (setq cdfgForm nil)
251 (when setCdfgForm
252 ;---------------------------------------------------------------
253 ; some callbacks use cdfgForm instead
254 ;---------------------------------------------------------------
255 (setq cdfgForm cdfgData)
256 )
257 ;-----------------------------------------------------------------
258 ; Call the formInitProc if there is one.
259 ;-----------------------------------------------------------------
260 (when callInitProc
261 (setq callback (getq cdfgData formInitProc))
262 (when (and callback
263 (nequal callback "")
264 (CCSshouldCallbackBeExecuted callback filterFunc
265 cdfgData nil))
266 (when debug
267 (printf " Invoking formInitProc: '%s'\n" callback))
268 ;-----------------------------------------------------
269 ; Evaluate the callback
270 ;-----------------------------------------------------
271 (unless
272 (errset (evalstring
273 (strcat callback "(cdfgData)")) t)
274 (setq success nil)
275 )
276 )
277 )
278 ;-----------------------------------------------------------------
279 ; Control order of parameter evaluation. If order specified,
280 ; just do those, otherwise do all in arbitrary order
281 ;-----------------------------------------------------------------
282 (if order
283 (setq parameters (foreach mapcar param order
284 (get cdfgData param)))
285 (setq parameters (getq cdfgData parameters))
286 )
287 ;-----------------------------------------------------------------
288 ; loop through all parameters
289 ;-----------------------------------------------------------------
290 (foreach param parameters
291 (setq callback (getq param callback))
292 (when (and callback
293 (nequal callback "")
294 (CCSshouldCallbackBeExecuted callback filterFunc
295 cdfgData
296 (getq param name)))
297 (when debug
298 (printf " Invoking callback for '%s': '%s'\n"
299 (getq param name) callback))
300 ;--------------------------------------------------
301 ; evaluate the callback
302 ;--------------------------------------------------
303 (unless (errset (evalstring callback) t)
304 (setq success nil)
305 )
306 ))
307 success))
308
309/*****************************************************************
310* *
311* (CCSinvokeInstCdfCallbacks instance [?debug debug] *
312* [?order order] [?callInitProc callInitProc] [?useInstCDF nil] *
313* [?addFormFields nil] [?filterFunc nil] *
314* *
315* Invoke all the parameter callbacks in the CDF for an instance. *
316* This won't do anything if it doesn't have any CDF. *
317* debug is a flag to turn on debug messages. order allows just *
318* selected parameters to be called, in the specified order. *
319* callInitProc allows the formInitProc to be called. useInstCDF *
320* tells the formInitProc to be called with the instCDF rather *
321* than the effective lookalike CDF. addFormFields tells it to *
322* add the libraryName/cellName/viewName slots to emulate the *
323* fields on the cdfgForm, which are used by some bad callback *
324* code - note this is only done if useInstCDF is nil *
325* *
326*****************************************************************/
327
328(procedure (CCSinvokeInstCdfCallbacks instance @key (debug nil) order
329 (callInitProc nil) (useInstCDF nil)
330 (addFormFields nil) (filterFunc nil))
331 ;----------------------------------------------------------------------
332 ; Make cdfgData and cdfgForm dynamically scoped, to avoid
333 ; interfering with any global usage of these variables
334 ;----------------------------------------------------------------------
335 (let (cdf)
336 (when debug
337 (printf " Invoking callbacks for instance '%s'\n"
338 (dbGetq instance name)))
339 ;-----------------------------------------------------------------
340 ; Set the cdf to be the instance CDF
341 ;-----------------------------------------------------------------
342 (setq cdf (cdfGetInstCDF instance))
343 (unless useInstCDF
344 (setq cdf (CCScreateEffectiveCDFLookalike cdf))
345 (when addFormFields
346 (CCSaddFormFieldsToEffectiveCDFLookalike cdf instance)
347 )
348 )
349 ;-----------------------------------------------------------------
350 ; Return value will be nil if any callbacks had errors
351 ;-----------------------------------------------------------------
352 (CCSinvokeObjCdfCallbacks
353 cdf
354 ?debug debug ?order order ?callInitProc callInitProc
355 ?setCdfgForm (null useInstCDF) ?filterFunc filterFunc
356 )
357 ))
358
359/***************************************************************
360* *
361* (CCSconvertCdfToPcellParams cdf) *
362* *
363* Take modified parameters in the CDF, and return this as the *
364* list of parameter names, types, and values that is *
365* needed to create a pcell with dbCreateParamInst. *
366* *
367***************************************************************/
368
369(procedure (CCSconvertCdfToPcellParams cdf)
370 (foreach mapcar param
371 (setof par (getq cdf parameters)
372 (nequal (getq par value) (getq par defValue)))
373 (list
374 (getq param name)
375 ; need to map this to pcell parameter types...
376 (case (getq param paramType)
377 (("int" "boolean" "float" "string") (getq param paramType))
378 (t "string")
379 )
380 (getq param value)
381 )
382 )
383 )
384
385/***************************************************************
386* *
387* (CCSinvokeCdfCallbacks cellView @key (debug nil) *
388* (callInitProc nil) (useInstCDF nil) (addFormFields nil)) *
389* (filterFunc nil) *
390* *
391* Invoke the CDF callbacks for all instances in the cellView. *
392* Returns nil if any callback had a SKILL error, otherwise t *
393* *
394***************************************************************/
395
396(procedure (CCSinvokeCdfCallbacks cellView @key (debug nil)
397 (order nil)
398 (callInitProc nil) (useInstCDF nil)
399 (addFormFields nil) (filterFunc nil))
400 (let ((success t))
401 (when debug
402 (printf "Invoking callbacks for all instances in cell '%s'\n"
403 (dbGetq cellView cellName)))
404 (foreach instance (dbGetq cellView instances)
405 (unless
406 (CCSinvokeInstCdfCallbacks instance
407 ?debug debug
408 ?order order
409 ?callInitProc callInitProc
410 ?useInstCDF useInstCDF
411 ?addFormFields addFormFields
412 ?filterFunc filterFunc
413 )
414 (setq success nil)
415 )
416 ) ; foreach
417 success
418 )
419 ) ; procedure
第二个脚本遍历指定Library下所有原理图,并依次触发该原理图中cell的CDF callbacks函数,内容如下(文件名:CCSCdfCallbackEntireLib.il)。
1/*
2This SKILL code is not sufficient on its own. You need to also
3download CCSinvokeCdfCallbacks.il file before running this code.
4
5load "CCSinvokeCdfCallbacks.il"
6load "CCSCdfCallbackEntireLib.il"
7
8CCSCdfCallbackEntireLib("MYLIB")
9
10Where "MYLIB" is the design library.
11
12*/
13
14
15
16/***************************************************************
17* *
18* (CCSCdfCallbackEntireLib libName *
19* *
20* Invoke the CDF callbacks for all schematics of given library *
21* *
22***************************************************************/
23
24procedure(CCSCdfCallbackEntireLib(library)
25let((libName)
26unless(libName=ddGetObj(library) error("Library %s does not exists\n" library))
27foreach(cell libName~>cells
28 if(exists(x cell~>views~>name (x=="schematic"))
29 then
30 printf("Processing cell %s\n" cell~>name)
31;Open schematic
32 cv = dbOpenCellViewByType(library cell~>name "schematic" "schematic" "a")
33
34/* Run CDF Callback.
35
36Modify the below line if you want to run it with callInitProc and userInstCDF:
37CCSinvokeCdfCallbacks(cv ?callInitProc t ?useInstCDF t)
38
39Modify the below line if want to run callback of certain parameters only and in a particular order:
40CCSinvokeCdfCallbacks(cv ?order list("l" "w"))
41
42*/
43
44 CCSinvokeCdfCallbacks(cv)
45;Run schematic heck and Save
46 schCheck(cv)
47 dbSave(cv)
48 ) ;if
49 );foreach
50) ;let
51) ; procedure
以上是原理图迁移工艺脚本需要使用的代码,至于代码中更具体的内容,欢迎感兴趣的同学在评论中积极讨论,当然对于大部分同学来说只需要了解如何使用脚本即可。
deviceMapList:指定器件的对应关系,格式为:("old_cell name" ("lib_name" "new_cell name")).
propMapList:指定器件参数的对应关系,比如,不同工艺中有可能对MOS的栅长、栅宽等参数叫法不一致,所以需要用户提供正确的对应关系,否则可能出现替换之后属性错误的情况。
最简单的方法是查看CDF中属性名称,在CIW界面:Tools->CDF->Edit,然后按照下图中标注选择Library Name、Cell Name等,即可在Component Parameter一项查看到器件参数名称。
实例:smic18mmrf工艺向tsmc18rf迁移的操作,CCSdelInstCreate.il脚本第46~48行内容修改如下:
46( deviceMapList '(("n33" ("tsmc18rf" "nmos3v")) ("p33" ("tsmc18rf" "pmos3v"))))
47;; Modify propMapList as per the properties you want to copy
48 (propMapList '(("m" "m") ("l" "l") ("fw" "w") ("fingers" "fingers")) )
脚本使用第二步,替换完器件之后,使用以下脚本重新触发器件的CDF callbacks函数。
在CIW界面,依次load脚本CCSinvokeCdfCallbacks.il和CCSCdfCallbackEntireLib.il,然后按照格式:CCSCdfCallbackEntireLib("lib_name")调用函数。
重新触发CDF callbacks函数之后,使用脚本替换的器件与手工调用器件参数完全一致,仿真中生成的网表内容也一致,到此完成整个替换过程。
脚本极有可能只完成用户80%的原理图迁移工作,为大家带来一部分效率提升,剩下的已知或者未知问题只能手动修改。
如果在脚本使用中发现:脚本运行报error,并且无法实现替换功能,请尽量保证每次脚本只替换一种器件类型,并且器件名称和参数对应正确。
在触发CDF callbacks函数时偶尔会出现CIW报错但是并不影响功能,无需在意,关于CDF callbacks函数的触发脚本还有多种其它用法,请参考脚本前的注释内容。
以上脚本有官方网站配套的使用教程和说明,同步更新在知识星球中
======================