共计 1748 个字符,预计需要花费 5 分钟才能阅读完成。
为什么选择 Skill 语言?
Skill 是 Cadence EDA 工具链的专用脚本语言,就像 Photoshop 的 Action 脚本一样深度集成。在芯片设计领域,90% 的版图工程师每天都会用到 Skill 实现:

- 自动化重复操作(如批量修改金属层)
- 定制设计流程检查(DRC 规则扩展)
- 数据转换与报表生成
相比 Python/Tcl,Skill 的独特优势在于:
- 直接内存访问:无需 IPC 即可操作设计数据库对象
- 零延迟响应:函数调用与工具操作同线程执行
- 原生 API 支持 :如
geGetEditCellView获取当前编辑窗口
基础语法速成
变量与数据类型
; 变量声明(动态类型)a = 1 ; 整数
b = 3.14 ; 浮点数
c = "text" ; 字符串
d = list(1 2 3) ; 列表
流程控制
; if-else 判断
if( layer == "METAL1" then
printf("当前层是金属 1")
else
printf("其他层级")
)
; for 循环
for( i 1 10
printf("Count %d" i)
)
函数封装规范
推荐使用 procedure 定义可重用模块:
procedure(modifyLayerWidth(@optional (layer "METAL1") (width 0.2))
when(width <= 0
error("宽度必须大于 0")
)
foreach(shape geGetEditCellView()~>shapes
when(shape~>layerName == layer
shape~>width = width
)
)
t ; 返回成功标志
)
三大实战案例
案例 1:自动化版图修改
/* 批量调整通孔尺寸 */
procedure(resizeVias(newSize)
cv = geGetEditCellView()
viaList = setof(obj cv~>shapes obj~>objType == "via")
foreach( via viaList
via~>width = newSize
via~>height = newSize
)
printf("已修改 %d 个通孔" length(viaList))
)
案例 2:数据批处理
/* 提取所有器件尺寸到 CSV */
procedure(exportDeviceSizes(csvFile)
fp = outfile(csvFile)
fprintf(fp "Name,Width,Height\n")
foreach(inst geGetEditCellView()~>instances
fprintf(fp "%s,%g,%g\n"
inst~>name
inst~>width
inst~>height
)
)
close(fp)
)
案例 3:DRC 增强检查
/* 检查最小间距违规 */
procedure(checkMinSpace(layer space)
violations = 0
shapes = setof(s geGetEditCellView()~>shapes s~>layerName == layer)
for(i 0 length(shapes)-2
for(j i+1 length(shapes)-1
dist = distance(shapes[i] shapes[j])
when(dist < space
violations++
hiAddDrcMarker(list(shapes[i] shapes[j])
sprintf(nil "间距 %.2f < 规则 %.2f" dist space)
)
)
)
)
printf("发现 %d 处违规" violations)
)
性能优化技巧
- 避免重复查询 :将
geGetSelectedSet()结果存入变量 - 使用向量运算 :用
mapcar替代循环处理列表 - 内存回收:对大对象显式调用
delete()
常见错误排查
-
错误:
*Error* eval: undefined function
解决 :检查函数名拼写,确认是否在load()之后调用 -
错误:
*Error* dbGet: argument #1 should be any user-defined (type template)
解决:确认对象是否通过合法 API 获取
进阶思考
- 如何实现跨 cellview 的层次化遍历?
- 怎样用 Skill 创建自定义的 GUI 对话框?
通过这组范例,你应该已经能处理 80% 的日常自动化需求。记住 Skill 的核心价值在于:用脚本延伸工具的能力边界,而非替代设计思维。
正文完
