• 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. Recursively assign ?callback entries when creating a new...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 144
  • Views 14185
  • 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

Recursively assign ?callback entries when creating a new pull-down menu using hiCreateMenuItem()

Pacher Luca
Pacher Luca over 10 years ago

Dear SKILL users,

This is my first post on the Cadence IC SKILL Forum so I will try to be as precise and exhaustive as possible. I'm trying to write a SKILL script to add a new pull-down menu in the main Cadence Virtuoso Command Interpreter Window (CIW) and enable faster access to process and IP libraries documents in PDF format that come with the CMOS fabrication technology we are working with.

I know basic SKILL language programming and syntax. As a starting point I followed the code skeleton proposed in the well-known post

http://community.cadence.com/cadence_technology_forums/f/48/t/15213

Basically I want to:

1. define a SKILL list e.g. PDF_DOCLIST that stores absolute paths to PDF documents that I want to open from the newly-created pull-down menu using a (selectable) UNIX PDF viewer e.g. "/absolute/path/to/process/design/rules/filename.pdf"

2. define an auxiliary SKILL list e.g. LABEL_DOCLIST containing for each entry in the previously declared list the corresponding meaningful and human-readabe text label that explains the content of the PDF document that I want to access e.g. "Design Rule Manual (DRM)"

3. define a custom SKILL function e.g. openPDF(fileName) to open fileName using the PDF viewer specified according to the value of an external PDF_VIEWER environment variable if set, use a default value otherwise. Question: do exist in Cadence IC a SKILL routine to open a PDF file? I know that Cadence Allegro provides an axlPdfView(fileName) function for this task, as discussed in

community.cadence.com/.../11357

but I can't find an equivalent counterpart for the Cadence full-custom design environment.

4. loop over PDF files and recursively use the hiCreateMenuItem() function to dynamically create menu items and callbacks to the openPDF function. When I mention "dynamically" I'm referring to the fact that I want to use just one for/foreach loop over PDF_DOCLIST and LABELS_DOCLIST items, so I can add further menu entries just by adding new items to PDF_DOCLIST and LABELS_DOCLIST lists

5. complete the menu creation using hiCreatePulldownMenu() and  hiInsertBannerMenu()

Up to now I wrote the following code:

-----------------------------------------------------------------------------------------------------------------

ciwMenuInit()

PDF_DOCLIST = list("/path/to/fileName1.pdf" "/path/to/fileName2.pdf" "etc.")

LABEL_DOCLIST = list("Meaningful text label for fileName1.pdf" "Meaningful text label for fileName2.pdf" "etc.")

;; select the PDF viewer

if( getShellEnvVar("PDF_VIEWER") != nil  && isFile(getShellEnvVar("PDF_VIEWER") )

then

   PDF_VIEWER = getShellEnvVar("PDF_VIEWER")

else

   PDF_VIEWER = "/usr/bin/xpdf"

) ;; if

;; loop over PDF_DOCLIST items to add pull-down menu entries

index = 0

menu_entries = list()

foreach(fileName PDF_DOCLIST

   menu_entries = cons(

      hiCreateMenuItem(

         ?name       gensym('fileName)

         ?itemText   nth(index LABEL_DOCLIST)

         ?callback   "openPDF(fileName)"

      ) ;; hiCreateMenuItem

   menu_entries

   ) ;; cons

   index = index + 1

) ;; foreach

;; Define a new custom SKILL function to display the PDF

procedure(
   openPDF(fName)
      printf("Opening PDF document %s \n" fName)
      csh(strcat(PDF_VIEWER " " fName "&") )
) ;; procedure


;;  Create the new pull-down menu and populate it with previously-defined entries (I don't show here the technology Xyz I'm working with)

NewXyzMenu = hiCreatePulldownMenu(
   'NewXyzMenu
   "Open Xyz Documentation"
   menu_entries
) ;; hiCreatePulldownMenu

;; Insert the menu before the default Help entry in the CIW

hiInsertBannerMenu(
   window(1)
   NewXyzMenu
   99
) ;; hiInsertBannerMenu

-----------------------------------------------------------------------------------------------------------------

With this code I've succesfully added the pull-down menu in the Virtuoso CIW and all document names listed in LABEL_DOCLIST appear, but when I try to left-click on any items in the menu the call to the openPDF fails with the following error:

*Error* eval: unbound variable - fileName

I think that the iterator fileName of the foreach loop is considered as a local variable, hence for some reason its value is not seen within the hiCreateMenuItem() function when I specify the ?callback entry. This is strange since the same variable is seen by the gensym() function that creates a symbol for ?name. Interesting if I add an auxiliary global variable in the foreach loop e.g.

-----------------------------------------------------------------------------------------------------------------

foreach(fileName PDF_DOCLIST

   fileName_global = fileName

   menu_entries = cons(

      hiCreateMenuItem(

         ?name       gensym('fileName)

         ?itemText   nth(index LABEL_DOCLIST)

         ?callback   "openPDF(fileName_global)"

      ) ;; hiCreateMenuItem

   menu_entries

   ) ;; cons

   index = index + 1

) ;; foreach

-----------------------------------------------------------------------------------------------------------------

when I left click on any menu items it turns out that the call to openPDF function ALWAYS DISPLAYS THE SAME PDF FILE for all entries defined in PDF_DOCLIST !

Certainly something is wrong, maybe in the definition of the openPDF() function or in the iterated assignments to ?callback in the hiCreateMenuItem() function? Actually I tried to use let() and declare local variables too, but nothing changes.

I wrote a similar script to add the same feature in Cadence Encounter Digital Implementation System using Tcl and everything works fine:

-----------------------------------------------------------------------------------------------------------------

uiAdd XyzMenu -type menu  -label "Xyz PDK"  -in main

uiAdd XyzDocMenu  -type submenu -label "Open Xyz Documentation" -in XyzMenu

set PDF_DOCLIST [list "/path/to/fileName1.pdf" /path/to/fileName2.pdf" "etc"]

set LABEL_DOCLIST [list "Meaningful text label for fileName1.pdf" "Meaningful text label for fileName2.pdf" "etc."]

set PDF_VIEWER /usr/bin/xpdf

for {set i 0} {$i < [llength $PDF_DOCLIST]} {incr i} {
   uiAdd DesignRulesDoc  -type  command                               \
                                     -in    XyzDocMenu                              \
                                     -label [lindex $LABEL_DOCLIST $i]     \
                                    -command "exec $PDF_VIEWER [lindex $PDF_DOCLIST $i] &"
}

-----------------------------------------------------------------------------------------------------------------


Thanks in advance for hints and suggestions!

Cheers

Luca

--

OS: RHEL 6.6 64-bit

Cadence IC version: IC6.1.6

Cadence EDI version: 14.13

  • Cancel
Parents
  • theopaone
    theopaone over 10 years ago

    ?callback "openPDF(fileName)"

    With this line, your are passing in the symbol fileName rather than a value. This is the source of your error.

    Change this line to

    ?callback sprintf(nil "openPDK(%s)" fileName)


    This will insert the value of fileName into the string for the command.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • theopaone
    theopaone over 10 years ago

    ?callback "openPDF(fileName)"

    With this line, your are passing in the symbol fileName rather than a value. This is the source of your error.

    Change this line to

    ?callback sprintf(nil "openPDK(%s)" fileName)


    This will insert the value of fileName into the string for the command.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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