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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
楼主: okfunny

[原创] 分享一些脚本

[复制链接]
发表于 2018-1-19 16:50:37 | 显示全部楼层
谢谢分享
 楼主| 发表于 2018-2-13 23:26:48 | 显示全部楼层
准备通过一个实例给感兴趣的朋友讲讲skill 脚本,“如何通过skill 脚本抓取PAD location“
功能:可以 指定区域, 指定PAD layer, Pin layer, 层次化抓取
发表于 2018-2-15 20:51:23 | 显示全部楼层
Interesting
 楼主| 发表于 2018-3-1 22:35:21 | 显示全部楼层




  1. /*
  2. Dcript name: ok_GetPadLocation.il
  3. Author: Okfunny
  4. Date: 2018-03-01
  5. Description: This script is used to get PAD coordinate, user can set PAD layer, Pin layer, extraction range and,
  6.     It contains a very useful function which can use to copy specific layer hierarchially.
  7.     It is also quick start of learning skill, welcome to use and modify it ^_^
  8. Usage:
  9. Copy layer from sub block
  10. 1. select the layer you want to copy in LSW
  11. 2. draw a rectangle in a auxiliary layer to determine which region is copid from
  12. 3. select the rectangle
  13. 4. invoke the function ok_CopyFig(32)

  14. Get pad location
  15. 1. select the PAD layer in LSW
  16. 2. draw a rectangle in a auxiliary layer to determine which region is copid from
  17. 3. select the rectangle
  18. 4. invoke the function ok_GetPadLocation(32)

  19. the output looks like:
  20. create time: Mar  1 22:32:59 2018
  21. there are total 24 pads
  22. Name                    centerX    centerY      width     length
  23. PAD_4                   581.750     58.945     52.000     73.000
  24. PAD_14                  581.750    168.945     52.000     73.000
  25. PAD_24                  581.750    264.985     52.000     73.000

  26. */

  27. ; skill use semicolon to represent comments, use can delete these comments

  28. ; these are built-in fuctions used in this script, you can find usage in cadence help system: cdnshelp
  29. ; car  cadr cadar cadadr last list listp nconc append1 error geGetSelSet geGetEditCellView
  30. ; dbGetOverlaps dbGetHierPathTransform dbCopyFig dbCreateLabel dbDeleteObject
  31. ; hiDisplayMenu hiCreateSimpleMenu hiSetBindKey centerBox
  32. ; leMergeShapes geDeselectAll setof  strcat outfile fprintf getCurrentTime
  33. ; length leIsPointInsideFig dbDeleteObject close view

  34. ; user defined functions start with prefix ok_

  35. ; this is our first user defined fuction, procedure is a keyword to define a function
  36. ; ok_FlatList is function name, testList is argument
  37. ; this function is used to flatten a nested list
  38. procedure(ok_FlatList(testList)
  39.     ; let limits the variable range, and the last value is the return value of the fuction
  40.     ; listNew is a local variable which means it cannot be read and modified outside the function
  41.     ; It is a good habit to use local variable instead of global variable
  42.     let((listNew)
  43.         listNew=nil
  44.         ;listp is used to determine if it is a list
  45.         if(listp(testList)
  46.             then
  47.                 foreach(cell testList
  48.                     if(listp(cell)
  49.                         then
  50.                             ; nconc is used to concatenate two list
  51.                             listNew=nconc(listNew ok_FlatList(cell))
  52.                             ; append1 is used to append a item to a list
  53.                         else
  54.                             listNew=append1(listNew cell)
  55.                     )
  56.                 )
  57.             else
  58.                 ; error throw out a message if listNew is not a list
  59.                 error("ok_FlatList(): argument must be a list")
  60.         )
  61.         listNew
  62.     )
  63. )
  64. ;;Example
  65. ;;tlist=list("a" "b" list(1 2 list("c" 3) list("aa" "bb")))
  66. ;;ok_FlatList(tlist)


  67. ; this is out second user definde function, and the first functon can be involed as a built-in function
  68. ; this function is use to get the last item in a nested list
  69. procedure(ok_GetLast(testList)
  70.     car(last(ok_FlatList(testList)))
  71. )
  72. ;;Example
  73. ;;tlist=list(list(1,2), list(3,4,5,list(6,7)))
  74. ;;ok_GetLast(tlist)

  75. procedure(ok_CopyFigSingal(object x_Depth l_LPP)
  76.     ; prog is similar with let, but it can use the keyword return to return value in anywhere
  77.     prog((cv objHier transList objList objTransList objTransLista newObj list1 listNew)

  78.         ; geGetEditCellView is used to get current view ID, in this case, it means layer view window ID
  79.         ; ~> is operational character which used to access a structure's attributes
  80.         ; geGetEditCellView()~>?  can get all attributes name
  81.         ; geGetEditCellView()~>?? can get all attributes name and value
  82.         ; geGetEditCellView()~>bBox get current window size in a list (X_lowerleft:Y_lowerleft X_upperrignt:Y_upperright)
  83.         cv=geGetEditCellView()

  84.         ; get layers in l_LPP layer, in x_Depth level, in current window cv, in bBox region
  85.         objHier=dbGetOverlaps(cv object~>bBox l_LPP x_Depth t)

  86.         transList=nil

  87.         ; for each obj in in selected objects, loop operating the item
  88.         ; get the transform of the object, transform is a list such as (x:y rotation magnification)
  89.         foreach(obj objHier transList=nconc(transList list(dbGetHierPathTransform(obj))))

  90.         objList=nil
  91.         foreach(obj objHier objList=nconc(objList list(ok_GetLast(list(obj)))))

  92.         ; create a list with shape and it's transform
  93.         objTransList=mapcar('list objList transList)
  94.         objTransLista=setof(x objTransList ! member(car(x)~>objType list("inst" "mosaic")))

  95.         ; copy shape
  96.         newObj=foreach(mapcar xxx objTransLista dbCopyFig(car(xxx) cv cadr(xxx)))

  97.         ; return the new copied layers as a list
  98.         listNew=nconc(list(object) list(newObj))
  99.         return(listNew)
  100.     )
  101. )


  102. ; this is our first usefull function which can copy layers hierarchially
  103. ;
  104. procedure(ok_CopyFig(@optional
  105.     ; x_depth is the maximum level, default is 32
  106.     ; l_lpp is the layer which you want to copy, default is current layer selected in LSW
  107.     ; d_objects a auxiliary layer whose bBox is used to determine which range to copy from
  108.     (x_depth 32) (l_lpp leGetEntryLayer()) (d_objects geGetSelSet()))

  109.     prog((listNew)

  110.         ; if the mode is readonly, it do nothing and pop-up a window
  111.         if(geGetEditCellView()~>mode=="r"
  112.             then
  113.                 ; pop-up a window
  114.                 hiDisplayMenu(hiCreateSimpleMenu(
  115.                     'menu "" list("   read only   ") list(""))
  116.                 )
  117.             else
  118.                 listNew=nil

  119.                 foreach(obj d_objects
  120.                     listNew=nconc(listNew list(ok_CopyFigSingal(obj x_depth l_lpp)))
  121.                     )
  122.                 return(listNew)
  123.         )
  124.     )
  125. )


  126. procedure(ok_GetPadLocation(@optional
  127.     ;optional arguments, if invoke it without any arguments, it will use default value
  128.     ;pinLPP is Pin label layer in top level, default is AP:pin
  129.     ;depth is the maximum level, default is 32
  130.     (pinLPP list("AP" "pin")) (depth 32))

  131.     prog((cv pad_tmp pad labelInCV file outf bbox centerX centerY name)
  132.     cv=geGetEditCellView()

  133.     ; copy all PAD to current level to calculate
  134.     pad_tmp=cadar(ok_CopyFig(depth))

  135.     ; merge copied layers
  136.     pad=leMergeShapes(pad_tmp)
  137.     geDeselectAll()

  138.     ; filter the labels
  139.     labelInCV=setof(x cv~>shapes x~>objType=="label" && x~>lpp==pinLPP)


  140.     ; create a file to store the pad location, the file name is cellname + _padLoacation
  141.     file=strcat(cv~>cellName "_padLoacation")

  142.     ; open the file to write to
  143.     outf=outfile(file)

  144.     ; fprintf is used to write to a file in specific format
  145.     fprintf(outf "create time: %s\n" getCurrentTime())

  146.     ; get the count of pads
  147.     fprintf(outf "there are total %d pads\n" length(pad))

  148.     fprintf(outf "%-20s %10s %10s %10s %10s\n" "Name" "centerX" "centerY" "width" "length")

  149.     foreach(shape pad
  150.         ; calculate the pad coordinate and size
  151.         bbox=shape~>bBox
  152.         centerX=car(centerBox(bbox))
  153.         centerY=cadr(centerBox(bbox))
  154.         width=caadr(bbox) - caar(bbox)
  155.         length=cadadr(bbox) - cadar(bbox)

  156.         ; use this flag to determine if the label is in the pad region
  157.         p_count=1

  158.         ; if the label is inside the pad, then get the pad name
  159.         foreach(label labelInCV
  160.             if(leIsPointInsideFig(shape label~>xy)
  161.                 then
  162.                     label~>xy=centerX:centerY
  163.                     p_count=p_count+1
  164.                     name=label~>theLabel
  165.             )
  166.         )

  167.         if(p_count==0
  168.             then
  169.                 fprintf(outf "%-20s %10.3f %10.3f %10.3f %10.3f\n"
  170.                             "NC" centerX centerY width length)
  171.             else
  172.                 fprintf(outf "%-20s %10.3f %10.3f %10.3f %10.3f\n"
  173.                             name centerX centerY width length)
  174.         )
  175.     )

  176.     ; delete the copied pad layer
  177.     foreach(x pad dbDeleteObject(x))

  178.     ; close the file
  179.     close(outf)


  180.     ; view the location file
  181.     view(file)

  182.     printf("Please find result: %s\n" file)
  183.     )
  184. )

  185. ;set a bindkey with default setting: pin layer AP:pin, pad layer is current layer in LSW
  186. hiSetBindKey("Layout" "Ctrl<Key>b" "ok_GetPadLocation()")

  187. ;set a bindkey with default setting, only copy layer from level 1, layer is current layer in LSW
  188. hiSetBindKey("Layout" "Ctrl<Key>d" "ok_CopyFig(1)")

  189. ;set a bindkey with user defined layer setting: pin layer M11:pin, pad layer is current layer in LSW
  190. hiSetBindKey("Layout" "Ctrl<Key>g" "ok_GetPadLocation(list("Metal11" "pin")")

  191. println("load successfully")



复制代码
 楼主| 发表于 2018-3-1 22:56:29 | 显示全部楼层

load 脚本

load 脚本

示例显示1

示例显示1

示例显示2

示例显示2

随便选一层layer画个框框,框处要抓取坐标的区域,然后在LSW选中PAD layer

随便选一层layer画个框框,框处要抓取坐标的区域,然后在LSW选中PAD layer

执行快捷键 ctrl+g, 所有的label 会调整到PAD中心点

执行快捷键 ctrl+g, 所有的label 会调整到PAD中心点

执行脚本后弹出pad location文件,保存在当前目录下

执行脚本后弹出pad location文件,保存在当前目录下
发表于 2018-3-2 17:07:14 | 显示全部楼层
thank you
发表于 2018-3-3 19:19:05 | 显示全部楼层
学习了
发表于 2018-3-5 15:27:49 | 显示全部楼层
谢谢分享
发表于 2018-3-14 12:44:36 | 显示全部楼层
很不错的帖子!但是IC61以上版本都集成了后面几个脚本的功能
发表于 2018-3-14 15:31:09 | 显示全部楼层
thank you
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-4-20 08:10 , Processed in 0.029319 second(s), 6 queries , Gzip On, Redis On.

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