list box usage

Discussion in 'Cadence' started by PolyPusher, Dec 21, 2009.

  1. PolyPusher

    PolyPusher Guest

    Hi All,

    I have a list of nets in a list box and want to write, or someone
    could share if they have it, SKILL code that would toggle thru the
    list.

    For example these nets are in the list box.

    net010
    net020
    net030
    net040

    I have the code written to probe the nets upon selecting the net and
    simply wish to attach code to a bindkey that would "run" down the
    list, selecting one after another and "wrap" at the end of the list
    back to the beginning of the list.

    Happy Holidays!!!!!!
    PolyPusher
     
    PolyPusher, Dec 21, 2009
    #1
  2. PolyPusher wrote, on 12/21/09 16:29:
    Hi Eric,

    Using this code below as the thing that generates a list box (it's actually a
    list box field in a form, which I prefer, as it has more control than
    hiShowListBox() ):

    =====================================================================
    /* abSelectObjByName.il

    Author A.D.Beckett
    Group Custom IC (UK), Cadence Design Systems Ltd.
    Language SKILL
    Date Mar 26, 2003
    Modified Nov 16, 2008
    By A.D.Beckett

    Little utility for selecting instances, terminals or nets by name
    (at least, the shapes associated with them). To use:

    abSelectObjByName('instances)
    abSelectObjByName('nets)
    abSelectObjByName('netsAndVias)
    abSelectObjByName('terminals)
    abSelectObjByName('figGroups) ; OA only

    netsAndVias is for CDB releases - with OA, vias are on the net
    anyway.

    Extended to allow a function to be passed to do the "selection". so
    forms can be used for other things (e.g. abProtect package)

    ***************************************************

    SCCS Info: @(#) abSelectObjByName.il 11/16/08.19:26:07 1.4

    */

    /***************************************************************
    * *
    * (abCreateSelectObjByNameForm) *
    * *
    * Create the form *
    * *
    ***************************************************************/

    (procedure (abCreateSelectObjByNameForm)
    (let (objects)
    (setq objects (hiCreateListBoxField
    ?name 'objects
    ?choices nil
    ?value nil
    ?multipleSelect t
    ?doubleClickCB "(abSelectObjByNameCB (hiGetCurrentForm))"
    ?valueByPosition t
    ))
    (hiCreateAppForm
    ?name 'abSelectObjByNameForm
    ?fields (list
    (list objects 0:0 300:400)
    )
    ?attachmentList (list
    hicLeftPositionSet|hicTopPositionSet|
    hicRightPositionSet|hicBottomPositionSet
    )
    ?initialSize 300:400
    ?formTitle "Select things"
    ?callback 'abSelectObjByNameCB
    )
    ))

    /***************************************************************
    * *
    * (abSelectObjByNameList cellView type names selectFunc) *
    * *
    * Given a list of names of a particular type *
    * (nets, instances, terminals), select them *
    * either directly, or using the selectFunc function *
    * *
    ***************************************************************/

    (procedure (abSelectObjByNameList cellView type names selectFunc)
    (let (objects object)
    ;-----------------------------------------------------------------
    ; Determine the objects which will be selected
    ;-----------------------------------------------------------------
    (setq objects
    (foreach mapcan name names
    (case type
    ;--------------------------------------------
    ; For instances, look for either instance or mosaic
    ;--------------------------------------------
    (instances
    (list
    (or
    (dbFindAnyInstByName cellView name)
    (dbFindMosaicByName cellView name)
    )
    ))
    ;--------------------------------------------
    ; For nets, include the pin figures, and the
    ; net figures
    ;--------------------------------------------
    (nets
    (setq object (dbFindNetByName cellView name))
    (nconc
    (dbGetq (dbGetq object pins) fig)
    (dbGetq object figs)
    ))
    ;--------------------------------------------
    ; For netsAndVias, include the pin figures, and the
    ; net figures, and any vias on the nets
    ;--------------------------------------------
    (netsAndVias
    (setq object (dbFindNetByName cellView name))
    (nconc
    (dbGetq (dbGetq object pins) fig)
    (dbGetq object figs)
    (setof inst (dbGetq
    (dbGetq object instTerms) inst)
    (leIsContact inst))
    ))
    ;--------------------------------------------
    ; For terminals, find the pin figures
    ;--------------------------------------------
    (terminals
    (dbGetq
    (dbGetq
    (dbFindTermByName cellView name)
    pins)
    fig
    ))
    ;--------------------------------------------
    ; For figGroups, just return them directly
    ;--------------------------------------------
    (figGroups
    (list
    (dbGetFigGroupByName cellView name)
    )
    )
    ))
    )
    ;-----------------------------------------------------------------
    ; Now select them (deselecting first)
    ;-----------------------------------------------------------------
    (if selectFunc
    (foreach obj objects
    (funcall selectFunc obj)
    )
    ; else
    (progn
    (geDeselectAllFig cellView)
    (foreach obj objects
    (geSelectFig obj)
    )
    )
    )
    t
    )
    )

    /***************************************************************
    * *
    * (abSelectObjByNameCB form) *
    * *
    * the form callback - does the selection, and zooms to fit *
    * the selected objects *
    * *
    ***************************************************************/

    (procedure (abSelectObjByNameCB form)
    (abSelectObjByNameList
    (getq form cellView)
    (getq form type)
    (hiGetListBoxValue (getq form objects))
    (getq form selectFunc)
    )
    (unless (getq form selectFunc)
    (leZoomToSelSet)
    )
    t
    )

    /****************************************************************
    * *
    * (abSelectObjByName [type [cellView [selectFunc]]]) *
    * *
    * Passed a type - instances, nets or terminals, and a cellView, *
    * give the user a list of objects to select. Also can give a *
    * a function object to do the "selection" if you want it to do *
    * something other than selection *
    * *
    ****************************************************************/

    (procedure (abSelectObjByName @optional (type 'instances)
    (cellView (geGetEditCellView))
    selectFunc)
    (let (objects intType)
    (unless (boundp 'abSelectObjByNameForm)
    (abCreateSelectObjByNameForm))
    (when cellView
    (setq intType (if (eq type 'netsAndVias) 'nets type))
    (setq objects (dbGet cellView intType))
    (hiSetFormName abSelectObjByNameForm
    (sprintf nil "Select %s by name" type))
    ;-----------------------------------------------------------
    ; Record what kind of objects these are
    ;-----------------------------------------------------------
    (putpropq abSelectObjByNameForm type type)
    (putpropq abSelectObjByNameForm cellView cellView)
    (putpropq abSelectObjByNameForm selectFunc selectFunc)
    ;-----------------------------------------------------------
    ; Deselect everything first
    ;-----------------------------------------------------------
    (putpropq (getq abSelectObjByNameForm objects) nil value)
    ;-----------------------------------------------------------
    ; Handle mosaics - return mosaic name instead
    ;-----------------------------------------------------------
    (when (eq type 'instances)
    (setq objects
    (foreach mapcar object objects
    (or (dbGetq object mosaic) object))))
    ;-----------------------------------------------------------
    ; Now update the choices
    ;-----------------------------------------------------------
    (putpropq (getq abSelectObjByNameForm objects)
    (sort (dbGetq objects name)
    (lambda (a b) (minusp (alphaNumCmp a b)))
    )
    choices)
    ;-----------------------------------------------------------
    ; And display it
    ;-----------------------------------------------------------
    (hiDisplayForm abSelectObjByNameForm)
    )
    t
    )
    )

    =====================================================================

    Then you could have a function (I'll write in C syntax, since this might be the
    bit you modify):

    procedure(abSelectObjByNameNext()
    let((len current)
    when(boundp('abSelectObjByNameForm)
    len=length(abSelectObjByNameForm->objects->choices)
    current=car(abSelectObjByNameForm->objects->value)
    if(current then
    current=mod(current len)+1
    else
    current=1
    )
    abSelectObjByNameForm->objects->value=list(current)
    )
    )
    )

    It's a bit primitive - I've not made it do the apply part (that could be at the
    end of the callback) and my code allows multiple selection - the Next operation
    just does a next on the first selection.

    Regards,

    Andrew.
     
    Andrew Beckett, Jan 19, 2010
    #2
  3. PolyPusher

    PolyPusher Guest

    Wow. I thought no one was going to even answer this one. This looks
    like exactly the functionality I was looking
    for.

    You wrote "I'll write in C syntax, since this might be the
    bit you modify", I know this a knucklehead thing to ask, but what is
    the syntax of the rest of the code? It is all skill no? Too much
    too learn, so little time. Sigh.

    Thank you very much!
    Eric
     
    PolyPusher, Jan 19, 2010
    #3
  4. PolyPusher wrote, on 01/19/10 16:53:
    Hi Eric,

    Yes, it's all SKILL. SKILL however has two different syntaxes (at least...), due
    to its heritage.

    SKILL essentially is LISP, but the parser was modified to allow C-like syntax.
    The parser however supports both - and in terms of how the code executes, it
    makes no difference which you use. So the following are equivalent:

    1+2
    plus(1 2)
    (plus 1 2)

    The first is the C-like "infix" syntax for expressions. The second is the C-like
    function syntax (all operators in SKILL are really functions), and the last is
    the LISP syntax.

    As I said, they're all equivalent - inside it's really LISP, but whether you
    enter the code as C or LISP style makes no difference. You can see this by doing:

    code='(3+4*5)
    car(code) => plus
    cadr(code) => 3
    caaddr(code) => times
    sstatus(printinfix nil)
    code => (plus 3 (times 4 5))

    So the parser magically converted the C-like syntax into LISP inside (the
    printinfix nil just tells it to output any list without any "infix" operators,
    i.e. in LISP syntax).

    Now, when I first started writing SKILL (as a designer, before I joined
    Cadence), back in about 1991-ish, I had written a lot of C, but also knew some
    LISP (I'm probably not a conventional analog designer ;-> ). As a result I found:

    a) I kept making mistakes with SKILL because it wasn't _quite_ C syntax
    b) I found that using the LISP syntax encouraged me to write using LISP
    approaches to problems
    c) vi has a nice "lisp" mode (even in SunOS/Solaris - not talking about
    gvim here) which took care of identing the code for me automatically

    I'm a bit bloody minded too. So I tend (and still tend) to write my SKILL code
    in LISP syntax - hence the "Lots of Irritating and Superflous Parentheses" in
    the first chunk of code I posted.

    However, I do recognize that the majority of the world writes SKILL using the
    C-syntax. So I tend to use LISP syntax for anything I'm writing myself, or for
    any packages I expect people to use as-is, but maybe C-syntax for any examples
    which are to illustrate how to do something, or something which is a sample to
    modify. Unless it's much clearer in LISP syntax (e.g. writing macros is often
    clearer in LISP syntax, I think).

    You'll wish you'd not asked now...

    Regards,

    Andrew.
     
    Andrew Beckett, Jan 19, 2010
    #4
  5. PolyPusher

    PolyPusher Guest

    "You'll wish you'd not asked now..."

    No, I am glad I asked and glad you replied. The C syntax seemed
    "easy" for me to grasp and always felt with enough experience I could
    do most things I want to do eventually. I didn't know you were a
    PolyPusher yourself once.

    The LISP syntax I still find confusing to read, it seems very foreign
    to me and now I understand why(most of my background is from C and
    BASIC(yes, I am old)), but am fascinated by its symmetry, it looks
    "cleaner".

    Thank you for your time and you Cadence people keep up the great
    work. I can't wait to get to IC61

    BTW, your CEO(Mike) came to our campus often when I worked at
    Intel. I always thought very highly of him.

    Thank you,
    Eric
     
    PolyPusher, Jan 19, 2010
    #5
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.