[ Skill ] 遍歷整個項目設計的兩個思路


https://www.cnblogs.com/yeungchie/

RecursiveProject 遞歸項目

  • code
/*****************************************
*                                        *
*   Program   :  ycRecursiveProject.il   *
*   Language  :  Cadence Skill           *
*   Author    :  YEUNGCHIE               *
*   Version   :  2020.12.20              *
*                                        *
*****************************************/
procedure(ycRecursiveProject(\@optional cv(geGetEditCellView()) "d")
    prog((insts viewNames viewName master)
        
        unless(boundp('masters) masters = nil)
        unless(boundp('ignoreLibNames) ignoreLibNames = nil)
        
        ; 優先處理頂層的操作放這里
        printf("Opened \t libName : %s \t cellName : %s \n" cv~>libName cv~>cellName)
        ;dbCreateRect(cv "MET6" list(0:0 10:300))
        ;;;;;;;;;;;;;;;;;;;;;;;;;;
        
        insts = cv~>instances
        foreach(inst insts
            case(cv~>cellViewType
                ("schematic"
                    ; schematic 雖然調用的是 symbol ,但需要處理的是 schematic
                    viewNames = inst~>master~>cell~>views~>name
                    if(member("schematic" viewNames)
                        viewName = "schematic"
                        viewName = nil
                    )
                )
                ("maskLayout"
                    viewName = inst~>viewName
                )
            )
            if(viewName
                master = dbOpenCellViewByType(
                    inst~>libName
                    inst~>cellName
                    viewName
                    nil
                    "r" ; 這里用的是只讀模式,需要編輯內容的時候改為追加模式 "a" 即可。
                )
                master = nil
            )
            when(master && !member(master masters)
                unless(member(inst~>libName ignoreLibNames)
                    ycRecursiveProject(master)
                )
            )
        )
        
        ; 優先處理底層的操作放這里
        
        ;;;;;;;;;;;;;;;;;;;;;;;;;;
        
        masters = append1(masters cv)
        ;dbSave(cv)
        ;dbClose(cv)
        ; 我喜歡不保存不關閉,因為這樣可以有一個反悔的機會,避免誤操作。
    )
); ycRecursiveProject
  • run
; 不太喜歡全局變量,所以套一個 prog
prog((masters ignoreLibNames)
    ; ignoreLibNames 用來指定忽略不需要打開哪些庫中的 cellView
    ignoreLibNames = list("techLib" "basic" "analogLib")
    ycRecursiveProject()
)

如果項目不大的可以用上面的 RecursiveProject 方式來處理,當項目比較大的時候遞歸的效率可能非常的低,此時推薦下面的 TraverseHierarchyTree ,Virtuoso 可以獲取到 Tree 文件,通過它來依次打開每個 cellView 。
曾經遞歸一個芯片頂層,花了兩天一夜還沒跑完,也可能是我 Memoization 沒做好,跟公司的一個大佬交流后決定換用下面的方式,結果只跑了不到半小時。

TraverseHierarchyTree 遍歷層次樹

  • code
/**********************************************
*                                             *
*   Program   :  ycTraverseHierarchyTree.il   *
*   Language  :  Cadence Skill                *
*   Author    :  YEUNGCHIE                    *
*   Version   :  2021.01.26                   *
*                                             *
**********************************************/
procedure(ycTraverseHierarchyTree(treeFile \@optional ignoreLibNames(nil) "tg")
    prog((file str libCellView hierList libName cellName viewName cv )
        ; 首先讀入 tree 文件,提取 cellView 調用信息。
        isFile(treeFile) || error("%s is balabala !\n" treeFile)
        file = infile(treeFile)
        while(gets(str file)
            if(rexMatchp("^*.+" str)
            then
                hierList = nil
            else
                libCellView = parseString(str)
                hierList = append1(hierList
                    list(
                        nth(0 libCellView)
                        nth(1 libCellView)
                        nth(2 libCellView)
                    )
                )
            )
        ); while
        close(file)
        
        unless(listp(ignoreLibNames) ignoreLibNames = list(ignoreLibNames))
        
        foreach(x artUnique(hierList)
            libName  = nth(0 x)
            unless(member(libName ignoreLibNames)
                cellName = nth(1 x)
                viewName = if(nth(2 x) == "symbol" "schematic" nth(2 x))
                when(cv = dbOpenCellViewByType(libName cellName viewName nil "r")
                    
                    ; 開始搞事情。
                    ; 看情況決定保存時機。
                    
                    ;dbSave(cv)
                    ;dbClose(cv)
                )
            )
        ); foreach hier
    )
); ycTraverseHierarchyTree
  • run
ycTraverseHierarchyTree("hier.tree" list("techLib" "basic" "analogLib"))


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM