Post

Rename CellName and Update Reference

Skill代码

;;--------------------------------------------------------------------
;; Function: CCSRenameCellAndUpdateReference
;; Purpose : 在多库中批量重命名 cell 前缀,并更新实例引用
;; Usage   :在 CIW load 这个脚本,然后运行 CCSRenameCellAndUpdateReference 这个 procedure
;; Args    : libList     - list of library names to process
;;           origPrefix  - the prefix to replace (string)
;;           newPrefix   - the new prefix (string)
;; Example : CCSRenameCellAndUpdateReference(
;;             (list "libA" "libB")
;;             "OLD_"
;;             "NEW_"
;;             T
;;           )
;; Author  : wanlin.wang
;; Date    : 2025/04/21
;;--------------------------------------------------------------------
procedure( CCSRenameCellAndUpdateReference( libList origPrefix newPrefix @optional (overwrite nil))
    let( ( srcSpec destSpec newCellName ovrFlag libSpecList)
        if(overwrite then ovrFlag = `TRUE   ; If overwrite is selected
            else  ovrFlag = `FALSE
        ) ; if
 
        ;; 构建gdm spec list(for libList)
        ;; 1. 创建空的 specList
        libSpecList = gdmCreateSpecList()
 
        ;; 2. 遍历库名列表,生成并添加 spec
        foreach(libName libList
            let((libSpec)
                libSpec = gdmCreateSpec(libName "" "" "" "CDBA")
                gdmAddSpecToSpecList(libSpec libSpecList)
            )
        )
 
        ;; 遍历所有指定的 library
        foreach(libName libList
            ;; 获取该 library 下所有 cell 名称
            foreach(cell ddGetObj(libName)->cells
                rexCompile(sprintf(nil "^%s" origPrefix))
                if(rexExecute(cell~>name) then
                    newCellName = rexReplace(cell~>name newPrefix 0)
 
                    ;; 构造源和目标的 GDM spec
                    srcSpec  = gdmCreateSpec( libName cell~>name  "" "" "CDBA" )
                    destSpec = gdmCreateSpec( libName newCellName "" "" "CDBA" )
 
                    ;; 调用 ccpRename:展开所有层次,从 libSpecList 中更新引用
                    ccpRename( srcSpec
                                destSpec
                                ovrFlag
                                `CCP_EXPAND_ALL
                                `CCP_UPDATE_FROM_LIBLIST
                                libSpecList
                    )
                );; end if
            ) ;; foreach cell
        ) ;; foreach libName
    ) ;; let
) ;; procedure
This post is licensed under CC BY 4.0 by the author.

支持创作者

如果本文帮助到你,可以通过以下收款码支持我:

收款码

感谢你的支持!