SKILL 脚本入门
SKILL 是 Cadence 环境下的脚本语言,用于自动化版图设计操作。
为什么学习 SKILL
- ✅ 批量操作:自动完成重复性工作
- ✅ 自定义工具:根据个人需求定制功能
- ✅ 提升效率:原本需要 1 小时的操作,脚本 1 秒完成
基础语法
变量定义
skill
; 定义变量
myVar = "Hello SKILL"
num1 = 10
num2 = 20函数定义
skill
procedure(myFunction(arg1 arg2)
printf("参数1: %s\n" arg1)
printf("参数2: %d\n" arg2)
arg1 + arg2
)
; 调用函数
result = myFunction("test" 100)循环结构
skill
; for 循环
for(i 0 10 1
printf("i = %d\n" i)
)
; foreach 循环
foreach(item myList
printf("item: %s\n" item)
)常用 API
获取当前 CellView
skill
cv = geGetEditCellView()
printf("当前 Cell: %s\n" cv~>cellName)创建矩形
skill
; 在 metal1 层创建矩形
rect = dbCreateRect(cv list("metal1" "drawing") list(0:0 10:5))获取所有 Shape
skill
shapes = cv~>shapes
foreach(shape shapes
printf("Shape type: %s\n" shape~>objType)
)实用脚本示例
批量修改图层颜色
skill
procedure(changeLayerColor(layerName color)
let((layer)
layer = techGetLayerByPurpose(techGetTechFile(cv) layerName "drawing")
when(layer
hiSetLayerColor(layer color)
printf("图层 %s 颜色已修改为 %s\n" layerName color)
)
)
)
; 使用示例
changeLayerColor("metal1" "red")
changeLayerColor("metal2" "blue")调试技巧
- 打印调试:使用
printf输出变量值 - 错误捕获:使用
err函数捕获异常 - 逐步执行:在 CIW 中逐行执行代码
