• 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. Trigger a Skill Code by Selecting/Deselecting an Instance...

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 144
  • Views 6567
  • 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

Trigger a Skill Code by Selecting/Deselecting an Instance in Schematic

mapReduce
mapReduce over 6 years ago

Hello,

Is there a way to call-back a user defined skill code after I select an instance in schematic. I found a similar question on this forum but they suggest using leRegUserLayerSelectionFilter. This function seems to create a user-defined filter option which is not exactly what I want.

Thanks!

  • Cancel
  • mbracht
    mbracht over 6 years ago

    Hi,

    For a start - you need to use leRegUserObjectSelectionFilter(<filterFunction>) to allow for all objects and not just shapes. However the filter function is called not only when you select an object by clicking on it but also when you hover the mouse over it.The code below handles this:

    (defun osf (fig)
       (let ()
          (when (car (last (geGetSelSet))) == fig && fig->objType == "inst"
             (printf "selected %L\n" fig->cellName)
             ; ...here goes your code....
          )
          t
       )
    )

    leRegUserObjectSelectionFilter("osf")

    So whatever code you want to run when an instance is selected, just put it in the when() statement.

    regards
    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mapReduce
    mapReduce over 6 years ago in reply to mbracht

    Hi Max,

    I tried the following code as per your suggestion:

     procedure(osf(fig)
        (let ()
           (when (car (last (geGetSelSet))) == fig && fig->objType == "inst"
             (printf "selected %L\n" fig->cellName)
           )
           t
         )
      )
    leRegUserObjectSelectionFilter("osf")

    But when I select any instance in my schematic, then nothing gets printed in the CIW. Could you please let me know what am I doing wrong.

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • henker
    henker over 6 years ago in reply to mapReduce

    leRegUserObjectSelectionFilter is a layout function (note the 'le' prefix = Layout Editor). I think there is no schematic equivalent.

    You could still redefine the selection bindkeys to add this functionality there.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mbracht
    mbracht over 6 years ago in reply to mapReduce

    Sorry my mistake - I didnt read your description carefully and because you mentioned a layout function figured that was about layouts.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mbracht
    mbracht over 6 years ago in reply to henker

    hmmh...what do you mean with selection bindkey? You select an instance by a single left click which is bound to schSingleSelectPt(). Now that function selects an instance when there is one under your mouse and does nothing while you are in an empty area of the schematic. So you'd have to know whether there is an instance under your mouse - and which one that would be. Is there a way to find this out in terms of a SKILL function?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • henker
    henker over 6 years ago in reply to mbracht

    What you basically need to do is

    1) remember the current selection

    2) do whatever the mouse action click/drag/etc is doing

    3) compare the now modified selection with the one stored at 1)

    So, default bindkey for e.g. layout area selection is

    hiSetBindKey( "Layout"     "<DrawThru1>"      "leSelBoxOrStretch()" )

    To match the 1),2),3) points, you could replace this (and all other selection bindkeys accordingly) with

    hiSetBindKey( "Layout"     "<DrawThru1>"      "selectionHook_start() leSelBoxOrStretch() selectionHook_done()" )

    and have the two functions for 1) and 3) as (toy example)

    procedure( selectionHook_start()
        let( (win)
            win = hiGetCurrentWindow()
            GLB_PRE = geGetSelSet(win)
        )
    )
    procedure( selectionHook_done(mode)
        let( (win pre cur sList dList)
            win = hiGetCurrentWindow()
            cur = geGetSelSet(win)
            pre = GLB_PRE
            GLB_PRE = nil

            ;; call select_hooks on current - remembered
            ;; call deselect_hooks on remembered - current
            dList = setof(e pre !member(e cur))
            sList = setof(e cur !member(e pre))

            when(dList printf("deselecting %L\n" dList~>objType))
            when(sList printf("selecting %L\n"   sList~>objType))
        );let
    )

    Could be much more optimized, setof+member is O(n^2), should be replaced with a table; with preknowledge if it is only adding or subtracting from selection (Shift or Ctrl pressed), then there can be either nothing deselected resp. selected, so this half could be omitted, etc.

    You could probably also have only one function with all three steps combined and pass the original function name (here leSelBoxOrStretch) as symbol to do 2) internally; so you would get rid of the global variable; but in this special case here leSelBoxOrStretch is a macro, and I did not find out how to evaluate a macro and pass it afterwards as argument or how to evaluate the macro symbol after being passed into the function (as macros are evaluated at compile time).

    Anyway, just a toy example...

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RiadKaced
    RiadKaced over 6 years ago

    Hi mapReduce

    The "leRegUserLayerSelectionFilter" is a Layout Editor function only as pointed out by @henkl. There is no equivalent in Schematic. However, what you are looking for is very easy with a custom Bindkey that redefines the deault selection bindkey. Here is an example where I'm overriding the LMB click for single selection with a custom function that does the selection and prints a message to the CIW about the instance being slected, here is the code.

    ; Define a custom function that overloads schSingleSelectPt()

    procedure(mySingleSelectPt()

      let((inst)

        ; Use the original selection function

        schSingleSelectPt()

        ; Print info about the selected Instance

        inst=car(geGetSelectedSet())

        printf("Instance %s (%s/%s)\n" inst~>name inst~>libName inst~>cellName)

      )

    )

    ; Redifine the bindkey. I always suggest to check the bindkey override

    ; from CIW -> Options -> Bindkeys. or with SKILL using

    ; hiGetBindKey("Schematics" "None<Btn1Down>")

    hiSetBindKey("Schematics" "None<Btn1Down>" "mySingleSelectPt()")

    Cheers,

    Riad.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mapReduce
    mapReduce over 6 years ago in reply to RiadKaced

    Thanks Riad and henkl for the suggestion!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sheppie
    Sheppie over 5 years ago in reply to RiadKaced

    Hi Riad,

    Thank you for your suggestion. I was looking for something similar and your implementation worked great for what I needed: changing the entry layer in LSW by simply selecting an existing shape in layout (the LPP of that shape will be the new entry layer). Please see the code below.

    Fullscreen 0640.SCLLeMouseSingleSelectPt.il.txt Download
    ;;; This procedure sets the entry layer depending on lpp of the shape selected.
    ;;; This functionality is standard in Mentor Pyxis, and ported to Virtuoso using this procedure and bind-key re-mapping.
    procedure( SCLMouseSingleSelectPt()
    	let( (	( selection nil ) )
    
    		;;; Use the original selection function
    		mouseSingleSelectPt()
    
    		selection = geGetSelectedSet()
    
    		;;; Put any custom code that should be triggered by selecting anything in a lay-out editor window below...
    		SCLSetLSWEntryLayerByShape( selection )
    
    	) ;;; end of let
    ) ;;; end of procedure SCLMouseSingleSelectPt
    
    ;;; Re-define the bindkey. I suggest to check the bindkey override
    ;;; from CIW -> Options -> Bindkeys; or with SKILL using:
    ;;; hiGetBindKey("Layout" "None<Btn1Down>")
    hiSetBindKey("Layout" "None<Btn1Down>" "SCLMouseSingleSelectPt()")
    

    Fullscreen 7723.SCLLeSetLSWEntryLayerByShape.il.txt Download
    ;;; This procedure is called from SCLMouseSingleSelectPt()
    procedure( SCLSetLSWEntryLayerByShape( selection )
    	let( (	( cvId nil )
    		( tfId nil )
    		( objId nil )
    		( lpp nil )
    		( proceed t ) )
    		
    		;;; If the selection has multiple items, then all object types have to be the same.
    		;;; This is to get this script to work with wires. A wire is a special type of path.
    		;;; A wire may consist of multiple segments, which will result in "selection" being
    		;;; a list of more then 1 item. With the 'setof' part all items NOT equal to the first
    		;;; item will be listed, thus signaling that not all items are from the same object type.
    		;;; This works when only one object has been selected too.
    		when( selection
    			if( setof( item selection nequal( item~>objType car( selection )~>objType ) )
    			then
    				;;; Different object types have been selected (like rectangles/paths/instances)
    				proceed = nil
    			else
    				foreach( item selection
    					when( proceed
    						cond(
    							;;; The item must be a shape AND it must have an lpp.
    							;;; If it doesn't comply to this, no use to proceed...
    							;;; For instance: an instance does not have an lpp...
    							( not( and( item~>isShape item~>lpp ) )
    								proceed = nil
    							)
    							;;; It is a valid item (it did not past the first conditional test),
    							;;; now see if the lpp has already been set: if not, this is the first item, thus set lpp.
    							( not( lpp )
    								lpp = item~>lpp
    							)
    							;;; It is a valid item, and the lpp has already been set, thus it is not the first item.
    							;;; Chech whether or not the LPP different, if it is, no need to proceed: which lpp
    							;;; should be used? 
    							( nequal( lpp item~>lpp )
    								proceed = nil
    							)
    						) ;;; end of cond
    					) ;;; end of when
    				) ;;; end of foreach item
    			) ;;; end of if
    
    			when( proceed
    				objId = car( selection )
    				cvId = objId~>cellView
    				tfId = techGetTechFile( cvId )
    
    				when( leIsLayerValid( lpp tfId )
    					unless( leIsLayerVisible( lpp tfId )
    						leSetLayerVisible( lpp t tfId )
    					) ;;; end of unless
    
    					leSetEntryLayer( lpp tfId )
    				) ;;; end of when
    			) ;;; end of when
    		) ;;; end of when
    	) ;;; end of let
    ) ;;; end of procedure SCLSetLSWEntryLayerByShape
    

    After downloading, remove the .txt part of the extention...

    This forum is a really good place to get inspiration.

    Kind regards,

    Sjoerd

    UPDATE: code has been updated to work with wires (= multi-segment path)

    • 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