Post

Automated Cell and Library Renaming with Instance Master Updates in Cadence Virtuoso

Automated Cell and Library Renaming with Instance Master Updates in Cadence Virtuoso

Introduction

In large-scale analog/digital IC design projects, design reuse and project forking are common practices. These often require renaming of entire libraries and cell hierarchies to conform to new naming conventions (e.g., transitioning from Hi5800V100 to Hi5800V200). Manual renaming of cells and libraries, along with updating all hierarchical instance references, is a tedious and error-prone task. To address this, we have developed a robust SKILL-based automation script: CCSRenameAndUpdate.il.

Objective

The primary goal of this script is to:

  1. Batch rename cells using a specified prefix change.
  2. Rename entire libraries while preserving their internal structure.
  3. Recursively update all instance master references within layout, symbol, and schematic views.

By automating this process, we ensure consistency, reduce manual intervention, and accelerate design preparation for derivative projects.

Implementation Overview

The script is implemented in three major steps, encapsulated in a top-level procedure: CCSRenameCellsAndInstancesByPrefix.

Source code,

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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
;;--------------------------------------------------------------------
;; File     : CCSRenameAndUpdate.il
;; Purpose  : 使用官方 API 重命名前缀 + 更新 instance master(layout/symbol/schematic)
;; Author   : wanlin.wang
;; Updated  : 2025/04/22
;;--------------------------------------------------------------------
 
;; === Step 1: 使用 ccpRename 重命名 Cell ===
procedure(renameCellPrefixByCCP(libList origPrefix newPrefix)
  let( (oldName newName srcSpec destSpec)
    foreach(libName libList
      foreach(cell ddGetObj(libName)->cells
        oldName = cell~>name
        when(rexMatchp(strcat("^" origPrefix) oldName)
          newName = rexReplace(oldName newPrefix 0)
          printf("Renaming cell: %s/%s -> %s\n" libName oldName newName)
 
          srcSpec  = gdmCreateSpec(libName oldName "" "" "CDBA")
          destSpec = gdmCreateSpec(libName newName "" "" "CDBA")
 
          let((dummySpecList)
            dummySpecList = gdmCreateSpecList()
            ccpRename(
              srcSpec
              destSpec
              t
              'CCP_EXPAND_ALL
              'CCP_UPDATE_COPIED_DATA
              dummySpecList
            )
          )
        )
      )
    )
  )
)
 
;; === Step 2: 重命名 Library
procedure(CCSRenameLibsByPrefix(libList origPrefix newPrefix)
  let((oldLibName newLibName src dst dummySpecList)
   
    foreach(oldLibName libList
      when(stringp(oldLibName) && rexMatchp(strcat("^" origPrefix) oldLibName)
        newLibName = rexReplace(oldLibName newPrefix 0)
        printf("Renaming library: %s -> %s\n" oldLibName newLibName)
 
        srcSpec = gdmCreateSpec(oldLibName nil nil nil "CDBA")
        dstSpec = gdmCreateSpec(newLibName nil nil nil "CDBA")
        dummySpecList = gdmCreateSpecList()
 
        ccpRename(
          srcSpec
          dstSpec
          t                         ;; allow overwrite
          'CCP_EXPAND_ALL
          'CCP_UPDATE_COPIED_DATA   ;; do not update references
          dummySpecList
        )
      )
    )
    t
  )
)
 
;; === Step 3: 遍历每个 cellView,更新实例的 master ===
procedure(updateInstanceMasterReference(libList origPrefix newPrefix)
  let( (lib cell cellView cv inst master oldMasterName newMasterName oldLibName newLibName newMasterCv renamedLibList)
     
    ;; 创建重命名后的库列表
    renamedLibList = list() ;; 初始化空列表
    foreach(lib libList
      when(stringp(lib) && rexMatchp(strcat("^" origPrefix) lib)
        newLibName = rexReplace(lib newPrefix 0) ;; 替换库名
        renamedLibList = cons(newLibName renamedLibList)   ;; 将替换后的库名添加到新的列表中
        printf("Library renamed: %s -> %s\n" lib newLibName) ;; 新增日志打印
      )
    )
 
    ;; 遍历每个新的库名
    foreach(lib renamedLibList
      printf("Processing library: %s\n" lib) ;; 日志打印库
      foreach(cell ddGetObj(lib)->cells
        printf("  Processing cell: %s\n" cell~>name) ;; 日志打印 cell
        foreach(cellView cell~>views
          printf("    Processing cellView: %s\n" cellView~>name) ;; 日志打印 cellView
          when(member(cellView~>name '("layout" "symbol" "schematic"))
            cv = dbOpenCellViewByType(lib cell~>name cellView~>name "" "a")
            when(cv
              foreach(instHeader cv~>instHeaders
                when(instHeader~>cellName
                  printf("      Processing instance's master cellName: %s\n" instHeader~>cellName) ;; 日志打印实例
 
                  oldMasterName = instHeader~>cellName
                  oldLibName    = instHeader~>libName
 
                  ;; 打印 oldLibName 和 oldMasterName,帮助调试
                  printf("        oldLibName: %s, oldMasterName: %s\n" oldLibName oldMasterName)
 
                  ;; 如果库名匹配前缀,则继续更新 cell 名
                  when(stringp(oldLibName) && rexMatchp(strcat("^" origPrefix) oldLibName)
                    newLibName = rexReplace(oldLibName newPrefix 0)
 
                    ;; 如果 master 名匹配前缀,则替换 master 名,否则保持原名
                    newMasterName = oldMasterName
                    when(stringp(oldMasterName) && rexMatchp(strcat("^" origPrefix) oldMasterName)
                      newMasterName = rexReplace(oldMasterName newPrefix 0)
                    )
 
                    printf("Updating instance in %s/%s/%s: %s/%s -> %s/%s\n"
                            lib cell~>name cellView~>name
                            oldLibName oldMasterName
                            newLibName newMasterName)
                    ;; 通过dbSetInstHeaderMasterName来替换实例的master
                    dbSetInstHeaderMasterName(instHeader newLibName newMasterName nil)
                  )
                )
              )
              dbSave(cv)
              dbClose(cv)
            )
          )
        )
      )
    )
  )
)
 
 
 
;; === 顶层函数 ===
procedure(CCSRenameCellsAndInstancesByPrefix(libList origPrefix newPrefix)
  printf(">>> Step 1: Rename Cells by Prefix...\n")
  renameCellPrefixByCCP(libList origPrefix newPrefix)
 
  printf(">>> Step 2: Rename Libraries by Prefix...\n")
  CCSRenameLibsByPrefix(libList origPrefix newPrefix)
 
  printf(">>> Step 3: Update Instance Master References...\n")
  updateInstanceMasterReference(libList origPrefix newPrefix)
  printf(">>> All Done.\n")
)

Step 1: Rename Cells by Prefix

Procedure: renameCellPrefixByCCP

  • Iterates through all cells in the specified libraries.
  • Detects cells with a given prefix using regular expressions.
  • Renames matched cells to a new prefix using the official ccpRename API.
  • Ensures that all data, including schematic/layout content, is copied and expanded (CCP_EXPAND_ALL and CCP_UPDATE_COPIED_DATA).
1
2
3
4
5
6
7
8
ccpRename(
  srcSpec
  destSpec
  t
  'CCP_EXPAND_ALL
  'CCP_UPDATE_COPIED_DATA
  dummySpecList
)

Step 2: Rename Libraries by Prefix

Procedure: CCSRenameLibsByPrefix

  • Operates on library names matching the specified prefix.
  • Reconstructs a new name and uses ccpRename to duplicate and rename the entire library.
  • Maintains internal cell structure but does not update references at this stage.

Step 3: Update Instance Master References

Procedure: updateInstanceMasterReference

  • Opens each relevant layout, symbol, and schematic view in the renamed libraries.
  • Iterates through instance headers to identify references to old libraries or cell names.
  • If both the library and cell names match the original prefix, it updates the instance’s master path using dbSetInstHeaderMasterName.
1
dbSetInstHeaderMasterName(instHeader newLibName newMasterName nil)
  • Saves and closes each modified cellView after updates.

Top-Level Invocation

Procedure: CCSRenameCellsAndInstancesByPrefix

  • Accepts a list of target libraries, original prefix, and desired new prefix.
  • Sequentially calls the three core steps to complete the transformation.

Example usage:

1
2
3
4
5
CCSRenameCellsAndInstancesByPrefix(
  (list "Hi5800V100_PLL" "Hi5800V100_TX")
  "Hi5800V100"
  "Hi5800V200"
)

Conclusion

The CCSRenameAndUpdate.il script provides a comprehensive, automated solution for prefix-based renaming across cells, libraries, and instance references. It significantly simplifies the process of adapting legacy designs to new project naming conventions, improving both design integrity and engineer productivity.

This solution is particularly useful in IP reuse workflows, project fork management, and hierarchical tapeout preparations in Cadence Virtuoso environments.

For integration, simply load the script into CIW, and invoke the top-level procedure with appropriate parameters.

This post is licensed under CC BY 4.0 by the author.

支持创作者

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

收款码

感谢你的支持!