• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Replace via array with one large via rectangle per inst...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 12831
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Replace via array with one large via rectangle per instance

socratic
socratic over 4 years ago

I would like to write some SKILL code to replace arrays of vias with one large via layer rectangle (as shown below).

I was trying to do something like another post about something similar, but his code was not doing the same thing that I am looking to do. https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/31242/merge-via-arrays

I will post my code to show my approach. I am getting an error in leSearchHierarchy of "Invalid bBox", and I am having trouble understanding why.

Does anyone have suggestions on this approach or a better approach?

  • Cancel
  • socratic
    socratic over 4 years ago

    procedure(vias_to_rect(lib cell)
    let((cv wid cont via1 via2 via3 via4 via5 via6 via7 via8 mergecont mergevia1 mergevia2 mergevia3 mergevia4 mergevia5 mergevia6 mergevia7 mergevia8)
    cv=dbOpenCellViewByType(lib cell "layout" "" "a")

    ;Flatten the layout
    foreach(fig1 cv~>vias
    leFlattenInst(fig1 30 t t t nil t t)

    ;Search and store individual vias
    via1=leSearchHierarchy( cv cv~>bBox 0 "rectangle" list( list( "layer" "==" list( "VIA1" "drawing" ) ) ) )

    ;Merge via arrays
    mergevia1=dbLayerSize(cv '("VIA1" "drawing") via1 0.04)

    ;Find the bottom left and top right corners of via array
    RightMax=nil
    LeftMin=nil
    TopMax=nil
    BottomMin=nil

    foreach(fig mergevia1
    when(fig~>objType=="rect"
    if(RightMax==nil
    then
    RightMax=xCoord(cadr(fig~>bBox))
    LeftMin=xCoord(car(fig~>bBox))
    TopMax=yCoord(cadr(fig~>bBox))
    BottomMin=yCoord(car(fig~>bBox))
    )
    Right=xCoord(cadr(fig~>bBox))
    Left=xCoord(car(fig~>bBox))
    Top=yCoord(cadr(fig~>bBox))
    Bottom=yCoord(car(fig~>bBox))

    if(Right>RightMax then RightMax = Right)
    if(Left<LeftMin then LeftMin = Left)
    if(Top>TopMax then TopMax = Top)
    if(Bottom<BottomMin then BottomMin = Bottom)

    )
    )

    ;Resize merged via to have the same area as the original array of vias
    LowerLeft=LeftMin:BottomMin
    UpperRight=RightMax:TopMax
    dbCreateRect(cv list("VIA1" "drawing") list(LowerLeft UpperRight))
    )
    )

    ;Delete original vias
    foreach(fig via1
    dbDeleteObject(fig)
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to socratic

    The brackets aren't quite right, but I didn't get the error you said - for me it "worked" except if you had multiple vias it ended up merging them all together, which I don't think you wanted. So instead of the leSearchHierarchy using cv~>bBox, I used the bBox of the specific via you were iterating over. I tidied the code up (sorted out the local variables, indentation and so on) and added the missing parentheses. It then works fine...

    procedure(vias_to_rect(lib cell @optional (viaLPP '("VIA1" "drawing")))
      let((cv viaBBox  via1 mergevia1 Bottom BottomMin Left LeftMin Right RightMax Top TopMax LowerLeft UpperRight)
        cv=dbOpenCellViewByType(lib cell "layout" "" "a")
    
        ;Flatten the layout
        foreach(fig1 cv~>vias
          viaBBox=fig1~>bBox
          leFlattenInst(fig1 30 t t t nil t t)
    
          ;Search and store individual vias
          via1=leSearchHierarchy( cv viaBBox 0 "rectangle" list( list( "layer" "==" viaLPP ) ) )
    
          ;Merge via arrays
          mergevia1=dbLayerSize(cv viaLPP via1 0.04)
    
          ;Find the bottom left and top right corners of via array
          RightMax=nil
          LeftMin=nil
          TopMax=nil
          BottomMin=nil
    
          foreach(fig mergevia1
            when(fig~>objType=="rect"
              if(RightMax==nil
              then
                RightMax=xCoord(cadr(fig~>bBox))
                LeftMin=xCoord(car(fig~>bBox))
                TopMax=yCoord(cadr(fig~>bBox))
                BottomMin=yCoord(car(fig~>bBox))
              )
              Right=xCoord(cadr(fig~>bBox))
              Left=xCoord(car(fig~>bBox))
              Top=yCoord(cadr(fig~>bBox))
              Bottom=yCoord(car(fig~>bBox))
    
              if(Right>RightMax then RightMax = Right)
              if(Left<LeftMin then LeftMin = Left)
              if(Top>TopMax then TopMax = Top)
              if(Bottom<BottomMin then BottomMin = Bottom)
              ; delete merged via
              dbDeleteObject(fig)
            )
          )
    
          ;Resize merged via to have the same area as the original array of vias
          when(LeftMin && BottomMin && RightMax && TopMax
            LowerLeft=LeftMin:BottomMin
            UpperRight=RightMax:TopMax
            dbCreateRect(cv viaLPP list(LowerLeft UpperRight))
            )
          ;Delete original vias
          foreach(fig via1
            dbDeleteObject(fig)
            )
          )
        )
      )
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • socratic
    socratic over 4 years ago in reply to Andrew Beckett

    Oh man, I see my mistake now. Your solution worked brilliantly! Also taught me to use better naming and indentation in the future too. Thanks so much for your time and help!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information