Home > Community > Forums > Custom IC SKILL > Rename label and part of instance in multiple layouts

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Rename label and part of instance in multiple layouts 

Last post Fri, Feb 6 2009 10:03 AM by Austin CAD Guy. 6 replies.
Started by AnuJoamon 02 Feb 2009 04:37 AM. Topic has 6 replies and 3199 views
Page 1 of 1 (7 items)
Sort Posts:
  • Mon, Feb 2 2009 4:37 AM

    • AnuJoamon
    • Not Ranked
    • Joined on Mon, Feb 2 2009
    • Bangalore, Karnataka
    • Posts 7
    • Points 110
    Rename label and part of instance in multiple layouts Reply

    I have many layout cells in my library in which I need to do two changes

    1. I want to replace label xxxABxxx with xxxCDxxx (in a specific layer say "m1" "dg")
    2. Replace instance yyyAByyy from library YYYY to instance zzzCDzzz from library ZZZZ.
    3. Check that there is no instance in the entire library coming either from the same library of one reference library (specified).

    Anuj.

     

    Anuj
    • Post Points: 20
  • Mon, Feb 2 2009 7:00 AM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 394
    • Points 7,420
    Re: Rename label and part of instance in multiple layouts Reply

    You have a lot of questions, so I highly recommend you read some Skill documentation. I am including some "untested" skill code. It should be almost ready to run. You should take a look at what I have done and look at some documentation to make sure you understand it. Your description of what you wanted is somewhat vague. It is unclear to me if "xxx", "yyy" and "zzz" are literal, or if wildcard matching is necessary. I assumed wildcards since that is the more complicated scenario. If the names are literal, then a simple == comparison is all that is needed in the check rather than a rexMatchp. Also, if it is literal, then you could skip the rexReplace and rexCompile commands altogether and do simple string assignments.

    I broke the code into a routine that runs on a cellview. This makes code testing easier. Run the "changeCell" routine on the current open layout cellview to make sure your labels and cellview are change appropriately. Since the save takes place in the calling routine, you can discard your edits, adjust the code and retest. If you change the value of the badLibrary in the optional arguments to whatever you are referring to in #3, then you can actually run "changeCell()" with no arguments and it will get the current open cellview and use the bad library name that you wish to check for.

    ;You must define myLibary and badRefLibrary

    procedure(doAllCells(myLibrary badRefLibrary)
      let((libId cv)
        libId = ddGetObj(myLibrary)
        foreach(cell libId~>cells~>name
            when(ddGetObj(myLibrary cell "layout")
                printf("Working on cell %s\n" cell)
                cv = dbOpenCellViewByType(myLibrary cell "layout" nil "a")
                changeCellView(cv badRefLibrary)
                dbSave(cv)
                dbClose(cv)
            )
        )
      ) ;let
    ) ;proc


    procedure(changeCellView(@optional (cv geGetEditCellView()) (badRefLibrary "myBadLibrary"))
      let((labels newLabel insts cellName newCellName badRefs)
        labels = setof(x cv~>shapes x~>objType=="label")
        rexCompile("AB")
        foreach(lbl labels
            ;If only replacing labels that are currently m1 then use this when statement
            when(lbl~>lpp == list("m1" "drawing")
                newLabel = rexReplace(lbl~>theLabel "CD" 0)
                lbl~>theLabel = newLabel
            )
            ;OR if wanting to convert the label to m1, use this
            lbl~>lpp = list("m1" "drawing")
        )

        insts = setof(x cv~>instances x~>libName == "YYYY" && rexMatchp("AB" x~>cellName))
        foreach(inst insts
            cellName = inst~>cellName
            rexCompile("yyy")
            newCellName = rexReplace(cellName "zzz" 0)
            rexCompile("AB")
            newCellName = rexReplace(newCellName "CD" 0)
            leReplaceAnyInstMaster(inst "ZZZZ" newCellName nil)
        )

        ;You must specify badRefLibrary
        badRefs = setof(x cv~>instances x~>libName == badRefLibrary)
        when(badRefs
            foreach(r badRefs
                printf("**ERROR: Found reference from library %s in %s\n" badRefLibrary r~>cellName)
            )
        )
      ) ;let
    ) ;proc

    -Derek

    • Post Points: 20
  • Tue, Feb 3 2009 9:42 PM

    • AnuJoamon
    • Not Ranked
    • Joined on Mon, Feb 2 2009
    • Bangalore, Karnataka
    • Posts 7
    • Points 110
    Re: Rename label and part of instance in multiple layouts Reply

    Thanks Derek. The examples provided by you have provided me clarity to proceed. But I am having some syntax problem while using the foreach ...

    procedure(checkWireCell(libname wireCellList)
        let((outfNameError outfError error libid cellList cellId cell cv inst)
       libid=ddGetObj(libname)
       foreach(cell wireCellList
          if(member("layout" dbAllCellViews(libid cell~>name)) then
              cv=dbOpenCellViewByType(libname cell~>name "layout" nil "r")
              if(length(cv~>instances)!=0
                  foreach(inst cv~>instances
                       if((inst~>libName!=libname && inst~>libName!="ALL_PARTS" ) then
                        fprintf(outfError "\nWARNING: INSTANCE  %s  Of Cell %s points to a different Library  (%s)" inst~>cellName cell~>name inst~>libName)
                        error = 1
                         )  ; if
                    )  ; foreach
                 ) ; if
              dbClose(cv)
          else
              fprintf(outfError "\nWARNING: Cell %s does not contain a layout view" cell~>name)
                           error = 1
          )
       )
     ) ; let
    ) ; proc

    Anuj
    • Post Points: 20
  • Tue, Feb 3 2009 10:04 PM

    • AnuJoamon
    • Not Ranked
    • Joined on Mon, Feb 2 2009
    • Bangalore, Karnataka
    • Posts 7
    • Points 110
    Re: Rename label and part of instance in multiple layouts Reply

    0 am trying the point 3 first, to check whether the instance comes from any other library. I I add the libray names in the if condition, I can get the thing going, but got stuck with the foreach syntax ... it says

    *Error* foreach: second argument must be a list - "list"

    Anuj
    • Post Points: 20
  • Wed, Feb 4 2009 6:35 AM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 394
    • Points 7,420
    Re: Rename label and part of instance in multiple layouts Reply

    Your second argument needs to be in this form:  list("a" "b" "c") or list(obj1 obj2 obj3)

    In your example, wireCellList must be a list of items, even if it is a list of only one item. The second foreach in the code you posted is using cv~>instances which will either be nil (a valid list), or a list of object ids like: list(db:421865904 db:421865868 db:421865832 db:421865796)

    If you have a string that has multiple items separated by a space, you can convert this to a list using parseString.

    From the error, it looks like you are passing in the string "list". This is what needs to change.

    -Derek

    • Post Points: 5
  • Wed, Feb 4 2009 6:49 AM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 394
    • Points 7,420
    Re: Rename label and part of instance in multiple layouts Reply

    I'd like to make one suggestion about your piece of code. You have two if statements without a then clause. This syntax is perfectly legal, but will only work if there is only one statement within the if. If you add a second statement, it becomes an implied else statement unless you add a then. I find that it is a clearer coding practice to use when if my if clause is not going to have an else.

    if(a==1
       doThis()
    )

    if(a==1 then
       doThis()
    )

    when(a==1
       doThis()
    )

    All three of the above will do the same thing, but the when statement is the most clear and can avoid the following coding mistake which is difficult to catch:

    if(a==1
       doThis()
       doThisAlso()
    )

    The above statement is actually an implied if/else. The doThisAlso() will only be called if a does not equal 1, unless you add the then to the syntax. I will use the above statement in my code only if it is clear in the context of what I am doing so I avoid confusing anyone who edits my code.

    if(a==1
       b = t
       b = nil
    )

    Notice that it is clear this is two different actions since I wouldn't set b to t and then set it to nil.

    Just my opinion.

    Derek

    • Post Points: 20
  • Fri, Feb 6 2009 10:03 AM

    Re: Rename label and part of instance in multiple layouts Reply

     And a good opinion it is, Derek.

    The use of the if statement without a then or else is a common source of costly errors. I had a customer who modified such a statement by putting in a third statement which turns it from an if/then/else to an if/then. They were desparate as it was holding up a tapeout.

    After I found the problem and sent the fixed code and a very big bill, they complained that all I added was two words, then and else and should not pay hunderds of dollars for two words. The bill was sent back to them listing $.50 cents per word and the rest for the knowledge where to place them. They paid.

    • Post Points: 5
Page 1 of 1 (7 items)
Sort Posts:
Started by AnuJoamon at 02 Feb 2009 04:37 AM. Topic has 6 replies.