• 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. How to stop the current iteration and start the next iteration...

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 10550
  • 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

How to stop the current iteration and start the next iteration of the loop( for/while ) in skill?

cwgong
cwgong over 15 years ago

 Hi All,

    The title is my question. " How to stop the current iteration and start the next iteration of the loop( for/while ) in skill? ".

    I tried to loop some input data, but some data will invoke error during the iteration, and the programming would be stopped and exit. So I need a key word like "continue" in language C or "next" in perl to ignore the unusual process and go to the next iteration in the loop. I tried to explore some documents, but got nothing.

    So, could anyone can give me some reference about this issue?

    Thanks very much.

 

 

 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    The next() and break() functions are for the SKILL debugger. They are NOT equivalent to functions in other languages which continue to the next point in a loop, or break out of a loop. The go() function is a goto in SKILL. I've never used it, and have avoided it like the plague - I'm opposed to it on philosophical grounds (I think it has no place in a functional language).

    There are several ways you can do loops which exit early. For example:

    lst='(1 2 3 4 0 5 6 7)
    forall(item lst
        when(errset(div=100.0/item)
            printf("100.0/%d is %g\n" item div)
            t
        )
    )

    Similarly you could use the exists() function to iterate over a list until a match is made. Or you could use a while loop, taking the cdr each time:

    status=t
    ptr=lst
    while(status && ptr
       item=car(ptr)
       if(some_bad_condition then
         status=nil
       else
         ptr=cdr(ptr)
       )
    )

    Or if you want to use a jump-out type approach, you could use:

    prog(()
      foreach(item lst
        if(errset(div=100.0/item) then
          printf("100.0/%d is %g\n" item div)
        else
          return()
        )
      )
    )

    The return is returning from the prog() - and although it happens in the middle of the foreach, it will jump out of the foreach cleanly. 

    Personally I don't tend to like this approach, because it's a bit of a goto in disguise, and it's still smacks of "spaghetti programming" to me. But I can see that for some difficult to handle errors, it could be useful.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    The next() and break() functions are for the SKILL debugger. They are NOT equivalent to functions in other languages which continue to the next point in a loop, or break out of a loop. The go() function is a goto in SKILL. I've never used it, and have avoided it like the plague - I'm opposed to it on philosophical grounds (I think it has no place in a functional language).

    There are several ways you can do loops which exit early. For example:

    lst='(1 2 3 4 0 5 6 7)
    forall(item lst
        when(errset(div=100.0/item)
            printf("100.0/%d is %g\n" item div)
            t
        )
    )

    Similarly you could use the exists() function to iterate over a list until a match is made. Or you could use a while loop, taking the cdr each time:

    status=t
    ptr=lst
    while(status && ptr
       item=car(ptr)
       if(some_bad_condition then
         status=nil
       else
         ptr=cdr(ptr)
       )
    )

    Or if you want to use a jump-out type approach, you could use:

    prog(()
      foreach(item lst
        if(errset(div=100.0/item) then
          printf("100.0/%d is %g\n" item div)
        else
          return()
        )
      )
    )

    The return is returning from the prog() - and although it happens in the middle of the foreach, it will jump out of the foreach cleanly. 

    Personally I don't tend to like this approach, because it's a bit of a goto in disguise, and it's still smacks of "spaghetti programming" to me. But I can see that for some difficult to handle errors, it could be useful.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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