• 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. skill writing style

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 15223
  • 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

skill writing style

nrk1
nrk1 over 11 years ago
I am new to skill and was looking at skill codes available on the web. I found abMapAndWire.ils by Andrew Beckett and noticed that variables are assigned in the first form below rather than the second. What are the differences? and advantages of the former? Tried searching the web and this forum and couldn't find something that directly mentioned these, probably because I don't know the proper names for them.
 
Form 1 (syntax form???):
(setq pin (car (getq terminal pins)))
 
Form 2 (assignment???):
pin=car(terminal~>pins)
 
Also, in the skill language reference, the syntax is given as
setq( x 5 )
rather than
(setq x 5)
 
What are the differences? and the preferred way? 
 
Thanks 
Regards

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    It doesn't matter which style you pick because they are completely equivalent. For example:

    code='(x=5)
    code => (x = 5)
    car(code) => setq
    cadr(code) => x
    sstatus(printinfix nil)
    code => (setq x 5)
    sstatus(printinfix t)

    So what you can see from the simple example above is that the parser will cope with either the C (or "infix") style of expression or the LISP style of expression, but actually it really represents it in a LISP format. Since the only difference is at parsing time, there's no efficiency difference between the two styles; they both execute in the same way.

    The sstatus(printinfix t/nil) is a way of getting the pretty printer to output in C or LISP styles. So if you've written a function, such as this:

    (procedure (abExtendBBox bbox @rest xy)
      (let (minx maxx miny maxy coord)
           (if (and (listp xy)
                    (listp (car xy))
                    (listp (car (car xy))))
               (setq xy (car xy)))
           (if (null bbox)
               (setq bbox (list (car xy) (car xy))))
           (setq minx (xCoord (lowerLeft bbox)))
           (setq maxx (xCoord (upperRight bbox)))
           (setq miny (yCoord (lowerLeft bbox)))
           (setq maxy (yCoord (upperRight bbox)))
           (foreach coord xy
                    (if (lessp (xCoord coord) minx) (setq minx (xCoord coord)))
                    (if (lessp (yCoord coord) miny) (setq miny (yCoord coord)))
                    (if (greaterp (xCoord coord) maxx) (setq maxx (xCoord coord)))
                    (if (greaterp (yCoord coord) maxy) (setq maxy (yCoord coord))))
           /* return the new bbox */
           (list (list minx miny) (list maxx maxy))))

    You can define this function and then do:

    pp(abExtendBBox)

     procedure(abExtendBBox(bbox \@rest xy)
        let((minx maxx miny maxy coord)
            if((listp(xy) && listp(car(xy)) && listp(car(car(xy))))
                (xy = car(xy))
            )
            if(!bbox
                (bbox = list(car(xy)
                        car(xy)
                    ))
            )
            (minx = (xCoord
                    (lowerLeft bbox)
                ))
            (maxx = (xCoord
                    (upperRight bbox)
                ))
            (miny = (yCoord
                    (lowerLeft bbox)
                ))
            (maxy = (yCoord
                    (upperRight bbox)
                ))
            foreach(coord xy
                if(((xCoord coord) < minx)
                    (minx = (xCoord coord))
                )
                if(((yCoord coord) < miny)
                    (miny = (yCoord coord))
                )
                if(((xCoord coord) > maxx)
                    (maxx = (xCoord coord))
                )
                if(((yCoord coord) > maxy)
                    (maxy = (yCoord coord))
                )
            )
            list(list(minx miny)
                list(maxx maxy)
            )
        )
    )

    It will turn it back into C-style. Or you can do sstatus(printinfix nil) before pp-ing a function, and it will dump it in LISP-style.

     

    Now, why do I write it in LISP-style (usually) rather than C-style? Well, when I first starting writing SKILL code in (about) 1991, I had written in a lot of languages previously (including C, and a little LISP). I found that if I used the C-style, I kept making mistakes because it wasn't quite C. Also, it is fussier about whitespace with C-style, whereas additional spaces don't matter with LISP style. Secondly, I found that it encouraged me to think in terms of LISP ways of doing things - i.e. thinking in terms of lists rather than arrays, and so on.

    So my natural inclination after all these years is to write in LISP style. However, if I'm writing a function as an example to be taken and modified (rather than just used verbatim), then I usually write it in C style because that's what is most commonly used. My usage of LISP style is a bit pedantic - so for example, I would write (setq a (times (difference b c) d)) whereas I have colleagues who would happily throw (setq a (b-c)*d) into their code. For me it's all or nothing...

    My general recommendation is to pick a style that works for you, and stick with it. Don't mix and match the styles within the same code because that makes it very hard to read.

    Regards,

    Andrew. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • nrk1
    nrk1 over 11 years ago

    Thanks for the quick and detailed response. 

    > I would write (setq a (times (difference b c) d)) whereas...

    Thanks for mentioning this. I had decided to follow the style in abMapAndWire, and it was precisely when I started writing "...(times (difference kk 1) x)" etc. that I had a doubt and posted my queries. 

    Regards

     

     

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

    Yes, the SKILL LISP mode is a bit verbose when it comes to expressions. In a number of LISP dialects the expression would be (setq a (* (- b c) d) (might be setf rather than setq). In SKILL however, the operator symbols can't directly be used as function names (they could, but they'd have to be escaped, which would be a bit clunky) - so instead we have wordy equivalents of the *, -, +, / functions etc.

    Regards,

    Andrew.

    • 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