在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 199|回复: 7

[求助] 批量修改电路图中mos管的isov参数

[复制链接]
发表于 昨天 16:25 | 显示全部楼层 |阅读模式
500资产
想批量修改电路图中的mos管的CDF Parameter参数isov=8。加载执行以下脚本没有报错也没有成功
(procedure (updateNBLParamTo8)
  (let ((cv (geGetEditCellView))
        inst param updatedCount)

    (setq updatedCount 0)

    (foreach inst (cv~>instances)
      (when (equal inst~>cellName "nch5_nbl")
        (setq param (dbFindProp inst "NBL ISO-RING(vdir)"))
        (when (and param (equal param~>value 24))

          (when (errset
                 (dbReplaceProp inst "NBL ISO-RING(vdir)" 'int 8)
                 t)
            (printf "Updated instance %s: changed NBL ISO-RING(vdir) from 24 to 8.\n"
                    inst~>name)
            (setq updatedCount (plus updatedCount 1))
          )
        )
      )
    )

    (sprintf nil "Updated %d instance(s) with NBL ISO-RING(vdir) = 24 → 8." updatedCount)
  )
)

发表于 昨天 17:29 | 显示全部楼层
将param打印出来看看是nil吗?
发表于 昨天 17:55 | 显示全部楼层

                               
登录/注册后可看大图

 楼主| 发表于 昨天 17:57 | 显示全部楼层


843071455 发表于 2025-6-10 17:29
将param打印出来看看是nil吗?


是的
发表于 昨天 19:34 来自手机 | 显示全部楼层
本帖最后由 843071455 于 2025-6-11 08:37 编辑


佳佳佳佳 发表于 2025-6-10 17:57
是的


那就说明从这一步开始 (when (and param (equal param~>value 24)),下面的都没有执行那自然也就没有起作用,而且你用的参数名称应该是isov,不应该是你写的nbl那一长串名字,还有就是假如调的器件的isov默认值为24(没有修改过),dbfindprop的结果应该也是nil(就算参数名字是isov正确的情况下),所以dbfindprop那一步可以不用,直接inst~>isov==24作为条件(前提isov的数据类型是int),然后直接修改成inst~>isov=8应该就可以了。
发表于 昨天 22:05 | 显示全部楼层


843071455 发表于 2025-6-10 19:34
那就说明从这一步开始 (when (and param (equal param~>value 24)),下面的都没有执行那自然也就没有起作 ...


正解。纠正一个笔误,后面的 == 8 为 = 8
 楼主| 发表于 8 小时前 | 显示全部楼层
; 1. 获取目标实例
cv = geGetEditCellView()
insts = setof(x cv~>instances x~>cellName == "nch5_nbl")  ; 过滤nch5_nbl实例
inst = car(insts)  ; 取第一个实例

; 2. 检查CDF数据
cdfgData = cdfGetInstCDF(inst)
param = get(cdfgData "isov")
if(param then
    printf("isov exists, current value=%A\n" param~>value)
else
    printf("isov does NOT exist!\n")
)

; 3. 手动更新参数
success = vfoSetParam(inst "isov" “8”)
if(success then
    printf("Successfully updated isov to 8\n")
else
    printf("Failed to update isov!\n")
)
我用这个方法调试成功了,但是我是想把整个库里面的所有nch5_nbl的iso都换了,调试以下脚本没有找到cell
procedure(updateNch5NblIsovSequentially()
   let((lib cells cellCount processedCount updatedCount totalInstances)
    ; 1. 强制加载test库(避免缓存问题)
    lib = ddGetObj("test")
    unless(lib error("Library 'test' not found! Check:\n1. Library name\n2. Library path"))

    ; 2. 混合方法查找所有包含schematic的cell
    cells = nil
    foreach(cell lib->cells
      when(member("schematic" cell->cellViews->viewName) ||  ; 方法1:检查viewName
           member("schematic" cell->views->name)            ; 方法2:兼容旧版检查
        cells = cons(cell cells)
      )
    )
    cells = reverse(cells) ; 保持原始顺序
    cellCount = length(cells)
    printf("Found %d cells with schematic views\n" cellCount)

    ; 3. 处理每个cell
    foreach(cell cells
      let((schId insts)
        printf("\nProcessing cell: %s\n" cell->name)
        
        ; 优先尝试标准方法打开
        schId = geOpenCellView(cell->name "schematic" nil nil 'overwrite)
        unless(schId
          ; 回退方法:尝试通过dbOpen
          schId = dbOpenCellViewByType(cell->lib->name cell->name "schematic" nil "a")
        )
        
        when(schId
          ; 增强实例查找
          insts = setof(x schId->instances
                      x->cellName=="nch5_nbl" ||
                      (x->master && x->master->name=="nch5_nbl") ||
                      get(cdfGetInstCDF(x) "modelName")=="nch5_nbl")
          totalInstances = totalInstances + length(insts)
          printf("Found %d target instances\n" length(insts))

          ; 参数更新
          foreach(inst insts
            let((cdfData param)
              cdfData = cdfGetInstCDF(inst)
              when(cdfData
                param = get(cdfData "isov")
                if(param then
                  printf("Checking %s (value=%s, readonly=%s)\n"
                        inst->name param->value param->readOnly)
                  unless(param->readOnly || param->value=="8"
                    when(vfoSetParam(inst "isov" "8")
                      updatedCount = updatedCount + 1
                      printf("--> Updated to 8\n")
                    )
                  )
                )
              )
            )
          )
         
          ; 保存关闭
          hiSave(schId)
          hiClose(schId 'noPrompt)
          processedCount = processedCount + 1
        )
      )
    )

    ; 4. 最终报告
    printf("\n=== Final Report ===\n")
    printf("Processed cells: %d/%d\n" processedCount cellCount)
    printf("Total target instances: %d\n" totalInstances)
    printf("Successfully updated: %d\n" updatedCount)
    when(totalInstances == 0
      printf("\nTroubleshooting Tips:\n")
      printf("1. Check if nch5_nbl exists: ddGetObj(\"test\" \"nch5_nbl\")\n")
      printf("2. Verify instance names: geGetSelSet()->cellName\n")
      printf("3. Check CDF structure: cdfGetInstCDF(inst)->?\n")
    )
    t
  )
)
 楼主| 发表于 5 小时前 | 显示全部楼层
procedure(updateSelectedNch5NblInstances()
  let((cv insts updatedCount failedCount skippedCount)
    ; 1. 获取当前编辑视图
    cv = geGetEditCellView()
    unless(cv
      error("No cellview is open for editing!")
    )

    ; 2. 获取所有nch5_nbl实例(支持多种识别方式)
    insts = setof(x cv->instances
                x->cellName == "nch5_nbl" ||          ; 标准名称匹配
                (x->master && x->master->name == "nch5_nbl") ||  ; Pcell实例
                (get(cdfGetInstCDF(x) "modelName") == "nch5_nbl")) ; CDF参数继承

    unless(insts
      warn("No nch5_nbl instances found in current view!")
      return(nil)
    )

    printf("Found %d nch5_nbl instances\n" length(insts))

    ; 3. 更新参数
    updatedCount = 0
    failedCount = 0
    skippedCount = 0
    foreach(inst insts
      let((cdfData param currentVal isReadOnly)
        ; 选中当前实例(可视化反馈)
        geSelectFig(inst)

        ; 获取CDF数据(带错误检查)
        unless(cdfData = cdfGetInstCDF(inst)
          printf("WARNING: No CDF data for instance %s\n" inst->name)
          failedCount = failedCount + 1
          next()
        )

        ; 检查isov参数(安全方式)
        param = get(cdfData "isov")
        unless(param
          printf("WARNING: No 'isov' parameter in instance %s\n" inst->name)
          failedCount = failedCount + 1
          next()
        )

        ; 安全获取参数值
        currentVal = param->value || "nil"
        isReadOnly = if(param->readOnly then "YES" else "NO")

        ; 打印当前状态(修复了格式化问题)
        printf("Updating %s (current isov=%s, readonly=%s)...\n"
              inst->name currentVal isReadOnly)

        ; 跳过只读参数
        when(param->readOnly
          printf("SKIPPED: Parameter is read-only\n")
          skippedCount = skippedCount + 1
          next()
        )

        ; 跳过已经是8的值
        when(param->value == "8"
          printf("SKIPPED: Value is already 8\n")
          skippedCount = skippedCount + 1
          next()
        )

        ; 执行更新
        if(vfoSetParam(inst "isov" "8") then
          printf("SUCCESS: Updated to 8\n")
          updatedCount = updatedCount + 1
        else
          printf("FAILED: Update operation rejected\n")
          failedCount = failedCount + 1
        )
      )
    )

    ; 4. 报告结果
    printf("\n=== Update Summary ===\n")
    printf("Total instances processed: %d\n" length(insts))
    printf("Successfully updated: %d\n" updatedCount)
    printf("Failed updates: %d\n" failedCount)
    printf("Skipped updates: %d\n" skippedCount)
    printf("  (already 8 or read-only)\n")

    t ; 返回成功
  )
)

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

X

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-6-11 20:03 , Processed in 0.025466 second(s), 6 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表