• 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. If condition failure

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 17157
  • 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

If condition failure

LaksNanu
LaksNanu over 9 years ago

Hi,

I am new to skill,

I am checking if any of the windows are opened, if windows are available, then check if particular (lib,cell,view) are opened,
if the layout is not already opened then print the statement. (i will substitute print statement to deopencellview later).

I am unable to find the problem with the below code. As it is not working properly, when i open cell view, it prints absent statement.

procedure( lpFgOpenDB()

   let( (openWin svw)

      openWin=cdr(hiGetWindowList())

      foreach(svw (openWin~>cellView)

         if( !(((svw~>libName) == "lp_amr") && ((svw~>cellName) == "apple") && ((svw~>viewName) == "layout"))

          then

           printf( "apple is absent\n" )

         else if( !(((svw~>libName) == "lp_amr") && ((svw~>cellName) == "orange") && ((svw~>viewName) == "layout"))

          then

           printf( "orange is absent\n" )

         );else if

         );if

      );foreach

   );lef

);proc

An alternative to the above code is also helpful

Thanks & Regards,

Lakshmiprashanth

((svw~>libName) == "lp_amr" && (svw~>cellName) == "fromlayout" && (svw~>viewName) == "layout")

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Your code will always say either "apple is absent" or "orange is absent" because for each window, it will check first that it is not "apple" - if so, it will print that, otherwise if it's not "orange" it will print that. Put another way, if the window contained "apple", it would tell you that orange was absent. If it contained "orange", it would tell you that apple is absent. That's not really a specific SKILL issue, it's a programming logic issue.

    I suspect what  you really want to do is find out for a particular lib/cell/view whether it's in a window already. You could do:

    procedure(CCFfindExistingWindow(libName cellName viewName)
      let((svw)
        car(exists(win hiGetWindowList()
         {
           svw=win~>cellView
           svw~>libName==libName && svw~>cellName==cellName svw~>viewName==viewName
         }
        ))
      )
    )

    If you then do CCFfindExistingWindow("lp_amr" "apple" "layout") it would return the window id of the window containing it, or nil if not found.

    Alternatively, you could use these built-in functions instead:

    procedure(CCFfindExistingWindow(libName cellName viewName)
      let((cv)
        cv=dbFindOpenCellView(ddGetObj(libName) cellName viewName)
        cv && geGetEditCellViewWindow(cv)
      )
    )

    That's probably a bit more direct.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 9 years ago

    Hi Laksmiprahanth,

    I think that the issue is that perhaps you are expecting the "!" to cover combined "&&" statements, however it has a higher precedence than the other operators and so only applies to the first item of the statement. You can rewrite the statement using the function rather than the operator, it should correct the problem and may offer more clarity:

    if( null(and((svw~>libName =="lp_amr")  (svw~>cellName == "apple") (svw~>viewName == "layout"))) then ...

    Hope this helps!

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Hi Lawrence,

    Our responses crossed. However, I don't think you're right. The three && conditions are surrounded by parentheses, and so the ! is doing the not of all of them, not just the first. Put another way, it's the same as your code.

    To show this, I used sstatus(printinfix nil) and pp'd the original code:

    (if
      (null
        (and
          (equal
            (getSGq svw libName) "lp_amr"
          )
          (equal
            (getSGq svw cellName) "apple"
          )
          (equal
            (getSGq svw viewName) "layout"
          )
       )
     ) then
     (printf "apple is absent\n")
    )

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 9 years ago
    Hi Andrew,

    yes, you are right, I missed that. Too many parentheses ! I'm glad that you provided the correct answer!

    Cheers,
    Lawrence.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • LaksNanu
    LaksNanu over 9 years ago
    Hi Andrew & Lawrence,

    Thanks for helping me to understand the mistakes,
    And moreover the code given by you is working .
    This is what I needed.

    Regards,
    Lakshmiprashanth
    • 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