• 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. Button to select instance from schematic

Stats

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

Button to select instance from schematic

AdrienL
AdrienL over 1 year ago

Hello,

I've been searching for hours for a simple solution, but I can't find anything.

I have a Form (hiCreateAppForm) and I would like to have a button that when clicked : Open a schematic (selected before) and allows to select an instance.

Once the instance is selected, it should get back to the form and give me the db object of the clicked instance.

There are some buttons with this kind of behaviour in ADE or Virtuoso.

I'm pretty sure therefore that there is a simple solution but I can't find one.

  • Cancel
Parents
  • AurelBuche
    AurelBuche over 1 year ago

    Hi Adrien,

    I don't believe there is a simple solution to what you are looking for...

    A solution would be to use enterPoint but you would have to manage cases according to what is clicked (and I am not sure if the interaction would be very user-friendly, I am not a huge fan of enter functions and I avoid using them [maybe I am wrong])

    However I took an hour to build you a custom-tailored SKILL++ example inspired by this discussion (Trigger a Skill Code by Selecting/Deselecting an Instance in Schematic)

    It should work on the fly. The principle is detailled her : 

    1. It opens a form
    2. You fill library, cell & view
    3. You click on 'Select Instance' button
    4. It raises (or opens) associated window
    5. It modifies the click bindkey to register selected instance so it can be accessed in other form functions
    6. You have to click on an instance
    7. It restores the click bindkey
    8. It raises the form with selected instance value

    The code relies on SKILL++ closures and is written in Lisp style, I hope you are OK with that

    If you have any question don't hesitate

    Cheers

    Aurélien

    (inScheme
    (let (form prev_click_bk selected_inst)
    
      ;; -------------------------------------------------------
      ;; Properly set and unset custom
      ;; bindkey to select instance
      ;; -------------------------------------------------------
    
      (defun set_bk (new_bk)
        "Register NEW_BK as click callback and store previous one"
        (unless (equal new_bk (hiGetBindKey "Schematics" "None<Btn1Down>"))
          (setq prev_click_bk (hiGetBindKey "Schematics" "None<Btn1Down>"))
          (hiSetBindKey "Schematics" "None<Btn1Down>" new_bk)
          ))
    
      (defun unset_bk ()
        "Unregister custom click callback and restore previous one"
        (hiSetBindKey "Schematics" "None<Btn1Down>" prev_click_bk)
        (setq prev_click_bk nil)
        )
    
      (defglobalfun cst_single_select_pt (@rest _args)
        "Callback to be registered as \"None<Btn1Down>\" bindkey"
        (unwindProtect
          ;; Run previous click callback, then store selected instance
          (prog1
            (evalstring prev_click_bk)
            (let ((inst (car (exists obj (geGetSelectedSet) (equal "inst" obj->objType)))))
              (when inst
                (setf form->inst_label->value inst->name)
                (setq selected_inst inst)
                ))
            ;; Raise form again
            (hiDisplayForm form)
            );prog1
          ;; Reset click callback
          (unset_bk)
          ));def
    
      ;; -------------------------------------------------------
      ;; Utilities
      ;; -------------------------------------------------------
    
      (defun get_view_type (lib cell view "ttt")
        "Return LIB/CELL/VIEW type"
        ;; Make sure view is valid
        (let ((dd_cv (ddGetObj lib cell view)))
          (assert dd_cv "%s/%s/%s does not exists" lib cell view)
          (assert dd_cv "%s/%s/%s is not a valid view: %A %A" lib cell view dd_cv (type dd_cv))
          )
        (ddMapGetFileViewType (ddGetObj lib cell view "*")))
    
      (defun raise_window (lib cell view "ttt")
        "Raise window where LIB/CELL/VIEW is currently edited, create it if necessary"
        (hiRaiseWindow
          ;; Try to find window showing lib/cell/view
          (or (car (exists win (hiGetWindowList)
                     (let ((cv (muffleWarnings (geGetWindowCellView win))))
                       (and cv
                            (equal lib  cv->libName  )
                            (equal cell cv->cellName )
                            (equal view cv->viewName )
                            ))))
              ;; Window was not found, open it
              (deOpenCellView lib cell view (get_view_type lib cell view) nil "r")
              (error "Unable to open %s/%s/%s in read-only mode" lib cell view)
              )));or ;hiRaiseWindow ;def
    
      ;; -------------------------------------------------------
      ;; Create & Display Interface
      ;; -------------------------------------------------------
    
      (defun create_form ()
        "Create and return custom layout form"
        (hiCreateLayoutForm 'cst_custom_form "Custom Form"
          (hiCreateFormLayout 'main_layout ?items (list
              ;; Library, cell & view
              (ddHiCreateLibraryComboField ?name 'lib_field  ?prompt "Library" )
              (ddHiCreateCellComboField    ?name 'cell_field ?prompt "Cell"    )
              (ddHiCreateViewComboField    ?name 'view_field ?prompt "View"    )
              ;; Button to select instance
              (hiCreateButton
                ?name       'select_instance_button
                ?buttonText "Select Instance"
                ?callback
                (lambda (@rest _args)
                  ;; Make sure cellview exists and is a valid schematic one
                  (letseq ( (new_bk     "cst_single_select_pt()"      )
                            (lib        (form->lib_field->value )     )
                            (cell       (form->cell_field->value)     )
                            (view       (form->view_field->value)     )
                            (view_type  (get_view_type lib cell view) )
                            )
                    (assert (equal "schematic" view_type)
                      "%s/%s/%s is not a schematic view but a %s one!"
                      lib cell view view_type)
                    ;; Open schematic window in read-only mode
                    (raise_window lib cell view)
                    ;; Register bindkey to select instance
                    (set_bk new_bk)
                    );letseq
                  ));select_instance_button
              ;; Label to show selected instance
              (hiCreateOutputStringField ?name 'inst_label ?prompt "Selected Instance" ?value "*No Instance Selected Yet*")
              ));main_layout
          ?callback
          (lambda (@rest _args)
            ;; Make sure bindkey is reverted if form is closed
            (unwindProtect
              ;; Display selected instance
              (printf "Selected instance is %A\n" selected_inst->name)
              (unset_bk)
              ))
          ));def
    
      (defglobalfun cst_show_custom_form (@rest _args)
        "Display custom form, form is generated only once"
        ;; Make sure form is created, instanciated (necessary to link fields) and initialized
        (unless form
          (setq form (create_form))
          (hiInstantiateForm form)
          (ddHiLinkFields form->lib_field form->cell_field form->view_field)
          )
        (hiDisplayForm (or form (setq form (create_form))))
        );def
    
      ));scheme closure
    
    
    ;; #TEST
    (cst_show_custom_form)
    
    ;*/
    
    
    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • AdrienL
    AdrienL over 1 year ago in reply to AurelBuche

    Thanks a lot Aurélien !

     I also found enterPoint(), but just like you, I didn't like that solution.

    During my searches I found the same discussion and thought I might use it. I just thought it was not super clean and there should be a better and cleaner solution.

    I'm not a big fan of changing the bind key, I'm scared the user could go in an other schematic and click on something completely different. It's not really a tragedy though.

    Anyway, I will try your solution, thank you very much. I'll tell you if works as expected.

    I will also wait for others to think about the project, maybe some one might come up with a simpler solution.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • AdrienL
    AdrienL over 1 year ago in reply to AurelBuche

    Thanks a lot Aurélien !

     I also found enterPoint(), but just like you, I didn't like that solution.

    During my searches I found the same discussion and thought I might use it. I just thought it was not super clean and there should be a better and cleaner solution.

    I'm not a big fan of changing the bind key, I'm scared the user could go in an other schematic and click on something completely different. It's not really a tragedy though.

    Anyway, I will try your solution, thank you very much. I'll tell you if works as expected.

    I will also wait for others to think about the project, maybe some one might come up with a simpler solution.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • AurelBuche
    AurelBuche over 1 year ago in reply to AdrienL

    Effectively my code is just a draft
    You will have to manage cases where the clicked view is not the right one

    In this case I think the best thing to do is to revert the bindkey, raise the form and display a message saying *wrong cellview* instead of the selected instance name

    I am conviced that my code is quite robust with the bindkeys though, as the previous one is called as it was and reverted afterwards

    Even if the bindkey changes in between, it will mean that the custom one is not called anymore so you just have to re-click the form

    Cheers

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AdrienL
    AdrienL over 1 year ago in reply to AurelBuche

    I implemented the code (with quite some modification to fit to my project of course) and it works. Thank you again!

    And after some tests there is no major problem with the bindkey and other schematics. What I do is just ignoring the select and logging an error in the CIW.

    • Cancel
    • Vote Up +1 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