• 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. Setting up Emacs for SKILL

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 15880
  • 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

Setting up Emacs for SKILL

snezana111
snezana111 over 9 years ago

Hello,

I am fairly new to SKILL and I don't have the option to use SKILL IDE in my version of Cadence.

My current working version of Cadence is IC6.1.6-64b.500.11

I am also novice in EMACS, and I have covered the basics in Common Lisp and SKILL, now I would like to organize my work and I understood there is a way you could use EMACS as an IDE for SKILL. I read through some threads like 

but I am not sure how to set it up. What compiler to use in order to use skillMode.el that is mentioned in the link above? (like, SBCL, or can I use some that are built in in EMACS, like IELM?)

What should happen if I load skillMode.el in emacs? And what is the proper way in doing that? Does it mean I can invoke procedures and function from Emacs and get the results i.e. for adding an instance in Schematic to display in the Schematic window?

Any help and advice appreciated

  • Cancel
  • ebecheto
    ebecheto over 9 years ago
    Dir Jelena,
    I had to fix my skill mode before answering to you.
    indeed, it was not working anymore with emacs > 22, because they removed the possibility in emacs to echo a string to stdout in 'interactive mode' (still feasible in batch mode). They had for some emacsclient reason changed the function `send-string-to-terminal' (how stupid of them).
    So i manage to find a workaround with Linux named piped. But then, it should work too with Allegro skill on Window/mobaxterm (but that's another matter).
    To explain briefly, before i was doing :
    _CADENCE SIDE   ____________________________________
    ipcBeginProcess("emacs" "" (lambda (cid data) evalstring(data)))
    _EMACS SIDE ________________________________________
     (write-region (region-beginning) (region-end) "~/.emacs2icfb.il")  (send-string-to-terminal "load(\"~/.emacs3icfb.il\")")
    And magically a bindkey was executing the code in cadence.... I have a log file with few standard function and when on the line of the function, bindkey C-v will executes it like :
    geOpen(?lib "analogLib" ?cell "vdc" ?view "spectre" ?mode "r")
    would open automatically the windows. (needed Alt-tab though to come back to emacs focus)
    _____WHAT'S UP KNOW_____
    Now i use an intermediate script called "~/Skill/ipcPipe2CAT.sh" that generate a named pipe "/tmp/ipcPipe2CAT_$USER", listen on it and echo to stdout when something comes. Emacs sends a string to it and Cadence (ipcBeginProcess "~/Skill/ipcPipe2CAT.sh" "" 'socketHandler) read from it.

    HERE are the codes to put in you rep $HOME/Skill:
    _emacs_ipcPipe.il_ to load in you ~/cdsinit_personal  (add in your ~/.bashrc : export SKILLDIR=$HOME/Skill)
    defun( socketHandler (ipcId data)
    let((fp res inPort)
    (errset eval(t))
    ; printf("RCV:%L\n" data)
    ; res=load("~/.emacs2icfb.il")
    if(rexMatchp("load" data) then 
    unless(errset(res=load("~/.emacs2icfb.il")  nil)
    error(car(parseString(nth(5 errset.errset)  "*Error* "))
    ))
    else
    inPort=infile("~/.emacs2icfb.il")
    when(inPort while(gets(nextLine inPort) unless((or nextLine=="\n" rexMatchp("^ *;" nextLine) )
    ;removing comment " *;" is not necessary, was only to check warning parenthesis mistake
    ; removing \n is to prevent last res=t ...
    res=evalstring(nextLine))))  close(inPort)
    )
    printf("\nEMACS>");<== can be commented/removed
    printf("%L\n" res)
    fprintf(fp=outfile("~/.virtuoso2emacs.txt") "%L" res) close(fp) ;=> saves resutls in a file for emacs to fetch it if you want
    ))
    
    ipcBeginProcess(strcat(getShellEnvVar("SKILLDIR") "/ipcPipe2CAT.sh") "" 'socketHandler)
    

    HERE is the file:
    _ipcPipe2CAT.sh_

    #!/bin/bash
    # copy paste from http://www.linuxjournal.com/content/using-named-pipes-fifos-bash
    # while debugging load : $> ~/Skill/ipcPipeCAT.sh | tee &
    pipe=/tmp/ipcPipe2CAT_$USER
    
    trap "rm -f $pipe" EXIT
    
    if [[ ! -p $pipe ]]; then mkfifo $pipe; fi
    ret=""
    while true; do
        if read line <$pipe; then
            if [[ "$line" == 'quit' ]]; then break; fi
            ret+=$line
            if [[ "$ret" == *'EOF' ]]; then echo ${ret%EOF}; ret="" ;fi
    #        echo "GOT:$line$()__$ret"
        fi
    done
    
    echo "Reader exiting"
    

    ___now the skillMode.el modifications___ 

    ;; ed modif for emacs2icfb
    
    (if (version< emacs-version "22")
     (defun write2icfb (beg end &optional stuff ) (unless stuff (setq stuff ""))
      (write-region beg end "~/.emacs2icfb.il")
      (write-region (format "\n") t "~/.emacs2icfb.il" t) ; last t means append=tru
      (send-string-to-terminal (format "load(\"%s\") eval(t) " "~/.emacs2icfb.il"))
     )
     (defun write2icfb (beg end &optional stuff ) (unless stuff (setq stuff ""))
      (write-region beg end "~/.emacs2icfb.il")
      (write-region (format "\n") t "~/.emacs2icfb.il" t) ; last t means append=tru
    ;<= ^^ prevent : *WARNING* (reader): too few right parentheses, (')' added at EOF ;<== when load a fine with a function => force load vs read
      (shell-command-to-string (format "echo '%sEOF' > /tmp/ipcPipe2CAT_%s " stuff user-login-name))
     )
    ); if emacs>22 requires an intermediate script to create pipe to stdout
    
    
    (defun send-buffer-to-icfb () "" (interactive) (write2icfb (point-min) (point-max)))
    (defun send-region-to-icfb () "" (interactive) (write2icfb (region-beginning) (region-end) "region"))
    (defun send-func-to-icfb () "" (interactive) (write2icfb (region-beginning) (region-end) "load"))
    (defun send-line-to-icfb   () "" (interactive) (write2icfb (line-beginning-position) (line-end-position)))
    (defun send-line-to-icfb-mv-forward () "" (interactive)
            (write2icfb (line-beginning-position) (line-beginning-position 2) )
            (forward-line 1)
    )
    
    (defun send-function-from-icfb-insert () "" (interactive) 
        (newline) (forward-line -1)
        (push-mark)  (insert ";=> ") 
        (insert-file-contents "~/.virtuoso2emacs.txt")
        (end-of-line) (exchange-point-and-mark)
    )
    
    (define-key skill-mode-map "\C-c\C-f" 'send-func-to-icfb)
    (define-key skill-mode-map "\C-c\C-b" 'send-buffer-to-icfb)
    (define-key skill-mode-map "\C-c\C-r" 'send-region-to-icfb)
    (define-key skill-mode-map "\C-c\C-l" 'send-line-to-icfb)
    (define-key skill-mode-map "\C-c\C-v" 'send-line-to-icfb-mv-forward)
    (define-key skill-mode-map "\C-c\C-s" 'send-function-from-icfb-insert)

    ___

    Now to load skill mode in emacs, just add in your ~/.emacs :

    (load "~/.emacs.d/skillMode.el")

    Well normally, to prevent un necessary loading of many package you do not always use, you should add:

    ;; (add-to-list 'load-path "~/.emacs.d/")
    ;; (require 'skill-mode)
    ;; (add-to-list 'auto-mode-alist '("\\.il$" . skill-mode))

    up to you.

    Enjoy

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • snezana111
    snezana111 over 9 years ago

    Thanks for the explanations!
    This is what I did (hopefully ok...)

    I made a ~/Skill directory in which emacs_ipcPipe.il, ipcPipe2CAT.sh (made it executable) and then my-log.txt is being created when I load skill-mode in emacs buffer and when I write out to icfb.

    in .cdsinit file I have added a load("~/Skill/emacs_2ipcPipe.il") line, and I've added the skillMode.el into /.emacs.d and I think I correctly run that too...

    in the comment area of skillMode.el there is a procedure described, the procedure socketHandler

    I tried adding it in .cdsinit file as a .il file also...but when I start Cadence then 218 emacs buffers open.

    When I start Cadence without invoking the socketHandler procedure, in the CIW I can see ~218 outputs that the "function socketHandler" redefined.

    If I load the procedure socketHandler from the CIW after I have started Cadence then an emacs buffer opens that is in skill-mode, but then when I want to quit Cadence - it crashes and quits very slowly, but eventually is killed in the process.

    If I open a new buffer in emacs and change the major mode to skill-mode it loads ok. I can use the C-c C-b to send the buffer to .emacs2icfb.il file

    Sending the buffer to icfb is actually just creating the .emacs2icfb.il which then I manually load into CIW and then I can call the functions I have written in that emacs buffer (.emacs2icfb)

    But, I don't have the .virtuoso2emacs.txt created in any case. So I think I've done something wrong?

    I made the ipcPipe2CAT.sh executable and put it's path into $PATH, so it should work ok, right?

    Also, what I had in mind originally was to send commands from emacs buffer to CIW and see the output immediately? Like you can do when programming in Common LISP using SBCL-SLIME combo ?

    ---------- edit ---------

    what I had in mind was actually this:

    ebecheto

    I don't know all the steps to use your  'inferior-lisp-program tweak. Could you provide the full code tweeks ?

    That is the full code: Just set "inferior-lisp-program" to start Virtuoso in -nographE mode; no additional setup is necessary.

    You can start Virtuoso in the current buffer's current directory with M-x inferior-lisp.  In another buffer/window, find a SKILL file and start Lisp mode with M-x lisp-mode.  It's helpful (but not required) to have this happen automatically when you visit files that end in ".il" or ".ils":

       (add-to-list 'auto-mode-alist '("\\.ils?$" . lisp-mode))

    Once you're editing a Lisp (SKILL) file in Lisp mode, and you have your virtuoso prompt open in the inferior lisp buffer, you can send commands to it for evaluation with C-c C-e (eval defun) or C-c C-r (eval region).  As usual, C-h m will show you the Lisp mode keys, and C-h b will list all the bindkeys for you. 

    Editing via Inferior Lisp Mode is much easier and more powerful than using the CIW: you have word completion via M-/, command history search via M-r, and of course all the usual Emacs editing commands, not to mention the entire history of your session (and previous Inferior Lisp sessions) is saved in the buffer, unlike the CIW which only keeps the last few lines.

    I'm currently lobbying my AE to improve -nographE mode; e.g. currently you can't use the Library Manager normally in -nographE mode.  You can still open schematics and layouts via deOpenCellView(), but return values from GUI events (e.g. mouse clicks and bindkeys) cannot be filtered: if you pan and zoom a bit, the inferior lisp buffer filles up with lines consisting only of "t".  Still, the overall integration with Emacs is so smooth that I am willing to put up with these little issues.

    I am actually still not 100% sure what and how to do it to achieve what tweeks did in that post.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ebecheto
    ebecheto over 9 years ago

    quick answer, (no time to debug it now). When i shared my code to a 'stagiaire', it looped also ...

    Yes, you have to $> chmod +x ~/Skill/ipcPipe2CAT.sh

    if it loop just , $> rm ~/.emacs2icfb.il

    Otherwise, just try from cadence :

    ipcBeginProcess(strcat(getShellEnvVar("SKILLDIR") "/ipcPipe2CAT.sh") "" 'socketHandler)

    then from a shell $>echo "1+2EOF"> /tmp/ipcPipe2CAT_$USER

    maybe change the socketHandler function so that is only `evalstring(data)' (for debug)



    _________

    Last thing in emacs, if you have not uncommented (add-to-list 'auto-mode-alist '("\\.il$" . skill-mode))
    you need to activate the mode, by pressing (Meta-x), i mean : Alt-x and the write :
    skill-mode
    normally you have the completion (tab key) that works for writing skill-mode in the mini-buffer.
    then in emacs, bindey C-v should execute the code of the current line. C-s should write the results as a comment on the following line if needed.

    I will make a patch of the socketHandler function so that it recognise, whether i launch a line, a region, or if i want to 'load a file'.
    But i'm too busy write now.


    Hope it helps.
    ++

    • 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