SKILL Q: Cycling through all open schematics and do something

Discussion in 'Cadence' started by svenn.are, Sep 26, 2003.

  1. svenn.are

    svenn.are Guest

    Hi,

    after reading a bit in the skcompref.pdf I find that there are many
    functions that work on the current window or d_cvId. So far I havent't
    found how to get all open d_cvId's as a list and then do something
    with the schematics in all of them. Purpose is to have two or more
    schematics side-by-side and then execute a command in CIW that
    extracts a textual list of transistors and geometries of all open
    windows and put them in a comma-separated list for Excel import. (or
    whatever)
     
    svenn.are, Sep 26, 2003
    #1
  2. Hi Svenn,

    Well, the functions you'll need are probably hiGetWindowList() and
    dbGetOpenCellViews()

    If you're looking for just those in windows, you'd use something like:

    foreach(win hiGetWindowList()
    when(win~>cellView
    ... do something...
    )
    )

    Or if you want to be good and use the API:

    foreach(win hiGetWindowList()
    cv=geGetEditCellView(win)
    getWarn() ; to swallow warnings about windows without cellViews
    when(cv
    ... do something...
    )
    )

    Andrew.
     
    Andrew Beckett, Sep 26, 2003
    #2
  3. svenn.are

    svenn.are Guest

    after a while the first idea came like this:

    (setq cv (dbOpenCellViewByType "LIBRARY" "CELL" "schematic" nil "r"))
    (setq instList (schGetMatchingObjects cv "cellName" "==" "*" nil))
    (foreach cell instList
    (setq symbol (car cell))
    (println (dbSearchPropByName symbol "w")))

    This way I get at least a nil for those symbols not having any w
    property, but I can't get the value of that w. I just get a
    db:12343213 reference back, and I can't say if it is a ddId a cvId a
    bagId or whatever SKILL is calling these things. It seems to me that
    there are many functions to set and change properties, but very few to
    list them.

    I tried to use some of the Bag functions or the ddGetObj, but they
    complained that that the symbol above was not of kind ddId. This is
    slowly getting on my nerves.
     
    svenn.are, Sep 26, 2003
    #3
  4. Hi Svenn,

    What you get back is easily identifiable - use

    (setq propId (dbSearchPropByName symbol "w"))

    Then propId~>objType will tell you what kind of object it is.
    Since this is a prop object, you can do propId~>name propId~>value etc.

    Alternatively you could do:

    (setq cv (dbOpenCellViewByType "LIBRARY" "CELL" "schematic" nil "r"))
    (foreach inst (dbGetq cv instances)
    (when (setq value (dbGetq inst w))
    (printf "Width of %s is %L" (dbGetq inst name) value)
    )
    )

    or something like that (off the top of my head). (dbGetq a b) is the same
    as a~>b for a dbObject, but in LISP-speak.

    Look in the Design Framework II SKILL functions manual, and it covers the
    database in a lot of detail, especially how the db object model works
    with the attributes of each db object.

    Regards,

    Andrew.
     
    Andrew Beckett, Sep 26, 2003
    #4
  5. svenn.are

    snmishra Guest

    svenn> wrote in message

    svenn> after a while the first idea came like this:

    svenn> (setq cv (dbOpenCellViewByType "LIBRARY" "CELL" "schematic"
    svenn> nil "r")) (setq instList (schGetMatchingObjects cv "cellName"
    svenn> "==" "*" nil)) (foreach cell instList
    svenn> (setq symbol (car cell)) (println (dbSearchPropByName
    svenn> symbol "w")))

    svenn> This way I get at least a nil for those symbols not having
    svenn> any w property, but I can't get the value of that w. I just
    svenn> get a db:12343213 reference back, and I can't say if it is a
    svenn> ddId a cvId a bagId or whatever SKILL is calling these
    svenn> things. It seems to me that there are many functions to set
    svenn> and change properties, but very few to list them.

    svenn> I tried to use some of the Bag functions or the ddGetObj, but
    svenn> they complained that that the symbol above was not of kind
    svenn> ddId. This is slowly getting on my nerves.

    svenn> -- Svenn

    Hi Svenn

    I think w is usually in the cdf and not a part of the properties of the
    cellView. Some thing like this might do the job for you:

    (setq cv (dbOpenCellViewByType "LIBRARY" "CELL" "schematic" nil "r"))
    (mapc
    (lambda (instance)
    (println (getq (getq (cdfGetInstCDF instance) "m") value)))
    (dbGetq cv instances))
     
    snmishra, Sep 26, 2003
    #5
  6. Actually there's not really any point getting the cdf for the instance, at least
    when you're in CDS_Netlisting_Mode set to Analog, because doing a
    (dbGetq instance "m") or instance~>m will return either the instance property
    or if it is not there, the default value from the CDF. Strictly speaking there
    isn't such thing as an instance CDF - it's just a "virtual" structure which is a
    combination of the instance properties overlaid on the cell CDF.

    Regards,

    Andrew.
     
    Andrew Beckett, Sep 27, 2003
    #6
  7. svenn.are

    snmishra Guest

    Andrew> On 26 Sep 2003 10:25:34 -0600,

    Andrew> Actually there's not really any point getting the cdf for
    Andrew> the instance, at least when you're in CDS_Netlisting_Mode
    Andrew> set to Analog, because doing a (dbGetq instance "m") or
    Andrew> instance~>m will return either the instance property or if
    Andrew> it is not there, the default value from the CDF. Strictly
    Andrew> speaking there isn't such thing as an instance CDF - it's
    Andrew> just a "virtual" structure which is a combination of the
    Andrew> instance properties overlaid on the cell CDF.

    Andrew> Regards,

    Andrew> Andrew.
    Andrew,

    Thanks for the clarification. I will fix my existing SKILL code to
    use dbGetq instead of cdfGetInstCDF.

    Satya

    Andrew> -- Andrew Beckett Senior Technical Leader Custom IC
    Andrew> Solutions Cadence Design Systems Ltd
     
    snmishra, Sep 27, 2003
    #7
  8. svenn.are

    svenn.are Guest

    Hi,
    after programming for a while I finally have something like a
    very-pre-alpha of a skill snippet for printing comma separated files
    containing instances and their properties. Each file is named
    %library%-%cellname%-%cellviewtype%.txt

    Currently the script must be loaded with (load "script.il") but maybe
    some day I get far enough to attach it behind a button or a menu item.

    Thanks a lot for the help contributed, without I would never reach
    this far. Skill is a language for the highly SKILL'ed and one day
    maybe I could earn real hard cash on it, but now it mostly (s)kill my
    project time.

    Comments and improvements are highly welcome.

    Here's the script.il:

    ;; A function to return a sorted list of properties
    (defun sabGetPropNamesSorted (obj)
    (setq lProps '())
    (foreach prop (dbGetq obj prop)
    (setq lProps (cons (dbGetq prop name) lProps)))
    (sort lProps 'alphalessp))

    ;; To cycle all open windows
    (foreach win (hiGetWindowList)
    (setq cv (geGetEditCellView win))
    (getWarn)
    (when cv
    (sprintf fileName "%s-%s-%s.txt" (dbGetq cv libName)
    (dbGetq cv cellName)
    (dbGetq cv cellViewType))
    (println fileName)
    (setq myPort (outfile fileName))
    (foreach inst (dbGetq cv instances) ;; loop on all instances
    (when (dbGetq inst prop) ;; Print only if it has a
    property
    (fprintf myPort "\n%s," (dbGetq inst name))
    (foreach prop (sabGetPropNamesSorted inst)
    (fprintf myPort "%s=%s," prop (dbGet inst prop)))))
    (close myPort)))
     
    svenn.are, Sep 29, 2003
    #8
  9. svenn.are

    snmishra Guest

    Hi Svenn

    Just a few things that I would do differently. I assume prop is a
    variable you set before loading the SKILL code.

    1. the formal variable for the "foreach" in "sabGetPropNamesSorted' is
    the same name as the variable prop. This probably works because
    foreach I think is a macro that actually uses mapcar and lambda. But I
    think somebody more enlightened might be able to shed more light on
    it.

    2. I would have written "sabGetPropNamesSorted" as follows:
    (defun sabGetPropNameSorted (obj prop)
    (sort (mapcar (lambda (x) (dbGetq x name)) (dbGetq obj prop))
    'alphalessp))
    I usually prefer not to use dynamic scoping ablities of SKILL.

    Regards
    Satya

    svenn> Hi, after programming for a while I finally have something
    svenn> like a very-pre-alpha of a skill snippet for printing comma
    svenn> separated files containing instances and their
    svenn> properties. Each file is named
    svenn> %library%-%cellname%-%cellviewtype%.txt

    svenn> Currently the script must be loaded with (load "script.il")
    svenn> but maybe some day I get far enough to attach it behind a
    svenn> button or a menu item.

    svenn> Thanks a lot for the help contributed, without I would
    svenn> never reach this far. Skill is a language for the highly
    svenn> SKILL'ed and one day maybe I could earn real hard cash on
    svenn> it, but now it mostly (s)kill my project time.

    svenn> Comments and improvements are highly welcome.

    svenn> Here's the script.il:

    svenn> ;; A function to return a sorted list of properties (defun
    svenn> sabGetPropNamesSorted (obj) (setq lProps '()) (foreach prop
    svenn> (dbGetq obj prop) (setq lProps (cons (dbGetq prop name)
    svenn> lProps))) (sort lProps 'alphalessp))

    svenn> ;; To cycle all open windows (foreach win (hiGetWindowList)
    svenn> (setq cv (geGetEditCellView win)) (getWarn) (when cv
    svenn> (sprintf fileName "%s-%s-%s.txt" (dbGetq cv libName)
    svenn> (dbGetq cv cellName) (dbGetq cv cellViewType)) (println
    svenn> fileName) (setq myPort (outfile fileName)) (foreach inst
    svenn> (dbGetq cv instances) ;; loop on all instances (when
    svenn> (dbGetq inst prop) ;; Print only if it has a property
    svenn> (fprintf myPort "\n%s," (dbGetq inst name)) (foreach prop
    svenn> (sabGetPropNamesSorted inst) (fprintf myPort "%s=%s," prop
    svenn> (dbGet inst prop))))) (close myPort)))

    svenn> -- Svenn
     
    snmishra, Sep 29, 2003
    #9
  10. svenn.are

    snmishra Guest

    Hi Svenn

    Sorry for the errors in my previous post. "prop", as I found out once I
    got back to work is a property. So you can ignore the part about
    variables ( the first point).

    2. becomes

    (defun sabGetPropNamesSorted (obj)
    (sort (mapcar (lambda (x) (dbGetq x name)) (dbGetq obj prop))
    'alphalessp))

    Thanks
    Satya

    snmishra> Hi Svenn Just a few things that I would do differently. I
    snmishra> assume prop is a variable you set before loading the SKILL
    snmishra> code.

    snmishra> 1. the formal variable for the "foreach" in
    snmishra> "sabGetPropNamesSorted' is
    snmishra> the same name as the variable prop. This probably works
    snmishra> because foreach I think is a macro that actually uses
    snmishra> mapcar and lambda. But I think somebody more enlightened
    snmishra> might be able to shed more light on it.

    snmishra> 2. I would have written "sabGetPropNamesSorted" as
    snmishra> follows:
    snmishra> (defun sabGetPropNameSorted (obj prop)
    snmishra> (sort (mapcar (lambda (x) (dbGetq x name)) (dbGetq obj
    snmishra> prop))
    snmishra> 'alphalessp))
    snmishra> I usually prefer not to use dynamic scoping ablities of
    snmishra> SKILL.

    snmishra> Regards Satya

    svenn> Hi, after programming for a while I finally have something
    svenn> like a very-pre-alpha of a skill snippet for printing comma
    svenn> separated files containing instances and their
    svenn> properties. Each file is named
    svenn> %library%-%cellname%-%cellviewtype%.txt

    svenn> Currently the script must be loaded with (load "script.il")
    svenn> but maybe some day I get far enough to attach it behind a
    svenn> button or a menu item.

    svenn> Thanks a lot for the help contributed, without I would never
    svenn> reach this far. Skill is a language for the highly SKILL'ed
    svenn> and one day maybe I could earn real hard cash on it, but now
    svenn> it mostly (s)kill my project time.

    svenn> Comments and improvements are highly welcome.

    svenn> Here's the script.il:

    svenn> ;; A function to return a sorted list of properties (defun
    svenn> sabGetPropNamesSorted (obj) (setq lProps '()) (foreach prop
    svenn> (dbGetq obj prop) (setq lProps (cons (dbGetq prop name)
    svenn> lProps))) (sort lProps 'alphalessp))

    svenn> ;; To cycle all open windows (foreach win (hiGetWindowList)
    svenn> (setq cv (geGetEditCellView win)) (getWarn) (when cv (sprintf
    svenn> fileName "%s-%s-%s.txt" (dbGetq cv libName) (dbGetq cv
    svenn> cellName) (dbGetq cv cellViewType)) (println fileName) (setq
    svenn> myPort (outfile fileName)) (foreach inst (dbGetq cv
    svenn> instances) ;; loop on all instances (when (dbGetq inst prop)
    svenn> ;; Print only if it has a property (fprintf myPort "\n%s,"
    svenn> (dbGetq inst name)) (foreach prop (sabGetPropNamesSorted
    svenn> inst) (fprintf myPort "%s=%s," prop (dbGet inst prop)))))
    svenn> (close myPort)))

    svenn> -- Svenn
     
    snmishra, Sep 29, 2003
    #10
  11. Svenn,

    (dbGetq) (or the ~> operator) can be used with the first argument (or
    left hand side in the case of the operator) being a list. In this case it
    does an implicit mapcar.

    In other words, doing:

    (dbGetq (dbGetq inst prop) name)
    or

    inst~>prop~>name

    will give the list of property names. This is equivalent to doing:

    (foreach mapcar prop (dbGetq inst prop) (dbGetq prop name))

    which is also identical to:

    (mapcar (lambda (prop) (dbGetq prop name)) (dbGetq inst prop))

    (the foreach mapcar is effectively a macro which forms the second
    bit of code for you).

    What this boils down to is that the sorted property names can
    be got simply by doing:

    (sort (dbGetq (dbGetq inst prop) name) 'alphalessp)

    Apart from that, the only other issue was that you used a global
    variable in your sorting function - if you're going to use variables
    in functions, it is best to use (let (var1 var2 var3) code ... )
    to declare them as local. However, by changing to use the
    code suggested above, you no longer need any local variables anyway!

    If you can't come on a SKILL class, then I'd definitely recommend reading
    the SKILL User Guide thoroughly - it's written in the style of a book on
    a programming language, and introduces the concepts in the language.

    That said, the main problem is that you then end up with 5000+ public
    SKILL functions to contend with - there is a very large API available
    for use, and getting familiar with that takes some time!

    Regards,

    Andrew.
     
    Andrew Beckett, Sep 30, 2003
    #11
  12. svenn.are

    svenn.are Guest

    Hi,
    thanks to skill wizards a couple of beginner errors have been
    identified and better solutions suggested. The global value thing was
    a quick and dirty solution that worked for the moment. Using local
    variables is something I ususally do when I know how the language
    handle these things.

    I chose to keep the defun as I think the code is more readable. I see
    that my choice of using lisp syntax is not at all readable compared to
    the skill extended syntax. Well, I think I'll stay with the lisp
    syntax as there are other lisp controlled EDA tools out there.

    As usual, comments and suggestions for improvement are welcome. Use at
    own risk.

    Here is the new revision:

    ;; A function to return a sorted list of properties
    (defun sabGetPropNamesSorted (obj)
    (sort (dbGetq (dbGetq inst prop) name) 'alphalessp))

    ;; To cycle all open windows
    (foreach win (hiGetWindowList)
    (setq cv (geGetEditCellView win))
    (getWarn)
    (when cv
    (sprintf fileName "%s-%s-%s.txt" (dbGetq cv libName)
    (dbGetq cv cellName)
    (dbGetq cv cellViewType))
    (println fileName)
    (setq myPort (outfile fileName))
    (foreach inst (dbGetq cv instances) ;; loop on all instances
    (when (dbGetq inst prop) ;; Print only if it has a
    property
    (fprintf myPort "\n%s," (dbGetq inst name))
    (foreach prop (sabGetPropNamesSorted inst)
    (fprintf myPort "%s=%s," prop (dbGet inst prop)))))
    (close myPort)))
     
    svenn.are, Sep 30, 2003
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.