update to a new 2007 version
[spice-mode.git] / spice-mode.el
blobe94f6950254efda19ef2b6ab2fb07d303454db05
1 ;;; spice-mode.el --- Major mode for SPICE
3 ;; Emacs Lisp Archive Entry
4 ;; Author: Geert A. M. Van der Plas <geert_vanderplas@email.com> 1999-
5 ;; Emmanuel Rouat <emmanuel.rouat@wanadoo.fr> 1997-
6 ;; Carlin J. Vieri, MIT AI Lab <cvieri@ai.mit.edu> 1994
7 ;; Keywords: spice, spice2g6, spice3, eldo, hspice, layla, mondriaan, fasthenry, CDL, spectre compatibility, netlist editing
8 ;; Package-Requires: ((emacs "24.3"))
9 ;; Filename: spice-mode.el
10 ;; Version: 1.2.25
11 ;; Maintainer: Geert A. M. Van der Plas <geert_vanderplas@email.com>
12 ;; Last-Updated: 01 November 2004
13 ;; Description: spice file editing
14 ;; URL: http://spice-mode.4t.com/
15 ;; old-URL: http://www.esat.kuleuven.ac.be/~vdplas/emacs/
16 ;; Compatibility: Emacs2[01], (partly tested)XEmacs21
18 ;; Please send suggestions and bug reports to
19 ;; mailto:Geert_VanderPlas@email.com
21 ;; Copyright (C) 1994, MIT Artificial Intelligence Lab
22 ;; Copyright (C) 1997- Emmanuel Rouat
23 ;; Copyright (C) 1999- Geert A. M. Van der Plas
25 ;; This file is free software; you can redistribute it and/or modify
26 ;; it under the terms of the GNU General Public License as published by
27 ;; the Free Software Foundation; either version 2, or (at your option)
28 ;; any later version.
30 ;; This file is distributed in the hope that it will be useful,
31 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
32 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 ;; GNU General Public License for more details.
35 ;; You should have received a copy of the GNU General Public License
36 ;; along with GNU Emacs; see the file COPYING. If not, write to
37 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
39 ;; INSTALL:
40 ;; ========
42 ;; byte compile spice-mode.el to spice-mode.elc (see `byte-compile-file')
43 ;; put these two files in an arbitrary, but accesible directory
44 ;; for example: $HOME/emacs, /usr/lib/emacs/site-lisp/ or
45 ;; /usr/local/lib/emacs/site-lisp/
47 ;; If you chose a non-standard place to put the files add the following
48 ;; line to your Emacs start-up file (`.emacs') or custom `site-start.el'
49 ;; file (replace <directory-name> by the directory where you placed
50 ;; spice-mode.el and spice-mode.elc):
51 ;; (setq load-path (cons (expand-file-name "<directory-name>") load-path))
53 ;; To use spice-mode, add either the following to your `.emacs' file. This
54 ;; assumes that you will use the .sp, .cir, .ckt, .mod, ... extensions for
55 ;; your spice source decks and output files:
56 ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
57 ;; (setq auto-mode-alist (append (list (cons "\\.sp$" 'spice-mode)
58 ;; (cons "\\.cir$" 'spice-mode)
59 ;; (cons "\\.ckt$" 'spice-mode)
60 ;; (cons "\\.mod$" 'spice-mode)
61 ;; (cons "\\.cdl$" 'spice-mode)
62 ;; (cons "\\.chi$" 'spice-mode) ;eldo outpt
63 ;; (cons "\\.inp$" 'spice-mode))
64 ;; auto-mode-alist))
66 ;; Other way to load spice mode (by Andrew Scott):
67 ;; ;;; Testing for spice-mode (Another spice mode, also works on Spice,
68 ;; ;;; Eldo, Layla; this one works on GNU Emacs-20.6 issues).
69 ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
70 ;; (add-to-list 'auto-mode-alist '("\\.cir$" . spice-mode))
71 ;; (add-to-list 'auto-mode-alist '("\\.ckt$" . spice-mode))
72 ;; (add-to-list 'auto-mode-alist '("\\.inp$" . spice-mode))
73 ;; (add-to-list 'auto-mode-alist '("\\.spout$" . spice-mode));hspice out
74 ;; (add-to-list 'auto-mode-alist '("\\.pdir$" . spice-mode))
75 ;; ;;; Intel formats
76 ;; (add-to-list 'auto-mode-alist '("\\.[sS][pP]$" . spice-mode))
77 ;; (add-to-list 'auto-mode-alist '("\\.[sm]?t0$" . spice-mode))
78 ;; (add-to-list 'auto-mode-alist '("\\.[h]?spice$" . spice-mode))
80 ;; CUSTOMIZATION:
81 ;; ==============
83 ;; use customization to modify the behaviour of spice-mode; add
84 ;; custom-set-variables to your `.emacs' file, for example:
85 ;; (custom-set-variables
86 ;; ; '(spice-initialize-file-function (quote geert-spice-file-header)) ;; use geert-spice-file-header function (not included in this file !)
87 ;; '(spice-initialize-empty-file t) ;; initialize empty/new spice file
88 ;; ; '(spice-standard '(spice2g6 (hspice eldo eldorf eldovloga layla))) ;; all 4 modes
89 ;; '(spice-standard (quote (spice2g6 (hspice eldo)))) ;; hspice and eldo
90 ;; '(spice-standard (quote (spice2g6 ()))) ;; spice2g6/3 only
91 ;; '(spice-simulator "Spice3") ;; default simulator
92 ;; '(spice-waveform-viewer "Nutmeg") ;; default waveform
93 ;; '(spice-highlight-keywords nil) ;; less highlighting
94 ;; '(spice-section-alist ;; add own sections
95 ;; ;; this is ugly, I know ;)
96 ;; (append (nth 1 (nth 0 (get 'spice-section-alist 'standard-value)))
97 ;; (list
98 ;; (list "My Header" "MY HEADER" nil)
99 ;; )))
100 ;; '(spice-use-func-menu t) ;; use func-menu (XEmacs)
101 ;; '(spice-show-describe-mode nil) ;; don't describe mode at startup
102 ;; )
104 ;; This can also be achieved interactively through customizations !
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
107 ;;; Commentary:
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
110 ;; The original spice-mode.el created by C. Vieri has been modified
111 ;; extensively. These changes have been heavily influenced by the eldo-mode.el
112 ;; of Emmanuel Rouat (the tempo-templates for one) and the vhdl-mode.el of
113 ;; Reto Zimmermann and Rodney J. Whitby (the font-locking, the
114 ;; customization, the menus, ...) Help in understanding 'advanced' lisp
115 ;; was provided by G. Debyser <geert.debyser@advalvas.be>, our (common) lisp
116 ;; expert. Since version 0.97 a lot of input/ideas have been provided by
117 ;; Emmanuel Rouat. Just take a look and search for eldo-mode ;)
119 ;; This package provides an Emacs major mode for editing SPICE decks.
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 ;;; TODO:
123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125 ;; - customization group spice- needs to be improved
126 ;; activate customizations needs to be looked at (potentially removed)
127 ;; - fix problem imenu sometimes truncating filenames of include files
128 ;; by replacing the functionality with own function
129 ;; - improve Y instance handling. use builtin macromodels, and own development;; models
130 ;; - ...
132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
133 ;;; BUGS:
134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
136 ;; - searching for .subckt could be buggy because of user's file structure
137 ;; - xinstance highlighting is buggy, and probably always will ?
138 ;; - font-lock expressions are incredibly complicated, and multiple spice
139 ;; formats are not handled correctly at the same time...
141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
143 ;; If you have any questions about this mode, feel free to contact me
144 ;; at the following address: geert_vanderplas@email.com. If I find the
145 ;; time, I can take a look at the problem
147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149 (defconst spice-version "1.2.25 (03 Jan 2007)"
150 "Current version of spice mode (spice2g6/spice3/hspice/eldo(rf&verilog-a)/fasthenry/layla/mondriaan/draccdl/spectre).")
152 (defconst spice-developer
153 "Geert Van der Plas & Emmanuel Rouat (<geert_vanderplas@email.com>, <emmanuel.rouat@wanadoo.fr>)"
154 "Current developers/maintainers of spice-mode.")
156 (defvar spice-running-xemacs (string-match "XEmacs" emacs-version)
157 "A variable that tells us whether we're in Xemacs or not")
159 (defvar spice-tempo-tags nil
160 "List of templates used in spice mode.")
163 ;; help function
164 (defun spice-custom-set (variable value &rest functions)
165 "Set variables as in `custom-set-default' and call FUNCTIONS (if
166 bound) afterwards."
167 (if (fboundp 'custom-set-default)
168 (custom-set-default variable value)
169 (set-default variable value))
170 (while functions
171 (when (fboundp (car functions)) (funcall (car functions)))
172 (setq functions (cdr functions))))
175 (defgroup spice nil
176 "Customizations for Spice mode."
177 :prefix "spice-"
178 :link '(url-link "http://spice-mode.4t.com/")
179 :group 'languages
183 ;;;###autoload
184 (defcustom spice-mode-hook nil
185 "*List of hook functions run by `spice-mode' (see `run-hooks')."
186 :type 'hook
187 :group 'spice)
190 ;;;###autoload
191 (defcustom spice-standard '(spice2g6 (hspice eldo eldorf eldovloga fasthenry)) ; "layla" has been removed
192 "*Spice standards used.
193 Basic standard:
194 Spice2g6 : Original Berkeley Spice (leave this always on!)
195 Additional standards:
196 Hspice (TM) : Commercial Spice, formerly Meta Software, now owned by Synopsys
197 Eldo (TM) : Commercial Spice, formerly Anacad, now owned by Mentor Graphics
198 EldoRf (TM) : RF Steady State analyses of Eldo (also turn on Eldo!)
199 EldoVlogA : Verilog-A extensions to Eldo netlist language (also turn on Eldo!)
200 FastHenry : Multipole-accelerated inductance analysis program from MIT
201 Layla : KULeuven LAYLA (layout synthesis) extensions to Spice format
202 Mondriaan : KULeuven MONDRIAAN (layout synthesis) extensions (also turn on Layla!)
203 DracCDL (TM): Dracula CDL extensions (Cadence LOGLVS netlists)
204 Spectre (TM): Spice compatibility of Spectre language (simulator language=spice decks)
206 :type '(list (choice :tag "Basic standard"
207 (const :tag "Spice2g6" spice2g6))
208 (set :tag "Additional standards" :indent 2
209 (const :tag "Hspice" hspice)
210 (const :tag "Eldo" eldo)
211 (const :tag "Eldo RF" eldorf)
212 (const :tag "Eldo Verilog-A" eldovloga)
213 (const :tag "FastHenry" fasthenry)
214 (const :tag "Layla" layla)
215 (const :tag "Mondriaan" mondriaan)
216 (const :tag "DracCDL" draccdl)
217 (const :tag "Spectre Spice Compatibility" spectre)))
218 :set (lambda (variable value)
219 (spice-custom-set variable value
220 'spice-check-spice-standard
221 'spice-mode-syntax-table-init
222 'spice-keywords-init
223 'spice-font-lock-init
224 'spice-imenu-init
225 'spice-update-existing-buffers))
226 :group 'spice)
229 ;;;###autoload
230 (defcustom spice-imenu-add-to-menubar t
231 "*Spice mode adds imenu (Index) item to menubar"
232 :group 'spice
233 :set (lambda (variable value)
234 (spice-custom-set variable value
235 'spice-update-existing-buffers))
236 :type 'boolean)
238 ;;;###autoload
239 (defcustom spice-use-func-menu nil
240 "*Spice func menu setting (untested), comparable to imenu"
241 :group 'spice
242 :set (lambda (variable value)
243 (spice-custom-set variable value
244 'spice-update-existing-buffers))
245 :type 'boolean)
247 ;;;###autoload
248 (defcustom spice-show-describe-mode nil ; was t
249 "*Spice mode runs `describe-mode' once at start of spice-mode"
250 :group 'spice
251 :type 'boolean)
253 ;;;###autoload
254 (defcustom spice-echo-intro t
255 "*Spice mode echos introductory message on entry to spice-mode"
256 :group 'spice
257 :type 'boolean)
259 (defgroup spice-initialize-file nil
260 "Customizations for initialization of empty/new spice files."
261 :group 'spice)
263 ;;;###autoload
264 (defcustom spice-initialize-empty-file nil
265 "*Spice initialize empty/new file setting"
266 :group 'spice-initialize-file
267 :type 'boolean)
269 ;;;###autoload
270 (defcustom spice-initialize-template-file "~/.spice-default"
271 "*File containing the default header that is inserted when opening
272 an empty file (ie. a new file), see also `spice-initialize-empty-file'"
273 :group 'spice-initialize-file
274 :type 'file)
276 ;;;###autoload
277 (defcustom spice-default-header nil
278 "*Default header for new Spice netlists, see also `spice-initialize-empty-file'"
279 :group 'spice-initialize-file
280 :type 'string)
282 ;;;###autoload
283 (defcustom spice-initialize-file-function 'spice-initialize-empty-file
284 "*Optional initialize function for empty/new files, see also
285 `spice-initialize-empty-file'. If a different function is specified it
286 should insert a default header/template in the current buffer. This
287 function should check which submode is in use with `spice-standard-p'
288 and adapt its output accordingly. It may also use the `spice-default-header'
289 variable and insert its contents into the buffer."
290 :group 'spice-initialize-file
291 :type 'function)
293 (defgroup spice-simulate nil
294 "Customizations for simulation."
295 :group 'spice)
298 (defcustom spice-simulator-alist
300 ;; Spice3; spice3 -b <file.cir>
302 ("Spice3" "spice3 -b" ""
303 ("\\s-*Error[\t ]+on[ \t]+line[\t ]+\\([0-9]+\\) +:.+"
304 0 1 nil (buffer-file-name))
305 ("Circuit: \\(.*\\)$" 1)) ; spice3 hack, is not the filename, but that's no prob
306 ;; Hspice; hspice <file.cir>
307 ;; **error**: only 1 connection at node 0:2
308 ("Hspice" "hspice" ""
309 ("\\s-*\\(..?error..?[: ]\\).+" 0 spice-linenum 1 (buffer-file-name))
310 ("[* ]* [iI]nput [fF]ile: +\\([^ \t]+\\).*$" 1))
311 ;; Eldo; eldo -i <file.cir>
312 ;; ERROR 503: MODEL "NMOS": Undeclared model reference.
313 ("Eldo" "eldo -i" ""
314 ("\\s-*\\(E[rR][rR][oO][rR] +[0-9]+:\\).*"
315 0 spice-linenum 1 (buffer-file-name))
316 ("Running \\(eldo\\).*$" 1)) ; eldo hack, true filename can not be found
317 ;; Spectre; spectre <file.cir>
318 ;; "viblok2.cir" 7: Unknown dot word `.param'.
319 ("Spectre" "spectre" ""
320 ("\\s-*\"\\([^ \t\n]+\\)\" +\\([0-9]+\\):.*"
321 1 2)
322 ("" 0)) ; filename is in regexp of error
323 ;;; Add your local simulators here:
326 "*List of available Spice simulators and their properties.
327 Each list entry specifies the following items for a simulator:
328 Simulator:
329 Simulator Name : name used in variable `spice-simulator' to choose
330 simulator
331 Simulate Command : command including options used for simulation program
332 Extra switches : extra switches for simulator, after filename
333 Error Message:
334 Regexp : regular expression to match error messages
335 File Subexp Index: index of subexpression that matches the file name
336 Line Subexp Index: index of subexpression that matches the line number.
337 use function `spice-linenum' when the line number
338 is not available
339 Col Subexp Index : index of subexpression that matches the column number
340 if not available but `spice-linenum' has been
341 supplied in the previous field, use 1
342 File Message:
343 Regexp : regular expression to match a file name message
344 File Subexp Index: index of subexpression that matches the file name
346 See also variable `spice-simulator-switches' to add options to the
347 simulate command.
349 Most simulators do not include the file name in the error message, but print
350 out a file name message in advance. In this case, set \"File Subexp Index\"
351 to 0 and fill out the \"File Message\" entries.
353 :type '(repeat (list :tag "Simulator" :indent 2
354 (string :tag "Simulator Name ")
355 (string :tag "Simulate Command ")
356 ;(string :tag "From Directory " "./")
357 (string :tag "Extra Switches ")
358 (list :tag "Error Message" :indent 4
359 (regexp :tag "Regexp ")
360 (integer :tag "File Subexp Index")
361 (integer :tag "Line Subexp Index"))
362 (list :tag "File Message" :indent 4
363 (regexp :tag "Regexp ")
364 (integer :tag "File Subexp Index"))))
365 :set (lambda (variable value)
366 (spice-custom-set variable value
367 'spice-menu-init
368 'spice-compile-variables-init
369 'spice-update-existing-buffers))
370 :group 'spice-simulate)
373 ;;;###autoload
374 (defcustom spice-simulator nil ; example: "Hspice"
375 "*Spice command, used when compiling buffer with `compile-mode',
376 see also `spice-simulator-switches'."
377 :group 'spice-simulate
378 :type 'string)
381 ;;;###autoload
382 (defcustom spice-simulator-switches "" ; example "-noconf"
383 "*Spice command switches, used when compiling buffer with `compile-mode',
384 see also `spice-simulator'."
385 :group 'spice-simulate
386 :type 'string)
389 (defcustom spice-waveform-viewer-alist
391 ;; Nutmeg; nutmeg <waveformdata.dat>
393 ("Nutmeg" "nutmeg" "" spice-run-interactive (".dat" ".ac0" ".tr0")) ; spice3 nutmeg viewer
394 ("Gwave" "gwave" "" spice-run-silent
395 (".raw" ".braw" ".ac0" ".tr0" ".sw0" ".W" ".N" ".acs")) ; gwave viewer
396 ("Xelga" "xelga" "" spice-run-silent ".cou") ; xelga eldo viewer
397 ("Awaves" "awaves_emacs" "" spice-run-silent (".ac0" ".tr0")) ; awaves hspice viewer, this doesn't work yet and will it ever ? Explanation: awaves is a script that starts an executable/binary in the background. This means the shell starting awaves ends immediately after the forking of the executable; after which all backgrounded programs get killed by emacs since their parent's parent shell (/bin/sh) ends. awaves shouldn't return immediately and then this will work; that's why I called the program awaves_emacs...
399 ;; ("Awaves2" "echo_awaves" "" spice-run-silent nil) ; awaves hspice viewer
400 ;;; Add your local waveform viewers here:
403 "*List of available Waveform viewers and their properties.
404 Each list entry specifies the following items for a waveform viewer:
405 Waveform Viewer:
406 Wave Viewer Name : name used in variable `spice-waveform-viewer' to choose
407 a waveform viewer
408 Wave Viewer Command : command including options used for waveform viewer
409 Extra switches : extra switches for waveform viewer, after filename
411 See also variable `spice-waveform-viewer-switches' to add options to the
412 waveform viewer command.
414 :type '(repeat (list :tag "Waveform Viewer" :indent 2
415 (string :tag "Waveform Viewer Name ")
416 (string :tag "Waveform Viewing Command ")
417 (string :tag "Extra Switches ")
418 (choice :tag "How"
419 :value spice-run-silent
420 (function-item spice-run-silent)
421 (function-item spice-run-interactive)
422 (function :tag "Other"))
423 (choice (string :tag "Filename Suffix ")
424 (function :tag "Function Deriving Filename")
425 (repeat (list :tag "List of Filename Suffixes")))))
426 :set (lambda (variable value)
427 (spice-custom-set variable value
428 'spice-menu-init
429 'spice-update-existing-buffers))
430 :group 'spice-simulate)
433 ;;;###autoload
434 (defcustom spice-waveform-viewer nil ; example: "Nutmeg"
435 "*Spice command, used when starting waveform viewer,
436 see also `spice-waveform-viewer-switches'."
437 :group 'spice-simulate
438 :type 'string)
441 ;;;###autoload
442 (defcustom spice-waveform-viewer-switches "" ; example "-b"
443 "*Spice waveform viewer command switches,
444 see also `spice-waveform-viewer'."
445 :group 'spice-simulate
446 :type 'string)
449 (defgroup spice-commands nil
450 "Customizations for commands."
451 :group 'spice)
453 ;;;###autoload
454 (defcustom spice-shell
455 (if (memq system-type '(ms-dos emx windows-nt))
456 shell-file-name
457 "/bin/sh")
458 "*Name of shell used to parse spice commands."
459 :group 'spice-commands
460 :type 'file)
462 ;;;###autoload
463 (defcustom spice-shell-command-option
464 (cond ((memq system-type '(ms-dos emx windows-nt) )
465 (cond ((boundp 'shell-command-option)
466 shell-command-option)
467 ((boundp 'shell-command-switch)
468 shell-command-switch)
470 "/c")))
471 (t ;Unix & EMX (Emacs 19 port to OS/2)
472 "-c"))
473 "*Shell argument indicating that next argument is the command."
474 :group 'spice-commands
475 :type 'string)
478 (defgroup spice-hide nil
479 "Customizations for hiding of comments."
480 :group 'spice)
482 ;;;###autoload
483 (custom-declare-variable 'spice-hide-line-prefix
484 '(concat
485 (regexp-quote
486 (concat comment-start
487 (if (boundp 'comment-padding)
488 (if (integerp comment-padding)
489 (make-string comment-padding ? )
490 comment-padding)
491 " ")))
492 "[a-z\\*!$0-9+\\.]")
493 "*Regexp string describing lines that are commented out and will be
494 hidden. The regexp is matched to the beginning of a line, the ^ is
495 added automatically. The initialization of this variable is handled
496 in `spice-hide-init', which is after the setting of `comment-start'
497 and `comment-padding' variables."
498 :initialize (lambda (variable value)
499 (message "Deferring initialization of %s with %s to spice-hide-init" variable value)) ; avoid init now, comment-start and padding aren't set yet.
500 :group 'spice-hide
501 :type 'string)
503 ;;;###autoload
504 (defcustom spice-auto-hide-comments nil
505 "*Boolean indicating automatic hiding of all commented regions at load time."
506 :group 'spice-hide
507 :type 'boolean)
510 (defgroup spice-section nil
511 "Customizations for sections."
512 :group 'spice)
514 ;; sections (entirely different implementation but sections idea has
515 ;; been taken from eldo-mode.el)
516 ;;;###autoload
517 (defcustom spice-section-alist
519 ;; Libraries
520 ("Libraries" "LIBRARIES" nil) ;
521 ;; Netlist
522 ("Netlist" "NETLIST" nil) ;
523 ;; Main Circuit
524 ("Main Circuit" "MAIN CIRCUIT" nil) ;
525 ;; Options
526 ("Options" "SIMULATION OPTIONS" nil) ;
527 ;; Supplies
528 ("Supplies" "SUPPLIES/REFERENCES" nil) ;
529 ;; Input Signals
530 ("Input Signals" "INPUT SIGNALS" nil) ;
531 ;; DC Analysis
532 ("DC Analysis" "DC ANALYSIS" nil) ;
533 ;; AC Analysis
534 ("AC Analysis" "AC ANALYSIS" nil) ;
535 ;; Transient Analysis
536 ("Transient Analysis" "TRANSIENT ANALYSIS" nil) ;
537 ;;; Add your site-local spice sections here:
540 "*List of valid sections in a Spice file and their options.
541 Each list entry specifies the following items for a section:
542 Section:
543 Section Name : name used in to select/create find section, make this
544 name short and descriptive.
545 Section String : string used in file to start section (usually all
546 uppercase variant of name).
547 Extra switches : extra switches for a section, unspecified for now."
548 :type '(repeat (list :tag "Section" :indent 2
549 (string :tag "Section Name ")
550 (string :tag "Section String ")
551 (sexp :tag "Extra Switches (nil)")))
552 :set (lambda (variable value)
553 (spice-custom-set variable value
554 'spice-keywords-init
555 'spice-font-lock-init
556 'spice-menu-init
557 'spice-imenu-init
558 'spice-update-existing-buffers))
559 :group 'spice-section)
562 (defgroup spice-faces nil
563 "Customizations for highlighting."
564 :group 'spice)
566 ;;;###autoload
567 (defcustom spice-highlight-keywords t
568 "*Non-nil means highlight SPICE keywords and other standardized words.
569 The following faces are used:
570 `spice-title-face' : title (first line in a spice file)
571 `spice-doc-face' : doc strings
572 `spice-analysis-face' : analyses
573 `spice-instance-name-face' : instance/element names
574 `spice-model-name-face' : subckt model names
575 `spice-layla-function-name-face': layla function names
576 `spice-include-file-face' : include files and libraries
577 `font-lock-keyword-face' : keywords
578 `font-lock-warning-face' : warnings
579 `font-lock-comment-face' : comment
580 `font-lock-function-name-face': subcircuit references / names of objects
581 `font-lock-type-face' : types
582 `font-lock-string-face' : strings & include files
583 `font-lock-constant-face' : simulator's options
584 `font-lock-variable-name-face': names of .param's & variables
585 NOTE: Activate the new setting in a spice buffer by re-fontifying it (menu
586 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking."
587 :type 'boolean
588 :group 'spice-faces)
590 ;; We try to use usual/standard font-lock faces, plus a few specific ones:
591 (custom-add-to-group
592 'spice-faces 'font-lock-comment-face 'custom-face)
593 (custom-add-to-group
594 'spice-faces 'font-lock-keyword-face 'custom-face)
595 (custom-add-to-group
596 'spice-faces 'font-lock-type-face 'custom-face)
597 (custom-add-to-group
598 'spice-faces 'font-lock-function-name-face 'custom-face)
599 (custom-add-to-group
600 'spice-faces 'font-lock-variable-name-face 'custom-face)
601 (custom-add-to-group
602 'spice-faces 'font-lock-warning-face 'custom-face)
603 (custom-add-to-group
604 'spice-faces 'font-lock-string-face 'custom-face)
607 (defgroup spice-output nil
608 "Customizations for spice output file handling."
609 :group 'spice)
611 ;;;###autoload
612 (defcustom spice-output-filename-alist
614 ;; Libraries
615 (eldo (concat (file-name-sans-extension (buffer-file-name)) ".chi")) ;
616 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".lis")) ;
617 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".spout")) ;
618 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".hspout")) ;
619 (spice2g6 (concat (file-name-sans-extension (buffer-file-name)) ".out")) ;
621 "*List of valid output names depending on selected spice standard:
622 Spice Standard : one of spice2g6, hspice, eldo or layla
623 Expression : expression calculating the output filename
625 :type '(repeat (list :tag "Output Filenames" :indent 2
626 (symbol :tag "Spice Standard ")
627 (sexp :tag "Expression ")))
628 :group 'spice-output)
631 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
632 ;; buffer local vars for spice-mode
634 ;;(defvar spice-standard-local nil
635 ;; "buffer local version of spice-standard.")
637 (defvar spice-output-local nil
638 "buffer local version of spice-output.")
640 (defun spice-standard-p (standard)
641 "Check if STANDARD is specified as used standard on local variable."
642 (or (eq standard (car spice-standard))
643 (memq standard (cadr spice-standard))))
646 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
647 ;; regexps for spice mode
649 (defconst spice-continuation-prefix "+"
650 "Continuation prefix for normal spice line")
652 (defconst spice-line-break "\\(\n\\s-*\\+\\s-*\\)*"
653 "Regexp that matches a (possible) line break (\n+)")
655 (defconst spice-model-name "\\([a-z][^ \t\n=]*\\)" ; "\\([a-z]\\sw*[^ \t\n=]*\\)"
656 "Regexp that describes a syntactically correct model or subckt name")
658 (defconst spice-library-regexp-start
659 "^\\.\\(inc\\|include\\|verilog\\|use_veriloga\\|lib\\(\\s-+key=\\w+\\)?\\|libfas\\|subckt\\s-+lib\\|model\\s-+lib\\)\\s-+[\"']?"
660 "Regexp that matches the beginning of library or include filename")
662 (defconst spice-library-regexp-end
663 "\\([^ \t\n\"']*\\)"
664 "Regexp that matches the end of library or include filename") ; doesn't catch end of buffer
666 (defconst spice-section-regexp-start "\\(^[*!$]\\s-*\\)"
667 "spice mode section header start regexp.")
669 (defconst spice-spice2g6-keywords
671 "subckt"
672 "print" "plot"
673 "opt" ; opt is actually a spice3 keyword, not 2g6
674 "nodeset"
675 "model" "macro" "include" ; include is actually a spice3 keyword, not 2g6
676 "ends" "end"
678 "List of Spice2g6 keywords")
680 (defconst spice-spice2g6-analyses
682 "tran" "op" "noise" "four" "disto" "dc" "ac"
684 "List of Spice2g6 analysis keywords")
686 (defconst spice-spice2g6-analysis-modifiers
688 "dec" "lin" "oct" ;; the ubiquitous spice2g6 ac modifiers
689 "pol" "zer" "pz" "cur" "vol" ;; pz analysis spice3
690 "ac" ;; .sens analysis spice3
692 "List of Spice2g6 analysis modifier keywords")
694 (defconst spice-eldo-keywords
696 "width" "use" "unprotect" "tvinclude" "topcell"
697 "table" "subdup" "solve" "sinus" "sigbus"
698 "setsoa" "setbus" "save" "restart" "ramp"
699 "protect" "probe" "plotbus"
700 "param" "overwrite_input" "optwind" "optpwl" "optnoise" "options"
701 "option" "optfour"
702 "notrc" "nocom" "modlogic"
703 "moddup" "meas" "mcmod" "lotgroup" "loop" "load"
704 "libfas" "lib" "init" "include" "ic" "hier" "guess" "global"
705 "extract" "endl" "enddata" "dspf_include" "distrib" "del"
706 "defwave" "defplotdig" "defmac" "data" "d2a" "comchar" "conso" "connect"
707 "chrsim" "chrent" "chrand" "checksoa" "checkbus" "alter" "addlib" "a2d"
709 "List of Eldo keywords")
711 (defconst spice-eldo-colon-keywords
713 "param" "pin" "model"
715 "List of Eldo colon keywords")
717 (defconst spice-eldo-macromodel-keywords
719 "opamp0" "opamp0d" "opamp1" "opamp1d" "opamp2" "opamp2d"
720 "satr" "satv" "vswitch" "cswitch"
721 "tri2sin" "stairgen" "sawgen" "trigen"
722 "amm" "pam"
723 "sa_ho" "tr_ho"
724 "pwm" "vco"
725 "peak_d" "lev_d"
726 "logamp" "expamp"
727 "diff" "integ"
728 "add" "sub" "mult" "div"
729 "sc_ideal" "sc_i" "sc_n" "sc_p" "sc_s1" "sc_s2"
730 "sc_sp1" "sc_sp2" "sc_b" "sc_u"
732 "List of Eldo macromodels")
734 (defconst spice-eldo-analyses
736 "wcase" "tf" "temp"
737 "step" "snf" "sens" "pz"
738 "noisetran" "mc"
740 "List of Eldo analysis keywords")
742 (defconst spice-eldo-analysis-modifiers
745 "List of Eldo analysis modifier keywords")
747 (defconst spice-eldorf-keywords
749 "sst"
751 "List of Eldo RF keywords")
753 (defconst spice-eldovloga-keywords
755 "verilog" "use_veriloga"
757 "List of Eldo Verilog-A keywords")
759 (defconst spice-eldovloga-colon-keywords
761 "port" "generic"
763 "List of Eldo Verilog-A colon keywords")
765 (defconst spice-eldorf-analyses
767 "sstac" "sstxf" "sstnoise"
769 "List of Eldo RF keywords")
771 (defconst spice-hspice-keywords
773 "width" "unprot" "unprotect" "uic"
774 "title" "sys" "system" "save"
775 "sample" "prot" "protect"
776 "probe" "pc" "parameter"
777 "param" "options" "option"
778 "nomod"
779 "measure" "meas" "macro"
780 "load" "lib" "include" "inc" "ic" "graph" "global"
781 "eom" "enddata" "dellib" "delete"
782 "del" "dcvolt" "data" "control" "comment"
783 "alter"
784 "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
786 "List of Hspice keywords")
788 (defconst spice-hspice-analyses
790 "disto"
791 "fft"
792 "tf" "temp"
793 "net" ;; S, Z, Y and H parameters
794 "sample"
795 "sens"
796 "pz"
797 "noise"
799 "List of Hspice analysis keywords")
801 (defconst spice-hspice-analysis-modifiers
803 "sweep" "poi"
805 "List of Hspice analysis modifier keywords")
807 (defconst spice-fasthenry-keywords
809 "units" "default" "external" "equiv"
811 "List of FastHenry keywords")
813 (defconst spice-fasthenry-analyses
815 "freq"
817 "List of FastHenry analysis keywords")
819 (defconst spice-fasthenry-analysis-modifiers
822 "List of FastHenry analysis modifier keywords")
824 (defconst spice-layla-keywords
826 "stop" "start"
827 "port" "performance" "parameter"
828 "param" "options" "option"
829 "net"
830 "model" "matching"
831 "include" "inc"
832 "bus"
834 "List of Layla keywords")
836 (defconst spice-mondriaan-keywords
838 "master" "routingarea" "routingchannel" "ports" "portgrid" "net"
840 "List of Mondriaan keywords")
842 (defconst spice-draccdl-keywords
844 "bipolar" "busdelimiter" "capa" "caparea" "capval" "default" "dioarea"
845 "dioperi" "diode" "edifdelimiter" "busdelimiter" "equation" "equiv"
846 "gnonswap" "ldd" "mega" "nonswap" "nopin" "nosub" "pin" "pininfo"
847 "resi" "ressize" "resval" "reverse" "scale" "spice" "unspec"
848 "eom" "global" "param" "macro" "swap"
850 "List of Dracula CDL keywords")
852 (defconst spice-spice2g6-types
854 "ac" "dc" "exp" "pulse" "pwl" "sffm" "sin"
856 "List of types in spice2g6")
858 (defconst spice-hspice-types
860 "metal" "dielectric" "pec" "rectangle" "circle" "strip" "polygon" ;; ""
862 "List of types in hspice")
864 (defconst spice-eldo-types
866 "pattern"
868 "List of source types in eldo")
870 (defconst spice-eldorf-types
872 "fpulse" "four" "probe"
874 "List of source types in eldorf")
876 (defconst spice-fasthenry-types
878 "point" "rect" "circle"
879 "user1" "user2" "user3" "user4" "user5" "user6" "user7"
881 "List of source types in fasthenry")
883 (defconst spice-special-model-type-names
885 "d" "npn" "pnp" "nmos" "pmos"
887 "List of model type names which are excluded for imenu")
889 (defconst spice-spice2g6-model-type-names
891 "r" "c" "urc" "ltra"
892 "njf" "pjf"
893 "nmf" "pmf"
894 "sw" "csw"
896 "List of model type names in spice2g6")
898 (defconst spice-eldo-model-type-names
900 "res" "cap" "ind"
901 "rn" "rp" "lpnp"
903 "List of model type names extra in eldo")
905 (defconst spice-eldo-vloga-model-type-names
907 "macro"
909 "List of model type names extra in Eldo Verilog-A")
911 (defconst spice-hspice-model-type-names
913 "l" "core" "w" "plot"
915 "List of model type names extra in hspice")
917 (defconst spice-spice2g6-output-keywords
918 '("print" "plot")
919 "List of output keywords in spice2g6")
921 (defconst spice-spice2g6-output-types
922 '("ac" "dc" "tran")
923 "List of output types in spice2g6")
925 (defconst spice-eldo-output-keywords
926 '("extract" "meas")
927 "List of output keywords in eldo")
929 (defconst spice-eldo-output-types
930 '("dcac" "dcsweep" "dctran" "noise" "four" "sweep")
931 "List of output types in eldo")
933 (defconst spice-eldorf-output-types
934 '("fsst" "tsst" "sstac" "sstxf" "ssnoise" )
935 "List of output types in eldo")
937 (defconst spice-hspice-output-keywords
938 '("probe" "graph" "measure")
939 "List of output keywords in hspice")
941 (defconst spice-hspice-output-types
942 '("noise" "disto")
943 "List of output types in hspice")
945 (defconst spice-spice2g6-options-keywords
946 '("trytocompact")
947 "List of spice2g6/3 options keywords.")
949 (defconst spice-eldo-options-keywords
950 '("wsf" "wsfascii" "sda"
951 "precise" "spi3asc" "spi3bin" "spicedc" "spiout" "libfas" "nolib"
952 "ammeter" "msgbias" "nowarn" "ulogic" "aspec" "mod4pins" "modwl" "wl"
953 "captab" "coustep" "input" "lcapop" "list" "noascii" "ascii"
954 "autostop" "nobound_phase" "nocou" "node" "nomod" "nopage" "nosizechk"
955 "notrc" "trap" "smooth" "be" "gear" "newton" "iem" "analog" "digital"
956 "osr" "mixed" "pstran" "dptran" "itl6" "itl7" "itl8" "nmaxsize"
957 "noconvassist" "nolat" "pivrel" "pivtol" "qtrunc" "noconvassist"
958 "nolat" "pivrel" "pivtol" "qtrunc" "relvar" "splitc" "noswitch"
959 "unbound" "randmc" "usedefap" "engnot" "nodcpart" "probeop"
960 "noprobeop" "histlim" "wbulk" "noinit" "nonoise" "tempcouk" "nofnsiem"
961 "icdc" "icdev" "carlo_gauss" "cteprec" "d2dmvl9bit" "defconvmsg"
962 "maxnodeord" "notrclib" "motorola" "aex")
963 "List of eldo options keywords.")
965 (defconst spice-eldorf-options-keywords
966 '("sst_freqdiv")
967 "List of Eldo RF options keywords.")
969 (defconst spice-hspice-options-keywords
970 '("acct" "converge"
971 "absh" "acout" "cds" "scale" "cshdc" "alt999" "alt9999" "csdf"
972 "accurate" "dvdt" "measout" "acout" "brief" "cshunt" "gshunt" "probe"
973 "kcltest" "dctran" "di" "itl5" "list" "sda" "gshunt" "cshunt" "post"
974 "node" "noelck" "gshunt" "maxamp" "nomod" "aspec" "icsweep" "relh"
975 "nopage" "newtol" "reli" "notop" "parhier" "off" "spice" "wl"
976 "dvtr" "nxx" "seed" "risetime" "imax" "nopiv" "imin" "opts" "cscal"
977 "vntol" "absv" "pathnum" "badchr" "fmax" "plim" "diagnostic" "pivref"
978 "fscal" "autostop" "nowarn" "gscal" "search" "lscal" "bypass" "verify"
979 "sparse" "pivot" "pzabs" "cpu" "pztol" "fast" "interp" "h9007" "expli"
980 "ritol" "itlpz" "itrprt" "unwrap" "captab" "newtol" "dccap")
981 "List of hspice options keywords.")
983 (defconst spice-spice2g6-options-parameters
984 '("gmin" "reltol" "abstol" "vntol" "trtol" "chgtol" "pivtol" "pivrel"
985 "tnom" "temp" "lvlcod" "itl1" "itl2" "itl3" "itl4" "itl5" "defl"
986 "defw" "defad" "defas" "method")
987 "List of spice2g6/3 options parameters.")
989 (defconst spice-eldo-options-parameters
990 '("cptime" "msgnode" "zoomtime" "bsim3ver" "defnrd" "defnrs" "defpd" "defps"
991 "gramp" "scale" "scalebsim" "scalm" "soiback" "flicker_noise"
992 "thermal_noise" "cousmp" "limprobe" "ascii" "savetime" "simudiv"
993 "stat" "timediv" "maxord" "bloc" "epsdig" "absvar" "capanw" "chgtol"
994 "dvdt" "eps" "fluxtol" "freqsmp" "ft" "hmin" "hmax" "itol" "lvltim"
995 "maxnodes" "maxtran" "maxv" "netsize" "ngtol" "ratprint" "reltrunc"
996 "sample" "startsmp" "step" "trtol" "tuning" "vmin" "vntol" "xa"
997 "numdgt" "dcpart" "couresol" "defa2d" "defd2a" "vbcsat" "dclog" "epso"
998 "optype")
999 "List of eldo options parameters.")
1001 (defconst spice-eldorf-options-parameters
1002 '("sst_start" "sst_stop" "sst_nper"
1003 "sst_npt" "sst_ovrsmp" "sst_spectrum" "sst_uic"
1004 "sst_max_liniter" "sst_verbose")
1005 "List of Eldo RF options parameters.")
1007 (defconst spice-hspice-options-parameters
1008 '("artist" "dcap" "absh" "absvar" "absi" "absv" "delmax" "absmos"
1009 "dcfor" "dchold" "fs" "mentor" "absvdc" "dcon" "ft" "co" "reltol" ; "post"
1010 "cvtol" "di" "dcstep" "imin" "ingold" "imax" "lennam" "psf" "maxamp"
1011 "dv" "defl" "relh" "gmax" "relvar" "measdgt" "zuken" "defnrd" "reli"
1012 "gmindc" "rmax" "defnrs" "relmos" "gramp" "rmin" "defpd" "relv"
1013 "slopetol" "defps" "relvdc" "timeres" "limpts" "scalm" "relq" "numdgt"
1014 "resmin" "optlst" "trtol" "genk" "pivot" "sparse" "lvltim" "klim"
1015 "maxord" "post_version" "bkpsiz" "mu" "xmu" "warnlimit" "expli"
1016 "bytol" "cptime" "epsmin" "mbypass" "expmax" "limtim" "vfloor")
1017 "List of hspice options parameters.")
1019 (defconst spice-layla-options-parameters
1020 '("begin_temp_iterations" "begin_acc_prob" "min_temp_scale_factor"
1021 "max_temp_scale_factor" "max_inner_loop_delta" "max_cost_delta"
1022 "min_range_scale_factor" "nr_temp_steps"
1023 "min_stable_inner_loops" "min_local_iterations" "max_local_iterations"
1024 "max_iterations" "bank_min_ar" "bank_max_ar" "bank_orientations"
1025 "bank_routing_space" "bus_sides" "bus_layer" "bus_port_width"
1026 "bus_port_height" "bus_port_distance" "bus_routing_space" "cap_min_ar"
1027 "cap_max_ar" "cap_orientations" "cap_routing_space" "cap_ar_step"
1028 "coil_orientations" "coil_routing_space" "alfa_area"
1029 "alfa_performance" "alfa_aspect_ratio" "alfa_overlap" "alfa_overlap_min"
1030 "alfa_overlap_max" "kappa_overlap" "device_min_ar" "device_max_ar"
1031 "device_orientations" "device_routing_space" "device_current"
1032 "diode_min_ar" "diode_max_ar" "diode_orientations"
1033 "diode_routing_space" "diode_current" "matching_compute_method"
1034 "dummy_min_ar" "dummy_max_ar" "dummy_orientations"
1035 "dummy_routing_space" "dummy_ar_step"
1036 "mos_min_ar" "mos_max_ar" "mos_orientations" "mos_routing_space"
1037 "mos_current" "prob_reshape" "prob_reorientation"
1038 "prob_symmetric_translation" "prob_symmetric_swap"
1039 "prob_symmetric_flip" "prob_symmetric_flip" "prob_symmetric_shift"
1040 "prob_independent_translation" "prob_independent_swap"
1041 "prob_independent_flip" "min_move_range" "net_compute_method"
1042 "write_init" "write_int" "int_write_interval" "write_fin" "write_final"
1043 "mentor_write_ipc" "gds2_write_ipc" "construct_net_performance"
1044 "construct_matching_performance" "aspect_ratio" "field_grow_factor"
1045 "field_aspect_ratio" "disable_symmetry" "disable_matching"
1046 "do_kul_routing" "kul_router_program" "kul_router_directives_file"
1047 "number_of_randomize_loops" "port_inherit_terminals" "bus_priority"
1048 "port_sides" "port_layer" "port_width" "port_height" "port_distance"
1049 "port_abutment" "port_routing_space" "port_no_routing" "port_current"
1050 "res_ar_step" "res_min_ar" "res_max_ar" "res_orientations"
1051 "res_routing_space" "res_width" "res_current" "disable_couple_flipping"
1052 "symmetry_max_offset_factor" "print_cost" "placement_name"
1053 "write_final_ample" "write_final_skill" "write_final_gds2_bin"
1054 "write_final_gds2_cells" "write_final_tud"
1055 "write_final_ample_generators" "write_final_ample_cells"
1056 "write_final_cif" "write_final_rose" "write_final_kul"
1057 "write_final_text"
1058 "write_int_ample" "write_int_skill" "write_int_gds2_bin"
1059 "write_int_gds2_cells" "write_int_tud" "write_int_ample_generators"
1060 "write_int_ample_cells" "write_int_cif" "write_int_rose"
1061 "write_int_kul" "write_int_text"
1062 "write_init_ample" "write_init_skill" "write_init_gds2_bin"
1063 "write_init_gds2_cells" "write_init_tud" "write_init_ample_generators"
1064 "write_init_ample_cells" "write_init_cif" "write_init_rose"
1065 "write_init_kul" "write_init_text" "time_out"
1066 "random_seed" "anneal_rs" )
1067 "List of LAYLA options parameters.")
1069 (defconst spice-layla-functions
1071 "bus_double_param" "bus_integer_param" "bus_string_param"
1072 "device_double_param" "device_integer_param" "device_string_param"
1073 "net_double_param" "net_integer_param" "net_string_param"
1074 "placement_double_param" "placement_integer_param" "placement_string_param"
1075 "port_double_param" "port_integer_param" "port_string_param"
1076 "symmetry_double_param" "symmetry_integer_param" "symmetry_string_param"
1078 "List of functions in Layla mode")
1080 (defconst spice-draccdl-device-keywords
1081 '("nonswap" )
1082 "List of Dracula CDL device keywords.")
1084 (defconst spice-draccdl-device-parameters
1085 '("w" "l" "sub" "ea" ;; CDL parameters
1086 "x" "y") ;; added X&Y, dracula extracts them (not CDL!)
1087 "List of Dracula & CDL device parameters.")
1089 (defconst spice-spice2g6-entity-start-keywords
1091 "ends" "macro" "subckt"
1093 "List of spice2g6 entity start keywords")
1095 (defconst spice-eldo-entity-start-keywords
1097 "endl"
1099 "List of eldo entity start keywords")
1101 (defconst spice-hspice-entity-start-keywords
1103 "endl" "eom"
1104 "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
1106 "List of hspice entity start keywords")
1108 (defconst spice-layla-entity-start-keywords
1110 "bus" "net" "symmetry" "performance" "port"
1112 "List of layla entity start keywords")
1114 (defconst spice-mondriaan-entity-start-keywords
1116 "routingarea" "routingchannel" ;; "net" ; already in layla
1118 "List of mondriaan entity start keywords")
1120 (defconst spice-draccdl-entity-start-keywords
1122 "eom"
1124 "List of DracCDL entity start keywords")
1126 (defvar spice-keywords nil
1127 "List of spice mode keywords.")
1129 (defvar spice-colon-keywords nil
1130 "List of spice mode colon keywords.")
1132 (defvar spice-analyses nil
1133 "List of spice mode analyses.")
1135 (defvar spice-analysis-modifiers nil
1136 "List of spice mode analysis modifiers.")
1138 (defvar spice-types nil
1139 "List of spice mode standardized types.")
1141 (defvar spice-functions nil
1142 "List of spice mode functions.")
1144 (defvar spice-section-headings nil
1145 "List of spice mode section headings.")
1147 (defvar spice-misc-model-type-names nil
1148 "List of miscellaneous model type name.")
1150 (defvar spice-model-type-names nil
1151 "List of all model type name.")
1153 (defvar spice-output-keywords nil
1154 "List of all output keywords.")
1156 (defvar spice-output-types nil
1157 "List of all output types.")
1159 (defvar spice-options-keywords nil
1160 "List of all output options keywords.")
1162 (defvar spice-options-parameters nil
1163 "List of all output options parameters.")
1165 (defvar spice-entity-start-keywords nil
1166 "List of entity definition keywords.")
1168 (defvar spice-keywords-regexp nil
1169 "Regexp for keywords.")
1171 (defvar spice-colon-keywords-regexp nil
1172 "Regexp for colon keywords.")
1174 (defvar spice-analyses-regexp nil
1175 "Regexp for analyses.")
1177 (defvar spice-analysis-modifiers-regexp nil
1178 "Regexp for analysis modifiers.")
1180 (defvar spice-layla-keywords-regexp nil
1181 "Regexp for layla keywords.")
1183 (defvar spice-mondriaan-keywords-regexp nil
1184 "Regexp for mondriaan keywords.")
1186 (defvar spice-draccdl-keywords-regexp nil
1187 "Regexp for dracula CDL keywords.")
1189 (defvar spice-types-regexp nil
1190 "Regexp for spice mode types.")
1192 (defvar spice-functions-regexp nil
1193 "Regexp for spice mode functions (Layla).")
1195 (defvar spice-section-headings-regexp nil
1196 "Regexp for spice mode section headings.")
1198 (defvar spice-xinstance-regexp nil
1199 "Regexp for x instances.")
1201 (defvar spice-model-name-regexp nil
1202 "Regexp model names of elements.")
1204 (defvar spice-entity-start-regexp nil
1205 "Regexp for start of entity definition.")
1207 (require 'font-lock)
1209 (defvar spice-instance-name-face 'spice-instance-name-face
1210 "Face name to use spice instances.")
1212 (defface spice-instance-name-face
1213 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1214 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1215 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
1216 (((class color) (background dark)) (:foreground "Yellow" :bold t))
1217 (t (:bold t)))
1218 "Spice mode face used to highlight instances."
1219 :group 'spice-faces)
1221 (defvar spice-model-name-face 'spice-model-name-face
1222 "Face name to use spice instances.")
1224 (defface spice-model-name-face
1225 '((((class grayscale) (background light)) (:foreground "LightGray"))
1226 (((class grayscale) (background dark)) (:foreground "DimGray"))
1227 (((class color) (background light)) (:foreground "Red3"))
1228 (((class color) (background dark)) (:foreground "LightSteelBlue"))
1229 (t (:bold t)))
1230 "Spice mode face used to highlight models."
1231 :group 'spice-faces)
1233 (defvar spice-title-face 'spice-title-face
1234 "Face name for title string.")
1236 (defface spice-title-face
1237 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1238 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1239 (((class color) (background light))
1240 (:foreground "Yellow" :background "black" :bold t))
1241 (((class color) (background dark))
1242 (:foreground "green3":background "lightyellow" :bold t))
1243 (t (:bold t)))
1244 "Spice mode face used for title string."
1245 :group 'spice-faces)
1247 (defvar spice-layla-function-name-face 'spice-layla-function-name-face
1248 "Face name to use for layla function names.")
1250 (defface spice-layla-function-name-face
1251 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1252 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1253 (((class color) (background light))
1254 (:foreground "Darkgreen"))
1255 (((class color) (background dark)) (:foreground "green"))
1256 (t (:bold t)))
1257 "Spice mode face used to higlight layla functions."
1258 :group 'spice-faces)
1261 (defvar spice-analysis-face 'spice-analysis-face
1262 "Face name to highlight spice mode analysis commands.")
1264 (defface spice-analysis-face
1265 '((((class color) (background light)) (:foreground "Magenta" :bold t :underline t))
1266 (((class color) (background dark)) (:foreground "Lightgreen" :bold t :underline t))
1267 (t (:bold t)))
1268 "Spice mode face used to highlight analysis commands."
1269 :group 'spice-faces)
1271 (defvar spice-doc-face (if spice-running-xemacs
1272 'font-lock-doc-string-face
1273 'font-lock-string-face)
1274 "Face name to use for doc strings.")
1276 (custom-add-to-group
1277 'spice-faces (if spice-running-xemacs
1278 'font-lock-doc-string-face
1279 'font-lock-string-face)
1280 'custom-face)
1283 (defvar spice-constant-face (if spice-running-xemacs
1284 'font-lock-reference-face
1285 (if (facep 'font-lock-constant-face)
1286 'font-lock-constant-face
1287 'font-lock-reference-face)) ; old emacs20.1
1288 "Face name to use for constants.")
1290 (custom-add-to-group
1291 'spice-faces (if spice-running-xemacs
1292 'font-lock-reference-face
1293 (if (facep 'font-lock-constant-face)
1294 'font-lock-constant-face
1295 'font-lock-reference-face))
1296 'custom-face)
1298 (defvar spice-include-file-face (if spice-running-xemacs
1299 'font-lock-preprocessor-face
1300 'font-lock-string-face)
1301 "Face name to use for include files and libraries.")
1303 (custom-add-to-group
1304 'spice-faces (if spice-running-xemacs
1305 'font-lock-preprocessor-face
1306 'font-lock-string-face)
1307 'custom-face)
1309 (if (not spice-running-xemacs)
1310 (custom-add-to-group
1311 'spice-faces 'font-lock-builtin-face 'custom-face)
1313 (defface spice-builtin-face
1314 '((((class grayscale) (background light)) (:foreground "LightGray"))
1315 (((class grayscale) (background dark)) (:foreground "DimGray"))
1316 (((class color) (background light)) (:foreground "Orchid" :bold t))
1317 (((class color) (background dark)) (:foreground "LightBlue" :bold t))
1318 (t (:bold t)))
1319 "Spice mode face used for builtin types."
1320 :group 'spice-faces))
1322 (defvar spice-builtin-face (if spice-running-xemacs
1323 'spice-builtin-face
1324 'font-lock-builtin-face)
1325 "Face name for builtin types.")
1329 (defun spice-keywords-init ()
1330 "Initialize reserved words."
1331 (setq spice-keywords
1332 (append spice-spice2g6-keywords
1333 (when (spice-standard-p 'hspice)
1334 spice-hspice-keywords)
1335 (when (spice-standard-p 'eldo)
1336 spice-eldo-keywords)
1337 (when (spice-standard-p 'eldorf)
1338 spice-eldorf-keywords)
1339 (when (spice-standard-p 'fasthenry)
1340 spice-fasthenry-keywords)))
1341 (setq spice-colon-keywords
1342 (append (when (spice-standard-p 'eldo)
1343 spice-eldo-colon-keywords)
1344 (when (spice-standard-p 'eldovloga)
1345 spice-eldovloga-colon-keywords)))
1346 (setq spice-analyses
1347 (append spice-spice2g6-analyses
1348 (when (spice-standard-p 'hspice)
1349 spice-hspice-analyses)
1350 (when (spice-standard-p 'eldo)
1351 spice-eldo-analyses)
1352 (when (spice-standard-p 'eldorf)
1353 spice-eldorf-analyses)
1354 (when (spice-standard-p 'fasthenry)
1355 spice-fasthenry-analyses)))
1356 (setq spice-analysis-modifiers
1357 (append spice-spice2g6-analysis-modifiers
1358 (when (spice-standard-p 'hspice)
1359 spice-hspice-analysis-modifiers)
1360 (when (spice-standard-p 'eldo)
1361 spice-eldo-analysis-modifiers)
1362 (when (spice-standard-p 'fasthenry)
1363 spice-fasthenry-analysis-modifiers)))
1364 (setq spice-misc-model-type-names
1365 (append spice-spice2g6-model-type-names
1366 (when (spice-standard-p 'hspice)
1367 spice-hspice-model-type-names)
1368 (when (spice-standard-p 'eldovloga)
1369 spice-eldo-vloga-model-type-names)
1370 (when (spice-standard-p 'eldo)
1371 spice-eldo-model-type-names)))
1372 (setq spice-output-keywords
1373 (append spice-spice2g6-output-keywords
1374 (when (spice-standard-p 'hspice)
1375 spice-hspice-output-keywords)
1376 (when (spice-standard-p 'eldo)
1377 spice-eldo-output-keywords)))
1378 (setq spice-output-types
1379 (append spice-spice2g6-output-types
1380 (when (spice-standard-p 'hspice)
1381 spice-hspice-output-types)
1382 (when (spice-standard-p 'eldo)
1383 spice-eldo-output-types)
1384 (when (spice-standard-p 'eldorf)
1385 spice-eldorf-output-types)))
1386 (setq spice-model-type-names
1387 (append spice-misc-model-type-names
1388 spice-special-model-type-names))
1389 (setq spice-types
1390 (append spice-spice2g6-types
1391 (when (spice-standard-p 'hspice)
1392 spice-hspice-types)
1393 (when (spice-standard-p 'eldo)
1394 spice-eldo-types)
1395 (when (spice-standard-p 'eldorf)
1396 spice-eldorf-types)
1397 (when (spice-standard-p 'fasthenry)
1398 spice-fasthenry-types)))
1399 (setq spice-options-keywords
1400 (append spice-spice2g6-options-keywords
1401 (when (spice-standard-p 'hspice)
1402 spice-hspice-options-keywords)
1403 (when (spice-standard-p 'eldo)
1404 spice-eldo-options-keywords)
1405 (when (spice-standard-p 'eldorf)
1406 spice-eldorf-options-keywords)))
1407 (setq spice-options-parameters
1408 (append spice-spice2g6-options-parameters
1409 (when (spice-standard-p 'hspice)
1410 spice-hspice-options-parameters)
1411 (when (spice-standard-p 'layla)
1412 spice-layla-options-parameters)
1413 (when (spice-standard-p 'eldo)
1414 spice-eldo-options-parameters)
1415 (when (spice-standard-p 'eldorf)
1416 spice-eldorf-options-parameters)))
1417 (setq spice-functions spice-layla-functions)
1418 (setq spice-section-headings (list "Changelog")) ; Changelog is special case
1419 (let ((section-alist spice-section-alist) heading)
1420 (while section-alist
1421 (setq heading (downcase (car (cdr (car section-alist)))))
1422 (setq spice-section-headings (append spice-section-headings
1423 (list heading)))
1424 (setq section-alist (cdr section-alist))))
1425 (setq spice-entity-start-keywords
1426 (append spice-spice2g6-entity-start-keywords
1427 (when (spice-standard-p 'hspice)
1428 spice-hspice-entity-start-keywords)
1429 (when (spice-standard-p 'layla)
1430 spice-layla-entity-start-keywords)
1431 (when (spice-standard-p 'mondriaan)
1432 spice-mondriaan-entity-start-keywords)
1433 (when (spice-standard-p 'draccdl)
1434 spice-draccdl-entity-start-keywords)
1435 (when (spice-standard-p 'eldo)
1436 spice-eldo-entity-start-keywords)))
1437 (setq spice-section-headings-regexp
1438 (concat spice-section-regexp-start "\\("
1439 (regexp-opt spice-section-headings) "\\)\\(.*\\)$"
1440 ; "\\s-*$" ; ??
1442 (setq spice-keywords-regexp
1443 (concat "^\\.\\("
1444 (regexp-opt spice-keywords)
1445 "\\)\\>"))
1446 (setq spice-colon-keywords-regexp
1447 (concat "\\<\\("
1448 (regexp-opt spice-colon-keywords)
1449 "\\)\\(:\\)"))
1450 (setq spice-analyses-regexp
1451 (concat "^\\s-*"
1452 "\\(\\.\\)\\("
1453 (regexp-opt spice-analyses)
1454 "\\)\\>"))
1455 (setq spice-analysis-modifiers-regexp
1456 (concat "\\<\\(" (regexp-opt spice-analysis-modifiers) "\\)\\>"))
1457 (setq spice-layla-keywords-regexp
1458 (concat "^\\s-*\\*?"
1459 "\\.\\("
1460 (regexp-opt spice-layla-keywords)
1461 "\\)\\>"))
1462 (setq spice-mondriaan-keywords-regexp
1463 (concat "^\\s-*\\*?"
1464 "\\.\\("
1465 (regexp-opt spice-mondriaan-keywords)
1466 "\\)\\>"))
1467 (setq spice-draccdl-keywords-regexp
1468 (concat "^\\s-*"
1469 "\\.\\("
1470 (regexp-opt spice-draccdl-keywords)
1471 "\\)\\>"))
1472 (setq spice-types-regexp
1473 (concat "\\<\\(" ;"\\(\\s-+\\|\n\\+\\s-*\\)\\<\\("
1474 (regexp-opt spice-types)
1475 "\\)\\>"))
1476 (setq spice-functions-regexp
1477 (concat "^\\s-*\\(\\*?\\.\\("
1478 (regexp-opt spice-functions)
1479 "\\)\\)\\>(\\([^,]+\\),\\([^,]+\\),[^,]+)"))
1480 ; old xinstance regexp
1481 ; "\\([ \t]+[^ $!(=\t\n][^ (=\t\n]*\\|\n[+]\\)*" ; $! are hspice & eldo's doc string starters
1482 (setq spice-xinstance-regexp
1483 (concat "^\\(x\\S-*\\)"
1484 "\\(\\([ \t]+[^ *"
1485 ;; "\\(\\([ \t]*[^ *" ;; should solve problem when no space between + and name, but fails horribly due to CPU hungry recursion in matcher....
1486 (when (spice-standard-p 'hspice) "$")
1487 (when (spice-standard-p 'eldo) "!")
1488 ":(=\t\n][^ :(=\t\n]*\\|[ \t]*\\(\n?[*"
1489 (when (spice-standard-p 'hspice) "$")
1490 (when (spice-standard-p 'eldo) "!")
1491 "].*\\)?\n[+]\\)*\\s-*\\)" ;; \\([a-z]\\w*\\)
1492 "\\<" spice-model-name "\\>"
1493 "\\(\\s-*\n\\|\\s-+[^=\n]\\)"
1496 (setq spice-model-name-regexp
1497 (concat "^\\([qmd]\\S-*\\)" ;; only bips, mos and diodes
1498 "\\([ \t]+[^ *" ;; first '*' was '+' ! but fails see spice-xinstance-regexp...
1499 (when (spice-standard-p 'hspice) "$")
1500 (when (spice-standard-p 'eldo) "!")
1501 "(=\t\n][^ (=\t\n]*\\|[ \t]*\\([*"
1502 (when (spice-standard-p 'hspice) "$")
1503 (when (spice-standard-p 'eldo) "!")
1504 "].*\\)?\n[+]\\)*\\s-*" ;; \\([a-z]\\w*\\)
1505 "\\<" spice-model-name "\\>"
1506 "\\(\\s-*\n\\|\\s-+[^=]\\)"
1508 (setq spice-entity-start-regexp
1509 (concat "^\\*?\\.\\("
1510 (regexp-opt spice-entity-start-keywords)
1511 "\\)")))
1514 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1515 ;; Font lock initialization
1516 (defvar spice-font-lock-keywords-0 nil
1517 ;; set in `spice-font-lock-init' because dependent on custom variables
1518 "For consideration as a value of `spice-font-lock-keywords'.
1519 This does highlighting of keywords and standard identifiers.")
1521 (defvar spice-font-lock-keywords-1 nil
1522 ;; set in `spice-font-lock-init' because dependent on custom variables
1523 "For consideration as a value of `spice-font-lock-keywords'.
1524 This does highlighting of keywords and standard identifiers.")
1526 (defvar spice-font-lock-keywords-2 nil
1527 ;; set in `spice-font-lock-init' because dependent on custom variables
1528 "For consideration as a value of `spice-font-lock-keywords'.
1529 This does highlighting of keywords and standard identifiers.")
1531 (defvar spice-font-lock-keywords-3 nil
1532 ;; set in `spice-font-lock-init' because dependent on custom variables
1533 "For consideration as a value of `spice-font-lock-keywords'.
1534 This does highlighting of keywords and standard identifiers.")
1536 (defvar spice-font-lock-keywords-4 nil
1537 ;; set in `spice-font-lock-init' because dependent on custom variables
1538 "For consideration as a value of `spice-font-lock-keywords'.
1539 This does highlighting of keywords and standard identifiers.")
1541 (defvar spice-font-lock-keywords-5 nil
1542 ;; set in `spice-font-lock-init' because dependent on custom variables
1543 "For consideration as a value of `spice-font-lock-keywords'.
1544 This does highlighting of keywords and standard identifiers.")
1546 (defvar spice-font-lock-keywords-6 nil
1547 ;; set in `spice-font-lock-init' because dependent on custom variables
1548 "For consideration as a value of `spice-font-lock-keywords'.
1549 This does highlighting of keywords and standard identifiers.")
1551 (defvar spice-font-lock-keywords-7 nil
1552 ;; set in `spice-font-lock-init' because dependent on custom variables
1553 "For consideration as a value of `spice-font-lock-keywords'.
1554 This does highlighting of keywords and standard identifiers.")
1556 (defvar spice-font-lock-keywords-8 nil
1557 ;; set in `spice-font-lock-init' because dependent on custom variables
1558 "For consideration as a value of `spice-font-lock-keywords'.
1559 This does highlighting of keywords and standard identifiers.")
1561 (defvar spice-font-lock-keywords-9 nil
1562 ;; set in `spice-font-lock-init' because dependent on custom variables
1563 "For consideration as a value of `spice-font-lock-keywords'.
1564 This does highlighting of keywords and standard identifiers.")
1566 (defvar spice-font-lock-keywords-10 nil
1567 ;; set in `spice-font-lock-init' because dependent on custom variables
1568 "For consideration as a value of `spice-font-lock-keywords'.
1569 This does highlighting of keywords and standard identifiers.")
1571 (defvar spice-font-lock-keywords-11 nil
1572 ;; set in `spice-font-lock-init' because dependent on custom variables
1573 "For consideration as a value of `spice-font-lock-keywords'.
1574 This does highlighting of keywords and standard identifiers.")
1576 (defvar spice-font-lock-keywords-12 nil
1577 ;; set in `spice-font-lock-init' because dependent on custom variables
1578 "For consideration as a value of `spice-font-lock-keywords'.
1579 This does highlighting of keywords and standard identifiers.")
1581 (defvar spice-font-lock-keywords-13 nil
1582 ;; set in `spice-font-lock-init' because dependent on custom variables
1583 "For consideration as a value of `spice-font-lock-keywords'.
1584 This does highlighting of keywords and standard identifiers.")
1587 ;; fast variable name matcher in parameter=value constructs
1588 (defun spice-match-variable-name (limit)
1589 "match variable names"
1590 (let (pos found (start (point)))
1591 (setq found nil)
1592 (setq pos (search-forward "=" limit 'end)) ;
1593 (while (and pos
1594 (not found))
1595 (forward-word -1)
1596 (if (< (point) start) (goto-char pos))
1597 (if (looking-at "\\([a-z]\\w*\\)\\s-*\\(=\\)")
1598 (progn
1599 (goto-char pos)
1600 ;; (message (match-string 1))
1601 (setq found t))
1602 (progn
1603 (goto-char pos)
1604 (setq pos (search-forward "=" limit 'end)))))
1605 found))
1607 ;; font-lock aux functions
1608 (defun spice-match-eldo-colon-keywords (limit)
1609 "match ((param|pin|model|port|generic):)" ;; latter two are eldo verilog-A
1610 (let (pos found (start (point)))
1611 (setq found nil)
1612 (setq pos (search-forward ":" limit 'end)) ;
1613 (while pos
1614 (forward-word -1)
1615 (if (< (point) start) (goto-char pos))
1616 ;; (message "pos is %d" pos)
1617 (if (looking-at ;; "\\(\\(param\\|pin\\|model\\|port\\|generic\\):\\)")
1618 spice-colon-keywords-regexp)
1619 (progn
1620 (goto-char pos)
1621 (setq pos nil)
1622 (setq found t))
1623 (progn
1624 (goto-char pos)
1625 (setq pos (search-forward ":" limit 'end)))))
1626 found))
1628 ;; these are try outs to solve the font-locking of problematic xinstances:
1630 (defun spice-match-xinstances-dummy (limit)
1631 "match xinstances"
1632 (let (min max pt)
1633 (setq pt (point))
1634 (goto-char (point-min))
1635 (setq min (point))
1636 (goto-char (point-max))
1637 (setq max (point))
1638 (save-excursion
1639 (set-buffer (get-buffer-create "*Matcher*"))
1640 (goto-char (point-max))
1641 (insert (format "Point min is %s\n" min))
1642 (insert (format "Current point is %s\n" pt))
1643 (insert (format "Limit is %s\n" limit))
1644 (insert (format "Point max is %s\n" max))
1650 (defun spice-idle-font-lock (beg end)
1651 "runs font-lock on a region"
1652 (message "rerunning font-lock on %s:%s=%s" beg end (buffer-substring beg end))
1653 (save-excursion (font-lock-fontify-region beg end)))
1655 (defvar spice-previous-xinstance-match-result nil)
1656 (make-variable-buffer-local 'spice-previous-xinstance-match-result)
1658 (defun spice-match-in-xinstance (limit)
1659 "checks if in xinstance"
1660 (let ((pt (point)))
1661 (if (or (looking-at "^\\s-*[xX]")
1662 (re-search-backward "^[xX]" (point-min) t))
1663 (if (and (looking-at spice-xinstance-regexp)
1664 (or (> (match-end 5) pt)
1665 (not spice-previous-xinstance-match-result))
1667 (progn
1668 (message ".")
1669 (goto-char (match-end 5))
1670 (if (or (> pt (match-beginning 1))
1671 (< limit (match-end 5)))
1672 (progn
1673 (message "*")
1674 ;;(spice-idle-font-lock (match-beginning 1) (match-end 5))
1675 (run-with-idle-timer 1 nil 'spice-idle-font-lock
1676 (match-beginning 1) (match-end 5))
1678 ;; (if (> (match-end 5) limit)
1679 ;; (run-with-idle-timer 1 nil 'spice-idle-font-lock
1680 ;; (match-beginning 1) (match-end 5)))
1682 (goto-char pt)
1683 nil)
1684 nil)
1687 (defun spice-match-next-xinstance (limit)
1688 "checks if there is a next xinstance partly within limit"
1689 (if (re-search-forward "^[xX]" limit 'end)
1690 (progn
1691 (backward-char 1)
1692 (if (looking-at spice-xinstance-regexp)
1693 (progn
1694 (message "+")
1695 (goto-char (match-end 5))
1697 (message "-")
1698 (forward-char 1)
1699 (spice-match-next-xinstance limit))
1701 nil))
1703 (defun spice-match-xinstance (limit)
1704 "match xinstances"
1705 (if (spice-match-in-xinstance limit)
1707 (spice-match-next-xinstance limit)))
1709 (defun spice-match-xinstances-old (limit)
1710 "match an xinstance"
1711 (setq spice-previous-xinstance-match-result (spice-match-xinstance limit))
1712 spice-previous-xinstance-match-result)
1714 ;; this xinstances matcher is a complete parser !
1716 (defun spice-match-xinstances (limit)
1717 "match xinstance subckt name, this one parses the lines, should work for
1718 all cases, infinite number of comment lines, continuation lines. Could fail
1719 when modifying an xinstance line though, hard to tell."
1720 (interactive)
1721 (let ((result nil) match-start)
1722 (while
1723 (and (not result)
1724 (re-search-forward "^\\(x\\S-*\\)" limit 'end)) ;; should be checked ?
1725 (setq match-start (match-data))
1726 ;;(message "match-start is %s" match-start)
1727 (while
1729 (and (looking-at "\\([ \t]+\\|\\s-*\n[+]\\s-*\\)\\(\\([a-z][^ :(=\t\n]*\\)\\|\\([^ *$!:(=\t\n][^ :(=\t\n]*\\)\\)\\(\\s-*\n\\|\\s-+[^=\n]\\)")
1730 (progn
1731 (goto-char (match-end 2))
1732 (setq result t)))
1733 (save-match-data
1734 (and
1735 (looking-at "\\(\\([ \t]+\\|\\s-*\n\\s-*\\)[$!*].*\\)")
1736 (progn
1737 (goto-char (match-end 1))
1738 t))))
1739 nil))
1740 (when result (set-match-data
1741 (append (list (car match-start) (car (cdr (match-data))))
1742 (cdr (cdr match-start)) (cdr (cdr (match-data))))))
1743 ;;(when result (message "Matched %s[%d]" (match-string 3) (match-end 3)))
1744 (when result (when (< limit (match-end 3)) (setq result nil)))
1745 result))
1747 (defvar spice-font-lock-keywords nil
1748 "Regular expressions to highlight in spice mode.")
1750 (defun spice-font-lock-init ()
1751 "Initialize fontification." ; makes spice-font-lock-keywords valid
1752 ;; highlight title & titles after .alter & .title (hspice only)
1753 (setq spice-font-lock-keywords-0
1754 (append (list ;; first line of spice deck
1755 (list "\\`.+$" 0 spice-title-face)
1756 (list spice-section-headings-regexp
1757 '(1 font-lock-comment-face)
1758 '(2 spice-title-face)
1759 (list (regexp-opt-depth spice-section-headings-regexp)
1760 spice-doc-face 'keep t)))
1761 ;; hspice title in .alter or .title line
1762 (when (spice-standard-p 'hspice)
1763 (list
1764 (list "^\\.\\(alter\\|title\\)\\s-+\\(.+\\)$"
1765 2 spice-title-face)))))
1766 ;; highlight layla functions: .xx_yy_param(name,prop,val);
1767 (setq spice-font-lock-keywords-1
1768 (list
1769 (list spice-functions-regexp
1770 '(1 spice-layla-function-name-face)
1771 (list (- (regexp-opt-depth spice-functions-regexp) 1)
1772 font-lock-function-name-face)
1773 (list (regexp-opt-depth spice-functions-regexp)
1774 font-lock-variable-name-face)
1776 ;; highlight spice keywords (mainly .<keyword> & .<analysis>)
1777 (setq spice-font-lock-keywords-2
1778 (list ;; .opt, .nodeset, ...
1779 (list spice-keywords-regexp 0 font-lock-keyword-face)
1780 ;; '+' of continuation lines ? maybe over the top ...
1781 ;; (list (concat "^"
1782 ;; (when (spice-standard-p 'layla) "\\*?")
1783 ;; "\\+") 0 font-lock-keyword-face)
1784 ;; .op, .ac, .dc, .tran, ...
1785 (list spice-analyses-regexp
1786 '(1 font-lock-keyword-face)
1787 '(2 spice-analysis-face)
1788 (list spice-analysis-modifiers-regexp
1789 nil nil '(0 font-lock-type-face)))))
1791 (setq spice-font-lock-keywords-12
1792 ;; do dracula CDL stuff
1793 (list
1794 ;; add $ docs when they are followed by a space...
1795 (list (concat "\\<\\([$]\\)\\s-+\\(.*\\)$")
1796 (list 1 font-lock-comment-face)
1797 (list 2 spice-doc-face 'keep))
1798 ;; special models on element line
1799 (list (concat "\\([$]\\(?:ldd\\)?\\[\\)" spice-model-name "\\(\\]\\)")
1800 '(1 font-lock-keyword-face)
1801 '(2 spice-model-name-face)
1802 '(3 font-lock-keyword-face))
1803 ;; normal .model on element line
1804 (list (concat "\\([$]\\.model\\)\\s-*=\\s-*" spice-model-name)
1805 '(1 font-lock-keyword-face)
1806 '(2 spice-model-name-face))
1807 ;; element options behind $ syntax
1808 (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-keywords) "\\)")
1809 '(1 font-lock-keyword-face)
1810 '(2 font-lock-keyword-face))
1811 ;; element parameters behind $ syntax
1812 (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-parameters) "\\)\\s-*=")
1813 '(1 font-lock-keyword-face)
1814 '(2 font-lock-variable-name-face))
1815 ;; general '.' keywords
1816 (list spice-draccdl-keywords-regexp 0 font-lock-keyword-face)))
1818 ;; highlight layla specific keywords, also if *. syntax is used
1819 (setq spice-font-lock-keywords-3
1820 (append (list
1821 (list spice-layla-keywords-regexp 0 font-lock-keyword-face)
1822 (list "^\\(\\*\\)\\+" 1 font-lock-keyword-face))
1823 (when (spice-standard-p 'mondriaan)
1824 (list
1825 (list spice-mondriaan-keywords-regexp 0 font-lock-keyword-face)))))
1827 (setq spice-font-lock-keywords-13
1828 ;; do spectre stuff
1829 (list
1830 ;; * spectre: + syntax
1831 (list "^\\(\\*\\)\\s-+spectre:\\s-+" 1 font-lock-keyword-face)
1832 ;; // comments
1833 (list "//.*$" 0 font-lock-comment-face)
1834 ;; add simulator language=spice
1835 (list "^\\s-*\\(simulator\\)\\>"
1836 '(1 font-lock-keyword-face))))
1838 ;; varia: .end, spice instances and '*' comment lines and output lines
1839 (setq spice-font-lock-keywords-4
1840 (list
1841 ;; elements
1842 ;;'("^[a-z]\\S-*" . spice-instance-name-face)
1843 '("^[a-z][^ \t\n]+" . spice-instance-name-face)
1844 ;(list (concat "^\\*\\([^"
1845 ; (when (spice-standard-p 'layla) "+")
1846 ; "\n].*\\|\n\\)") 0 font-lock-comment-face)
1847 (list (concat "^\\*[^\n"
1848 (when (or (spice-standard-p 'hspice)
1849 (spice-standard-p 'draccdl)
1850 (spice-standard-p 'layla)) "$")
1851 (when (spice-standard-p 'eldo) "!")
1852 "]*") 0 font-lock-comment-face)
1853 (list (concat "^\\.\\(" (regexp-opt spice-output-keywords)
1854 "\\)\\s-*" spice-line-break "\\s-+\\("
1855 (regexp-opt spice-output-types) "\\)\\>")
1856 '(0 font-lock-type-face keep)) ;
1858 ;; highlight additional . unknowns (to detect stupid typing errors)
1859 (setq spice-font-lock-keywords-5
1860 (list '("^\\s-*\\.[^ \t\n]*" 0 font-lock-warning-face)))
1862 ;; highlight additional $ and ! comments, only eldo, hspice, draccdl and layla
1863 (setq spice-font-lock-keywords-6
1864 (list
1865 (list (concat "\\<\\(["
1866 (when (or (spice-standard-p 'hspice)
1867 (spice-standard-p 'draccdl)
1868 (spice-standard-p 'layla)) "$")
1869 (when (spice-standard-p 'eldo) "!")
1870 "]\\)\\(.*\\)$")
1871 (list 1 font-lock-comment-face)
1872 (list 2 spice-doc-face 'append) ;; needs at least 'append or 'keep
1874 (list (concat "\\<\\([*"
1875 (when (or (spice-standard-p 'hspice)
1876 (spice-standard-p 'draccdl)
1877 (spice-standard-p 'layla)) "$")
1878 (when (spice-standard-p 'eldo) "!")
1879 "]\\)")
1880 ;; elisp mode like quotes, for extra clarity
1881 (list "['\"]\\([^'\"]+\\)['\"]" nil nil
1882 (list 1 spice-constant-face 'prepend)))))
1884 ;; subcircuit instance names of x instances and model names of mos,bip&diode
1885 (setq spice-font-lock-keywords-7
1886 (list
1887 (list spice-xinstance-regexp 5 spice-model-name-face)
1888 ;; test xinstance function matcher
1889 ;;(list 'spice-match-xinstances
1890 ;; '(4 spice-model-name-face keep t)
1891 ;; '(5 font-lock-warning-face keep t))
1892 (list spice-model-name-regexp 4 spice-model-name-face)
1895 ;; highlight poly's of inductors and caps
1896 (setq spice-font-lock-keywords-8
1897 (list
1898 '("^[cl]\\w*\\s-+\\w[^ \t\n]*\\s-+\\w[^ \t\n]*\\s-+\\(poly\\)"
1899 1 font-lock-type-face)))
1901 ;; types, included files, libs and names of subcircuits, ports, libs, models
1902 (setq spice-font-lock-keywords-9
1903 (append
1904 ;; names and types of models/subckt, lib concept of eldo...
1905 (when (spice-standard-p 'eldo)
1906 (list
1907 (list (concat "^\\s-*\\.\\(model\\|subckt\\|macro\\)\\s-+"
1908 "\\(\\(lib\\)\\s-+[^ \t\n]+\\s-+\\)"
1909 spice-model-name)
1910 '(3 font-lock-keyword-face)
1911 '(4 font-lock-function-name-face))))
1912 (list
1913 ;; types
1914 (list "^[+vi.]" '(0 'default) ;; find v & i's and continuation and . lines
1915 (list spice-types-regexp nil nil '(1 font-lock-type-face)))
1916 ;; libs, inc's, ...
1917 (list (concat spice-library-regexp-start
1918 spice-library-regexp-end) 3 spice-include-file-face)
1919 ;; names of (defined) entities
1920 (list
1921 (concat spice-entity-start-regexp
1922 "\\(\\s-+\\([a-z]\\w*\\)\\s-*"
1923 "\\|\\s-*[\n][+]\\s-*\\([a-z]\\w*\\)\\s-*\\)")
1924 (1+ (regexp-opt-depth spice-entity-start-regexp))
1925 font-lock-function-name-face)
1926 ;; names and types of models
1927 (list (concat "^\\s-*\\.model\\s-+"
1928 spice-model-name
1929 spice-line-break "\\s-+\\("
1930 (regexp-opt spice-model-type-names) "\\)\\>")
1931 '(1 font-lock-function-name-face)
1932 '(3 font-lock-type-face))
1935 ;; highlight additional eldo reserved words
1936 (setq spice-font-lock-keywords-10
1937 (list
1938 ;; eldo's labels
1939 (list "\\<\\(label\\)\\s-*=\\s-*\\([^\"]\\w*\\)\\>"
1940 '(1 font-lock-type-face)
1941 '(2 font-lock-variable-name-face))
1942 ;; eldo's labels(2)
1943 (list "\\<\\(label\\)\\s-*=\\s-*\"\\([^\"]+\\)\""
1944 '(1 font-lock-type-face)
1945 '(2 font-lock-variable-name-face))
1946 ;; eldo's param,model&pin:
1947 ;;'("\\<\\(\\(param\\|pin\\|model\\):\\)" 0 font-lock-keyword-face)
1948 (list 'spice-match-eldo-colon-keywords
1949 (list 1 font-lock-keyword-face)
1950 '(2 'default))
1951 ;; eldo's builtin macro models
1952 (list (concat "^y\\w+\\s-+\\<\\("
1953 (regexp-opt spice-eldo-macromodel-keywords) "\\)\\>")
1954 '(1 spice-builtin-face))
1955 ;; eldo's y instances, type is second word on line
1956 (list (concat "^y\\w+\\s-+\\<" spice-model-name "\\>")
1957 1 spice-model-name-face)))
1958 ;; highlight property names property=value & strings (way at the end)
1959 (setq spice-font-lock-keywords-11
1960 (list
1961 ;; this is 1 second faster when loading 28 files, appx 10000 lines
1962 ;; .options keywords & parameters
1963 (list (concat "^\\s-*" ;; was "^"
1964 (when (spice-standard-p 'layla) "\\*?")
1965 "\\.opt\\(ion"
1966 (when (or (spice-standard-p 'hspice)
1967 (spice-standard-p 'layla))
1968 "\\(s\\)?")
1969 "\\)?\\s-+")
1970 '(0 font-lock-keyword-face) ;; not used, already colored
1971 (list (concat "\\<\\(\\("
1972 (regexp-opt spice-options-keywords)
1973 "\\)\\>\\|\\("
1974 (regexp-opt spice-options-parameters)
1975 "\\)\\s-*=\\)") nil nil
1976 (list 1 spice-constant-face)))
1977 ;; param=value
1978 ;; '("\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
1979 ;; this function matcher is much faster, it searches for '=' and then
1980 ;; returns the word in front of the '=', doesn't work in xemacs though
1981 ;;(if (string-match "XEmacs" emacs-version)
1982 ;; (list "\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
1983 (list 'spice-match-variable-name
1984 (list 1 font-lock-variable-name-face 'append)
1985 ;;(list 1 font-lock-variable-name-face)
1986 '(2 'default 'append)) ;; default is required for XEmacs
1987 ;; 'append is required for Xemacs 21.4.11 on Windows. Otherwise
1988 ;; the matcher overrules the previous highlighting (for instance when
1989 ;; this 'var=value' is after a doc starter...
1990 ;; )
1992 ;; changelog entries
1993 (list
1994 (concat
1995 "^[*"
1996 (when (or (spice-standard-p 'hspice)
1997 (spice-standard-p 'layla)) "$")
1998 (when (spice-standard-p 'eldo) "!")
1999 "]+\\s-+\\([A-Z].*[0-9]\\)\\s-+\\([a-zA-Z].*\\)<\\(.*@.*\\)>$")
2000 '(1 font-lock-string-face t)
2001 '(2 font-lock-type-face t)
2002 '(3 font-lock-variable-name-face t))
2004 ;; strings
2005 '("\"[^\"]*\"" 0 font-lock-string-face)
2007 ;; scale factors and powers or is this overkill ?
2008 (list (concat
2009 "\\<[-+]?[0-9.]+\\(\\("
2010 (regexp-opt '("T" "G" "Meg" "K" "mil" "m" "u" "M" "n" "p" "f"))
2011 "\\)[a-zA-Z]*\\)\\>")
2012 (list 2 spice-constant-face 'append))
2013 (list (concat
2014 "[0-9.]\\(e\\)[-+]?[0-9]+\\>")
2015 (list 1 spice-constant-face 'append))
2017 ;; set font-lock-keywords, all of 'em
2018 (setq spice-font-lock-keywords
2019 (append spice-font-lock-keywords-0 ;; title first
2020 (when (spice-standard-p 'layla)
2021 spice-font-lock-keywords-1)
2022 (when spice-highlight-keywords
2023 spice-font-lock-keywords-2)
2024 (when (and
2025 spice-highlight-keywords
2026 (spice-standard-p 'layla))
2027 spice-font-lock-keywords-3)
2028 (when (spice-standard-p 'spectre)
2029 spice-font-lock-keywords-13)
2030 (when (spice-standard-p 'draccdl)
2031 spice-font-lock-keywords-12)
2032 spice-font-lock-keywords-4
2033 (when spice-highlight-keywords
2034 spice-font-lock-keywords-5)
2035 (when (or (spice-standard-p 'layla)
2036 (spice-standard-p 'hspice)
2037 (spice-standard-p 'draccdl)
2038 (spice-standard-p 'eldo))
2039 spice-font-lock-keywords-6)
2040 spice-font-lock-keywords-7
2041 (when spice-highlight-keywords
2042 spice-font-lock-keywords-8)
2043 spice-font-lock-keywords-9
2044 (when (spice-standard-p 'eldo)
2045 spice-font-lock-keywords-10)
2046 (when spice-highlight-keywords
2047 spice-font-lock-keywords-11)
2051 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2052 ;;; Comments (taken from eldo-mode.el)
2053 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2055 ;; uncomment function, should work for any case now:
2056 (defun spice-uncomment-region (beg end)
2057 "Uncomment selected region - comment symbol is '*'
2058 Doc comments (starting with '!') are unaffected."
2059 (interactive "*r")
2060 (comment-region beg end '(2))) ; 2 is arbitrary, can be any value
2063 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2064 ;;; spice mode map
2065 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2067 ;; (require 'tempo) ; ? is this necessary
2069 (defvar spice-mode-map ()
2070 "Keymap used in spice-mode.")
2072 (if spice-mode-map
2074 (let ((map (make-sparse-keymap)))
2076 ;; key binding for template completion
2077 (define-key map "\t" 'tempo-complete-tag)
2078 ;; (define-key map "\S-\t" 'indent-for-tab-command)
2079 (define-key map [(shift tab)] 'indent-for-tab-command)
2080 (define-key map [(shift iso-lefttab)] 'indent-for-tab-command)
2082 ;; key bindings for compile
2083 (define-key map "\C-c\C-r" 'spice-compile) ;; r for run
2084 (define-key map "\C-c\C-k" 'kill-compilation)
2086 ;; replace global binding
2087 (define-key map "\C-x`" 'spice-next-error)
2089 ;; key bindings for waveform viewer
2090 (define-key map "\C-c\C-v" 'spice-run-waveform-viewer)
2092 ;; key bindings for output file loading
2093 (define-key map "\C-c\C-o" 'spice-load-output-file)
2095 ;; key bindings for include file loading
2096 (define-key map "\C-c\C-l" 'spice-load-include-files)
2098 ;; comment region, use auctex-mode bindings...
2099 (define-key map "\C-c\C-c" 'comment-region)
2100 ;;(define-key map "\C-c:" 'spice-uncomment-region) ;; \C-u\C-c\C-c
2102 ;; .subckt search
2103 (define-key map "\C-c\C-s" 'spice-search-subckt)
2105 ;; join lines
2106 (define-key map "\M-^" 'spice-delete-indentation)
2108 ;; key bindings for hiding/unhidding comments
2109 (define-key map "\C-c;" 'spice-hide-all-comments)
2110 (define-key map "\C-c:" 'spice-unhide-all-comments)
2112 ;; changelog addition
2113 (define-key map "\C-c\C-ac" 'spice-add-changelog-entry)
2115 ;; fontification
2116 (when spice-running-xemacs
2117 (define-key map "\C-c\C-f" 'font-lock-fontify-buffer))
2119 (setq spice-mode-map map)))
2122 (defvar spice-output-mode-map ()
2123 "Keymap used in Spice-output mode.")
2125 (if spice-output-mode-map
2127 (let ((map (make-sparse-keymap)))
2128 ;; nothing for now ...
2130 (setq spice-output-mode-map map)))
2133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2134 ;;; libraries & include files (taken & adapted from eldo-mode.el, E. Rouat)
2135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2137 ;; (if spice-running-xemacs
2138 ;; (require 'overlay)
2139 ;; (require 'lucid)) ;; what else can we do ??
2141 ;;------------------------------------------------------------
2142 ;; Mouse bindings (only used by 'spice-load-file-at-mouse')
2143 ;; I separate this from spice-mode-map so that this particular
2144 ;; mouse binding doesn't interfere with other bindings
2146 (defvar spice-mode-mouse-map nil
2147 "Map containing mouse bindings for spice-mode.")
2149 (if spice-mode-mouse-map
2151 (let ((map (make-sparse-keymap)))
2152 (set-keymap-parent map spice-mode-map)
2153 ;; mouse button bindings
2154 ;;(define-key map "\r" 'ffap)
2155 (define-key map "\r" 'spice-load-file-at-point)
2156 (if spice-running-xemacs
2157 (define-key map 'button2 'spice-load-file-at-mouse) ;; ffap-at-mouse ?
2158 (define-key map [mouse-2] 'spice-load-file-at-mouse))
2159 (if spice-running-xemacs
2160 (define-key map 'Sh-button2 'mouse-yank)
2161 (define-key map [S-mouse-2] 'mouse-yank-at-click))
2162 (setq spice-mode-mouse-map map)))
2165 ;; overlays and extents are a mess. Depending on emacs/xemacs versions the
2166 ;; following code might actually work. What is known now is that this
2167 ;; works in: emacs 20.7, 21.1 and 21.2 (Linux versions have been tested),
2168 ;; xemacs 21.1 (Windows) and xemacs 21.5 (Linux). You need
2169 ;; fsf-compat package for xemacs 21.4.5 (Linux). Anyone still following this ?
2171 ;; create set-extent-keymap procedure when it does not exist
2172 (eval-and-compile
2173 (unless (fboundp 'set-extent-keymap)
2174 (defun set-extent-keymap (extent keymap)
2175 "fallback version of set-extent-keymap (for emacs 2[01])"
2176 (set-extent-property extent 'local-map keymap))))
2179 (defun spice-colorize-libraries (beg end old-len)
2180 "This function colorises libraries and included files when the mouse
2181 passes over them. Clicking on the middle-mouse button loads them in a buffer.
2182 BEWARE, this feature was hard to implement, and contains (non-fatal) bugs,
2183 primarily because emacs 20 does not have the same support for this as xemacs
2184 has."
2185 (save-excursion
2186 (save-match-data
2187 (let (end-point)
2188 (goto-char end)
2189 (end-of-line)
2190 (setq end-point (point))
2191 (goto-char beg)
2192 (beginning-of-line) ; scan entire line !
2193 ;; delete overlays existing on this line
2194 (let ((overlays (overlays-in (point) end-point)))
2195 (while overlays
2196 (if (and (overlay-get (car overlays) 'detachable)
2197 (overlay-get (car overlays) 'spice-library))
2198 (delete-overlay (car overlays))
2200 (setq overlays (cdr overlays)))) ; let
2201 ; make new ones, could reuse deleted one ?
2202 (while (search-forward-regexp spice-library-regexp-start end-point t)
2203 (let (start-lib extent)
2204 (setq start-lib (point))
2205 (search-forward-regexp spice-library-regexp-end end-point)
2206 ; (let ((end-lib (point)))
2207 (or (extent-at (point) (buffer-name) 'mouse-face) ;; not yet extended
2208 (progn
2209 (setq extent (make-extent start-lib (point)))
2210 (set-extent-property extent 'start-closed 't)
2211 (set-extent-property extent 'end-closed 't)
2212 (set-extent-property extent 'detachable 't)
2213 (set-extent-property extent 'spice-library 't)
2214 (set-extent-property extent 'mouse-face 'highlight)
2215 (set-extent-keymap extent spice-mode-mouse-map)))))))))
2218 (defun spice-colorize-libraries-buffer ()
2219 (interactive)
2220 ;; (message "running colorize libraries buffer")
2221 ;; delete overlays
2222 (let ((overlays (overlays-in (point-min) (point-max))))
2223 (while overlays
2224 (if (and
2225 (overlay-get (car overlays) 'detachable)
2226 (overlay-get (car overlays) 'spice-library))
2227 (delete-overlay (car overlays)))
2228 (setq overlays (cdr overlays)))) ; let
2229 ;; remake overlays
2230 (spice-colorize-libraries (point-min) (point-max) nil))
2233 ;; ffap needs wrapper to detect end of buffer condition
2234 (defun spice-load-file-at-point ()
2235 "wrapper for ffap. But if at end of buffer inserts a newline instead"
2236 (interactive)
2237 (if (looking-at "\\'")
2238 (newline) ;; assumes \r is bound to load file...
2239 (ffap)))
2242 ;; ffap-at-mouse isn't available in xemacs < 21
2243 ;; so define this function to do more or less the same (primarily
2244 ;; wraps ffap-at-mouse, except for xemacs 20)...
2245 (defun spice-load-file-at-mouse (event)
2246 "loads file under button 2 click. Checks if file is readable."
2247 (interactive "@e")
2248 (if (fboundp 'ffap-at-mouse)
2249 (ffap-at-mouse event) ;; use ffap-at-mouse if available
2250 (save-excursion ;; implement a spice specific ffap-at-mouse
2251 (mouse-set-point event)
2252 (beginning-of-line)
2253 (if (looking-at (concat spice-library-regexp-start
2254 spice-library-regexp-end))
2255 (if (file-readable-p (substitute-in-file-name (match-string 3)))
2256 (find-file (substitute-in-file-name (match-string 3)))
2257 (progn
2258 (message "File '%s' isn't readable, use shift-mouse2 to paste in this field" (match-string 3))))
2259 ))))
2262 ;;------------------------------------------------------------
2263 ;; Changelog and sections support (taken from eldo-mode, trying
2264 ;; to be compatible :)
2265 ;;------------------------------------------------------------
2267 (defun spice-doc-char ()
2268 "Return doc char that's valid in the selected spice submode"
2269 (cond
2270 ((and (spice-standard-p 'eldo)
2271 (spice-standard-p 'hspice))
2272 "*") ; if both eldo and hspice is turned on
2273 ((spice-standard-p 'eldo)
2274 "!") ; only eldo
2275 ((spice-standard-p 'hspice)
2276 "$") ; only hspice
2278 "*"))) ; everything else
2281 (defun spice-find-changelog-point ()
2282 "Find adequate position to place Changelog entries: just before .end
2283 or if not found at end of buffer."
2284 (save-excursion
2285 (goto-char (point-min))
2286 (let ((pos (re-search-forward
2287 "^\\.end\\b" nil t)))
2288 (if pos (progn (forward-line 1)
2289 (point))
2290 (point-max)))))
2293 (defun spice-add-changelog-entry (changelog-entry)
2294 "Find changelog section (create it if not found) and add an entry for today."
2295 (interactive "sChangelog entry: ")
2296 (goto-char (point-min))
2297 (if (not (re-search-forward
2298 (concat spice-section-regexp-start "Changelog") nil t))
2299 (spice-add-section "Changelog" (spice-find-changelog-point)))
2301 (spice-goto-section "Changelog")
2302 ; (forward-line 2)
2303 (let ((string (concat (spice-doc-char)
2304 (if (equal (spice-doc-char) "*") "* " " ")
2305 (substring (current-time-string) 0 11)
2306 (substring (current-time-string) -4) " "
2307 (user-full-name) " <" user-mail-address ">")))
2308 (if (not (search-forward string nil t))
2309 (insert "\n" string "\n\n")
2310 (forward-line 2))
2311 (insert (spice-doc-char)
2312 (if (equal (spice-doc-char) "*") "*" "")
2313 " - " changelog-entry "\n")))
2316 (defun spice-goto-section (section)
2317 "Move point to the beginning of the specified section; If the
2318 section is not found, leave point at previous location."
2319 (interactive "ssection: ")
2320 (let ((pos (point)))
2321 (goto-char (point-min))
2322 (if (not (re-search-forward
2323 (concat spice-section-regexp-start section "\\b") nil t))
2324 (progn (message "Couldn't find section %s" section)
2325 (goto-char pos))
2326 (progn
2327 (forward-line 2)
2328 (recenter))))) ;; added recenter
2331 (defun spice-comment-bar (&optional aligned)
2332 "Insert solid comment bar from column zero to end of line. If optional
2333 argument is provided, bar will be added from current column."
2334 (interactive)
2335 (if (not aligned) (beginning-of-line) )
2336 (insert "*")
2337 (insert-char ?- (- (1- fill-column) (current-column)))
2338 (insert "\n"))
2341 (defun spice-add-section (section &optional arg)
2342 "Add a section in buffer at (optional) point arg"
2343 (interactive "ssection: ")
2344 (if arg
2345 (goto-char arg))
2346 (spice-comment-bar)
2347 (insert
2348 (concat (spice-doc-char) "\t" section " \n"))
2349 (spice-comment-bar)
2350 ;; (unless (assoc section spice-section-alist)
2351 ;; ;; new entry
2352 ;; (custom-set-variables
2353 ;; (quote (spice-section-alist
2354 ;; (append spice-section-alist
2355 ;; (list (list section (upcase section) nil))))))
2356 ;; )
2360 (defvar spice-cache-section-alist nil)
2362 (defun spice-cache-section-p (section)
2363 "checks for all sections in file and remembers if they were present or not"
2364 (save-excursion
2365 (setq spice-cache-section-alist nil)
2366 (goto-char (point-min))
2367 (while (re-search-forward spice-section-headings-regexp nil t)
2368 (setq spice-cache-section-alist
2369 (cons (cons (downcase (spice-match-string-no-properties 2)) t)
2370 spice-cache-section-alist)))
2371 (spice-section-p section)))
2374 (defun spice-section-p (section)
2375 "checks if named section is in file, returns t if found, nil otherwise,
2376 uses cache generated with the `spice-cache-section-p' function."
2377 (assoc section spice-cache-section-alist))
2380 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2381 ;;; Templates (extensive, long code...)
2382 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2384 (require 'tempo)
2386 ;;; element templates
2388 ;; resistors
2389 (tempo-define-template
2390 "spice-spice2g6-resistor"
2391 '("R"
2392 (p "[name]: ") '(just-one-space)
2393 (p "[pos node]: ") '(just-one-space)
2394 (p "[neg node]: ") '(just-one-space)
2395 (p "[val]: "))
2396 ;; "spice2g6 resistor"
2398 "tempo template for spice2g6 resistor"
2399 'spice-tempo-tags)
2402 (tempo-define-template
2403 "spice-spice3-semiconductor-resistor"
2404 '("R"
2405 (p "[name]: ") '(just-one-space)
2406 (p "[pos node]: ") '(just-one-space)
2407 (p "[neg node]: ") '(just-one-space)
2408 (p "<value>: " value) '(just-one-space)
2409 (p "<mname>: " mname) '(just-one-space)
2410 (p "<length>: " l 'noinsert)
2411 (if (string-equal (tempo-lookup-named 'l) "")
2412 () (list 'l "L=" '(s l)))
2413 '(just-one-space)
2414 (p "<width>: " w 'noinsert)
2415 (if (string-equal (tempo-lookup-named 'w) "")
2416 () (list 'l "W=" '(s w)))
2417 '(just-one-space)
2418 (p "<temp>: " temp 'noinsert)
2419 (if (string-equal (tempo-lookup-named 'temp) "")
2420 () (list 'l "TEMP=" '(s temp)))
2421 '(just-one-space)
2423 ;; "spice3 semiconductor resistor"
2424 "RSS"
2425 "tempo template for spice3 semiconductor resistor"
2426 'spice-tempo-tags)
2429 (tempo-define-template
2430 "spice-eldo-resistor"
2431 '("R"
2432 (p "[name]: ") '(just-one-space)
2433 (p "[pos node]: ") '(just-one-space)
2434 (p "[neg node]: ") '(just-one-space)
2435 (p "<mname>: " mname) '(just-one-space)
2436 (if (string-equal (tempo-lookup-named 'mname) "")
2437 (list 'l "r=" '(p "[val]: "))
2438 (list 'l '(p "[val]: "))) '(just-one-space)
2439 (p "<temp coef 1>: " tc1 'noinsert)
2440 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2441 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2442 '(just-one-space)
2443 (if (and (tempo-lookup-named 'tc2)
2444 (not (string-equal (tempo-lookup-named 'tc2) "")))
2445 (list 'l "TC2=" '(s tc2)))
2446 '(just-one-space)
2447 (p "<ac resistance>: " ac 'noinsert)
2448 (if (string-equal (tempo-lookup-named 'ac) "")
2449 () (list 'l "AC=" '(s ac)))
2450 '(just-one-space)
2451 (p "<temp>: " temp 'noinsert)
2452 (if (string-equal (tempo-lookup-named 'temp) "")
2453 () (list 'l "T=" '(s temp)))
2454 '(just-one-space)
2455 (p "<m>: " m 'noinsert)
2456 (if (string-equal (tempo-lookup-named 'm) "")
2457 () (list 'l "M=" '(s m)))
2458 '(just-one-space)
2459 (p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)
2460 (if (string-equal (tempo-lookup-named 'nonoise) "y")
2461 (list 'l "NONOISE"))
2462 '(just-one-space)
2463 (p "<kf>: " kf 'noinsert)
2464 (if (string-equal (tempo-lookup-named 'kf) "")
2465 () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
2466 '(just-one-space)
2467 (if (and (tempo-lookup-named 'af)
2468 (not (string-equal (tempo-lookup-named 'af) "")))
2469 (list 'l '(s af)))
2470 '(just-one-space)
2472 ;; "eldo resistor"
2473 "RE"
2474 "tempo template for eldo resistor"
2475 'spice-tempo-tags)
2478 (tempo-define-template
2479 "spice-eldo-expression-resistor"
2480 '("R"
2481 (p "[name]: ") '(just-one-space)
2482 (p "[pos node]: ") '(just-one-space)
2483 (p "[neg node]: ") '(just-one-space)
2484 (p "[VALUE | TABLE]: " type 'noinsert) '(just-one-space)
2485 (if (string-equal (tempo-lookup-named 'type) "VALUE")
2486 (list 'l "VALUE={" '(p "[val, enter expression without {}]: ") "}")
2487 (list 'l "TABLE={" '(p "[table of values, enter table without {}]: ") "}"))
2488 '(just-one-space)
2489 (if (string-equal (tempo-lookup-named 'type) "VALUE")
2490 (list 'l '(p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)))
2491 (if (and (tempo-lookup-named 'nonoise)
2492 (string-equal (tempo-lookup-named 'nonoise) "y"))
2493 (list 'l "NONOISE"))
2494 '(just-one-space)
2495 (p "<kf>: " kf 'noinsert)
2496 (if (string-equal (tempo-lookup-named 'kf) "")
2497 () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
2498 '(just-one-space)
2499 (if (and (tempo-lookup-named 'af)
2500 (not (string-equal (tempo-lookup-named 'af) "")))
2501 (list 'l '(s af)))
2503 ;; "eldo expression resistor"
2504 "REE"
2505 "tempo template for eldo expression resistor"
2506 'spice-tempo-tags)
2509 (tempo-define-template
2510 "spice-eldo-semiconductor-resistor"
2511 '("P"
2512 (p "[name]: ") '(just-one-space)
2513 (p "[pos node]: ") '(just-one-space)
2514 (p "[neg node]: ") '(just-one-space)
2515 (p "[mname]: " mname) '(just-one-space)
2516 (p "<res>: " r 'noinsert)
2517 (if (string-equal (tempo-lookup-named 'r) "")
2518 () (list 'l "R=" '(s r)))
2519 '(just-one-space)
2520 (p "<length>: " l 'noinsert)
2521 (if (string-equal (tempo-lookup-named 'l) "")
2522 () (list 'l "L=" '(s l)))
2523 '(just-one-space)
2524 (p "<contact offset length>: " cl 'noinsert)
2525 (if (string-equal (tempo-lookup-named 'cl) "")
2526 () (list 'l "CL=" '(s cl)))
2527 '(just-one-space)
2528 (p "<width>: " w 'noinsert)
2529 (if (string-equal (tempo-lookup-named 'w) "")
2530 () (list 'l "W=" '(s w)))
2531 '(just-one-space)
2532 (p "<contact offset width>: " cw 'noinsert)
2533 (if (string-equal (tempo-lookup-named 'cw) "")
2534 () (list 'l "CW=" '(s cw)))
2535 '(just-one-space)
2536 (p "<area>: " area 'noinsert)
2537 (if (string-equal (tempo-lookup-named 'area) "")
2538 () (list 'l "AREA=" '(s area)))
2539 '(just-one-space)
2540 (p "<init cond (voltage, voltage)>: " ic 'noinsert)
2541 (if (string-equal (tempo-lookup-named 'ic) "")
2542 () (list 'l "IC=" '(s ic)))
2543 '(just-one-space)
2545 ;; "eldo semiconductor resistor"
2546 "RES"
2547 "tempo template for eldo semiconductor resistor"
2548 'spice-tempo-tags)
2551 (tempo-define-template
2552 "spice-hspice-resistor"
2553 '("R"
2554 (p "[name]: ") '(just-one-space)
2555 (p "[pos node]: ") '(just-one-space)
2556 (p "[neg node]: ") '(just-one-space)
2557 (p "<mname>: " mname) '(just-one-space)
2558 (if (string-equal (tempo-lookup-named 'mname) "")
2559 (list 'l "R=" '(p "[val]: "))
2560 (list 'l '(p "<val>: " val 'noinsert)
2561 '(if (not (string-equal (tempo-lookup-named 'val) ""))
2562 (list 'l "R=" '(s val))))) '(just-one-space)
2563 (p "<temp coef 1>: " tc1 'noinsert)
2564 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2565 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2566 '(just-one-space)
2567 (if (and (tempo-lookup-named 'tc2)
2568 (not (string-equal (tempo-lookup-named 'tc2) "")))
2569 (list 'l "TC2=" '(s tc2)))
2570 '(just-one-space)
2571 (p "<scale>: " scale 'noinsert)
2572 (if (string-equal (tempo-lookup-named 'scale) "")
2573 () (list 'l "SCALE=" '(s scale)))
2574 '(just-one-space)
2575 (p "<m>: " m 'noinsert)
2576 (if (string-equal (tempo-lookup-named 'm) "")
2577 () (list 'l "M=" '(s m)))
2578 '(just-one-space)
2579 (p "<ac resistance>: " ac 'noinsert)
2580 (if (string-equal (tempo-lookup-named 'ac) "")
2581 () (list 'l "AC=" '(s ac)))
2582 '(just-one-space)
2583 (p "<diff temp>: " dtemp 'noinsert)
2584 (if (string-equal (tempo-lookup-named 'dtemp) "")
2585 () (list 'l "DTEMP=" '(s dtemp)))
2586 '(just-one-space)
2587 (p "<length>: " l 'noinsert)
2588 (if (string-equal (tempo-lookup-named 'l) "")
2589 () (list 'l "L=" '(s l)))
2590 '(just-one-space)
2591 (p "<width>: " w 'noinsert)
2592 (if (string-equal (tempo-lookup-named 'w) "")
2593 () (list 'l "W=" '(s w)))
2594 '(just-one-space)
2595 (p "<cap>: " c 'noinsert)
2596 (if (string-equal (tempo-lookup-named 'c) "")
2597 () (list 'l "C=" '(s c)))
2598 '(just-one-space)
2600 ;; "hspice resistor"
2601 "RH"
2602 "template for hspice resistor tempo templates"
2603 'spice-tempo-tags)
2606 (tempo-define-template
2607 "spice-layla-resistor"
2608 '("R"
2609 (p "[name]: ") '(just-one-space)
2610 (p "[pos node]: ") '(just-one-space)
2611 (p "[neg node]: ") '(just-one-space)
2612 ; (p "<mname>: ") '(just-one-space)
2613 (p "[value]: ") '(just-one-space)
2614 (p "<width>: " w 'noinsert)
2615 (if (string-equal (tempo-lookup-named 'w) "")
2616 () (list 'l "width=" '(s w)))
2617 '(just-one-space)
2618 "\n+ type=\""
2619 (p "[type (no quotes)]: ") "\""
2620 '(just-one-space)
2621 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
2622 (if (string-equal (tempo-lookup-named 'symmetry) "")
2623 () (list 'l "symmetry=\"" '(s symmetry) "\""))
2624 '(just-one-space)
2625 (p "<matching (no quotes)>: " matching 'noinsert)
2626 (if (string-equal (tempo-lookup-named 'matching) "")
2627 () (list 'l "matching=\"" '(s matching) "\""))
2628 '(just-one-space)
2629 (p "<couple>: " couple 'noinsert)
2630 (if (string-equal (tempo-lookup-named 'couple) "")
2631 () (list 'l "couple=" '(s couple)))
2632 '(just-one-space)
2633 (p "<array (no quotes)>: " array 'noinsert)
2634 (if (string-equal (tempo-lookup-named 'array) "")
2635 () (list 'l "array=\"" '(s array) "\""))
2636 '(just-one-space)
2637 (p "<orientations (no quotes)>: " orientations 'noinsert)
2638 (if (string-equal (tempo-lookup-named 'orientations) "")
2639 () (list 'l "orientations=\"" '(s orientations) "\""))
2640 '(just-one-space)
2641 (p "<unit_value>: " unit_value 'noinsert)
2642 (if (string-equal (tempo-lookup-named 'unit_value) "")
2643 () (list 'l "unit_value=" '(s unit_value)))
2644 '(just-one-space)
2645 (p "<current>: " current 'noinsert)
2646 (if (string-equal (tempo-lookup-named 'current) "")
2647 () (list 'l "current=" '(s current)))
2648 '(just-one-space)
2649 (p "<power>: " power 'noinsert)
2650 (if (string-equal (tempo-lookup-named 'power) "")
2651 () (list 'l "power=" '(s power)))
2652 '(just-one-space)
2653 (p "<min_ar>: " min_ar 'noinsert)
2654 (if (string-equal (tempo-lookup-named 'min_ar) "")
2655 () (list 'l "min_ar=" '(s min_ar)))
2656 '(just-one-space)
2657 (p "<max_ar>: " max_ar 'noinsert)
2658 (if (string-equal (tempo-lookup-named 'max_ar) "")
2659 () (list 'l "max_ar=" '(s max_ar)))
2660 '(just-one-space)
2661 (p "<routing_space>: " routing_space 'noinsert)
2662 (if (string-equal (tempo-lookup-named 'routing_space) "")
2663 () (list 'l "routing_space=" '(s routing_space)))
2664 '(just-one-space)
2666 ;; "layla resistor"
2667 "RL"
2668 "tempo template for layla resistor"
2669 'spice-tempo-tags)
2672 ;; capacitors
2673 (tempo-define-template
2674 "spice-spice2g6-capacitor"
2675 '("C"
2676 (p "[name]: ") '(just-one-space)
2677 (p "[pos node]: ") '(just-one-space)
2678 (p "[neg node]: ") '(just-one-space)
2679 (p "[val]: ") '(just-one-space)
2680 (p "<initial cond (voltage)>: " ic 'noinsert)
2681 (if (string-equal (tempo-lookup-named 'ic) "")
2682 () (list 'l "ic=" '(s ic)))
2684 ;; "spice2g6 capacitor"
2686 "tempo template for spice2g6 capacitor"
2687 'spice-tempo-tags)
2690 (tempo-define-template
2691 "spice-spice3-semiconductor-capacitor"
2692 '("C"
2693 (p "[name]: ") '(just-one-space)
2694 (p "[pos node]: ") '(just-one-space)
2695 (p "[neg node]: ") '(just-one-space)
2696 (p "<value>: " value) '(just-one-space)
2697 (p "<mname>: " mname) '(just-one-space)
2698 (p "<length>: " l 'noinsert)
2699 (if (string-equal (tempo-lookup-named 'l) "")
2700 () (list 'l "L=" '(s l)))
2701 '(just-one-space)
2702 (p "<width>: " w 'noinsert)
2703 (if (string-equal (tempo-lookup-named 'w) "")
2704 () (list 'l "W=" '(s w)))
2705 '(just-one-space)
2706 (p "<initial conditions (Voltage)>: " ic 'noinsert)
2707 (if (string-equal (tempo-lookup-named 'ic) "")
2708 () (list 'l "IC=" '(s ic)))
2709 '(just-one-space)
2711 ;; "spice3 semiconductor capacitor"
2712 "CSS"
2713 "tempo template for spice3 semiconductor capacitor"
2714 'spice-tempo-tags)
2717 (tempo-define-template
2718 "spice-eldo-capacitor"
2719 '("C"
2720 (p "[name]: ") '(just-one-space)
2721 (p "[pos node]: ") '(just-one-space)
2722 (p "[neg node]: ") '(just-one-space)
2723 (p "<mname | POLY>: " mname) '(just-one-space)
2724 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2725 (list 'l '(p "[val and poly coefficients]: "))
2726 (list 'l '(p "[val]: ")))
2727 '(just-one-space)
2728 (p "<m>: " m 'noinsert)
2729 (if (string-equal (tempo-lookup-named 'm) "")
2730 () (list 'l "M=" '(s m)))
2731 '(just-one-space)
2732 (p "<length>: " l 'noinsert)
2733 (if (string-equal (tempo-lookup-named 'l) "")
2734 () (list 'l "L=" '(s l)))
2735 '(just-one-space)
2736 (p "<width>: " w 'noinsert)
2737 (if (string-equal (tempo-lookup-named 'w) "")
2738 () (list 'l "W=" '(s w)))
2739 '(just-one-space)
2740 (p "<diff temp>: " dtemp 'noinsert)
2741 (if (string-equal (tempo-lookup-named 'dtemp) "")
2742 () (list 'l "DTEMP=" '(s dtemp)))
2743 '(just-one-space)
2744 (p "<temp coef 1>: " tc1 'noinsert)
2745 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2746 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2747 '(just-one-space)
2748 (if (and (tempo-lookup-named 'tc2)
2749 (not (string-equal (tempo-lookup-named 'tc2) "")))
2750 (list 'l "TC2=" '(s tc2)))
2751 '(just-one-space)
2752 (p "<initial cond (voltage)>: " ic 'noinsert)
2753 (if (string-equal (tempo-lookup-named 'ic) "")
2754 () (list 'l "IC=" '(s ic)))
2756 ;; "eldo capacitor"
2757 "CE"
2758 "tempo template for eldo capacitor"
2759 'spice-tempo-tags)
2762 (tempo-define-template
2763 "spice-eldo-expression-capacitor"
2764 '("C"
2765 (p "[name]: ") '(just-one-space)
2766 (p "[pos node]: ") '(just-one-space)
2767 (p "[neg node]: ") '(just-one-space)
2768 (p "<temp coef 1>: " tc1 'noinsert)
2769 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2770 (list 'l "TC1=" '(s tc1)))
2771 '(just-one-space)
2772 (p "<temp coef 2>: " tc2 'noinsert)
2773 (if (string-equal (tempo-lookup-named 'tc2) "") ()
2774 (list 'l "TC2=" '(s tc2)))
2775 '(just-one-space)
2776 (p "<temp coef 3>: " tc3 'noinsert)
2777 (if (string-equal (tempo-lookup-named 'tc3) "") ()
2778 (list 'l "TC3=" '(s tc3)))
2779 '(just-one-space)
2780 "VALUE={"
2781 (p "[val enter expression without {}]: ")
2784 ;; "eldo expression capacitor"
2785 "CEE"
2786 "tempo template for eldo expression capacitor"
2787 'spice-tempo-tags)
2790 (tempo-define-template
2791 "spice-hspice-capacitor"
2792 '("C"
2793 (p "[name]: ") '(just-one-space)
2794 (p "[pos node]: ") '(just-one-space)
2795 (p "[neg node]: ") '(just-one-space)
2796 (p "<mname | POLY>: " mname) '(just-one-space)
2797 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2798 (list 'l '(p "[val and poly coefficients]: " val))
2799 (if (string-equal (tempo-lookup-named 'mname) "")
2800 (list 'l "C=" '(p "[val or expression]: " val))
2801 (list 'l "C=" '(p "[val]: " val))))
2802 '(just-one-space)
2803 (if (and (not (string-equal (tempo-lookup-named 'mname) "POLY"))
2804 (char-equal (string-to-char (tempo-lookup-named 'val))
2805 (string-to-char "'")))
2806 (list 'l '(p "<ctype>: " ctype 'noinsert)))
2807 (if (and (tempo-lookup-named 'ctype)
2808 (not (string-equal (tempo-lookup-named 'ctype) "")))
2809 (list 'l "CTYPE=" '(s ctype)))
2810 '(just-one-space)
2811 (p "<temp coef 1>: " tc1 'noinsert)
2812 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2813 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2814 '(just-one-space)
2815 (if (and (tempo-lookup-named 'tc2)
2816 (not (string-equal (tempo-lookup-named 'tc2) "")))
2817 (list 'l "TC2=" '(s tc2)))
2818 '(just-one-space)
2819 (p "<scale>: " scale 'noinsert)
2820 (if (string-equal (tempo-lookup-named 'scale) "")
2821 () (list 'l "SCALE=" '(s scale)))
2822 '(just-one-space)
2823 (p "<initial cond (voltage)>: " ic 'noinsert)
2824 (if (string-equal (tempo-lookup-named 'ic) "")
2825 () (list 'l "IC=" '(s ic)))
2826 '(just-one-space)
2827 (p "<m>: " m 'noinsert)
2828 (if (string-equal (tempo-lookup-named 'm) "")
2829 () (list 'l "M=" '(s m)))
2830 '(just-one-space)
2831 (p "<width>: " w 'noinsert)
2832 (if (string-equal (tempo-lookup-named 'w) "")
2833 () (list 'l "W=" '(s w)))
2834 '(just-one-space)
2835 (p "<length>: " l 'noinsert)
2836 (if (string-equal (tempo-lookup-named 'l) "")
2837 () (list 'l "L=" '(s l)))
2838 '(just-one-space)
2839 (p "<diff temp>: " dtemp 'noinsert)
2840 (if (string-equal (tempo-lookup-named 'dtemp) "")
2841 () (list 'l "DTEMP=" '(s dtemp)))
2842 '(just-one-space)
2844 ;; "hspice capacitor"
2845 "CH"
2846 "tempo template for hspice capacitor"
2847 'spice-tempo-tags)
2850 (tempo-define-template
2851 "spice-layla-capacitor"
2852 '("C"
2853 (p "[name]: ") '(just-one-space)
2854 (p "[pos node]: ") '(just-one-space)
2855 (p "[neg node]: ") '(just-one-space)
2856 (p "[value]: ") '(just-one-space)
2857 (p "<units_ver>: " units_ver 'noinsert)
2858 (if (string-equal (tempo-lookup-named 'units_ver) "")
2859 () (list 'l "units_ver=" '(s units_ver)))
2860 '(just-one-space)
2861 (p "<units_hor>: " units_hor 'noinsert)
2862 (if (string-equal (tempo-lookup-named 'units_hor) "")
2863 () (list 'l "units_hor=" '(s units_hor)))
2864 '(just-one-space)
2865 "\n+ type=\""
2866 (p "[type (no quotes)]: ") "\""
2867 '(just-one-space)
2868 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
2869 (if (string-equal (tempo-lookup-named 'symmetry) "")
2870 () (list 'l "symmetry=\"" '(s symmetry) "\""))
2871 '(just-one-space)
2872 (p "<matching (no quotes)>: " matching 'noinsert)
2873 (if (string-equal (tempo-lookup-named 'matching) "")
2874 () (list 'l "matching=\"" '(s matching) "\""))
2875 '(just-one-space)
2876 (p "<couple>: " couple 'noinsert)
2877 (if (string-equal (tempo-lookup-named 'couple) "")
2878 () (list 'l "couple=" '(s couple)))
2879 '(just-one-space)
2880 (p "<array (no quotes)>: " array 'noinsert)
2881 (if (string-equal (tempo-lookup-named 'array) "")
2882 () (list 'l "array=\"" '(s array) "\""))
2883 '(just-one-space)
2884 (p "<orientations (no quotes)>: " orientations 'noinsert)
2885 (if (string-equal (tempo-lookup-named 'orientations) "")
2886 () (list 'l "orientations=\"" '(s orientations) "\""))
2887 '(just-one-space)
2888 (p "<unit_value>: " unit_value 'noinsert)
2889 (if (string-equal (tempo-lookup-named 'unit_value) "")
2890 () (list 'l "unit_value=" '(s unit_value)))
2891 '(just-one-space)
2892 (p "<power>: " power 'noinsert)
2893 (if (string-equal (tempo-lookup-named 'power) "")
2894 () (list 'l "power=" '(s power)))
2895 '(just-one-space)
2896 (p "<min_ar>: " min_ar 'noinsert)
2897 (if (string-equal (tempo-lookup-named 'min_ar) "")
2898 () (list 'l "min_ar=" '(s min_ar)))
2899 '(just-one-space)
2900 (p "<max_ar>: " max_ar 'noinsert)
2901 (if (string-equal (tempo-lookup-named 'max_ar) "")
2902 () (list 'l "max_ar=" '(s max_ar)))
2903 '(just-one-space)
2904 (p "<routing_space>: " routing_space 'noinsert)
2905 (if (string-equal (tempo-lookup-named 'routing_space) "")
2906 () (list 'l "routing_space=" '(s routing_space)))
2907 '(just-one-space)
2909 ;; "layla capacitor"
2910 "CL"
2911 "tempo template for layla capacitor"
2912 'spice-tempo-tags)
2915 ;; inductors
2916 (tempo-define-template
2917 "spice-spice2g6-inductor"
2918 '("L"
2919 (p "[name]: ") '(just-one-space)
2920 (p "[pos node]: ") '(just-one-space)
2921 (p "[neg node]: ") '(just-one-space)
2922 (p "[val]: ") '(just-one-space)
2923 (p "<initial cond (current)>: " ic 'noinsert)
2924 (if (string-equal (tempo-lookup-named 'ic) "")
2925 () (list 'l "ic=" '(s ic)))
2927 ;; "spice2g6 inductor"
2929 "tempo template for spice2g6 inductor"
2930 'spice-tempo-tags)
2933 (tempo-define-template
2934 "spice-eldo-inductor"
2935 '("L"
2936 (p "[name]: ") '(just-one-space)
2937 (p "[pos node]: ") '(just-one-space)
2938 (p "[neg node]: ") '(just-one-space)
2939 (p "<mname | POLY>: " mname) '(just-one-space)
2940 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2941 (list 'l '(p "[val and poly coefficients]: "))
2942 (list 'l '(p "[val]: ")))
2943 '(just-one-space)
2944 (p "<initial cond (current)>: " ic 'noinsert)
2945 (if (string-equal (tempo-lookup-named 'ic) "")
2946 () (list 'l "ic=" '(s ic)))
2948 ;; "eldo inductor"
2949 "LE"
2950 "tempo template for eldo inductor"
2951 'spice-tempo-tags)
2954 (tempo-define-template
2955 "spice-eldo-expression-inductor"
2956 '("L"
2957 (p "[name]: ") '(just-one-space)
2958 (p "[pos node]: ") '(just-one-space)
2959 (p "[neg node]: ") '(just-one-space)
2960 "VALUE={"
2961 (p "[val enter expression without {}]: ")
2964 ;; "eldo expression inductor"
2965 "LEE"
2966 "tempo template for eldo expression inductor"
2967 'spice-tempo-tags)
2970 (tempo-define-template
2971 "spice-hspice-inductor"
2972 '("L"
2973 (p "[name]: ") '(just-one-space)
2974 (p "[pos node]: ") '(just-one-space)
2975 (p "[neg node]: ") '(just-one-space)
2976 (p "<POLY | NT>: " poly 'noinsert) '(just-one-space)
2977 (cond ((string-equal (tempo-lookup-named 'poly) "POLY")
2978 (list 'l "POLY " '(p "[value and coefficients]: ")))
2979 ((string-equal (tempo-lookup-named 'poly) "NT")
2980 (list 'l "NT=" '(p "[number of turns]: " nt)))
2982 (list 'l "L=" '(p "[value or expression]: " val)))
2984 '(just-one-space)
2985 (if (and (tempo-lookup-named 'val)
2986 (char-equal (string-to-char (tempo-lookup-named 'val))
2987 (string-to-char "'")))
2988 (list 'l '(p "<ltype>: " ltype 'noinsert)))
2989 (if (and (tempo-lookup-named 'ltype)
2990 (not (string-equal (tempo-lookup-named 'ltype) "")))
2991 (list 'l "LTYPE=" '(s ltype)))
2992 '(just-one-space)
2993 (p "<temp coef 1>: " tc1 'noinsert)
2994 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2995 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2996 '(just-one-space)
2997 (if (and (tempo-lookup-named 'tc2)
2998 (not (string-equal (tempo-lookup-named 'tc2) "")))
2999 (list 'l "TC2=" '(s tc2)))
3000 '(just-one-space)
3001 (p "<scale>: " scale 'noinsert)
3002 (if (string-equal (tempo-lookup-named 'scale) "")
3003 () (list 'l "SCALE=" '(s scale)))
3004 '(just-one-space)
3005 (p "<initial cond (current)>: " ic 'noinsert)
3006 (if (string-equal (tempo-lookup-named 'ic) "")
3007 () (list 'l "IC=" '(s ic)))
3008 '(just-one-space)
3009 (p "<m>: " m 'noinsert)
3010 (if (string-equal (tempo-lookup-named 'm) "")
3011 () (list 'l "M=" '(s m)))
3012 '(just-one-space)
3013 (p "<diff temp>: " dtemp 'noinsert)
3014 (if (string-equal (tempo-lookup-named 'dtemp) "")
3015 () (list 'l "DTEMP=" '(s dtemp)))
3016 '(just-one-space)
3017 (p "<res>: " r 'noinsert)
3018 (if (string-equal (tempo-lookup-named 'r) "")
3019 () (list 'l "R=" '(s r)))
3020 '(just-one-space)
3022 ;; "hspice inductor"
3023 "LH"
3024 "tempo template for hspice inductor"
3025 'spice-tempo-tags)
3028 (tempo-define-template
3029 "spice-layla-inductor"
3030 '("L"
3031 (p "[name]: ") '(just-one-space)
3032 (p "[pos node]: ") '(just-one-space)
3033 (p "[neg node]: ") '(just-one-space)
3034 (p "<value>: ") '(just-one-space)
3035 (p "<outer radius>: " radius 'noinsert)
3036 (if (string-equal (tempo-lookup-named 'radius) "")
3037 () (list 'l "radius=" '(s radius)))
3038 '(just-one-space)
3039 (p "<width>: " w 'noinsert)
3040 (if (string-equal (tempo-lookup-named 'w) "")
3041 () (list 'l "w=" '(s w)))
3042 '(just-one-space)
3043 (p "<number of turns>: " n 'noinsert)
3044 (if (string-equal (tempo-lookup-named 'n) "")
3045 () (list 'l "n=" '(s n)))
3046 '(just-one-space)
3047 (p "<space>: " space 'noinsert)
3048 (if (string-equal (tempo-lookup-named 'space) "")
3049 () (list 'l "space=" '(s space)))
3050 '(just-one-space)
3051 (p "<end_fraction [0-1]>: " end_fraction 'noinsert)
3052 (if (string-equal (tempo-lookup-named 'end_fraction) "")
3053 () (list 'l "end_fraction=" '(s end_fraction)))
3054 '(just-one-space)
3055 "\n+ type=\""
3056 (p "[type (no quotes)]: ") "\""
3057 '(just-one-space)
3058 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
3059 (if (string-equal (tempo-lookup-named 'symmetry) "")
3060 () (list 'l "symmetry=\"" '(s symmetry) "\""))
3061 '(just-one-space)
3062 (p "<matching (no quotes)>: " matching 'noinsert)
3063 (if (string-equal (tempo-lookup-named 'matching) "")
3064 () (list 'l "matching=\"" '(s matching) "\""))
3065 '(just-one-space)
3066 (p "<couple>: " couple 'noinsert)
3067 (if (string-equal (tempo-lookup-named 'couple) "")
3068 () (list 'l "couple=" '(s couple)))
3069 '(just-one-space)
3070 (p "<array (no quotes)>: " array 'noinsert)
3071 (if (string-equal (tempo-lookup-named 'array) "")
3072 () (list 'l "array=\"" '(s array) "\""))
3073 '(just-one-space)
3074 (p "<orientations (no quotes)>: " orientations 'noinsert)
3075 (if (string-equal (tempo-lookup-named 'orientations) "")
3076 () (list 'l "orientations=\"" '(s orientations) "\""))
3077 '(just-one-space)
3078 (p "<power>: " power 'noinsert)
3079 (if (string-equal (tempo-lookup-named 'power) "")
3080 () (list 'l "power=" '(s power)))
3081 '(just-one-space)
3082 (p "<min_ar>: " min_ar 'noinsert)
3083 (if (string-equal (tempo-lookup-named 'min_ar) "")
3084 () (list 'l "min_ar=" '(s min_ar)))
3085 '(just-one-space)
3086 (p "<max_ar>: " max_ar 'noinsert)
3087 (if (string-equal (tempo-lookup-named 'max_ar) "")
3088 () (list 'l "max_ar=" '(s max_ar)))
3089 '(just-one-space)
3090 (p "<routing_space>: " routing_space 'noinsert)
3091 (if (string-equal (tempo-lookup-named 'routing_space) "")
3092 () (list 'l "routing_space=" '(s routing_space)))
3093 '(just-one-space)
3095 ;; "layla inductor"
3096 "LL"
3097 "tempo template for layla inductor"
3098 'spice-tempo-tags)
3101 ;; coupled inductors
3102 (tempo-define-template
3103 "spice-spice2g6-coupled-inductors"
3104 '("K"
3105 (p "[name]: ") '(just-one-space)
3106 (p "[first inductor]: ") '(just-one-space)
3107 (p "[second inductor]: ") '(just-one-space)
3108 (p "[coupling coefficient]: ")
3110 ;; "spice2g6 inductor coupling"
3112 "tempo template for spice2g6 coupled inductors"
3113 'spice-tempo-tags)
3116 ;; lossless transmission lines
3117 (tempo-define-template
3118 "spice-spice2g6-lossless-transmission"
3119 '("T"
3120 (p "[name]: ") '(just-one-space)
3121 (p "[out port1]: ") '(just-one-space)
3122 (p "[ref port1]: ") '(just-one-space)
3123 (p "[out port2]: ") '(just-one-space)
3124 (p "[ref port2]: ") '(just-one-space)
3125 "Z0=" (p "[char impedance]: ") '(just-one-space)
3126 (p "<time delay in seconds>: " td 'noinsert)
3127 (if (string-equal (tempo-lookup-named 'td) "")
3128 (list 'l '(p "<freq>: " freq 'noinsert)) (list 'l "td=" '(s td)))
3129 '(just-one-space)
3130 (if (and (tempo-lookup-named 'freq)
3131 (not (string-equal (tempo-lookup-named 'freq) "")))
3132 (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
3133 '(just-one-space)
3134 (if (and (tempo-lookup-named 'nrmlen)
3135 (not (string-equal (tempo-lookup-named 'nrmlen) "")))
3136 (list 'l "nl=" '(s nrmlen)))
3137 '(just-one-space)
3138 (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
3139 (if (string-equal (tempo-lookup-named 'ic) "")
3140 () (list 'l "ic=" '(s ic)))
3142 ;;"spice2g6 lossless transmission line"
3144 "tempo template for spice2g6 lossless transmission line"
3145 'spice-tempo-tags)
3148 (tempo-define-template
3149 "spice-hspice-lossless-transmission"
3150 '("T"
3151 (p "[name]: ") '(just-one-space)
3152 (p "[out port1]: ") '(just-one-space)
3153 (p "[ref port1]: ") '(just-one-space)
3154 (p "[out port2]: ") '(just-one-space)
3155 (p "[ref port2]: ") '(just-one-space)
3156 "Z0=" (p "[char impedance]: ") '(just-one-space)
3157 (p "<time delay in seconds per meter>: " td 'noinsert)
3158 (if (string-equal (tempo-lookup-named 'td) "")
3159 (list 'l '(p "<freq>: " freq 'noinsert))
3160 (list 'l "td=" '(s td) '(p "<length [1m]>: " l 'noinsert)))
3161 '(just-one-space)
3162 (if (and (tempo-lookup-named 'l)
3163 (not (string-equal (tempo-lookup-named 'l) "")))
3164 (list 'l "l=" '(s l)))
3165 '(just-one-space)
3166 (if (and (tempo-lookup-named 'freq)
3167 (not (string-equal (tempo-lookup-named 'freq) "")))
3168 (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
3169 '(just-one-space)
3170 (if (and (tempo-lookup-named 'nrmlen)
3171 (not (string-equal (tempo-lookup-named 'nrmlen) "")))
3172 (list 'l "nl=" '(s nrmlen)))
3173 '(just-one-space)
3174 (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
3175 (if (string-equal (tempo-lookup-named 'ic) "")
3176 () (list 'l "ic=" '(s ic)))
3178 ;;"hspice lossless transmission line"
3179 "TH"
3180 "tempo template for hspice lossless transmission line"
3181 'spice-tempo-tags)
3184 ;; lossy transmission lines
3185 (tempo-define-template
3186 "spice-spice2g6-lossy-transmission"
3187 '("O"
3188 (p "[name]: ") '(just-one-space)
3189 (p "[out port1]: ") '(just-one-space)
3190 (p "[ref port1]: ") '(just-one-space)
3191 (p "[out port2]: ") '(just-one-space)
3192 (p "[ref port2]: ") '(just-one-space)
3193 (p "[mname]: ") '(just-one-space)
3195 ;;"spice2g6 lossy transmission line"
3197 "tempo template for spice2g6 lossy transmission line"
3198 'spice-tempo-tags)
3201 (tempo-define-template
3202 "spice-spice3-rcline"
3203 '("U"
3204 (p "[name]: ") '(just-one-space)
3205 (p "[in port]: ") '(just-one-space)
3206 (p "[out port]: ") '(just-one-space)
3207 (p "[ref port]: ") '(just-one-space)
3208 (p "[mname]: ") '(just-one-space)
3209 "L="
3210 (p "[length (m)]: ") '(just-one-space)
3211 (p "<lumps>: " lumps 'noinsert)
3212 (if (string-equal (tempo-lookup-named 'lumps) "")
3213 () (list 'l "N=" '(s lumps)))
3214 '(just-one-space)
3216 ;;"spice3 lossy transmission line"
3217 "RCLS"
3218 "tempo template for spice2g6 lossy transmission line"
3219 'spice-tempo-tags)
3222 (tempo-define-template
3223 "spice-eldo-rcline"
3224 '("R"
3225 (p "[name]: ") '(just-one-space)
3226 (p "[pos node]: ") '(just-one-space)
3227 (p "[neg node]: ") '(just-one-space)
3228 (p "[mname]: " mname) '(just-one-space)
3229 (p "<res>: " r 'noinsert)
3230 (if (string-equal (tempo-lookup-named 'r) "")
3231 () (list 'l "R=" '(s r)))
3232 '(just-one-space)
3233 (p "<temp coef 1>: " tc1 'noinsert)
3234 (if (string-equal (tempo-lookup-named 'tc1) "") ()
3235 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
3236 '(just-one-space)
3237 (if (and (tempo-lookup-named 'tc2)
3238 (not (string-equal (tempo-lookup-named 'tc2) "")))
3239 (list 'l "TC2=" '(s tc2)))
3240 '(just-one-space)
3241 (p "<cap>: " c 'noinsert)
3242 (if (string-equal (tempo-lookup-named 'c) "")
3243 () (list 'l "C=" '(s c)))
3244 '(just-one-space)
3245 (p "<length>: " l 'noinsert)
3246 (if (string-equal (tempo-lookup-named 'l) "")
3247 () (list 'l "L=" '(s l)))
3248 '(just-one-space)
3249 (p "<width>: " w 'noinsert)
3250 (if (string-equal (tempo-lookup-named 'w) "")
3251 () (list 'l "W=" '(s w)))
3252 '(just-one-space)
3253 (p "<m>: " m 'noinsert)
3254 (if (string-equal (tempo-lookup-named 'm) "")
3255 () (list 'l "M=" '(s m)))
3256 '(just-one-space)
3257 (p "<diff temp>: " dtemp 'noinsert)
3258 (if (string-equal (tempo-lookup-named 'dtemp) "")
3259 () (list 'l "DTEMP=" '(s dtemp)))
3260 '(just-one-space)
3261 (p "<scale>: " scale 'noinsert)
3262 (if (string-equal (tempo-lookup-named 'scale) "")
3263 () (list 'l "SCALE=" '(s scale)))
3264 '(just-one-space)
3266 ;;"eldo rcline"
3267 "RCLE"
3268 "tempo template for eldo rcline"
3269 'spice-tempo-tags)
3272 ;; active elements
3274 ;; diodes
3275 (tempo-define-template
3276 "spice-spice2g6-diode"
3277 '("D"
3278 (p "[name]: ") '(just-one-space)
3279 (p "[positive node]: ") '(just-one-space)
3280 (p "[negative node]: ") '(just-one-space)
3281 (p "[mname]: ") '(just-one-space)
3282 (p "<area>: ") '(just-one-space)
3283 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3284 (if (and (tempo-lookup-named 'off)
3285 (string-equal (tempo-lookup-named 'off) "y"))
3286 (list 'l "OFF"))
3287 '(just-one-space)
3288 (p "<initial cond (diode voltage)>: " ic 'noinsert)
3289 (if (string-equal (tempo-lookup-named 'ic) "")
3290 () (list 'l "IC=" '(s ic)))
3291 '(just-one-space)
3292 (p "<temp>: " temp 'noinsert)
3293 (if (string-equal (tempo-lookup-named 'temp) "")
3294 () (list 'l "TEMP=" '(s temp)))
3295 '(just-one-space)
3297 ;;"spice2g6 diode"
3299 "tempo template for spice2g6 diode"
3300 'spice-tempo-tags)
3303 (tempo-define-template
3304 "spice-eldo-diode"
3305 '("D"
3306 (p "[name]: ") '(just-one-space)
3307 (p "[positive node]: ") '(just-one-space)
3308 (p "[negative node]: ") '(just-one-space)
3309 (p "[mname]: ") '(just-one-space)
3310 (p "<area>: " area 'noinsert) '(just-one-space)
3311 (if (string-equal (tempo-lookup-named 'area) "")
3312 () (list 'l "AREA=" '(s area)))
3313 '(just-one-space)
3314 (p "<perimeter>: " peri 'noinsert)
3315 (if (string-equal (tempo-lookup-named 'peri) "")
3316 () (list 'l "PERI=" '(s peri)))
3317 '(just-one-space)
3318 (p "<temp>: " temp 'noinsert)
3319 (if (string-equal (tempo-lookup-named 'temp) "")
3320 () (list 'l "TEMP=" '(s temp)))
3321 '(just-one-space)
3322 (p "<off [y/n]>: " off 'noinsert)
3323 (if (and (tempo-lookup-named 'off)
3324 (string-equal (tempo-lookup-named 'off) "y"))
3325 (list 'l "OFF"))
3326 '(just-one-space)
3327 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3328 (if (and (tempo-lookup-named 'nonoise)
3329 (string-equal (tempo-lookup-named 'nonoise) "y"))
3330 (list 'l "NONOISE"))
3331 '(just-one-space)
3333 ;;"eldo diode"
3334 "DE"
3335 "tempo template for eldo diode"
3336 'spice-tempo-tags)
3339 (tempo-define-template
3340 "spice-hspice-diode"
3341 '("D"
3342 (p "[name]: ") '(just-one-space)
3343 (p "[positive node]: ") '(just-one-space)
3344 (p "[negative node]: ") '(just-one-space)
3345 (p "[mname]: ") '(just-one-space)
3346 (p "<area>: " area 'noinsert) '(just-one-space)
3347 (if (string-equal (tempo-lookup-named 'area) "")
3348 (list 'l '(p "<width>: " w 'noinsert))
3349 (list 'l "AREA=" '(s area) '(p "<perimeter>: " peri 'noinsert)))
3350 '(just-one-space)
3351 (if (and (tempo-lookup-named 'peri)
3352 (not (string-equal (tempo-lookup-named 'peri) "")))
3353 (list 'l "PJ=" '(s peri)))
3354 '(just-one-space)
3355 (if (string-equal (tempo-lookup-named 'area) "")
3356 (list 'l '(p "<length>: " l 'noinsert)))
3357 '(just-one-space)
3358 (if (and (tempo-lookup-named 'l)
3359 (not (string-equal (tempo-lookup-named 'l) "")))
3360 () (list 'l "L=" '(s l)))
3361 '(just-one-space)
3362 (p "<width poly cap>: " wp 'noinsert)
3363 (if (string-equal (tempo-lookup-named 'wp) "")
3364 () (list 'l "WP=" '(s wp)))
3365 '(just-one-space)
3366 (p "<length poly cap>: " lp 'noinsert)
3367 (if (string-equal (tempo-lookup-named 'lp) "")
3368 () (list 'l "LP=" '(s lp)))
3369 '(just-one-space)
3370 (p "<width metal cap>: " wm 'noinsert)
3371 (if (string-equal (tempo-lookup-named 'wm) "")
3372 () (list 'l "WM=" '(s wm)))
3373 '(just-one-space)
3374 (p "<length metal cap>: " lm 'noinsert)
3375 (if (string-equal (tempo-lookup-named 'lm) "")
3376 () (list 'l "LM=" '(s lm)))
3377 '(just-one-space)
3378 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3379 (if (and (tempo-lookup-named 'off)
3380 (string-equal (tempo-lookup-named 'off) "y"))
3381 (list 'l "OFF"))
3382 '(just-one-space)
3383 (p "<initial cond (voltage)>: " ic 'noinsert)
3384 (if (string-equal (tempo-lookup-named 'ic) "")
3385 () (list 'l "IC=" '(s ic)))
3386 '(just-one-space)
3387 (p "<m>: " m 'noinsert)
3388 (if (string-equal (tempo-lookup-named 'm) "")
3389 () (list 'l "M=" '(s m)))
3390 '(just-one-space)
3391 (p "<diff temp>: " dtemp 'noinsert)
3392 (if (string-equal (tempo-lookup-named 'dtemp) "")
3393 () (list 'l "DTEMP=" '(s dtemp)))
3394 '(just-one-space)
3396 ;;"hspice diode"
3397 "DH"
3398 "tempo template for hspice diode"
3399 'spice-tempo-tags)
3402 (tempo-define-template
3403 "spice-layla-diode"
3404 '("D"
3405 (p "[name]: ") '(just-one-space)
3406 (p "[positive node]: ") '(just-one-space)
3407 (p "[negative node]: ") '(just-one-space)
3408 ; (p "<mname>: ") '(just-one-space)
3409 (p "[area]: ") '(just-one-space)
3410 (p "<units_ver>: " units_ver 'noinsert)
3411 (if (string-equal (tempo-lookup-named 'units_ver) "")
3412 () (list 'l "units_ver=" '(s units_ver)))
3413 '(just-one-space)
3414 (p "<units_hor>: " units_hor 'noinsert)
3415 (if (string-equal (tempo-lookup-named 'units_hor) "")
3416 () (list 'l "units_hor=" '(s units_hor)))
3417 '(just-one-space)
3418 "\n+ type=\""
3419 (p "[type (no quotes)]: ") "\""
3420 '(just-one-space)
3421 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
3422 (if (string-equal (tempo-lookup-named 'symmetry) "")
3423 () (list 'l "symmetry=\"" '(s symmetry) "\""))
3424 '(just-one-space)
3425 (p "<matching (no quotes)>: " matching 'noinsert)
3426 (if (string-equal (tempo-lookup-named 'matching) "")
3427 () (list 'l "matching=\"" '(s matching) "\""))
3428 '(just-one-space)
3429 (p "<couple>: " couple 'noinsert)
3430 (if (string-equal (tempo-lookup-named 'couple) "")
3431 () (list 'l "couple=" '(s couple)))
3432 '(just-one-space)
3433 (p "<array (no quotes)>: " array 'noinsert)
3434 (if (string-equal (tempo-lookup-named 'array) "")
3435 () (list 'l "array=\"" '(s array) "\""))
3436 '(just-one-space)
3437 (p "<orientations (no quotes)>: " orientations 'noinsert)
3438 (if (string-equal (tempo-lookup-named 'orientations) "")
3439 () (list 'l "orientations=\"" '(s orientations) "\""))
3440 '(just-one-space)
3441 (p "<unit_value>: " unit_value 'noinsert)
3442 (if (string-equal (tempo-lookup-named 'unit_value) "")
3443 () (list 'l "unit_value=" '(s unit_value)))
3444 '(just-one-space)
3445 (p "<current>: " current 'noinsert)
3446 (if (string-equal (tempo-lookup-named 'current) "")
3447 () (list 'l "current=" '(s current)))
3448 '(just-one-space)
3449 (p "<power>: " power 'noinsert)
3450 (if (string-equal (tempo-lookup-named 'power) "")
3451 () (list 'l "power=" '(s power)))
3452 '(just-one-space)
3453 (p "<min_ar>: " min_ar 'noinsert)
3454 (if (string-equal (tempo-lookup-named 'min_ar) "")
3455 () (list 'l "min_ar=" '(s min_ar)))
3456 '(just-one-space)
3457 (p "<max_ar>: " max_ar 'noinsert)
3458 (if (string-equal (tempo-lookup-named 'max_ar) "")
3459 () (list 'l "max_ar=" '(s max_ar)))
3460 '(just-one-space)
3461 (p "<routing_space>: " routing_space 'noinsert)
3462 (if (string-equal (tempo-lookup-named 'routing_space) "")
3463 () (list 'l "routing_space=" '(s routing_space)))
3464 '(just-one-space)
3466 ;;"layla diode"
3467 "DL"
3468 "tempo template for layla diode"
3469 'spice-tempo-tags)
3472 ;; bipolars
3473 (tempo-define-template
3474 "spice-spice2g6-bipolar"
3475 '("Q"
3476 (p "[name]: ") '(just-one-space)
3477 (p "[collector node]: ") '(just-one-space)
3478 (p "[base node]: ") '(just-one-space)
3479 (p "[emitter node]: ") '(just-one-space)
3480 (p "<substrate node>: ") '(just-one-space)
3481 (p "[mname]: ") '(just-one-space)
3482 (p "<area>: ") '(just-one-space)
3483 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3484 (if (and (tempo-lookup-named 'off)
3485 (string-equal (tempo-lookup-named 'off) "y"))
3486 (list 'l "OFF"))
3487 '(just-one-space)
3488 (p "<initial cond (vbe, vce)>: " ic 'noinsert)
3489 (if (string-equal (tempo-lookup-named 'ic) "")
3490 () (list 'l "IC=" '(s ic)))
3491 '(just-one-space)
3492 (p "<temp>: " temp 'noinsert)
3493 (if (string-equal (tempo-lookup-named 'temp) "")
3494 () (list 'l "TEMP=" '(s temp)))
3495 '(just-one-space)
3497 ;;"spice2g6 bipolar"
3499 "tempo template for spice2g6 bipolar"
3500 'spice-tempo-tags)
3503 (tempo-define-template
3504 "spice-eldo-bipolar"
3505 '("Q"
3506 (p "[name]: ") '(just-one-space)
3507 (p "[collector node]: ") '(just-one-space)
3508 (p "[base node]: ") '(just-one-space)
3509 (p "[emitter node]: ") '(just-one-space)
3510 (p "<substrate node>: ") '(just-one-space)
3511 (p "[mname]: ") '(just-one-space)
3512 (p "<area>: " area 'noinsert) '(just-one-space)
3513 (if (string-equal (tempo-lookup-named 'area) "")
3514 () (list 'l "AREA=" '(s area)))
3515 '(just-one-space)
3516 (p "<rel base area>: " areab 'noinsert)
3517 (if (string-equal (tempo-lookup-named 'areab) "")
3518 () (list 'l "AREAB=" '(s areab)))
3519 '(just-one-space)
3520 (p "<rel collector area>: " areac 'noinsert)
3521 (if (string-equal (tempo-lookup-named 'areac) "")
3522 () (list 'l "AREAC=" '(s areac)))
3523 '(just-one-space)
3524 (p "<temp>: " temp 'noinsert)
3525 (if (string-equal (tempo-lookup-named 'temp) "")
3526 () (list 'l "T=" '(s temp)))
3527 '(just-one-space)
3528 (p "<m>: " m 'noinsert)
3529 (if (string-equal (tempo-lookup-named 'm) "")
3530 () (list 'l "M=" '(s m)))
3531 '(just-one-space)
3532 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3533 (if (and (tempo-lookup-named 'off)
3534 (string-equal (tempo-lookup-named 'off) "y"))
3535 (list 'l "OFF"))
3536 '(just-one-space)
3537 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3538 (if (and (tempo-lookup-named 'nonoise)
3539 (string-equal (tempo-lookup-named 'nonoise) "y"))
3540 (list 'l "NONOISE"))
3541 '(just-one-space)
3543 ;;"eldo bipolar"
3544 "QE"
3545 "tempo template for eldo bipolar"
3546 'spice-tempo-tags)
3549 (tempo-define-template
3550 "spice-hspice-bipolar"
3551 '("Q"
3552 (p "[name]: ") '(just-one-space)
3553 (p "[collector node]: ") '(just-one-space)
3554 (p "[base node]: ") '(just-one-space)
3555 (p "[emitter node]: ") '(just-one-space)
3556 (p "<substrate node>: ") '(just-one-space)
3557 (p "[mname]: ") '(just-one-space)
3558 (p "<area>: " area 'noinsert) '(just-one-space)
3559 (if (string-equal (tempo-lookup-named 'area) "")
3560 () (list 'l "AREA=" '(s area)))
3561 '(just-one-space)
3562 (p "<rel base area>: " areab 'noinsert)
3563 (if (string-equal (tempo-lookup-named 'areab) "")
3564 () (list 'l "AREAB=" '(s areab)))
3565 '(just-one-space)
3566 (p "<rel collector area>: " areac 'noinsert)
3567 (if (string-equal (tempo-lookup-named 'areac) "")
3568 () (list 'l "AREAC=" '(s areac)))
3569 '(just-one-space)
3570 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3571 (if (and (tempo-lookup-named 'off)
3572 (string-equal (tempo-lookup-named 'off) "y"))
3573 (list 'l "OFF"))
3574 '(just-one-space)
3575 (p "<init vbe>: " vbe 'noinsert)
3576 (if (string-equal (tempo-lookup-named 'vbe) "")
3577 () (list 'l "VBE=" '(s vbe)))
3578 '(just-one-space)
3579 (p "<init vce>: " vce 'noinsert)
3580 (if (string-equal (tempo-lookup-named 'vce) "")
3581 () (list 'l "VCE=" '(s vce)))
3582 '(just-one-space)
3583 (p "<m>: " m 'noinsert)
3584 (if (string-equal (tempo-lookup-named 'm) "")
3585 () (list 'l "M=" '(s m)))
3586 '(just-one-space)
3587 (p "<diff temp>: " dtemp 'noinsert)
3588 (if (string-equal (tempo-lookup-named 'dtemp) "")
3589 () (list 'l "DTEMP=" '(s dtemp)))
3590 '(just-one-space)
3592 ;;"hspice bipolar"
3593 "QH"
3594 "tempo template for hspice bipolar"
3595 'spice-tempo-tags)
3598 ;; jfets
3599 (tempo-define-template
3600 "spice-spice2g6-jfet"
3601 '("J"
3602 (p "[name]: ") '(just-one-space)
3603 (p "[drain node]: ") '(just-one-space)
3604 (p "[gate node]: ") '(just-one-space)
3605 (p "[source node]: ") '(just-one-space)
3606 (p "[mname]: ") '(just-one-space)
3607 (p "<area>: ") '(just-one-space)
3608 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3609 (if (and (tempo-lookup-named 'off)
3610 (string-equal (tempo-lookup-named 'off) "y"))
3611 (list 'l "OFF"))
3612 '(just-one-space)
3613 (p "<initial cond (vds, vgs)>: " ic 'noinsert)
3614 (if (string-equal (tempo-lookup-named 'ic) "")
3615 () (list 'l "IC=" '(s ic)))
3616 '(just-one-space)
3617 (p "<temp>: " temp 'noinsert)
3618 (if (string-equal (tempo-lookup-named 'temp) "")
3619 () (list 'l "TEMP=" '(s temp)))
3620 '(just-one-space)
3622 ;;"spice2g6 jfet"
3624 "tempo template for spice2g6 jfet"
3625 'spice-tempo-tags)
3628 (tempo-define-template
3629 "spice-eldo-jfet"
3630 '("J"
3631 (p "[name]: ") '(just-one-space)
3632 (p "[drain node]: ") '(just-one-space)
3633 (p "[gate node]: ") '(just-one-space)
3634 (p "[source node]: ") '(just-one-space)
3635 (p "[mname]: ") '(just-one-space)
3636 (p "<area>: " area 'noinsert) '(just-one-space)
3637 (if (string-equal (tempo-lookup-named 'area) "")
3638 () (list 'l "AREA=" '(s area)))
3639 '(just-one-space)
3640 (p "<length>: " l 'noinsert)
3641 (if (string-equal (tempo-lookup-named 'l) "")
3642 () (list 'l "L=" '(s l)))
3643 '(just-one-space)
3644 (p "<width>: " w 'noinsert)
3645 (if (string-equal (tempo-lookup-named 'w) "")
3646 () (list 'l "W=" '(s w)))
3647 '(just-one-space)
3648 (p "<temp>: " temp 'noinsert)
3649 (if (string-equal (tempo-lookup-named 'temp) "")
3650 () (list 'l "T=" '(s temp)))
3651 '(just-one-space)
3652 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3653 (if (and (tempo-lookup-named 'off)
3654 (string-equal (tempo-lookup-named 'off) "y"))
3655 (list 'l "OFF"))
3656 '(just-one-space)
3657 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3658 (if (and (tempo-lookup-named 'nonoise)
3659 (string-equal (tempo-lookup-named 'nonoise) "y"))
3660 (list 'l "NONOISE"))
3661 '(just-one-space)
3663 ;;"eldo jfet"
3664 "JE"
3665 "tempo template for eldo jfet"
3666 'spice-tempo-tags)
3669 (tempo-define-template
3670 "spice-hspice-jfet"
3671 '("J"
3672 (p "[name]: ") '(just-one-space)
3673 (p "[drain node]: ") '(just-one-space)
3674 (p "[gate node]: ") '(just-one-space)
3675 (p "[source node]: ") '(just-one-space)
3676 (p "[mname]: ") '(just-one-space)
3677 (p "<area>: " area 'noinsert)
3678 (if (string-equal (tempo-lookup-named 'area) "")
3679 (list 'l '(p "<length>: " l 'noinsert) '(p "<width>: " w 'noinsert))
3680 (list 'l "AREA=" '(s area)))
3681 '(just-one-space)
3682 (if (and (tempo-lookup-named 'l)
3683 (not (string-equal (tempo-lookup-named 'l) "")))
3684 (list 'l "L=" '(s l)))
3685 '(just-one-space)
3686 (if (and (tempo-lookup-named 'w)
3687 (not (string-equal (tempo-lookup-named 'w) "")))
3688 (list 'l "W=" '(s w)))
3689 '(just-one-space)
3690 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3691 (if (and (tempo-lookup-named 'off)
3692 (string-equal (tempo-lookup-named 'off) "y"))
3693 (list 'l "OFF"))
3694 '(just-one-space)
3695 (p "<initial cond (vds,vgs)>: " ic 'noinsert)
3696 (if (string-equal (tempo-lookup-named 'ic) "")
3697 () (list 'l "IC=" '(s ic)))
3698 '(just-one-space)
3699 (p "<m>: " m 'noinsert)
3700 (if (string-equal (tempo-lookup-named 'm) "")
3701 () (list 'l "M=" '(s m)))
3702 '(just-one-space)
3703 (p "<diff temp>: " dtemp 'noinsert)
3704 (if (string-equal (tempo-lookup-named 'dtemp) "")
3705 () (list 'l "DTEMP=" '(s dtemp)))
3706 '(just-one-space)
3708 ;;"hspice jfet"
3709 "JH"
3710 "tempo template for hspice jfet"
3711 'spice-tempo-tags)
3714 ;; mosfets
3715 (tempo-define-template
3716 "spice-spice2g6-mosfet"
3717 '("M"
3718 (p "[name]: ") '(just-one-space)
3719 (p "[drain node]: ") '(just-one-space)
3720 (p "[gate node]: ") '(just-one-space)
3721 (p "[source node]: ") '(just-one-space)
3722 (p "[bulk node]: ") '(just-one-space)
3723 (p "[mname]: ") '(just-one-space)
3724 (p "<length>: " l 'noinsert)
3725 (if (string-equal (tempo-lookup-named 'l) "")
3726 () (list 'l "L=" '(s l)))
3727 '(just-one-space)
3728 (p "<width>: " w 'noinsert)
3729 (if (string-equal (tempo-lookup-named 'w) "")
3730 () (list 'l "W=" '(s w)))
3731 '(just-one-space)
3732 (p "<area drain>: " ad 'noinsert)
3733 (if (string-equal (tempo-lookup-named 'ad) "")
3734 () (list 'l "AD=" '(s ad)))
3735 '(just-one-space)
3736 (p "<area source>: " as 'noinsert)
3737 (if (string-equal (tempo-lookup-named 'as) "")
3738 () (list 'l "AS=" '(s as)))
3739 '(just-one-space)
3740 (p "<perimeter drain>: " pd 'noinsert)
3741 (if (string-equal (tempo-lookup-named 'pd) "")
3742 () (list 'l "PD=" '(s pd)))
3743 '(just-one-space)
3744 (p "<perimeter source>: " ps 'noinsert)
3745 (if (string-equal (tempo-lookup-named 'ps) "")
3746 () (list 'l "PS=" '(s ps)))
3747 '(just-one-space)
3748 (p "<number of drain contacts>: " nrd 'noinsert)
3749 (if (string-equal (tempo-lookup-named 'nrd) "")
3750 () (list 'l "NRD=" '(s nrd)))
3751 '(just-one-space)
3752 (p "<number of source contacts>: " nrs 'noinsert)
3753 (if (string-equal (tempo-lookup-named 'nrs) "")
3754 () (list 'l "NRS=" '(s nrs)))
3755 '(just-one-space)
3756 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3757 (if (and (tempo-lookup-named 'off)
3758 (string-equal (tempo-lookup-named 'off) "y"))
3759 (list 'l "OFF"))
3760 '(just-one-space)
3761 (p "<initial cond (vds, vgs, vgs)>: " ic 'noinsert)
3762 (if (string-equal (tempo-lookup-named 'ic) "")
3763 () (list 'l "IC=" '(s ic)))
3764 '(just-one-space)
3766 ;;"spice2g6 mosfet"
3768 "tempo template for spice2g6 mosfet"
3769 'spice-tempo-tags)
3772 (tempo-define-template
3773 "spice-eldo-mosfet"
3774 '("M"
3775 (p "[name]: ") '(just-one-space)
3776 (p "[drain node]: ") '(just-one-space)
3777 (p "[gate node]: ") '(just-one-space)
3778 (p "[source node]: ") '(just-one-space)
3779 (p "[bulk node]: ") '(just-one-space)
3780 (p "<optional nodes>: ") '(just-one-space)
3781 "MOD="
3782 (p "[mname]: ") '(just-one-space)
3783 (p "<length>: " l 'noinsert)
3784 (if (string-equal (tempo-lookup-named 'l) "")
3785 () (list 'l "L=" '(s l)))
3786 '(just-one-space)
3787 (p "<width>: " w 'noinsert)
3788 (if (string-equal (tempo-lookup-named 'w) "")
3789 () (list 'l "W=" '(s w)))
3790 '(just-one-space)
3791 (p "<area drain>: " ad 'noinsert)
3792 (if (string-equal (tempo-lookup-named 'ad) "")
3793 () (list 'l "AD=" '(s ad)))
3794 '(just-one-space)
3795 (p "<area source>: " as 'noinsert)
3796 (if (string-equal (tempo-lookup-named 'as) "")
3797 () (list 'l "AS=" '(s as)))
3798 '(just-one-space)
3799 (p "<perimeter drain>: " pd 'noinsert)
3800 (if (string-equal (tempo-lookup-named 'pd) "")
3801 () (list 'l "PD=" '(s pd)))
3802 '(just-one-space)
3803 (p "<perimeter source>: " ps 'noinsert)
3804 (if (string-equal (tempo-lookup-named 'ps) "")
3805 () (list 'l "PS=" '(s ps)))
3806 '(just-one-space)
3807 (p "<geometry model>: " geo 'noinsert)
3808 (if (string-equal (tempo-lookup-named 'geo) "")
3809 () (list 'l "GEO=" '(s geo)))
3810 '(just-one-space)
3811 (p "<number of drain contacts>: " nrd 'noinsert)
3812 (if (string-equal (tempo-lookup-named 'nrd) "")
3813 () (list 'l "NRD=" '(s nrd)))
3814 '(just-one-space)
3815 (p "<number of source contacts>: " nrs 'noinsert)
3816 (if (string-equal (tempo-lookup-named 'nrs) "")
3817 () (list 'l "NRS=" '(s nrs)))
3818 '(just-one-space)
3819 (p "<m>: " m 'noinsert)
3820 (if (string-equal (tempo-lookup-named 'm) "")
3821 () (list 'l "M=" '(s m)))
3822 '(just-one-space)
3823 (p "<extra drain contact resistance>: " rdc 'noinsert)
3824 (if (string-equal (tempo-lookup-named 'rdc) "")
3825 () (list 'l "RDC=" '(s rdc)))
3826 '(just-one-space)
3827 (p "<extra source contact resistance>: " rsc 'noinsert)
3828 (if (string-equal (tempo-lookup-named 'rsc) "")
3829 () (list 'l "RSC=" '(s rsc)))
3830 '(just-one-space)
3831 (p "<temp>: " temp 'noinsert)
3832 (if (string-equal (tempo-lookup-named 'temp) "")
3833 () (list 'l "T=" '(s temp)))
3834 '(just-one-space)
3835 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3836 (if (and (tempo-lookup-named 'off)
3837 (string-equal (tempo-lookup-named 'off) "y"))
3838 (list 'l "OFF"))
3839 '(just-one-space)
3840 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3841 (if (and (tempo-lookup-named 'nonoise)
3842 (string-equal (tempo-lookup-named 'nonoise) "y"))
3843 (list 'l "NONOISE"))
3844 '(just-one-space)
3846 ;;"eldo mosfet"
3847 "ME"
3848 "tempo template for eldo mosfet"
3849 'spice-tempo-tags)
3852 (tempo-define-template
3853 "spice-hspice-mosfet"
3854 '("M"
3855 (p "[name]: ") '(just-one-space)
3856 (p "[drain node]: ") '(just-one-space)
3857 (p "[gate node]: ") '(just-one-space)
3858 (p "[source node]: ") '(just-one-space)
3859 (p "[bulk node]: ") '(just-one-space)
3860 (p "[mname]: ") '(just-one-space)
3861 (p "<length>: " l 'noinsert)
3862 (if (string-equal (tempo-lookup-named 'l) "")
3863 () (list 'l "L=" '(s l)))
3864 '(just-one-space)
3865 (p "<width>: " w 'noinsert)
3866 (if (string-equal (tempo-lookup-named 'w) "")
3867 () (list 'l "W=" '(s w)))
3868 '(just-one-space)
3869 (p "<area drain>: " ad 'noinsert)
3870 (if (string-equal (tempo-lookup-named 'ad) "")
3871 () (list 'l "AD=" '(s ad)))
3872 '(just-one-space)
3873 (p "<area source>: " as 'noinsert)
3874 (if (string-equal (tempo-lookup-named 'as) "")
3875 () (list 'l "AS=" '(s as)))
3876 '(just-one-space)
3877 (p "<perimeter drain>: " pd 'noinsert)
3878 (if (string-equal (tempo-lookup-named 'pd) "")
3879 () (list 'l "PD=" '(s pd)))
3880 '(just-one-space)
3881 (p "<perimeter source>: " ps 'noinsert)
3882 (if (string-equal (tempo-lookup-named 'ps) "")
3883 () (list 'l "PS=" '(s ps)))
3884 '(just-one-space)
3885 (p "<number of drain contacts>: " nrd 'noinsert)
3886 (if (string-equal (tempo-lookup-named 'nrd) "")
3887 () (list 'l "NRD=" '(s nrd)))
3888 '(just-one-space)
3889 (p "<number of source contacts>: " nrs 'noinsert)
3890 (if (string-equal (tempo-lookup-named 'nrs) "")
3891 () (list 'l "NRS=" '(s nrs)))
3892 '(just-one-space)
3893 (p "<extra drain contact resistance>: " rdc 'noinsert)
3894 (if (string-equal (tempo-lookup-named 'rdc) "")
3895 () (list 'l "RDC=" '(s rdc)))
3896 '(just-one-space)
3897 (p "<extra source contact resistance>: " rsc 'noinsert)
3898 (if (string-equal (tempo-lookup-named 'rsc) "")
3899 () (list 'l "RSC=" '(s rsc)))
3900 '(just-one-space)
3901 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3902 (if (and (tempo-lookup-named 'off)
3903 (string-equal (tempo-lookup-named 'off) "y"))
3904 (list 'l "OFF"))
3905 '(just-one-space)
3906 (p "<init cond (vds,vgs,vbs)>: " ic 'noinsert)
3907 (if (string-equal (tempo-lookup-named 'ic) "")
3908 () (list 'l "IC=" '(s ic)))
3909 '(just-one-space)
3910 (p "<diff temp>: " dtemp 'noinsert)
3911 (if (string-equal (tempo-lookup-named 'dtemp) "")
3912 () (list 'l "DTEMP=" '(s dtemp)))
3913 '(just-one-space)
3914 (p "<geometry model>: " geo 'noinsert)
3915 (if (string-equal (tempo-lookup-named 'geo) "")
3916 () (list 'l "GEO=" '(s geo)))
3917 '(just-one-space)
3918 (p "<m>: " m 'noinsert)
3919 (if (string-equal (tempo-lookup-named 'm) "")
3920 () (list 'l "M=" '(s m)))
3921 '(just-one-space)
3922 (p "<delvto>: " delvto 'noinsert)
3923 (if (string-equal (tempo-lookup-named 'delvto) "")
3924 () (list 'l "DELVTO=" '(s delvto)))
3925 '(just-one-space)
3927 ;;"hspice mosfet"
3928 "MH"
3929 "tempo template for hspice mosfet"
3930 'spice-tempo-tags)
3933 (tempo-define-template
3934 "spice-layla-mosfet"
3935 '("M"
3936 (p "[name]: ") '(just-one-space)
3937 (p "[drain node]: ") '(just-one-space)
3938 (p "[gate node]: ") '(just-one-space)
3939 (p "[source node]: ") '(just-one-space)
3940 (p "[bulk node]: ") '(just-one-space)
3941 (p "[mname]: ") '(just-one-space)
3942 (p "<length>: " l 'noinsert)
3943 (if (string-equal (tempo-lookup-named 'l) "")
3944 () (list 'l "L=" '(s l)))
3945 '(just-one-space)
3946 (p "<width>: " w 'noinsert)
3947 (if (string-equal (tempo-lookup-named 'w) "")
3948 () (list 'l "W=" '(s w)))
3949 '(just-one-space)
3950 "\n+ type=\""
3951 (p "[type (no quotes)]: ") "\""
3952 '(just-one-space)
3953 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
3954 (if (string-equal (tempo-lookup-named 'symmetry) "")
3955 () (list 'l "symmetry=\"" '(s symmetry) "\""))
3956 '(just-one-space)
3957 (p "<matching (no quotes)>: " matching 'noinsert)
3958 (if (string-equal (tempo-lookup-named 'matching) "")
3959 () (list 'l "matching=\"" '(s matching) "\""))
3960 '(just-one-space)
3961 (p "<couple>: " couple 'noinsert)
3962 (if (string-equal (tempo-lookup-named 'couple) "")
3963 () (list 'l "couple=" '(s couple)))
3964 '(just-one-space)
3965 (p "<array (no quotes)>: " array 'noinsert)
3966 (if (string-equal (tempo-lookup-named 'array) "")
3967 () (list 'l "array=\"" '(s array) "\""))
3968 '(just-one-space)
3969 (p "<orientations (no quotes)>: " orientations 'noinsert)
3970 (if (string-equal (tempo-lookup-named 'orientations) "")
3971 () (list 'l "orientations=\"" '(s orientations) "\""))
3972 '(just-one-space)
3973 (p "<unit_value>: " unit_value 'noinsert)
3974 (if (string-equal (tempo-lookup-named 'unit_value) "")
3975 () (list 'l "unit_value=" '(s unit_value)))
3976 '(just-one-space)
3977 (p "<current>: " current 'noinsert)
3978 (if (string-equal (tempo-lookup-named 'current) "")
3979 () (list 'l "current=" '(s current)))
3980 '(just-one-space)
3981 (p "<power>: " power 'noinsert)
3982 (if (string-equal (tempo-lookup-named 'power) "")
3983 () (list 'l "power=" '(s power)))
3984 '(just-one-space)
3985 (p "<min_ar>: " min_ar 'noinsert)
3986 (if (string-equal (tempo-lookup-named 'min_ar) "")
3987 () (list 'l "min_ar=" '(s min_ar)))
3988 '(just-one-space)
3989 (p "<max_ar>: " max_ar 'noinsert)
3990 (if (string-equal (tempo-lookup-named 'max_ar) "")
3991 () (list 'l "max_ar=" '(s max_ar)))
3992 '(just-one-space)
3993 (p "<routing_space>: " routing_space 'noinsert)
3994 (if (string-equal (tempo-lookup-named 'routing_space) "")
3995 () (list 'l "routing_space=" '(s routing_space)))
3996 '(just-one-space)
3998 ;;"layla mosfet"
3999 "ML"
4000 "tempo template for layla mosfet"
4001 'spice-tempo-tags)
4004 ;; mesfets
4005 (tempo-define-template
4006 "spice-spice2g6-mesfet"
4007 '("Z"
4008 (p "[name]: ") '(just-one-space)
4009 (p "[drain node]: ") '(just-one-space)
4010 (p "[gate node]: ") '(just-one-space)
4011 (p "[source node]: ") '(just-one-space)
4012 (p "[mname]: ") '(just-one-space)
4013 (p "<area>: ") '(just-one-space)
4014 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
4015 (if (and (tempo-lookup-named 'off)
4016 (string-equal (tempo-lookup-named 'off) "y"))
4017 (list 'l "OFF"))
4018 '(just-one-space)
4019 (p "<initial cond (vds, vgs)>: " ic 'noinsert)
4020 (if (string-equal (tempo-lookup-named 'ic) "")
4021 () (list 'l "IC=" '(s ic)))
4022 '(just-one-space)
4024 ;;"spice2g6 mesfet"
4026 "tempo template for spice2g6 mesfet"
4027 'spice-tempo-tags)
4030 ;; subcircuit defs
4031 (tempo-define-template
4032 "spice-spice2g6-subckt"
4033 '(".subckt "
4034 (p "[subckt name]: " lname) 'r 'n 'n
4035 ".ends " (s lname) '>)
4036 "SUB"
4037 "template for inserting a subckt definition"
4038 'spice-tempo-tags)
4041 ;; Controlled sources
4043 ;; Voltage sources
4045 (tempo-define-template
4046 "spice-spice2g6-vcvs"
4047 '("E"
4048 (p "[name]: ") '(just-one-space)
4049 (p "[positive node]: ") '(just-one-space)
4050 (p "[negative node]: ") '(just-one-space)
4051 (p "[positive controling node]: ") '(just-one-space)
4052 (p "[negative controling node]: ") '(just-one-space)
4053 (p "[gain]: ") '(just-one-space)
4055 "VCVS"
4056 "template for inserting a voltage controled voltage source"
4057 'spice-tempo-tags)
4059 (tempo-define-template
4060 "spice-spice2g6-ccvs"
4061 '("H"
4062 (p "[name]: ") '(just-one-space)
4063 (p "[positive node]: ") '(just-one-space)
4064 (p "[negative node]: ") '(just-one-space)
4065 (p "[voltage source]: ") '(just-one-space)
4066 (p "[gain]: ") '(just-one-space)
4068 "CCVS"
4069 "template for inserting a current controled voltage source"
4070 'spice-tempo-tags)
4073 ;; Current sources
4075 (tempo-define-template
4076 "spice-spice2g6-vccs"
4077 '("G"
4078 (p "[name]: ") '(just-one-space)
4079 (p "[positive node]: ") '(just-one-space)
4080 (p "[negative node]: ") '(just-one-space)
4081 (p "[positive controling node]: ") '(just-one-space)
4082 (p "[negative controling node]: ") '(just-one-space)
4083 (p "[transadmitance]: ") '(just-one-space)
4085 "VCCS"
4086 "template for inserting a voltage controled current source"
4087 'spice-tempo-tags)
4089 (tempo-define-template
4090 "spice-spice2g6-cccs"
4091 '("F"
4092 (p "[name]: ") '(just-one-space)
4093 (p "[positive node]: ") '(just-one-space)
4094 (p "[negative node]: ") '(just-one-space)
4095 (p "[voltage source]: ") '(just-one-space)
4096 (p "[gain]: ") '(just-one-space)
4098 "CCCS"
4099 "template for inserting a current controled current source"
4100 'spice-tempo-tags)
4103 ;; Waveforms
4105 (tempo-define-template
4106 "spice-pulse"
4107 '("pulse("
4108 (p "[start value]: ") " "
4109 (p "[pulsed value]: ") " "
4110 (p "[delay]: ") " "
4111 (p "[rise time]: ") " "
4112 (p "[fall time]: ") " "
4113 (p "[pulse duration]: ") " "
4114 (p "[period]: ")
4115 ")"'n)
4116 "PU"
4117 "template for inserting an Pulse waveform"
4118 'spice-tempo-tags)
4120 (tempo-define-template
4121 "spice-sine"
4122 '("sin("
4123 (p "[Offset]: ") " "
4124 (p "[Amplitude]: ") " "
4125 (p "[Frequency]: ") " "
4126 (p "[Delay]: ") " "
4127 (p "[Damping factor]: ")
4128 (p "[Phase delay]: ") '(just-one-space)
4129 ")"'n)
4130 "sin"
4131 "template for inserting a Sine function"
4132 'spice-tempo-tags)
4134 (tempo-define-template
4135 "spice-exp"
4136 '("exp("
4137 (p "[start value]: ") " "
4138 (p "[target value]: ") " "
4139 (p "[rise delay]: ") " "
4140 (p "[tau1]: ") " "
4141 (p "[fall delay]: ") " "
4142 (p "[tau2]: ")
4143 ")"'n)
4144 "exp"
4145 "template for inserting an EXP waveform"
4146 'spice-tempo-tags)
4148 ;;(tempo-define-template
4149 ;; "spice-pwl"
4150 ;; '("pwl("
4151 ;; (p "[start time]: ") " "
4152 ;; (p "[start value]: ") " "
4153 ;; ")"'n)
4154 ;; "pwl"
4155 ;; "template for inserting an PWL waveform")
4157 (load "skeleton")
4158 (define-skeleton spice-pwl
4159 "Skeleton for Piece Wise Linear waveform"
4160 "Time/value doublet: "
4161 "pwl(" str
4162 ( "Next doublet: (%s) "
4163 " "str )
4164 resume:
4166 'spice-tempo-tags)
4169 (tempo-define-template
4170 "hspice-sffm"
4171 '("sffm("
4172 (p "[offset value]: ") " "
4173 (p "[amplitude value]: ") " "
4174 (p "[carrier frequency]: ") " "
4175 (p "[modulation index]: ") " "
4176 (p "[signal frequency]: ")
4177 ")"'n)
4178 "sffm"
4179 "template for inserting an HSPICE SFFM waveform"
4180 'spice-tempo-tags)
4182 (tempo-define-template
4183 "hspice-am"
4184 '("am("
4185 (p "[signal amplitude]: ") " "
4186 (p "[offset constant]: ") " "
4187 (p "[modulation frequency]: ") " "
4188 (p "[carrier frequency]: ") " "
4189 (p "[delay time]: ")
4190 ")"'n)
4191 "am"
4192 "template for inserting an HSPICE AM waveform"
4193 'spice-tempo-tags)
4195 (tempo-define-template
4196 "spice-ac"
4197 '("ac("
4198 (p "[magnitude]: ") " "
4199 (p "[phase]: ")
4200 ")"'n)
4201 "ac"
4202 "template for inserting an AC waveform"
4203 'spice-tempo-tags)
4205 (tempo-define-template
4206 "spice-eldo-pattern"
4207 '("pattern "
4208 (p "[Vhi]: ") " "
4209 (p "[Vlo]: ") " "
4210 (p "[delay]: ") " "
4211 (p "[rise time]: ") " "
4212 (p "[fall time]: ") " "
4213 (p "[Bit duration]: ") " "
4214 (p "[Bits]: ")
4216 "eldo-pattern"
4217 "template for inserting an ELDO Pattern function"
4218 'spice-tempo-tags)
4220 (tempo-define-template
4221 "spice-eldo-noise"
4222 '("noise("
4223 (p "[White noise level]: ") " "
4224 (p "[Flicker noise level]: ") " "
4225 (p "[Alpha]: ") " "
4226 (p "[Cut-off freq]: ") " "
4227 (p "[Filter order]: ")
4228 ")"'n)
4229 "noise"
4230 "template for inserting an ELDO NOISE waveform"
4231 'spice-tempo-tags)
4233 (tempo-define-template
4234 "spice-eldorf-fpulse"
4235 '("fpulse("
4236 (p "[initial value]: ") " "
4237 (p "[pulse value]: ") " "
4238 (p "[delay time]: ") " "
4239 (p "[rise time]: ") " "
4240 (p "[fall time]: ") " "
4241 (p "[pulse duration]: ") " "
4242 (p "[FUND1|FUND2|FUND3 (of .sst)]: ")
4243 ")"'n)
4244 "eldorf-fpulse"
4245 "template for inserting an Eldo-RF fpulse waveform"
4246 'spice-tempo-tags)
4248 (tempo-define-template
4249 "spice-eldorf-four"
4250 '("four" '(just-one-space)
4251 (p "[FUND1]: ")
4252 (p "<FUND2>: " fund2 'noinsert)
4253 (if (string-equal (tempo-lookup-named 'fund2) "")
4255 (list 'l " " '(s fund2) '(p "<FUND3>: " fund3 'noinsert)))
4256 (if (string-equal (tempo-lookup-named 'fund3) "")
4258 (list 'l " " '(s fund3)))
4259 '(just-one-space)
4260 (p "[MA|RI|DB|PMA|PDB|PDBM]: ") '(just-one-space)
4262 (p "[int_val1]: ")
4263 (p "<int_val2>: " int_val2 'noinsert)
4264 (if (string-equal (tempo-lookup-named 'int_val2) "")
4266 (list 'l "," '(s int_val2) '(p "<int_val3>: " int_val3 'noinsert)))
4267 (if (string-equal (tempo-lookup-named 'int_val3) "")
4269 (list 'l "," '(s int_val3)))
4270 ")" '(just-one-space)
4271 (p "[real_val1]: ") '(just-one-space)
4272 (p "[real_val2]: ") '(just-one-space)
4274 "eldorf-four"
4275 "template for inserting an Eldo-RF Fpulse waveform"
4276 'spice-tempo-tags)
4278 ;; Eldo Extracts
4280 (tempo-define-template
4281 "spice-eldo-phmag"
4282 '(".EXTRACT AC label=\"Phase margin\" xycond(vp("
4283 (p "[Node]: " lname)
4284 "),vdb(" (s lname) ")<0.0)+180 "
4286 "phmag"
4287 "template for extracting the phase margin"
4288 'spice-tempo-tags)
4290 (tempo-define-template
4291 "spice-eldo-gmag"
4292 '(".EXTRACT AC label=\"Gain margin\" -xycond(vdb("
4293 (p "[Node]: " lname)
4294 "),vp(" (s lname) ")<-180) "
4296 "gmag"
4297 "template for extracting the gain margin"
4298 'spice-tempo-tags)
4300 (tempo-define-template
4301 "spice-eldo-fc"
4302 '(".EXTRACT AC label=\"Cut freq\" xdown(vdb("
4303 (p "[Node]: " lname)
4304 "),yval(vdb(" (s lname) "),1)-3) "
4306 "fc"
4307 "template for extracting the cut frequency"
4308 'spice-tempo-tags)
4310 (tempo-define-template
4311 "spice-eldo-ugfc"
4312 '(".EXTRACT AC label=\"Unity gain freq\" xdown(vdb("
4313 (p "[Node]: " lname)
4314 "),0) "
4316 "ugfc"
4317 "template for extracting the unity gain frequency"
4318 'spice-tempo-tags)
4320 (tempo-define-template
4321 "spice-eldo-period"
4322 '(".EXTRACT TRAN xdown(v("
4323 (p "[Node]: " lname)
4324 "),"
4325 (p "[threshold]: " vth)
4327 (p "[estimation time]: " t)
4328 ",end)"
4329 "-xdown(v(" (s lname) "),"(s vth) ","(s t) ",start) !period"
4331 "period"
4332 "template for extracting the period of a signal"
4333 'spice-tempo-tags)
4335 (tempo-define-template
4336 "spice-eldo-period-macro"
4337 '(".DEFMAC period(a,th,time)=xdown(a,th,time,end)"
4338 "-xdown(a,th,time,start)"
4340 "period"
4341 "macro for extracting the period of signal a"
4342 'spice-tempo-tags)
4344 (tempo-define-template
4345 "spice-eldo-duty-macro"
4346 '(".DEFMAC duty_cycle(a,th,time)=(xdown(a,th,time,end)"
4347 "-xup(a,th,time,end))/(xdown(a,th,time,end)-xdown(a,th,time,start))*100"
4349 "duty"
4350 "macro for extracting the duty cycle of signal a"
4351 'spice-tempo-tags)
4353 (tempo-define-template
4354 "spice-eldo-settling-macro"
4355 '(".DEFMAC settling(xaxis,a,ratio,Tstart,Tfinal)=xycond(xaxis,(a>(yval(a,Tfinal)*(1+ratio)))"
4356 " || (a<(yval(a,Tfinal)*(1-ratio))),Tfinal,Tstart) - Tstart"
4358 "settling"
4359 "macro for extracting the settling cycle of signal A, within ±ratio of value of A at time Tfinal"
4360 'spice-tempo-tags)
4363 ;; Eldo Macromodels
4365 (tempo-define-template
4366 "spice-eldo-comp"
4367 '("COMP"
4368 (p "[Instance name]: ") " "
4369 (p "[Positive input]: ") " "
4370 (p "[Negative input]: ") " "
4371 (p "[Output]: ") " "
4372 (p "[Model name]: ") " "
4373 (p "<Vhigh>: " vhi 'noinsert)
4374 (if (string-equal (tempo-lookup-named 'vhi) "")
4375 (list 'l "VHI=5.0") ;; default value
4376 (list 'l "VHI=" '(s vhi)))
4377 '(just-one-space)
4378 (p "<Vlow>: " vlo 'noinsert)
4379 (if (string-equal (tempo-lookup-named 'vlo) "")
4380 (list 'l "VLO=0.0") ;; default value
4381 (list 'l "VLO=" '(s vlo)))
4382 '(just-one-space)
4383 (p "<Input offset>: " voff 'noinsert)
4384 (if (string-equal (tempo-lookup-named 'voff) "")
4385 (list 'l "VOFF=0.0") ;; default value
4386 (list 'l "VOFF=" '(s voff)))
4387 '(just-one-space)
4388 (p "<Hysteresis voltage>: " vdef 'noinsert)
4389 (if (string-equal (tempo-lookup-named 'vdef) "")
4390 (list 'l "VDEF=0.0") ;; default value
4391 (list 'l "VDEF=" '(s vdef)))
4392 '(just-one-space)
4393 (p "<Commutation time>: " tcom 'noinsert)
4394 (if (string-equal (tempo-lookup-named 'tcom) "")
4395 (list 'l "TCOM=1ns") ;; default value
4396 (list 'l "TCOM=" '(s tcom)))
4397 '(just-one-space)
4398 (p "<Transit time>: " tpd 'noinsert)
4399 (if (string-equal (tempo-lookup-named 'tpd) "")
4400 (list 'l "TPD=0.0") ;; default value
4401 (list 'l "TPD=" '(s tpd)))
4402 '(just-one-space)
4404 "comp"
4405 "template for inserting an ELDO Single output comparator"
4406 'spice-tempo-tags)
4408 (tempo-define-template
4409 "spice-eldo-compd"
4410 '("COMPD"
4411 (p "[Instance name]: ") " "
4412 (p "[Positive input]: ") " "
4413 (p "[Negative input]: ") " "
4414 (p "[Positive Output]: ") " "
4415 (p "[Negative Output]: ") " "
4416 (p "[Model name]: ") " "
4417 (p "<Vhigh>: " vhi 'noinsert)
4418 (if (string-equal (tempo-lookup-named 'vhi) "")
4419 (list 'l "VHI=5.0") ;; default value
4420 (list 'l "VHI=" '(s vhi)))
4421 '(just-one-space)
4422 (p "<Vlow>: " vlo 'noinsert)
4423 (if (string-equal (tempo-lookup-named 'vlo) "")
4424 (list 'l "VLO=0.0") ;; default value
4425 (list 'l "VLO=" '(s vlo)))
4426 '(just-one-space)
4427 (p "<Input offset>: " voff 'noinsert)
4428 (if (string-equal (tempo-lookup-named 'voff) "")
4429 (list 'l "VOFF=0.0") ;; default value
4430 (list 'l "VOFF=" '(s voff)))
4431 '(just-one-space)
4432 (p "<Hysteresis voltage>: " vdef 'noinsert)
4433 (if (string-equal (tempo-lookup-named 'vdef) "")
4434 (list 'l "VDEF=0.0") ;; default value
4435 (list 'l "VDEF=" '(s vdef)))
4436 '(just-one-space)
4437 (p "<Commutation time>: " tcom 'noinsert)
4438 (if (string-equal (tempo-lookup-named 'tcom) "")
4439 (list 'l "TCOM=1ns") ;; default value
4440 (list 'l "TCOM=" '(s tcom)))
4441 '(just-one-space)
4442 (p "<Transit time>: " tpd 'noinsert)
4443 (if (string-equal (tempo-lookup-named 'tpd) "")
4444 (list 'l "TPD=0.0") ;; default value
4445 (list 'l "TPD=" '(s tpd)))
4446 '(just-one-space)
4448 "compd"
4449 "template for inserting an ELDO Differential output comparator"
4450 'spice-tempo-tags)
4452 (tempo-define-template
4453 "spice-eldo-linear-opa0"
4454 '("Y"
4455 (p "[Instance name]: ") " OPAMP0 "
4456 (p "[Positive input]: ") " "
4457 (p "[Negative input]: ") " "
4458 (p "[Output]: ") " "
4459 (p "[Ground]: ") " param: "
4460 (p "<Gain>: " gain 'noinsert)
4461 (if (string-equal (tempo-lookup-named 'gain) "")
4462 (list 'l "GAIN=1e5") ;; default value
4463 (list 'l "GAIN=" '(s gain)))
4464 '(just-one-space)
4465 (p "<Input impedance>: " rin 'noinsert)
4466 (if (string-equal (tempo-lookup-named 'rin) "")
4467 (list 'l "RIN=1e7") ;; default value
4468 (list 'l "RIN=" '(s rin)))
4469 '(just-one-space)
4471 "opa0"
4472 "template for inserting an ELDO single output linear opamp"
4473 'spice-tempo-tags)
4475 (tempo-define-template
4476 "spice-eldo-linear-opa0d"
4477 '("Y"
4478 (p "[Instance name]: ") " OPAMP0D "
4479 (p "[Positive input]: ") " "
4480 (p "[Negative input]: ") " "
4481 (p "[Positive Output]: ") " "
4482 (p "[Negative Output]: ") " "
4483 (p "[Ground]: ") " param: "
4484 (p "<Gain>: " gain 'noinsert)
4485 (if (string-equal (tempo-lookup-named 'gain) "")
4486 (list 'l "GAIN=1e5") ;; default value
4487 (list 'l "GAIN=" '(s gain)))
4488 '(just-one-space)
4489 (p "<Input impedance>: " rin 'noinsert)
4490 (if (string-equal (tempo-lookup-named 'rin) "")
4491 (list 'l "RIN=1e7") ;; default value
4492 (list 'l "RIN=" '(s rin)))
4493 '(just-one-space)
4495 "opa0d"
4496 "template for inserting an ELDO differential output linear opamp"
4497 'spice-tempo-tags)
4500 (tempo-define-template
4501 "spice-eldo-linear-opa1"
4502 '("Y"
4503 (p "[Instance name]: ") " OPAMP1 "
4504 (p "[Positive input]: ") " "
4505 (p "[Negative input]: ") " "
4506 (p "[Output]: ") " "
4507 (p "[Ground]: ") " param: "
4508 (p "<Gain>: " gain 'noinsert)
4509 (if (string-equal (tempo-lookup-named 'gain) "")
4510 (list 'l "GAIN=1e5") ;; default value
4511 (list 'l "GAIN=" '(s gain)))
4512 '(just-one-space)
4513 (p "<Input offset>: " voff 'noinsert)
4514 (if (string-equal (tempo-lookup-named 'voff) "")
4515 (list 'l "VOFF=0.0") ;; default value
4516 (list 'l "VOFF=" '(s voff)))
4517 '(just-one-space)
4518 (p "<Dominant pole>: " p1 'noinsert)
4519 (if (string-equal (tempo-lookup-named 'p1) "")
4520 (list 'l "P1=100") ;; default value
4521 (list 'l "P1=" '(s p1)))
4522 '(just-one-space)
4523 (p "<Input impedance>: " rin 'noinsert)
4524 (if (string-equal (tempo-lookup-named 'rin) "")
4525 (list 'l "RIN=1e7") ;; default value
4526 (list 'l "RIN=" '(s rin)))
4527 '(just-one-space)
4529 "opa1"
4530 "template for inserting an ELDO single output 1-pole linear opamp"
4531 'spice-tempo-tags)
4533 (tempo-define-template
4534 "spice-eldo-linear-opa1d"
4535 '("Y"
4536 (p "[Instance name]: ") " OPAMP1D "
4537 (p "[Positive input]: ") " "
4538 (p "[Negative input]: ") " "
4539 (p "[Positive Output]: ") " "
4540 (p "[Negative Output]: ") " "
4541 (p "[Ground]: ") " param: "
4542 (p "<Gain>: " gain 'noinsert)
4543 (if (string-equal (tempo-lookup-named 'gain) "")
4544 (list 'l "GAIN=1e5") ;; default value
4545 (list 'l "GAIN=" '(s gain)))
4546 '(just-one-space)
4547 (p "<Input offset>: " voff 'noinsert)
4548 (if (string-equal (tempo-lookup-named 'voff) "")
4549 (list 'l "VOFF=0.0") ;; default value
4550 (list 'l "VOFF=" '(s voff)))
4551 '(just-one-space)
4552 (p "<Dominant pole>: " p1 'noinsert)
4553 (if (string-equal (tempo-lookup-named 'p1) "")
4554 (list 'l "P1=100") ;; default value
4555 (list 'l "P1=" '(s p1)))
4556 '(just-one-space)
4557 (p "<Input impedance>: " rin 'noinsert)
4558 (if (string-equal (tempo-lookup-named 'rin) "")
4559 (list 'l "RIN=1e7") ;; default value
4560 (list 'l "RIN=" '(s rin)))
4561 '(just-one-space)
4562 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
4563 (if (string-equal (tempo-lookup-named 'cmrr) "")
4564 (list 'l "CMRR=0.0") ;; default value
4565 (list 'l "CMRR=" '(s cmrr)))
4566 '(just-one-space)
4568 "opa1d"
4569 "template for inserting an ELDO differential output 1-pole linear opamp"
4570 'spice-tempo-tags)
4572 (tempo-define-template
4573 "spice-eldo-linear-opa2"
4574 '("Y"
4575 (p "[Instance name]: ") " OPAMP2 "
4576 (p "[Positive input]: ") " "
4577 (p "[Negative input]: ") " "
4578 (p "[Output]: ") " "
4579 (p "[Ground]: ") " param: "
4580 (p "<Gain>: " gain 'noinsert)
4581 (if (string-equal (tempo-lookup-named 'gain) "")
4582 (list 'l "GAIN=1e5") ;; default value
4583 (list 'l "GAIN=" '(s gain)))
4584 '(just-one-space)
4585 (p "<Input offset>: " voff 'noinsert)
4586 (if (string-equal (tempo-lookup-named 'voff) "")
4587 (list 'l "VOFF=0.0") ;; default value
4588 (list 'l "VOFF=" '(s voff)))
4589 '(just-one-space)
4590 (p "<Dominant pole>: " p1 'noinsert)
4591 (if (string-equal (tempo-lookup-named 'p1) "")
4592 (list 'l "P1=100") ;; default value
4593 (list 'l "P1=" '(s p1)))
4594 '(just-one-space)
4595 (p "<Non-dominant pole>: " p2 'noinsert)
4596 (if (string-equal (tempo-lookup-named 'p2) "")
4597 (list 'l "P2=1e6") ;; default value
4598 (list 'l "P2=" '(s p2)))
4599 '(just-one-space)
4600 (p "<Input impedance>: " rin 'noinsert)
4601 (if (string-equal (tempo-lookup-named 'rin) "")
4602 (list 'l "RIN=1e7") ;; default value
4603 (list 'l "RIN=" '(s rin)))
4604 '(just-one-space)
4606 "opa2"
4607 "template for inserting an ELDO single output 2-pole linear opamp"
4608 'spice-tempo-tags)
4610 (tempo-define-template
4611 "spice-eldo-linear-opa2d"
4612 '("Y"
4613 (p "[Instance name]: ") " OPAMP2D "
4614 (p "[Positive input]: ") " "
4615 (p "[Negative input]: ") " "
4616 (p "[Positive Output]: ") " "
4617 (p "[Negative Output]: ") " "
4618 (p "[Ground]: ") " param: "
4619 (p "<Gain>: " gain 'noinsert)
4620 (if (string-equal (tempo-lookup-named 'gain) "")
4621 (list 'l "GAIN=1e5") ;; default value
4622 (list 'l "GAIN=" '(s gain)))
4623 '(just-one-space)
4624 (p "<Input offset>: " voff 'noinsert)
4625 (if (string-equal (tempo-lookup-named 'voff) "")
4626 (list 'l "VOFF=0.0") ;; default value
4627 (list 'l "VOFF=" '(s voff)))
4628 '(just-one-space)
4629 (p "<Dominant pole>: " p1 'noinsert)
4630 (if (string-equal (tempo-lookup-named 'p1) "")
4631 (list 'l "P1=100") ;; default value
4632 (list 'l "P1=" '(s p1)))
4633 '(just-one-space)
4634 (p "<Non-dominant pole>: " p2 'noinsert)
4635 (if (string-equal (tempo-lookup-named 'p2) "")
4636 (list 'l "P2=1e6") ;; default value
4637 (list 'l "P2=" '(s p2)))
4638 '(just-one-space)
4639 (p "<Input impedance>: " rin 'noinsert)
4640 (if (string-equal (tempo-lookup-named 'rin) "")
4641 (list 'l "RIN=1e7") ;; default value
4642 (list 'l "RIN=" '(s rin)))
4643 '(just-one-space)
4644 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
4645 (if (string-equal (tempo-lookup-named 'cmrr) "")
4646 (list 'l "CMRR=0.0") ;; default value
4647 (list 'l "CMRR=" '(s cmrr)))
4648 '(just-one-space)
4650 "opa2d"
4651 "template for inserting an ELDO differential output 2-pole linear opamp"
4652 'spice-tempo-tags)
4655 (tempo-define-template
4656 "spice-eldo-delay"
4657 '("DEL"
4658 (p "[Instance name]: ") " "
4659 (p "[Input]: ") " "
4660 (p "[Output]: ") " "
4661 (p "[Delay value]: ") " "
4663 "del"
4664 "template for inserting an ELDO delay"
4665 'spice-tempo-tags)
4667 (tempo-define-template
4668 "spice-eldo-satr"
4669 '("Y"
4670 (p "[Instance name]: ") " SATR "
4671 (p "[Input]: ") " "
4672 (p "[Output]: ") " param: "
4673 (p "<Value of resistance>: " r 'noinsert)
4674 (if (string-equal (tempo-lookup-named 'r) "")
4675 (list 'l "R=1") ;; default value
4676 (list 'l "R=" '(s r)))
4677 '(just-one-space)
4678 (p "<Max current>: " imax 'noinsert)
4679 (if (string-equal (tempo-lookup-named 'imax) "")
4680 (list 'l "IMAX=1") ;; default value
4681 (list 'l "IMAX=" '(s imax)))
4682 '(just-one-space)
4683 (p "<Slew rate(V/µs)>: " sr 'noinsert)
4684 (if (string-equal (tempo-lookup-named 'sr) "")
4685 (list 'l "SR=0") ;; default value
4686 (list 'l "SR=" '(s sr)))
4687 '(just-one-space)
4688 (p "<Dominant pole>: " p1 'noinsert)
4689 (if (string-equal (tempo-lookup-named 'p1) "")
4690 (list 'l "P1=1e6") ;; default value
4691 (list 'l "P1=" '(s p1)))
4692 '(just-one-space)
4693 (p "<resistance of low-pass filter>: " r1 'noinsert)
4694 (if (string-equal (tempo-lookup-named 'r1) "")
4695 (list 'l "R1=30") ;; default value
4696 (list 'l "R1=" '(s r1)))
4698 "satr"
4699 "template for inserting an ELDO saturating resistor"
4700 'spice-tempo-tags)
4702 (tempo-define-template
4703 "spice-eldo-satv"
4704 '("Y"
4705 (p "[Instance name]: ") " SATV "
4706 (p "[Positive input]: ") " "
4707 (p "[Negative input]: ") " "
4708 (p "[Positive Output]: ") " "
4709 (p "[Negative Output]: ") " param: "
4710 (p "<VMax>: " vmax 'noinsert)
4711 (if (string-equal (tempo-lookup-named 'vmax) "")
4712 (list 'l "VMAX=5.0") ;; default value
4713 (list 'l "VMAX=" '(s vmax)))
4714 '(just-one-space)
4715 (p "<VMin>: " vmin 'noinsert)
4716 (if (string-equal (tempo-lookup-named 'vmin) "")
4717 (list 'l "VMIN=-5.0") ;; default value
4718 (list 'l "VMIN=" '(s vmin)))
4719 '(just-one-space)
4720 (p "<Positive saturation voltage>: " vsatp 'noinsert)
4721 (if (string-equal (tempo-lookup-named 'vsatp) "")
4722 (list 'l "VSATP=4.75") ;; default value
4723 (list 'l "VSATP=" '(s vsatp)))
4724 '(just-one-space)
4725 (p "<Negative saturation voltage>: " vsatn 'noinsert)
4726 (if (string-equal (tempo-lookup-named 'vsatn) "")
4727 (list 'l "VSATN=-4.75") ;; default value
4728 (list 'l "VSATN=" '(s vsatn)))
4729 '(just-one-space)
4730 (p "<Slope at VSATP>: " pslope 'noinsert)
4731 (if (string-equal (tempo-lookup-named 'pslope) "")
4732 (list 'l "PSLOPE=0.25") ;; default value
4733 (list 'l "PSLOPE=" '(s pslope)))
4734 '(just-one-space)
4735 (p "<Slope at VSATN>: " nslope 'noinsert)
4736 (if (string-equal (tempo-lookup-named 'nslope) "")
4737 (list 'l "NSLOPE=0.25") ;; default value
4738 (list 'l "NSLOPE=" '(s nslope)))
4740 "satv"
4741 "template for inserting an ELDO voltage limitor"
4742 'spice-tempo-tags)
4744 (tempo-define-template
4745 "spice-eldo-vswitch"
4746 '("Y"
4747 (p "[Instance name]: ") " VSWITCH "
4748 (p "[Input]: ") " "
4749 (p "[Output]: ") " "
4750 (p "[Positive controlling node]: ") " "
4751 (p "[Negative controlling node]: ") " param: "
4752 (p "<Level (1/2)>: " level 'noinsert)
4753 (if (string-equal (tempo-lookup-named 'level) "")
4754 (list 'l "LEVEL=1") ;; default value
4755 (list 'l "LEVEL=2" ))
4756 '(just-one-space)
4757 (p "<Voltage for 'ON' state>: " von 'noinsert)
4758 (if (string-equal (tempo-lookup-named 'von) "")
4759 (list 'l "VON=0.95") ;; default value
4760 (list 'l "VON=" '(s von)))
4761 '(just-one-space)
4762 (p "<Voltage for 'OFF' state>: " voff 'noinsert)
4763 (if (string-equal (tempo-lookup-named 'voff) "")
4764 (list 'l "VOFF=0.05") ;; default value
4765 (list 'l "VOFF=" '(s voff)))
4766 '(just-one-space)
4767 (p "<RON resistance>: " ron 'noinsert)
4768 (if (string-equal (tempo-lookup-named 'ron) "")
4769 (list 'l "RON=1e-2") ;; default value
4770 (list 'l "RON=" '(s ron)))
4771 '(just-one-space)
4772 (p "<ROFF resistance>: " roff 'noinsert)
4773 (if (string-equal (tempo-lookup-named 'roff) "")
4774 (list 'l "ROFF=1e10") ;; default value
4775 (list 'l "ROFF=" '(s roff)))
4777 "vswitch"
4778 "template for inserting an ELDO voltage controled switch"
4779 'spice-tempo-tags)
4781 (tempo-define-template
4782 "spice-eldo-cswitch"
4783 '("Y"
4784 (p "[Instance name]: ") " CSWITCH "
4785 (p "[Input]: ") " "
4786 (p "[Output]: ") " IC: "
4787 (p "[Controlling current]: ") " param: "
4788 (p "<Level (1/2)>: " level 'noinsert)
4789 (if (string-equal (tempo-lookup-named 'level) "")
4790 (list 'l "LEVEL=1") ;; default value
4791 (list 'l "LEVEL=2" ))
4792 '(just-one-space)
4793 (p "<Current for 'ON' state>: " ion 'noinsert)
4794 (if (string-equal (tempo-lookup-named 'ion) "")
4795 (list 'l "ION=0.95") ;; default value
4796 (list 'l "ION=" '(s ion)))
4797 '(just-one-space)
4798 (p "<Current for 'OFF' state>: " ioff 'noinsert)
4799 (if (string-equal (tempo-lookup-named 'ioff) "")
4800 (list 'l "IOFF=0.05") ;; default value
4801 (list 'l "IOFF=" '(s ioff)))
4802 '(just-one-space)
4803 (p "<RON resistance>: " ron 'noinsert)
4804 (if (string-equal (tempo-lookup-named 'ron) "")
4805 (list 'l "RON=1e-2") ;; default value
4806 (list 'l "RON=" '(s ron)))
4807 '(just-one-space)
4808 (p "<ROFF resistance>: " roff 'noinsert)
4809 (if (string-equal (tempo-lookup-named 'roff) "")
4810 (list 'l "ROFF=1e10") ;; default value
4811 (list 'l "ROFF=" '(s roff)))
4813 "cswitch"
4814 "template for inserting an ELDO current controled switch"
4815 'spice-tempo-tags)
4817 (tempo-define-template
4818 "spice-eldo-tri2sin"
4819 '("Y"
4820 (p "[Instance name]: ") " TRI2SIN "
4821 (p "[Positive input]: ") " "
4822 (p "[Negative input]: ") " "
4823 (p "[Positive output]: ") " "
4824 (p "[Negative output]: ") " param: "
4825 (p "<Level (1/2)>: " level 'noinsert)
4826 (if (string-equal (tempo-lookup-named 'level) "")
4827 (list 'l "LEVEL=1") ;; default value
4828 (list 'l "LEVEL=" '(s level)))
4829 '(just-one-space)
4830 (p "<Gain>: " gain 'noinsert)
4831 (if (string-equal (tempo-lookup-named 'gain) "")
4832 (list 'l "GAIN=1e5") ;; default value
4833 (list 'l "GAIN=" '(s gain)))
4834 '(just-one-space)
4835 (p "<Input offset>: " voff 'noinsert)
4836 (if (string-equal (tempo-lookup-named 'voff) "")
4837 (list 'l "VOFF=0.0") ;; default value
4838 (list 'l "VOFF=" '(s voff)))
4839 '(just-one-space)
4840 (p "<Upper input voltage limit >: " vu 'noinsert)
4841 (if (string-equal (tempo-lookup-named 'vu) "")
4842 (list 'l "VU=1") ;; default value
4843 (list 'l "VU=" '(s vu)))
4844 '(just-one-space)
4845 (p "<Lower input voltage limit >: " vl 'noinsert)
4846 (if (string-equal (tempo-lookup-named 'vl) "")
4847 (list 'l "VL=1") ;; default value
4848 (list 'l "VL=" '(s vl)))
4850 "tri2sin"
4851 "template for inserting an ELDO triangular to sine wave converter"
4852 'spice-tempo-tags)
4854 (tempo-define-template
4855 "spice-eldo-stairgen"
4856 '("Y"
4857 (p "[Instance name]: ") " STAIRGEN "
4858 (p "[Positive input]: ") " "
4859 (p "[Negative input]: ") " param: "
4860 (p "<Start voltage>: " vstart 'noinsert)
4861 (if (string-equal (tempo-lookup-named 'vstart) "")
4862 (list 'l "VSTART=0.0") ;; default value
4863 (list 'l "VSTART=" '(s vstart)))
4864 '(just-one-space)
4865 (p "<Step voltage>: " vdelta 'noinsert)
4866 (if (string-equal (tempo-lookup-named 'vdelta) "")
4867 (list 'l "VDELTA=0.1") ;; default value
4868 (list 'l "VDELTA=" '(s vdelta)))
4869 '(just-one-space)
4870 (p "<Number of steps>: " nstep 'noinsert)
4871 (if (string-equal (tempo-lookup-named 'nstep) "")
4872 (list 'l "NSTEP=10") ;; default value
4873 (list 'l "NSTEP=" '(s nstep)))
4874 '(just-one-space)
4875 (p "<Period>: " tdu 'noinsert)
4876 (if (string-equal (tempo-lookup-named 'tdu) "")
4877 (list 'l "TDU=1e-4") ;; default value
4878 (list 'l "TDU=" '(s tdu)))
4879 '(just-one-space)
4880 (p "<Slew rate (V/µs)>: " slr 'noinsert)
4881 (if (string-equal (tempo-lookup-named 'slr) "")
4882 (list 'l "SLR=1") ;; default value
4883 (list 'l "SLR=" '(s slr)))
4885 "stairgen"
4886 "template for inserting an ELDO staircase waveform generator"
4887 'spice-tempo-tags)
4889 (tempo-define-template
4890 "spice-eldo-sawgen"
4891 '("Y"
4892 (p "[Instance name]: ") " SAWGEN "
4893 (p "[Positive input]: ") " "
4894 (p "[Negative input]: ") " param: "
4895 (p "<Start voltage>: " v0 'noinsert)
4896 (if (string-equal (tempo-lookup-named 'v0) "")
4897 (list 'l "V0=0.0") ;; default value
4898 (list 'l "V0=" '(s v0)))
4899 '(just-one-space)
4900 (p "<Voltage magnitude>: " v1 'noinsert)
4901 (if (string-equal (tempo-lookup-named 'v1) "")
4902 (list 'l "V1=5.0") ;; default value
4903 (list 'l "V1=" '(s v1)))
4904 '(just-one-space)
4905 (p "<Period>: " tdu 'noinsert)
4906 (if (string-equal (tempo-lookup-named 'tdu) "")
4907 (list 'l "TDU=1e-4") ;; default value
4908 (list 'l "TDU=" '(s tdu)))
4909 '(just-one-space)
4910 (p "<Delay>: " tdel 'noinsert)
4911 (if (string-equal (tempo-lookup-named 'tdel) "")
4912 (list 'l "TDEL=0.0") ;; default value
4913 (list 'l "TDEL=" '(s tdel)))
4915 "sawgen"
4916 "template for inserting an ELDO sawtooth waveform generator"
4917 'spice-tempo-tags)
4919 (tempo-define-template
4920 "spice-eldo-trigen"
4921 '("Y"
4922 (p "[Instance name]: ") " TRIGEN "
4923 (p "[Positive input]: ") " "
4924 (p "[Negative input]: ") " param: "
4925 (p "<Start voltage>: " v0 'noinsert)
4926 (if (string-equal (tempo-lookup-named 'v0) "")
4927 (list 'l "V0=0.0") ;; default value
4928 (list 'l "V0=" '(s v0)))
4929 '(just-one-space)
4930 (p "<Voltage magnitude>: " v1 'noinsert)
4931 (if (string-equal (tempo-lookup-named 'v1) "")
4932 (list 'l "V1=5.0") ;; default value
4933 (list 'l "V1=" '(s v1)))
4934 '(just-one-space)
4935 (p "<First edge duration>: " rdu 'noinsert)
4936 (if (string-equal (tempo-lookup-named 'rdu) "")
4937 (list 'l "RDU=1e-4") ;; default value
4938 (list 'l "RDU=" '(s rdu)))
4939 '(just-one-space)
4940 (p "<Second edge duration>: " fdu 'noinsert)
4941 (if (string-equal (tempo-lookup-named 'fdu) "")
4942 (list 'l "FDU=1e-4") ;; default value
4943 (list 'l "FDU=" '(s fdu)))
4944 '(just-one-space)
4945 (p "<Delay>: " tdel 'noinsert)
4946 (if (string-equal (tempo-lookup-named 'tdel) "")
4947 (list 'l "TDEL=0.0") ;; default value
4948 (list 'l "TDEL=" '(s tdel)))
4950 "trigen"
4951 "template for inserting an ELDO triangular waveform generator"
4952 'spice-tempo-tags)
4954 (tempo-define-template
4955 "spice-eldo-amm"
4956 '("Y"
4957 (p "[Instance name]: ") " AMM "
4958 (p "[Positive input]: ") " "
4959 (p "[Negative input]: ") " "
4960 (p "[Positive Output]: ") " "
4961 (p "[Negative Output]: ") " param: "
4962 (p "<Level (1/2)>: " level 'noinsert)
4963 (if (string-equal (tempo-lookup-named 'level) "")
4964 (list 'l "LEVEL=1") ;; default value
4965 (list 'l "LEVEL=" '(s level)))
4966 '(just-one-space)
4967 (p "<Slewrate (V/µs)>: " slr 'noinsert)
4968 (if (string-equal (tempo-lookup-named 'slr) "")
4969 (list 'l "SLR=10") ;; default value
4970 (list 'l "SLR=" '(s slr)))
4971 '(just-one-space)
4972 (p "<Offset voltage>: " voff 'noinsert)
4973 (if (string-equal (tempo-lookup-named 'voff) "")
4974 (list 'l "VOFF=0.0") ;; default value
4975 (list 'l "VOFF=" '(s voff)))
4976 '(just-one-space)
4977 (p "<Carrier frequency>: " fc 'noinsert)
4978 (if (string-equal (tempo-lookup-named 'fc) "")
4979 (list 'l "FC=1e6") ;; default value
4980 (list 'l "FC=" '(s fc)))
4981 '(just-one-space)
4982 (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
4983 (if (string-equal (tempo-lookup-named 'nsam) "")
4984 (list 'l "NSAM=10") ;; default value
4985 (list 'l "NSAM=" '(s nsam)))
4987 "amm"
4988 "template for inserting an ELDO amplitude modulator"
4989 'spice-tempo-tags)
4991 (tempo-define-template
4992 "spice-eldo-pam"
4993 '("Y"
4994 (p "[Instance name]: ") " PAM "
4995 (p "[Positive input]: ") " "
4996 (p "[Negative input]: ") " "
4997 (p "[Positive Output]: ") " "
4998 (p "[Negative Output]: ") " param: "
4999 (p "<Level (1/2)>: " level 'noinsert)
5000 (if (string-equal (tempo-lookup-named 'level) "")
5001 (list 'l "LEVEL=1") ;; default value
5002 (list 'l "LEVEL=" '(s level)))
5003 '(just-one-space)
5004 (p "<Slewrate (V/µs)>: " slr 'noinsert)
5005 (if (string-equal (tempo-lookup-named 'slr) "")
5006 (list 'l "SLR=10") ;; default value
5007 (list 'l "SLR=" '(s slr)))
5008 '(just-one-space)
5009 (p "<Offset voltage>: " voff 'noinsert)
5010 (if (string-equal (tempo-lookup-named 'voff) "")
5011 (list 'l "VOFF=0.0") ;; default value
5012 (list 'l "VOFF=" '(s voff)))
5013 '(just-one-space)
5014 (p "<Carrier frequency>: " fc 'noinsert)
5015 (if (string-equal (tempo-lookup-named 'fc) "")
5016 (list 'l "FC=1e6") ;; default value
5017 (list 'l "FC=" '(s fc)))
5018 '(just-one-space)
5019 (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
5020 (if (string-equal (tempo-lookup-named 'nsam) "")
5021 (list 'l "NSAM=10") ;; default value
5022 (list 'l "NSAM=" '(s nsam)))
5024 "pam"
5025 "template for inserting an ELDO pulse amplitude modulator"
5026 'spice-tempo-tags)
5029 (tempo-define-template
5030 "spice-eldo-saho"
5031 '("Y"
5032 (p "[Instance name]: ") " SA_HO "
5033 (p "[Positive input]: ") " "
5034 (p "[Negative input]: ") " "
5035 (p "[Positive Output]: ") " "
5036 (p "[Negative Output]: ") " param: "
5037 (p "<Sampling frequency>: " fs 'noinsert)
5038 (if (string-equal (tempo-lookup-named 'fs) "")
5039 (list 'l "FS=1e6") ;; default value
5040 (list 'l "FS=" '(s fs)))
5041 '(just-one-space)
5042 (p "<Acquisition time>: " tacq 'noinsert)
5043 (if (string-equal (tempo-lookup-named 'tacq) "")
5044 (list 'l "TACQ=1e-9") ;; default value
5045 (list 'l "TACQ=" '(s tacq)))
5046 '(just-one-space)
5047 (p "<Droop voltage>: " dv 'noinsert)
5048 (if (string-equal (tempo-lookup-named 'dv) "")
5049 (list 'l "DV=20mv") ;; default value
5050 (list 'l "DV=" '(s dv)))
5051 '(just-one-space)
5053 "saho"
5054 "template for inserting an ELDO sample&hold"
5055 'spice-tempo-tags)
5057 (tempo-define-template
5058 "spice-eldo-trho"
5059 '("Y"
5060 (p "[Instance name]: ") " TR_HO "
5061 (p "[Positive input]: ") " "
5062 (p "[Negative input]: ") " "
5063 (p "[Positive Output]: ") " "
5064 (p "[Negative Output]: ") " "
5065 (p "[Controlling node]: ") " param: "
5066 (p "<Threshold voltage for CRT>: " vth 'noinsert)
5067 (if (string-equal (tempo-lookup-named 'vth) "")
5068 (list 'l "VTH=0.5") ;; default value
5069 (list 'l "VTH=" '(s vth)))
5070 '(just-one-space)
5071 (p "<Acquisition time>: " tacq 'noinsert)
5072 (if (string-equal (tempo-lookup-named 'tacq) "")
5073 (list 'l "TACQ=1e-9") ;; default value
5074 (list 'l "TACQ=" '(s tacq)))
5076 "trho"
5077 "template for inserting an ELDO track&hold"
5078 'spice-tempo-tags)
5081 (tempo-define-template
5082 "spice-eldo-peakd"
5083 '("Y"
5084 (p "[Instance name]: ") " PEAK_D "
5085 (p "[Positive input]: ") " "
5086 (p "[Negative input]: ") " "
5087 (p "[Positive Output]: ") " "
5088 (p "[Negative Output]: ") " "
5089 (p "[Controlling node]: ") " param: "
5090 (p "<Level (1/2)>: " level 'noinsert)
5091 (if (string-equal (tempo-lookup-named 'level) "")
5092 (list 'l "LEVEL=1") ;; default value
5093 (list 'l "LEVEL=2" ))
5094 '(just-one-space)
5095 (p "<Threshold voltage for CRT>: " vth 'noinsert)
5096 (if (string-equal (tempo-lookup-named 'vth) "")
5097 (list 'l "VTH=0.5") ;; default value
5098 (list 'l "VTH=" '(s vth)))
5099 '(just-one-space)
5100 (p "<Threshold voltage for reset on output>: " res 'noinsert)
5101 (if (string-equal (tempo-lookup-named 'res) "")
5102 (list 'l "RES=0.5") ;; default value
5103 (list 'l "RES=" '(s res)))
5104 '(just-one-space)
5105 (p "<Output slewrate (V/µs)>: " slr 'noinsert)
5106 (if (string-equal (tempo-lookup-named 'slr) "")
5107 (list 'l "SLR=1.0") ;; default value
5108 (list 'l "SLR=" '(s slr)))
5109 '(just-one-space)
5110 (p "<Output slewrate on reset>: " rslr 'noinsert)
5111 (if (string-equal (tempo-lookup-named 'rslr) "")
5112 (list 'l "RSLR=1.0") ;; default value
5113 (list 'l "RSLR=" '(s rslr)))
5115 "peakd"
5116 "template for inserting an ELDO peak detector"
5117 'spice-tempo-tags)
5120 (tempo-define-template
5121 "spice-eldo-levdso"
5122 '("Y"
5123 (p "[Instance name]: ") " LEV_D "
5124 (p "[Positive input]: ") " "
5125 (p "[Negative input]: ") " "
5126 (p "[Positive Output]: ") " "
5127 (p "[Negative Output]: ") " param: "
5128 (p "<Rise time (µs)>: " tr 'noinsert)
5129 (if (string-equal (tempo-lookup-named 'tr) "")
5130 (list 'l "TR=1.0") ;; default value
5131 (list 'l "TR=" '(s tr)))
5132 '(just-one-space)
5133 (p "<Fall time (µs)>: " tf 'noinsert)
5134 (if (string-equal (tempo-lookup-named 'tf) "")
5135 (list 'l "TF=1.0") ;; default value
5136 (list 'l "TF=" '(s tf)))
5137 '(just-one-space)
5138 (p "<Transit time (s)>: " tpd 'noinsert)
5139 (if (string-equal (tempo-lookup-named 'tpd) "")
5140 (list 'l "TPD=0.0") ;; default value
5141 (list 'l "TPD=" '(s tpd)))
5142 '(just-one-space)
5143 (p "<Lower voltage level>: " v0 'noinsert)
5144 (if (string-equal (tempo-lookup-named 'v0) "")
5145 (list 'l "V0=0.0") ;; default value
5146 (list 'l "V0=" '(s v0)))
5147 '(just-one-space)
5148 (p "<Higher voltage level>: " v1 'noinsert)
5149 (if (string-equal (tempo-lookup-named 'v1) "")
5150 (list 'l "V1=1.0") ;; default value
5151 (list 'l "V1=" '(s v1)))
5152 '(just-one-space)
5153 (p "<Input offset voltage>: " voff 'noinsert)
5154 (if (string-equal (tempo-lookup-named 'voff) "")
5155 (list 'l "VOFF=0.0") ;; default value
5156 (list 'l "VOFF=" '(s voff)))
5157 '(just-one-space)
5158 (p "<Lower reference voltage>: " vrl 'noinsert)
5159 (if (string-equal (tempo-lookup-named 'vrl) "")
5160 (list 'l "VRL=-0.1") ;; default value
5161 (list 'l "VRL=" '(s vrl)))
5162 '(just-one-space)
5163 (p "<Higher reference voltage>: " vru 'noinsert)
5164 (if (string-equal (tempo-lookup-named 'vru) "")
5165 (list 'l "VRU=0.1") ;; default value
5166 (list 'l "VRU=" '(s vru)))
5168 "levdso"
5169 "template for inserting an ELDO single-output level detector"
5170 'spice-tempo-tags)
5173 (tempo-define-template
5174 "spice-eldo-levddo"
5175 '("Y"
5176 (p "[Instance name]: ") " LEV_D "
5177 (p "[Positive input]: ") " "
5178 (p "[Negative input]: ") " "
5179 (p "[Positive Output]: ") " "
5180 (p "[Negative Output]: ") " "
5181 (p "[Reference node]: ") " param: "
5182 (p "<Rise time (µs)>: " tr 'noinsert)
5183 (if (string-equal (tempo-lookup-named 'tr) "")
5184 (list 'l "TR=1.0") ;; default value
5185 (list 'l "TR=" '(s tr)))
5186 '(just-one-space)
5187 (p "<Fall time (µs)>: " tf 'noinsert)
5188 (if (string-equal (tempo-lookup-named 'tf) "")
5189 (list 'l "TF=1.0") ;; default value
5190 (list 'l "TF=" '(s tf)))
5191 '(just-one-space)
5192 (p "<Transit time (s)>: " tpd 'noinsert)
5193 (if (string-equal (tempo-lookup-named 'tpd) "")
5194 (list 'l "TPD=0.0") ;; default value
5195 (list 'l "TPD=" '(s tpd)))
5196 '(just-one-space)
5197 (p "<Lower voltage level>: " v0 'noinsert)
5198 (if (string-equal (tempo-lookup-named 'v0) "")
5199 (list 'l "V0=0.0") ;; default value
5200 (list 'l "V0=" '(s v0)))
5201 '(just-one-space)
5202 (p "<Higher voltage level>: " v1 'noinsert)
5203 (if (string-equal (tempo-lookup-named 'v1) "")
5204 (list 'l "V1=1.0") ;; default value
5205 (list 'l "V1=" '(s v1)))
5206 '(just-one-space)
5207 (p "<Input offset voltage>: " voff 'noinsert)
5208 (if (string-equal (tempo-lookup-named 'voff) "")
5209 (list 'l "VOFF=0.0") ;; default value
5210 (list 'l "VOFF=" '(s voff)))
5211 '(just-one-space)
5212 (p "<Lower reference voltage>: " vrl 'noinsert)
5213 (if (string-equal (tempo-lookup-named 'vrl) "")
5214 (list 'l "VRL=-0.1") ;; default value
5215 (list 'l "VRL=" '(s vrl)))
5216 '(just-one-space)
5217 (p "<Higher reference voltage>: " vru 'noinsert)
5218 (if (string-equal (tempo-lookup-named 'vru) "")
5219 (list 'l "VRU=0.1") ;; default value
5220 (list 'l "VRU=" '(s vru)))
5222 "levddo"
5223 "template for inserting an ELDO differential-output level detector"
5224 'spice-tempo-tags)
5227 (tempo-define-template
5228 "spice-eldo-logamp"
5229 '("Y"
5230 (p "[Instance name]: ") " LOGAMP "
5231 (p "[Input]: ") " "
5232 (p "[Output]: ") " param: "
5233 (p "<Gain>: " gain 'noinsert)
5234 (if (string-equal (tempo-lookup-named 'gain) "")
5235 (list 'l "K=1.0") ;; default value
5236 (list 'l "K=" '(s gain)))
5237 '(just-one-space)
5238 (p "<Log function argument>: " e 'noinsert)
5239 (if (string-equal (tempo-lookup-named 'e) "")
5240 (list 'l "E=1") ;; default value
5241 (list 'l "E=" '(s vmin)))
5242 '(just-one-space)
5243 (p "<Vmax>: " vmax 'noinsert)
5244 (if (string-equal (tempo-lookup-named 'vmax) "")
5245 (list 'l "VMAX=5.0") ;; default value
5246 (list 'l "VMAX=" '(s vmax)))
5247 '(just-one-space)
5248 (p "<Vmin>: " vmin 'noinsert)
5249 (if (string-equal (tempo-lookup-named 'vmin) "")
5250 (list 'l "VMIN=-5.0") ;; default value
5251 (list 'l "VMIN=" '(s vmin)))
5252 '(just-one-space)
5253 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5254 (if (string-equal (tempo-lookup-named 'vsatp) "")
5255 (list 'l "VSATP=4.75") ;; default value
5256 (list 'l "VSATP=" '(s vsatp)))
5257 '(just-one-space)
5258 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5259 (if (string-equal (tempo-lookup-named 'vsatn) "")
5260 (list 'l "VSATN=-4.75") ;; default value
5261 (list 'l "VSATN=" '(s vsatn)))
5262 '(just-one-space)
5263 (p "<Slope at VSATP>: " pslope 'noinsert)
5264 (if (string-equal (tempo-lookup-named 'pslope) "")
5265 (list 'l "PSLOPE=0.25") ;; default value
5266 (list 'l "PSLOPE=" '(s pslope)))
5267 '(just-one-space)
5268 (p "<Slope at VSATN>: " nslope 'noinsert)
5269 (if (string-equal (tempo-lookup-named 'nslope) "")
5270 (list 'l "NSLOPE=0.25") ;; default value
5271 (list 'l "NSLOPE=" '(s nslope)))
5273 "logamp"
5274 "template for inserting an ELDO logarithmic amplifier"
5275 'spice-tempo-tags)
5277 (tempo-define-template
5278 "spice-eldo-antilog"
5279 '("Y"
5280 (p "[Instance name]: ") " EXPAMP "
5281 (p "[Input]: ") " "
5282 (p "[Output]: ") " param: "
5283 (p "<Gain>: " k 'noinsert)
5284 (if (string-equal (tempo-lookup-named 'k) "")
5285 (list 'l "K=1.0") ;; default value
5286 (list 'l "K=" '(s k)))
5287 '(just-one-space)
5288 (p "<Exp function argument>: " e 'noinsert)
5289 (if (string-equal (tempo-lookup-named 'e) "")
5290 (list 'l "E=1") ;; default value
5291 (list 'l "E=" '(s vmin)))
5292 '(just-one-space)
5293 (p "<Base of power function>: " base 'noinsert)
5294 (if (string-equal (tempo-lookup-named 'base) "")
5295 (list 'l "BASE={EXP(1)}") ;; default value
5296 (list 'l "BASE=" '(s base)))
5297 '(just-one-space)
5298 (p "<Vmax>: " vmax 'noinsert)
5299 (if (string-equal (tempo-lookup-named 'vmax) "")
5300 (list 'l "VMAX=5.0") ;; default value
5301 (list 'l "VMAX=" '(s vmax)))
5302 '(just-one-space)
5303 (p "<Vmin>: " vmin 'noinsert)
5304 (if (string-equal (tempo-lookup-named 'vmin) "")
5305 (list 'l "VMIN=-5.0") ;; default value
5306 (list 'l "VMIN=" '(s vmin)))
5307 '(just-one-space)
5308 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5309 (if (string-equal (tempo-lookup-named 'vsatp) "")
5310 (list 'l "VSATP=4.75") ;; default value
5311 (list 'l "VSATP=" '(s vsatp)))
5312 '(just-one-space)
5313 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5314 (if (string-equal (tempo-lookup-named 'vsatn) "")
5315 (list 'l "VSATN=-4.75") ;; default value
5316 (list 'l "VSATN=" '(s vsatn)))
5317 '(just-one-space)
5318 (p "<Slope at VSATP>: " pslope 'noinsert)
5319 (if (string-equal (tempo-lookup-named 'pslope) "")
5320 (list 'l "PSLOPE=0.25") ;; default value
5321 (list 'l "PSLOPE=" '(s pslope)))
5322 '(just-one-space)
5323 (p "<Slope at VSATN>: " nslope 'noinsert)
5324 (if (string-equal (tempo-lookup-named 'nslope) "")
5325 (list 'l "NSLOPE=0.25") ;; default value
5326 (list 'l "NSLOPE=" '(s nslope)))
5328 "expamp"
5329 "template for inserting an ELDO anti-logarithmic amplifier"
5330 'spice-tempo-tags)
5332 (tempo-define-template
5333 "spice-eldo-diff"
5334 '("Y"
5335 (p "[Instance name]: ") " DIFF "
5336 (p "[Input]: ") " "
5337 (p "[Output]: ") " param: "
5338 (p "<Time constant>: " k 'noinsert)
5339 (if (string-equal (tempo-lookup-named 'k) "")
5340 (list 'l "K=1") ;; default value
5341 (list 'l "K=" '(s k)))
5342 '(just-one-space)
5343 (p "<DC value>: " c0 'noinsert)
5344 (if (string-equal (tempo-lookup-named 'c0) "")
5345 (list 'l "C0=1") ;; default value
5346 (list 'l "C0=" '(s c0)))
5347 '(just-one-space)
5348 (p "<Slewrate (V/s)>: " slr 'noinsert)
5349 (if (string-equal (tempo-lookup-named 'slr) "")
5350 (list 'l "SLR=1e9") ;; default value
5351 (list 'l "SLR=" '(s slr)))
5353 "diff"
5354 "template for inserting an ELDO differentiator"
5355 'spice-tempo-tags)
5357 (tempo-define-template
5358 "spice-eldo-integ"
5359 '("Y"
5360 (p "[Instance name]: ") " INTEG "
5361 (p "[Input]: ") " "
5362 (p "[Output]: ") " param: "
5363 (p "<Time constant>: " k 'noinsert)
5364 (if (string-equal (tempo-lookup-named 'k) "")
5365 (list 'l "K=1") ;; default value
5366 (list 'l "K=" '(s k)))
5367 '(just-one-space)
5368 (p "<DC value>: " c0 'noinsert)
5369 (if (string-equal (tempo-lookup-named 'c0) "")
5370 (list 'l "C0=1") ;; default value
5371 (list 'l "C0=" '(s c0)))
5373 "integ"
5374 "template for inserting an ELDO integrator"
5375 'spice-tempo-tags)
5377 (tempo-define-template
5378 "spice-eldo-adder"
5379 '("Y"
5380 (p "[Instance name]: ") " "
5381 (p "<ADD/SUB/MULT/DIV>: ") " "
5382 (p "[Input 2]: ") " "
5383 (p "[Output]: ") " param: "
5384 (p "<Vmax>: " vmax 'noinsert)
5385 (if (string-equal (tempo-lookup-named 'vmax) "")
5386 (list 'l "VMAX=5.0") ;; default value
5387 (list 'l "VMAX=" '(s vmax)))
5388 '(just-one-space)
5389 (p "<Vmin>: " vmin 'noinsert)
5390 (if (string-equal (tempo-lookup-named 'vmin) "")
5391 (list 'l "VMIN=-5.0") ;; default value
5392 (list 'l "VMIN=" '(s vmin)))
5393 '(just-one-space)
5394 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5395 (if (string-equal (tempo-lookup-named 'vsatp) "")
5396 (list 'l "VSATP=4.75") ;; default value
5397 (list 'l "VSATP=" '(s vsatp)))
5398 '(just-one-space)
5399 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5400 (if (string-equal (tempo-lookup-named 'vsatn) "")
5401 (list 'l "VSATN=-4.75") ;; default value
5402 (list 'l "VSATN=" '(s vsatn)))
5403 '(just-one-space)
5404 (p "<Slope at VSATP>: " pslope 'noinsert)
5405 (if (string-equal (tempo-lookup-named 'pslope) "")
5406 (list 'l "PSLOPE=0.25") ;; default value
5407 (list 'l "PSLOPE=" '(s pslope)))
5408 '(just-one-space)
5409 (p "<Slope at VSATN>: " nslope 'noinsert)
5410 (if (string-equal (tempo-lookup-named 'nslope) "")
5411 (list 'l "NSLOPE=0.25") ;; default value
5412 (list 'l "NSLOPE=" '(s nslope)))
5414 "add"
5415 "template for inserting an ELDO adder/subtrator/multiplier/divider"
5416 'spice-tempo-tags)
5418 ;; -------------------
5419 ;; Digital Macromodels
5420 ;; -------------------
5422 (tempo-define-template
5423 "spice-eldo-inv"
5424 '("INV"
5425 (p "[Instance name]: ") " "
5426 (p "[First input]: ") " "
5427 (p "[Second input]: ") " "
5428 (p "[Output]: ") " "
5429 (p "[Model name]: ") " "
5430 (p "<Vhigh>: " vhi 'noinsert)
5431 (if (string-equal (tempo-lookup-named 'vhi) "")
5432 (list 'l "VHI=5.0") ;; default value
5433 (list 'l "VHI=" '(s vhi)))
5434 '(just-one-space)
5435 (p "<Vlow>: " vlo 'noinsert)
5436 (if (string-equal (tempo-lookup-named 'vlo) "")
5437 (list 'l "VLO=0.0") ;; default value
5438 (list 'l "VLO=" '(s vlo)))
5439 '(just-one-space)
5440 (p "<Threshold input voltage>: " vth 'noinsert)
5441 (if (string-equal (tempo-lookup-named 'vth) "")
5442 (list 'l "VTH=2.5") ;; default value
5443 (list 'l "VTH=" '(s vth)))
5444 '(just-one-space)
5445 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5446 (if (string-equal (tempo-lookup-named 'vthi) "")
5447 (list 'l "") ;; default value
5448 (list 'l "VTHI=" '(s vthi)))
5449 '(just-one-space)
5450 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5451 (if (string-equal (tempo-lookup-named 'vtlo) "")
5452 (list 'l "") ;; default value
5453 (list 'l "VTLO=" '(s vtlo)))
5454 '(just-one-space)
5455 (p "<Transit time>: " tpd 'noinsert)
5456 (if (string-equal (tempo-lookup-named 'tpd) "")
5457 (list 'l "TPD=1.0ns") ;; default value
5458 (list 'l "TPD=" '(s tpd)))
5459 '(just-one-space)
5460 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5461 (if (string-equal (tempo-lookup-named 'tpdup) "")
5462 (list 'l "") ;; default value
5463 (list 'l "TPDUP=" '(s tpdup)))
5464 '(just-one-space)
5465 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5466 (if (string-equal (tempo-lookup-named 'tpdown) "")
5467 (list 'l "") ;; default value
5468 (list 'l "TPDOWN=" '(s tpdown)))
5469 '(just-one-space)
5470 (p "<Input capacitance>: " cin 'noinsert)
5471 (if (string-equal (tempo-lookup-named 'cin) "")
5472 (list 'l "CIN=0.0") ;; default value
5473 (list 'l "CIN=" '(s cin)))
5474 '(just-one-space)
5476 "inv"
5477 "template for inserting an ELDO INVERTER gate macromodel"
5478 'spice-tempo-tags)
5480 (tempo-define-template
5481 "spice-eldo-xor"
5482 '("XOR"
5483 (p "[Instance name]: ") " "
5484 (p "[First input]: ") " "
5485 (p "[Second input]: ") " "
5486 (p "[Output]: ") " "
5487 (p "[Model name]: ") " "
5488 (p "<Vhigh>: " vhi 'noinsert)
5489 (if (string-equal (tempo-lookup-named 'vhi) "")
5490 (list 'l "VHI=5.0") ;; default value
5491 (list 'l "VHI=" '(s vhi)))
5492 '(just-one-space)
5493 (p "<Vlow>: " vlo 'noinsert)
5494 (if (string-equal (tempo-lookup-named 'vlo) "")
5495 (list 'l "VLO=0.0") ;; default value
5496 (list 'l "VLO=" '(s vlo)))
5497 '(just-one-space)
5498 (p "<Threshold input voltage>: " vth 'noinsert)
5499 (if (string-equal (tempo-lookup-named 'vth) "")
5500 (list 'l "VTH=2.5") ;; default value
5501 (list 'l "VTH=" '(s vth)))
5502 '(just-one-space)
5503 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5504 (if (string-equal (tempo-lookup-named 'vthi) "")
5505 (list 'l "") ;; default value
5506 (list 'l "VTHI=" '(s vthi)))
5507 '(just-one-space)
5508 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5509 (if (string-equal (tempo-lookup-named 'vtlo) "")
5510 (list 'l "") ;; default value
5511 (list 'l "VTLO=" '(s vtlo)))
5512 '(just-one-space)
5513 (p "<Transit time>: " tpd 'noinsert)
5514 (if (string-equal (tempo-lookup-named 'tpd) "")
5515 (list 'l "TPD=1.0ns") ;; default value
5516 (list 'l "TPD=" '(s tpd)))
5517 '(just-one-space)
5518 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5519 (if (string-equal (tempo-lookup-named 'tpdup) "")
5520 (list 'l "") ;; default value
5521 (list 'l "TPDUP=" '(s tpdup)))
5522 '(just-one-space)
5523 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5524 (if (string-equal (tempo-lookup-named 'tpdown) "")
5525 (list 'l "") ;; default value
5526 (list 'l "TPDOWN=" '(s tpdown)))
5527 '(just-one-space)
5528 (p "<Input capacitance>: " cin 'noinsert)
5529 (if (string-equal (tempo-lookup-named 'cin) "")
5530 (list 'l "CIN=0.0") ;; default value
5531 (list 'l "CIN=" '(s cin)))
5532 '(just-one-space)
5534 "xor"
5535 "template for inserting an ELDO Exclusive-OR gate macromodel"
5536 'spice-tempo-tags)
5538 (tempo-define-template
5539 "spice-eldo-and2"
5540 '("AND"
5541 (p "[Instance name]: ") " "
5542 (p "[First input]: ") " "
5543 (p "[Second input]: ") " "
5544 (p "[Output]: ") " "
5545 (p "[Model name]: ") " "
5546 (p "<Vhigh>: " vhi 'noinsert)
5547 (if (string-equal (tempo-lookup-named 'vhi) "")
5548 (list 'l "VHI=5.0") ;; default value
5549 (list 'l "VHI=" '(s vhi)))
5550 '(just-one-space)
5551 (p "<Vlow>: " vlo 'noinsert)
5552 (if (string-equal (tempo-lookup-named 'vlo) "")
5553 (list 'l "VLO=0.0") ;; default value
5554 (list 'l "VLO=" '(s vlo)))
5555 '(just-one-space)
5556 (p "<Threshold input voltage>: " vth 'noinsert)
5557 (if (string-equal (tempo-lookup-named 'vth) "")
5558 (list 'l "VTH=2.5") ;; default value
5559 (list 'l "VTH=" '(s vth)))
5560 '(just-one-space)
5561 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5562 (if (string-equal (tempo-lookup-named 'vthi) "")
5563 (list 'l "") ;; default value
5564 (list 'l "VTHI=" '(s vthi)))
5565 '(just-one-space)
5566 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5567 (if (string-equal (tempo-lookup-named 'vtlo) "")
5568 (list 'l "") ;; default value
5569 (list 'l "VTLO=" '(s vtlo)))
5570 '(just-one-space)
5571 (p "<Transit time>: " tpd 'noinsert)
5572 (if (string-equal (tempo-lookup-named 'tpd) "")
5573 (list 'l "TPD=1.0ns") ;; default value
5574 (list 'l "TPD=" '(s tpd)))
5575 '(just-one-space)
5576 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5577 (if (string-equal (tempo-lookup-named 'tpdup) "")
5578 (list 'l "") ;; default value
5579 (list 'l "TPDUP=" '(s tpdup)))
5580 '(just-one-space)
5581 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5582 (if (string-equal (tempo-lookup-named 'tpdown) "")
5583 (list 'l "") ;; default value
5584 (list 'l "TPDOWN=" '(s tpdown)))
5585 '(just-one-space)
5586 (p "<Input capacitance>: " cin 'noinsert)
5587 (if (string-equal (tempo-lookup-named 'cin) "")
5588 (list 'l "CIN=0.0") ;; default value
5589 (list 'l "CIN=" '(s cin)))
5590 '(just-one-space)
5592 "and"
5593 "template for inserting an ELDO 2 input AND gate macromodel"
5594 'spice-tempo-tags)
5597 (tempo-define-template
5598 "spice-eldo-nand2"
5599 '("NAND"
5600 (p "[Instance name]: ") " "
5601 (p "[First input]: ") " "
5602 (p "[Second input]: ") " "
5603 (p "[Output]: ") " "
5604 (p "[Model name]: ") " "
5605 (p "<Vhigh>: " vhi 'noinsert)
5606 (if (string-equal (tempo-lookup-named 'vhi) "")
5607 (list 'l "VHI=5.0") ;; default value
5608 (list 'l "VHI=" '(s vhi)))
5609 '(just-one-space)
5610 (p "<Vlow>: " vlo 'noinsert)
5611 (if (string-equal (tempo-lookup-named 'vlo) "")
5612 (list 'l "VLO=0.0") ;; default value
5613 (list 'l "VLO=" '(s vlo)))
5614 '(just-one-space)
5615 (p "<Threshold input voltage>: " vth 'noinsert)
5616 (if (string-equal (tempo-lookup-named 'vth) "")
5617 (list 'l "VTH=2.5") ;; default value
5618 (list 'l "VTH=" '(s vth)))
5619 '(just-one-space)
5620 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5621 (if (string-equal (tempo-lookup-named 'vthi) "")
5622 (list 'l "") ;; default value
5623 (list 'l "VTHI=" '(s vthi)))
5624 '(just-one-space)
5625 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5626 (if (string-equal (tempo-lookup-named 'vtlo) "")
5627 (list 'l "") ;; default value
5628 (list 'l "VTLO=" '(s vtlo)))
5629 '(just-one-space)
5630 (p "<Transit time>: " tpd 'noinsert)
5631 (if (string-equal (tempo-lookup-named 'tpd) "")
5632 (list 'l "TPD=1.0ns") ;; default value
5633 (list 'l "TPD=" '(s tpd)))
5634 '(just-one-space)
5635 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5636 (if (string-equal (tempo-lookup-named 'tpdup) "")
5637 (list 'l "") ;; default value
5638 (list 'l "TPDUP=" '(s tpdup)))
5639 '(just-one-space)
5640 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5641 (if (string-equal (tempo-lookup-named 'tpdown) "")
5642 (list 'l "") ;; default value
5643 (list 'l "TPDOWN=" '(s tpdown)))
5644 '(just-one-space)
5645 (p "<Input capacitance>: " cin 'noinsert)
5646 (if (string-equal (tempo-lookup-named 'cin) "")
5647 (list 'l "CIN=0.0") ;; default value
5648 (list 'l "CIN=" '(s cin)))
5649 '(just-one-space)
5651 "nand"
5652 "template for inserting an ELDO 2 input NAND gate macromodel"
5653 'spice-tempo-tags)
5655 (tempo-define-template
5656 "spice-eldo-or2"
5657 '("OR"
5658 (p "[Instance name]: ") " "
5659 (p "[First input]: ") " "
5660 (p "[Second input]: ") " "
5661 (p "[Output]: ") " "
5662 (p "[Model name]: ") " "
5663 (p "<Vhigh>: " vhi 'noinsert)
5664 (if (string-equal (tempo-lookup-named 'vhi) "")
5665 (list 'l "VHI=5.0") ;; default value
5666 (list 'l "VHI=" '(s vhi)))
5667 '(just-one-space)
5668 (p "<Vlow>: " vlo 'noinsert)
5669 (if (string-equal (tempo-lookup-named 'vlo) "")
5670 (list 'l "VLO=0.0") ;; default value
5671 (list 'l "VLO=" '(s vlo)))
5672 '(just-one-space)
5673 (p "<Threshold input voltage>: " vth 'noinsert)
5674 (if (string-equal (tempo-lookup-named 'vth) "")
5675 (list 'l "VTH=2.5") ;; default value
5676 (list 'l "VTH=" '(s vth)))
5677 '(just-one-space)
5678 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5679 (if (string-equal (tempo-lookup-named 'vthi) "")
5680 (list 'l "") ;; default value
5681 (list 'l "VTHI=" '(s vthi)))
5682 '(just-one-space)
5683 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5684 (if (string-equal (tempo-lookup-named 'vtlo) "")
5685 (list 'l "") ;; default value
5686 (list 'l "VTLO=" '(s vtlo)))
5687 '(just-one-space)
5688 (p "<Transit time>: " tpd 'noinsert)
5689 (if (string-equal (tempo-lookup-named 'tpd) "")
5690 (list 'l "TPD=1.0ns") ;; default value
5691 (list 'l "TPD=" '(s tpd)))
5692 '(just-one-space)
5693 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5694 (if (string-equal (tempo-lookup-named 'tpdup) "")
5695 (list 'l "") ;; default value
5696 (list 'l "TPDUP=" '(s tpdup)))
5697 '(just-one-space)
5698 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5699 (if (string-equal (tempo-lookup-named 'tpdown) "")
5700 (list 'l "") ;; default value
5701 (list 'l "TPDOWN=" '(s tpdown)))
5702 '(just-one-space)
5703 (p "<Input capacitance>: " cin 'noinsert)
5704 (if (string-equal (tempo-lookup-named 'cin) "")
5705 (list 'l "CIN=0.0") ;; default value
5706 (list 'l "CIN=" '(s cin)))
5707 '(just-one-space)
5709 "or"
5710 "template for inserting an ELDO 2 input OR gate macromodel"
5711 'spice-tempo-tags)
5713 (tempo-define-template
5714 "spice-eldo-nor2"
5715 '("NOR"
5716 (p "[Instance name]: ") " "
5717 (p "[First input]: ") " "
5718 (p "[Second input]: ") " "
5719 (p "[Output]: ") " "
5720 (p "[Model name]: ") " "
5721 (p "<Vhigh>: " vhi 'noinsert)
5722 (if (string-equal (tempo-lookup-named 'vhi) "")
5723 (list 'l "VHI=5.0") ;; default value
5724 (list 'l "VHI=" '(s vhi)))
5725 '(just-one-space)
5726 (p "<Vlow>: " vlo 'noinsert)
5727 (if (string-equal (tempo-lookup-named 'vlo) "")
5728 (list 'l "VLO=0.0") ;; default value
5729 (list 'l "VLO=" '(s vlo)))
5730 '(just-one-space)
5731 (p "<Threshold input voltage>: " vth 'noinsert)
5732 (if (string-equal (tempo-lookup-named 'vth) "")
5733 (list 'l "VTH=2.5") ;; default value
5734 (list 'l "VTH=" '(s vth)))
5735 '(just-one-space)
5736 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5737 (if (string-equal (tempo-lookup-named 'vthi) "")
5738 (list 'l "") ;; default value
5739 (list 'l "VTHI=" '(s vthi)))
5740 '(just-one-space)
5741 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5742 (if (string-equal (tempo-lookup-named 'vtlo) "")
5743 (list 'l "") ;; default value
5744 (list 'l "VTLO=" '(s vtlo)))
5745 '(just-one-space)
5746 (p "<Transit time>: " tpd 'noinsert)
5747 (if (string-equal (tempo-lookup-named 'tpd) "")
5748 (list 'l "TPD=1.0ns") ;; default value
5749 (list 'l "TPD=" '(s tpd)))
5750 '(just-one-space)
5751 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5752 (if (string-equal (tempo-lookup-named 'tpdup) "")
5753 (list 'l "") ;; default value
5754 (list 'l "TPDUP=" '(s tpdup)))
5755 '(just-one-space)
5756 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5757 (if (string-equal (tempo-lookup-named 'tpdown) "")
5758 (list 'l "") ;; default value
5759 (list 'l "TPDOWN=" '(s tpdown)))
5760 '(just-one-space)
5761 (p "<Input capacitance>: " cin 'noinsert)
5762 (if (string-equal (tempo-lookup-named 'cin) "")
5763 (list 'l "CIN=0.0") ;; default value
5764 (list 'l "CIN=" '(s cin)))
5765 '(just-one-space)
5767 "nor"
5768 "template for inserting an ELDO 2 input NOR gate macromodel"
5769 'spice-tempo-tags)
5772 (tempo-define-template
5773 "spice-eldo-and3"
5774 '("AND3"
5775 (p "[Instance name]: ") " "
5776 (p "[First input]: ") " "
5777 (p "[Second input]: ") " "
5778 (p "[Output]: ") " "
5779 (p "[Model name]: ") " "
5780 (p "<Vhigh>: " vhi 'noinsert)
5781 (if (string-equal (tempo-lookup-named 'vhi) "")
5782 (list 'l "VHI=5.0") ;; default value
5783 (list 'l "VHI=" '(s vhi)))
5784 '(just-one-space)
5785 (p "<Vlow>: " vlo 'noinsert)
5786 (if (string-equal (tempo-lookup-named 'vlo) "")
5787 (list 'l "VLO=0.0") ;; default value
5788 (list 'l "VLO=" '(s vlo)))
5789 '(just-one-space)
5790 (p "<Threshold input voltage>: " vth 'noinsert)
5791 (if (string-equal (tempo-lookup-named 'vth) "")
5792 (list 'l "VTH=2.5") ;; default value
5793 (list 'l "VTH=" '(s vth)))
5794 '(just-one-space)
5795 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5796 (if (string-equal (tempo-lookup-named 'vthi) "")
5797 (list 'l "") ;; default value
5798 (list 'l "VTHI=" '(s vthi)))
5799 '(just-one-space)
5800 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5801 (if (string-equal (tempo-lookup-named 'vtlo) "")
5802 (list 'l "") ;; default value
5803 (list 'l "VTLO=" '(s vtlo)))
5804 '(just-one-space)
5805 (p "<Transit time>: " tpd 'noinsert)
5806 (if (string-equal (tempo-lookup-named 'tpd) "")
5807 (list 'l "TPD=1.0ns") ;; default value
5808 (list 'l "TPD=" '(s tpd)))
5809 '(just-one-space)
5810 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5811 (if (string-equal (tempo-lookup-named 'tpdup) "")
5812 (list 'l "") ;; default value
5813 (list 'l "TPDUP=" '(s tpdup)))
5814 '(just-one-space)
5815 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5816 (if (string-equal (tempo-lookup-named 'tpdown) "")
5817 (list 'l "") ;; default value
5818 (list 'l "TPDOWN=" '(s tpdown)))
5819 '(just-one-space)
5820 (p "<Input capacitance>: " cin 'noinsert)
5821 (if (string-equal (tempo-lookup-named 'cin) "")
5822 (list 'l "CIN=0.0") ;; default value
5823 (list 'l "CIN=" '(s cin)))
5824 '(just-one-space)
5826 "and3"
5827 "template for inserting an ELDO 3 input AND gate macromodel"
5828 'spice-tempo-tags)
5831 (tempo-define-template
5832 "spice-eldo-nand3"
5833 '("NAND3"
5834 (p "[Instance name]: ") " "
5835 (p "[First input]: ") " "
5836 (p "[Second input]: ") " "
5837 (p "[Output]: ") " "
5838 (p "[Model name]: ") " "
5839 (p "<Vhigh>: " vhi 'noinsert)
5840 (if (string-equal (tempo-lookup-named 'vhi) "")
5841 (list 'l "VHI=5.0") ;; default value
5842 (list 'l "VHI=" '(s vhi)))
5843 '(just-one-space)
5844 (p "<Vlow>: " vlo 'noinsert)
5845 (if (string-equal (tempo-lookup-named 'vlo) "")
5846 (list 'l "VLO=0.0") ;; default value
5847 (list 'l "VLO=" '(s vlo)))
5848 '(just-one-space)
5849 (p "<Threshold input voltage>: " vth 'noinsert)
5850 (if (string-equal (tempo-lookup-named 'vth) "")
5851 (list 'l "VTH=2.5") ;; default value
5852 (list 'l "VTH=" '(s vth)))
5853 '(just-one-space)
5854 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5855 (if (string-equal (tempo-lookup-named 'vthi) "")
5856 (list 'l "") ;; default value
5857 (list 'l "VTHI=" '(s vthi)))
5858 '(just-one-space)
5859 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5860 (if (string-equal (tempo-lookup-named 'vtlo) "")
5861 (list 'l "") ;; default value
5862 (list 'l "VTLO=" '(s vtlo)))
5863 '(just-one-space)
5864 (p "<Transit time>: " tpd 'noinsert)
5865 (if (string-equal (tempo-lookup-named 'tpd) "")
5866 (list 'l "TPD=1.0ns") ;; default value
5867 (list 'l "TPD=" '(s tpd)))
5868 '(just-one-space)
5869 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5870 (if (string-equal (tempo-lookup-named 'tpdup) "")
5871 (list 'l "") ;; default value
5872 (list 'l "TPDUP=" '(s tpdup)))
5873 '(just-one-space)
5874 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5875 (if (string-equal (tempo-lookup-named 'tpdown) "")
5876 (list 'l "") ;; default value
5877 (list 'l "TPDOWN=" '(s tpdown)))
5878 '(just-one-space)
5879 (p "<Input capacitance>: " cin 'noinsert)
5880 (if (string-equal (tempo-lookup-named 'cin) "")
5881 (list 'l "CIN=0.0") ;; default value
5882 (list 'l "CIN=" '(s cin)))
5883 '(just-one-space)
5885 "nand3"
5886 "template for inserting an ELDO 3 input NAND gate macromodel"
5887 'spice-tempo-tags)
5889 (tempo-define-template
5890 "spice-eldo-or3"
5891 '("OR3"
5892 (p "[Instance name]: ") " "
5893 (p "[First input]: ") " "
5894 (p "[Second input]: ") " "
5895 (p "[Output]: ") " "
5896 (p "[Model name]: ") " "
5897 (p "<Vhigh>: " vhi 'noinsert)
5898 (if (string-equal (tempo-lookup-named 'vhi) "")
5899 (list 'l "VHI=5.0") ;; default value
5900 (list 'l "VHI=" '(s vhi)))
5901 '(just-one-space)
5902 (p "<Vlow>: " vlo 'noinsert)
5903 (if (string-equal (tempo-lookup-named 'vlo) "")
5904 (list 'l "VLO=0.0") ;; default value
5905 (list 'l "VLO=" '(s vlo)))
5906 '(just-one-space)
5907 (p "<Threshold input voltage>: " vth 'noinsert)
5908 (if (string-equal (tempo-lookup-named 'vth) "")
5909 (list 'l "VTH=2.5") ;; default value
5910 (list 'l "VTH=" '(s vth)))
5911 '(just-one-space)
5912 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5913 (if (string-equal (tempo-lookup-named 'vthi) "")
5914 (list 'l "") ;; default value
5915 (list 'l "VTHI=" '(s vthi)))
5916 '(just-one-space)
5917 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5918 (if (string-equal (tempo-lookup-named 'vtlo) "")
5919 (list 'l "") ;; default value
5920 (list 'l "VTLO=" '(s vtlo)))
5921 '(just-one-space)
5922 (p "<Transit time>: " tpd 'noinsert)
5923 (if (string-equal (tempo-lookup-named 'tpd) "")
5924 (list 'l "TPD=1.0ns") ;; default value
5925 (list 'l "TPD=" '(s tpd)))
5926 '(just-one-space)
5927 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5928 (if (string-equal (tempo-lookup-named 'tpdup) "")
5929 (list 'l "") ;; default value
5930 (list 'l "TPDUP=" '(s tpdup)))
5931 '(just-one-space)
5932 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5933 (if (string-equal (tempo-lookup-named 'tpdown) "")
5934 (list 'l "") ;; default value
5935 (list 'l "TPDOWN=" '(s tpdown)))
5936 '(just-one-space)
5937 (p "<Input capacitance>: " cin 'noinsert)
5938 (if (string-equal (tempo-lookup-named 'cin) "")
5939 (list 'l "CIN=0.0") ;; default value
5940 (list 'l "CIN=" '(s cin)))
5941 '(just-one-space)
5943 "or3"
5944 "template for inserting an ELDO 3 input OR gate macromodel"
5945 'spice-tempo-tags)
5947 (tempo-define-template
5948 "spice-eldo-nor3"
5949 '("NOR3"
5950 (p "[Instance name]: ") " "
5951 (p "[First input]: ") " "
5952 (p "[Second input]: ") " "
5953 (p "[Output]: ") " "
5954 (p "[Model name]: ") " "
5955 (p "<Vhigh>: " vhi 'noinsert)
5956 (if (string-equal (tempo-lookup-named 'vhi) "")
5957 (list 'l "VHI=5.0") ;; default value
5958 (list 'l "VHI=" '(s vhi)))
5959 '(just-one-space)
5960 (p "<Vlow>: " vlo 'noinsert)
5961 (if (string-equal (tempo-lookup-named 'vlo) "")
5962 (list 'l "VLO=0.0") ;; default value
5963 (list 'l "VLO=" '(s vlo)))
5964 '(just-one-space)
5965 (p "<Threshold input voltage>: " vth 'noinsert)
5966 (if (string-equal (tempo-lookup-named 'vth) "")
5967 (list 'l "VTH=2.5") ;; default value
5968 (list 'l "VTH=" '(s vth)))
5969 '(just-one-space)
5970 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5971 (if (string-equal (tempo-lookup-named 'vthi) "")
5972 (list 'l "") ;; default value
5973 (list 'l "VTHI=" '(s vthi)))
5974 '(just-one-space)
5975 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5976 (if (string-equal (tempo-lookup-named 'vtlo) "")
5977 (list 'l "") ;; default value
5978 (list 'l "VTLO=" '(s vtlo)))
5979 '(just-one-space)
5980 (p "<Transit time>: " tpd 'noinsert)
5981 (if (string-equal (tempo-lookup-named 'tpd) "")
5982 (list 'l "TPD=1.0ns") ;; default value
5983 (list 'l "TPD=" '(s tpd)))
5984 '(just-one-space)
5985 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5986 (if (string-equal (tempo-lookup-named 'tpdup) "")
5987 (list 'l "") ;; default value
5988 (list 'l "TPDUP=" '(s tpdup)))
5989 '(just-one-space)
5990 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5991 (if (string-equal (tempo-lookup-named 'tpdown) "")
5992 (list 'l "") ;; default value
5993 (list 'l "TPDOWN=" '(s tpdown)))
5994 '(just-one-space)
5995 (p "<Input capacitance>: " cin 'noinsert)
5996 (if (string-equal (tempo-lookup-named 'cin) "")
5997 (list 'l "CIN=0.0") ;; default value
5998 (list 'l "CIN=" '(s cin)))
5999 '(just-one-space)
6001 "nor3"
6002 "template for inserting an ELDO 3 input NOR gate macromodel"
6003 'spice-tempo-tags)
6005 ;; -------------------------
6006 ;; Mixed signal Macromodels
6007 ;; -------------------------
6009 (tempo-define-template
6010 "spice-eldo-adc"
6011 '("ADC"
6012 (p "[Instance name]: ") " "
6013 (p "[Clock]: ") " "
6014 (p "[Analog input]: ") " "
6015 (p "[Digital Outputs from MSB to LSB]: ") " "
6016 (p "<Edge (1/-1)>: " edge 'noinsert)
6017 (if (string-equal (tempo-lookup-named 'edge) "")
6018 (list 'l "EDGE=1") ;; default value
6019 (list 'l "EDGE=-1"))
6020 '(just-one-space)
6021 (p "<Threshold clock voltage>: " vth 'noinsert)
6022 (if (string-equal (tempo-lookup-named 'vth) "")
6023 (list 'l "VTH=2.5") ;; default value
6024 (list 'l "VTH=" '(s vth)))
6025 '(just-one-space)
6026 (p "<Vhigh>: " vhi 'noinsert)
6027 (if (string-equal (tempo-lookup-named 'vhi) "")
6028 (list 'l "VHI=5.0") ;; default value
6029 (list 'l "VHI=" '(s vhi)))
6030 '(just-one-space)
6031 (p "<Vlow>: " vlo 'noinsert)
6032 (if (string-equal (tempo-lookup-named 'vlo) "")
6033 (list 'l "VLO=0.0") ;; default value
6034 (list 'l "VLO=" '(s vlo)))
6035 '(just-one-space)
6036 (p "<Analog input lower voltage>: " vinf 'noinsert)
6037 (if (string-equal (tempo-lookup-named 'vinf) "")
6038 (list 'l "VINF=0.0") ;; default value
6039 (list 'l "VTHI=" '(s vinf)))
6040 '(just-one-space)
6041 (p "<Analog input higher voltage>: " vsup 'noinsert)
6042 (if (string-equal (tempo-lookup-named 'vsup) "")
6043 (list 'l "VSUP=5.0") ;; default value
6044 (list 'l "VSUP=" '(s vsup)))
6045 '(just-one-space)
6046 (p "<Output bits commutation time>: " tcom 'noinsert)
6047 (if (string-equal (tempo-lookup-named 'tcom) "")
6048 (list 'l "TCOM=1.0ns") ;; default value
6049 (list 'l "TCOM=" '(s tcom)))
6050 '(just-one-space)
6051 (p "<Transit time>: " tpd 'noinsert)
6052 (if (string-equal (tempo-lookup-named 'tpd) "")
6053 (list 'l "TPD=10ns") ;; default value
6054 (list 'l "TPD=" '(s tpd)))
6055 '(just-one-space)
6057 "adc"
6058 "template for inserting an ELDO Analog to Digital Converter macromodel"
6059 'spice-tempo-tags)
6061 (tempo-define-template
6062 "spice-eldo-dac"
6063 '("DAC"
6064 (p "[Instance name]: ") " "
6065 (p "[Clock]: ") " "
6066 (p "[Digital inputs from MSB to LSB]: ") " "
6067 (p "[Analog output]: ") " "
6068 (p "<Edge (1/-1)>: " edge 'noinsert)
6069 (if (string-equal (tempo-lookup-named 'edge) "")
6070 (list 'l "EDGE=1") ;; default value
6071 (list 'l "EDGE=-1"))
6072 '(just-one-space)
6073 (p "<Threshold clock voltage>: " vth 'noinsert)
6074 (if (string-equal (tempo-lookup-named 'vth) "")
6075 (list 'l "VTH=2.5") ;; default value
6076 (list 'l "VTH=" '(s vth)))
6077 '(just-one-space)
6078 (p "<Threshold input voltage>: " vtin 'noinsert)
6079 (if (string-equal (tempo-lookup-named 'vtin) "")
6080 (list 'l "VTIN=2.5") ;; default value
6081 (list 'l "VTIN=" '(s vtin)))
6082 '(just-one-space)
6083 (p "<Analog Output Vhigh>: " vhi 'noinsert)
6084 (if (string-equal (tempo-lookup-named 'vhi) "")
6085 (list 'l "VHI=5.0") ;; default value
6086 (list 'l "VHI=" '(s vhi)))
6087 '(just-one-space)
6088 (p "<Analog Output Vlow>: " vlo 'noinsert)
6089 (if (string-equal (tempo-lookup-named 'vlo) "")
6090 (list 'l "VLO=0.0") ;; default value
6091 (list 'l "VLO=" '(s vlo)))
6092 '(just-one-space)
6093 (p "<Transit time>: " tpd 'noinsert)
6094 (if (string-equal (tempo-lookup-named 'tpd) "")
6095 (list 'l "TPD=10ns") ;; default value
6096 (list 'l "TPD=" '(s tpd)))
6097 '(just-one-space)
6098 (p "<Output slope (V/s)>: " sl 'noinsert)
6099 (if (string-equal (tempo-lookup-named 'sl) "")
6100 (list 'l "SL=10e8") ;; default value
6101 (list 'l "SL=" '(s tcom)))
6102 '(just-one-space)
6104 "DAC"
6105 "template for inserting an ELDO Digital to Analog Converter macromodel"
6106 'spice-tempo-tags)
6108 ;; -------------------------
6109 ;; Switched cap Macromodels
6110 ;; -------------------------
6112 (tempo-define-template
6113 "spice-eldo-switchcap-opa"
6114 '("OPA"
6115 (p "[Instance name]: ") " "
6116 (p "[Positive input]: ") " "
6117 (p "[Negative input]: ") " "
6118 (p "[Positive Output]: ") " "
6119 (p "[Negative Output]: ") " "
6120 (p "[Model name]: ") " "
6121 (p "<Input offset>: " voff 'noinsert)
6122 (if (string-equal (tempo-lookup-named 'voff) "")
6123 (list 'l "VOFF=0.0") ;; default value
6124 (list 'l "VOFF=" '(s voff)))
6125 '(just-one-space)
6126 (p "<Slew rate (V/s)>: " sl 'noinsert)
6127 (if (string-equal (tempo-lookup-named 'sl) "")
6128 (list 'l "SL=1e6") ;; default value
6129 (list 'l "SL=" '(s voff)))
6130 '(just-one-space)
6131 (p "<Gain>: " gain 'noinsert)
6132 (if (string-equal (tempo-lookup-named 'gain) "")
6133 (list 'l "GAIN=1e5") ;; default value
6134 (list 'l "GAIN=" '(s gain)))
6135 '(just-one-space)
6136 (p "<Input capacitance>: " cin 'noinsert)
6137 (if (string-equal (tempo-lookup-named 'cin) "")
6138 (list 'l "CIN=0") ;; default value
6139 (list 'l "CIN=" '(s cin)))
6140 '(just-one-space)
6141 (p "<Output resistance>: " rs 'noinsert)
6142 (if (string-equal (tempo-lookup-named 'rs) "")
6143 (list 'l "RS=10e6") ;; default value
6144 (list 'l "RS=" '(s rs)))
6145 '(just-one-space)
6146 (p "<Symmetrical saturation voltage>: " vsat 'noinsert)
6147 (if (string-equal (tempo-lookup-named 'vsat) "")
6148 (list 'l "VSAT=5.0") ;; default value
6149 (list 'l "VSAT=" '(s vsat)))
6150 '(just-one-space)
6151 (p "<Asymmetrical saturation voltage>: " vsatm 'noinsert)
6152 (if (string-equal (tempo-lookup-named 'vsatm) "")
6153 (list 'l "VSATM=5.0") ;; default value
6154 (list 'l "VSATM=" '(s vsatm)))
6155 '(just-one-space)
6156 (p "<Cutoff frequency (double stage only)>: " fc 'noinsert)
6157 (if (string-equal (tempo-lookup-named 'fc) "")
6158 (list 'l "FC=1k") ;; default value
6159 (list 'l "FC=" '(s fc)))
6160 '(just-one-space)
6161 (p "<Non-dominant pole (single stage only)>: " fndp 'noinsert)
6162 (if (string-equal (tempo-lookup-named 'fndp) "")
6163 (list 'l "FNDP=1k") ;; default value
6164 (list 'l "FNDP=" '(s fndp)))
6165 '(just-one-space)
6166 (p "<Max current>: " imax 'noinsert)
6167 (if (string-equal (tempo-lookup-named 'imax) "")
6168 (list 'l "IMAX=100mA") ;; default value
6169 (list 'l "IMAX=" '(s imax)))
6170 '(just-one-space)
6171 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
6172 (if (string-equal (tempo-lookup-named 'cmrr) "")
6173 (list 'l "CMRR=0.0") ;; default value
6174 (list 'l "CMRR=" '(s cmrr)))
6176 "opa"
6177 "template for inserting an ELDO differential single or double stage opamp"
6178 'spice-tempo-tags
6181 (tempo-define-template
6182 "spice-eldo-switch"
6183 '("S"
6184 (p "[Instance name]: ") " "
6185 (p "[Controlling node]: ") " "
6186 (p "[Node 1]: ") " "
6187 (p "[Node 2]: ") " "
6188 (p "[Model name]: ") " "
6189 (p "<RON resistance>: " ron 'noinsert)
6190 (if (string-equal (tempo-lookup-named 'ron) "")
6191 (list 'l "RON=1k") ;; default value
6192 (list 'l "RON=" '(s ron)))
6193 '(just-one-space)
6194 (p "<Overlap capacitance>: " crec 'noinsert)
6195 (if (string-equal (tempo-lookup-named 'crec) "")
6196 (list 'l "CREC=0") ;; default value
6197 (list 'l "CREC=" '(s crec)))
6199 "switch"
6200 "template for inserting an ELDO switch macromodel"
6201 'spice-tempo-tags
6205 ;; Layla constructs
6207 (tempo-define-template
6208 "layla-port"
6209 '(".port "
6210 (p "[Name of port]: ") " "
6211 (p "[Name of net]: ") " "
6213 "layla-port"
6214 "template for inserting a Layla port"
6215 'spice-tempo-tags)
6217 (tempo-define-template
6218 "layla-performance"
6219 '(".performance "
6220 (p "[Name of performance]: ") " "
6221 (p "[Nominal value]: ") " \n+"
6222 (p "[Weight (alfa)]: ") " "
6223 ; (p "[Weight (alfa)]: ") " "
6225 "layla-performance"
6226 "template for inserting a Layla performance"
6227 'spice-tempo-tags)
6229 (tempo-define-template
6230 "layla-net"
6231 '(".net "
6232 (p "[Name of net]: ") " "
6234 "layla-net"
6235 "template for inserting a Layla net"
6236 'spice-tempo-tags)
6238 (tempo-define-template
6239 "layla-bus"
6240 '(".bus "
6241 (p "[Name of bus]: ") " "
6243 "layla-bus"
6244 "template for inserting a Layla bus"
6245 'spice-tempo-tags)
6247 (defmacro spice-layla-function-template (name type)
6248 "Create a layla tempo define for name and type"
6249 (` (let (p_prompt)
6250 (setq p_prompt (concat "[Name of " (, name) "]: "))
6251 (tempo-define-template
6252 (concat "layla-" (, name) "-" (, type))
6253 (list (concat "." (, name) "_" (, type) "_param(")
6254 (list 'p p_prompt) ", "
6255 '(p "[Name of parameter]: ") ", "
6256 '(p "[Value of parameter]: ") ")"
6258 (concat "layla-" (, name) "-" (, type))
6259 (concat "template for inserting a " (, type) " parameter for a Layla "
6260 (, name))
6261 'spice-tempo-tags))))
6263 (spice-layla-function-template "bus" "double")
6264 (spice-layla-function-template "bus" "integer")
6265 (spice-layla-function-template "bus" "string")
6266 (spice-layla-function-template "device" "double")
6267 (spice-layla-function-template "device" "integer")
6268 (spice-layla-function-template "device" "string")
6269 (spice-layla-function-template "net" "double")
6270 (spice-layla-function-template "net" "integer")
6271 (spice-layla-function-template "net" "string")
6272 (spice-layla-function-template "placement" "double")
6273 (spice-layla-function-template "placement" "integer")
6274 (spice-layla-function-template "placement" "string")
6275 (spice-layla-function-template "port" "double")
6276 (spice-layla-function-template "port" "integer")
6277 (spice-layla-function-template "port" "string")
6278 (spice-layla-function-template "symmetry" "double")
6279 (spice-layla-function-template "symmetry" "integer")
6280 (spice-layla-function-template "symmetry" "string")
6283 ;;------------------------------------------------------------
6284 ;; Abbrev hook bindings (taken from eldo-mode)
6286 (defvar spice-mode-abbrev-table nil
6287 "Abbrev table to use in `spice-mode' buffers.")
6289 ;; the table, global init inline here:
6290 (if spice-mode-abbrev-table
6292 (let ((ac abbrevs-changed))
6293 (define-abbrev-table 'spice-mode-abbrev-table ())
6294 ;; passive elements:
6296 ;; resistors
6297 (define-abbrev spice-mode-abbrev-table "r" "" 'tempo-template-spice-spice2g6-resistor)
6298 (define-abbrev spice-mode-abbrev-table "rss" "" 'tempo-template-spice-spice3-semiconductor-resistor)
6299 (define-abbrev spice-mode-abbrev-table "re" "" 'tempo-template-spice-eldo-resistor)
6300 (define-abbrev spice-mode-abbrev-table "ree" "" 'tempo-template-spice-eldo-expression-resistor)
6301 (define-abbrev spice-mode-abbrev-table "res" "" 'tempo-template-spice-eldo-semiconductor-resistor)
6302 (define-abbrev spice-mode-abbrev-table "rh" "" 'tempo-template-spice-hspice-resistor)
6303 (define-abbrev spice-mode-abbrev-table "rl" "" 'tempo-template-spice-layla-resistor)
6305 ;; capacitors
6306 (define-abbrev spice-mode-abbrev-table "c" "" 'tempo-template-spice-spice2g6-capacitor)
6307 (define-abbrev spice-mode-abbrev-table "css" "" 'tempo-template-spice-spice3-semiconductor-capacitor)
6308 (define-abbrev spice-mode-abbrev-table "ce" "" 'tempo-template-spice-eldo-capacitor)
6309 (define-abbrev spice-mode-abbrev-table "cee" "" 'tempo-template-spice-eldo-expression-capacitor)
6310 (define-abbrev spice-mode-abbrev-table "ch" "" 'tempo-template-spice-hspice-capacitor)
6311 (define-abbrev spice-mode-abbrev-table "cl" "" 'tempo-template-spice-layla-capacitor)
6313 ;; inductors
6314 (define-abbrev spice-mode-abbrev-table "l" "" 'tempo-template-spice-spice2g6-inductor)
6315 (define-abbrev spice-mode-abbrev-table "le" "" 'tempo-template-spice-eldo-inductor)
6316 (define-abbrev spice-mode-abbrev-table "lee" "" 'tempo-template-spice-eldo-expression-inductor)
6317 (define-abbrev spice-mode-abbrev-table "lh" "" 'tempo-template-spice-hspice-inductor)
6318 (define-abbrev spice-mode-abbrev-table "ll" "" 'tempo-template-spice-layla-inductor)
6320 ;; coupled inductors
6321 (define-abbrev spice-mode-abbrev-table "k" "" 'tempo-template-spice-spice2g6-coupled-inductors)
6323 ;; lossless transmission lines
6324 (define-abbrev spice-mode-abbrev-table "t" "" 'tempo-template-spice-spice2g6-lossless-transmission)
6325 (define-abbrev spice-mode-abbrev-table "te" "" 'tempo-template-spice-spice2g6-lossless-transmission)
6326 (define-abbrev spice-mode-abbrev-table "th" "" 'tempo-template-spice-hspice-lossless-transmission)
6328 ;; lossy transmission lines
6329 (define-abbrev spice-mode-abbrev-table "o" "" 'tempo-template-spice-spice2g6-lossy-transmission)
6330 ; spice3 rcline
6331 (define-abbrev spice-mode-abbrev-table "rcls" "" 'tempo-template-spice-spice3-rcline)
6332 ; eldo rc-line
6333 (define-abbrev spice-mode-abbrev-table "rcle" "" 'tempo-template-spice-eldo-rcline)
6334 ; eldo lossy transmission line
6335 ; not implemented
6337 ;; active elements:
6339 ;; diodes
6340 (define-abbrev spice-mode-abbrev-table "d" "" 'tempo-template-spice-spice2g6-diode)
6341 (define-abbrev spice-mode-abbrev-table "de" "" 'tempo-template-spice-eldo-diode)
6342 (define-abbrev spice-mode-abbrev-table "dh" "" 'tempo-template-spice-hspice-diode)
6343 (define-abbrev spice-mode-abbrev-table "dl" "" 'tempo-template-spice-layla-diode)
6345 ;; bipolars
6346 (define-abbrev spice-mode-abbrev-table "q" "" 'tempo-template-spice-spice2g6-bipolar)
6347 (define-abbrev spice-mode-abbrev-table "qe" "" 'tempo-template-spice-eldo-bipolar)
6348 (define-abbrev spice-mode-abbrev-table "qh" "" 'tempo-template-spice-hspice-bipolar)
6351 ;; jfets
6352 (define-abbrev spice-mode-abbrev-table "j" "" 'tempo-template-spice-spice2g6-jfet)
6353 (define-abbrev spice-mode-abbrev-table "je" "" 'tempo-template-spice-eldo-jfet)
6354 (define-abbrev spice-mode-abbrev-table "jh" "" 'tempo-template-spice-hspice-jfet)
6357 ;; mosfets
6358 (define-abbrev spice-mode-abbrev-table "m" "" 'tempo-template-spice-spice2g6-mosfet)
6359 (define-abbrev spice-mode-abbrev-table "me" "" 'tempo-template-spice-eldo-mosfet)
6360 (define-abbrev spice-mode-abbrev-table "mh" "" 'tempo-template-spice-hspice-mosfet)
6361 (define-abbrev spice-mode-abbrev-table "ml" "" 'tempo-template-spice-layla-mosfet)
6364 ;; mesfets
6365 (define-abbrev spice-mode-abbrev-table "z" "" 'tempo-template-spice-spice2g6-mesfet)
6367 ;; subcircuits
6368 (define-abbrev spice-mode-abbrev-table "sub" "" 'tempo-template-spice-spice2g6-subckt)
6370 ;; controlled sources
6371 (define-abbrev spice-mode-abbrev-table "vcvs" "" 'tempo-template-spice-spice2g6-vcvs)
6372 (define-abbrev spice-mode-abbrev-table "e" "" 'tempo-template-spice-spice2g6-vcvs)
6373 (define-abbrev spice-mode-abbrev-table "ccvs" "" 'tempo-template-spice-spice2g6-ccvs)
6374 (define-abbrev spice-mode-abbrev-table "h" "" 'tempo-template-spice-spice2g6-ccvs)
6375 (define-abbrev spice-mode-abbrev-table "vccs" "" 'tempo-template-spice-spice2g6-vccs)
6376 (define-abbrev spice-mode-abbrev-table "g" "" 'tempo-template-spice-spice2g6-vccs)
6377 (define-abbrev spice-mode-abbrev-table "cccs" "" 'tempo-template-spice-spice2g6-cccs)
6378 (define-abbrev spice-mode-abbrev-table "f" "" 'tempo-template-spice-spice2g6-cccs)
6380 ;; transient signals
6381 (define-abbrev spice-mode-abbrev-table "pwl" "" '(spice-pwl))
6382 (define-abbrev spice-mode-abbrev-table "pu" "" 'tempo-template-spice-pulse)
6383 ;(define-abbrev spice-mode-abbrev-table "'su" "" 'tempo-template-spice-subckt)
6384 ;(define-abbrev spice-mode-abbrev-table "'ac" "" 'tempo-template-spice-ac)
6385 (define-abbrev spice-mode-abbrev-table "sin" "" 'tempo-template-spice-sine)
6386 ;(define-abbrev spice-mode-abbrev-table "'sffm" "" 'tempo-template-spice-hspice-sffm)
6387 (define-abbrev spice-mode-abbrev-table "exp" "" 'tempo-template-spice-exp)
6388 (define-abbrev spice-mode-abbrev-table "noi" "" 'tempo-template-spice-eldo-noise)
6389 (define-abbrev spice-mode-abbrev-table "pat" "" 'tempo-template-spice-eldo-pattern)
6391 ;; behavioral models
6392 ;; eldo
6393 (define-abbrev spice-mode-abbrev-table "comp" "" 'tempo-template-spice-eldo-comp)
6394 (define-abbrev spice-mode-abbrev-table "compd" "" 'tempo-template-spice-eldo-compd)
6395 (define-abbrev spice-mode-abbrev-table "opa0" "" 'tempo-template-spice-eldo-linear-opa0)
6396 (define-abbrev spice-mode-abbrev-table "opa0d" "" 'tempo-template-spice-eldo-linear-opa0d)
6397 (define-abbrev spice-mode-abbrev-table "opa1" "" 'tempo-template-spice-eldo-linear-opa0)
6398 (define-abbrev spice-mode-abbrev-table "opa1d" "" 'tempo-template-spice-eldo-linear-opa0d)
6399 (define-abbrev spice-mode-abbrev-table "opa2" "" 'tempo-template-spice-eldo-linear-opa0)
6400 (define-abbrev spice-mode-abbrev-table "opa2d" "" 'tempo-template-spice-eldo-linear-opa0d)
6402 ;; extracts
6403 (define-abbrev spice-mode-abbrev-table "phmag" "" 'tempo-template-spice-eldo-phmag)
6404 (define-abbrev spice-mode-abbrev-table "gmag" "" 'tempo-template-spice-eldo-gmag)
6405 (define-abbrev spice-mode-abbrev-table "fc" "" 'tempo-template-spice-eldo-fc)
6406 (define-abbrev spice-mode-abbrev-table "ugfc" "" 'tempo-template-spice-eldo-ugfc)
6407 (define-abbrev spice-mode-abbrev-table "tf" "" 'tempo-template-spice-eldo-period)
6408 (define-abbrev spice-mode-abbrev-table "tfm" "" 'tempo-template-spice-eldo-period-macro)
6409 (define-abbrev spice-mode-abbrev-table "dc" "" 'tempo-template-spice-eldo-duty-macro)
6410 (define-abbrev spice-mode-abbrev-table "he" "" 'tempo-template-spice-eldo-circuit-header)
6411 (setq abbrevs-changed ac)))
6414 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6415 ;;; Menus
6416 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6418 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6419 ;; Spice menu (using `easy-menu.el')
6421 (defun spice-create-mode-menu ()
6422 "Create Spice Mode menu."
6423 (append
6424 (list
6425 "Spice"
6426 '("Edit"
6427 ["Comment Region" comment-region (and (mark) (not buffer-read-only))]
6428 ["Uncomment Region" spice-uncomment-region (and (mark) (not buffer-read-only))]
6429 ["Comment bar" (spice-comment-bar 't) (not buffer-read-only)]
6430 ["Fill Paragraph (Break Line)" fill-paragraph (not buffer-read-only)]
6431 ["Join line" spice-delete-indentation (not buffer-read-only)]
6432 "--"
6433 ["Fontify..." font-lock-fontify-buffer t]
6434 "--"
6435 ["(Re)activate File links..." spice-colorize-libraries-buffer t]
6436 ["Load include/lib files..." spice-load-include-files (assoc spice-imenu-libraries-submenu-name imenu--index-alist)]
6437 ["Load output file" spice-load-output-file (spice-output-file-p)]
6438 ["Unload all other spice files" spice-unload-other-decks t]
6439 "--"
6440 ["Replace with .guess stats" spice-replace-with-guess-statements (and (mark) (not buffer-read-only))]
6441 ["Replace with .nodeset stats" spice-replace-with-nodeset-statements (and (mark) (not buffer-read-only))]
6442 "--"
6443 ["Hide Comment Regions" spice-hide-all-comments (spice-hide-all-comments-p)]
6444 ["Unhide Comment Regions" spice-unhide-all-comments spice-some-comment-regions-are-hidden]
6445 "--"
6446 ["Search .subckt def" spice-search-subckt t]
6447 "--"
6448 ["Add Changelog Entry" spice-add-changelog-entry (not buffer-read-only)]
6450 (list
6451 "Simulate"
6452 ;; ["Simulate" compile t]
6453 ["Simulate" spice-compile (and buffer-file-name (not (spice-output-p)))]
6454 ["Stop Simulation" kill-compilation (condition-case ()
6455 (get-buffer-process
6456 (compilation-find-buffer))
6457 (error nil))]
6458 "--"
6459 ["Next Error..." spice-next-error t]
6460 ["Previous Error..." spice-previous-error t]
6461 "--"
6462 (append
6463 '("Simulator")
6464 ;; example code taken literally from vhdl-mode.el !
6465 ;; add menu entries for defined simulators
6466 (let ((simu-alist spice-simulator-alist) menu-alist name)
6467 (while simu-alist
6468 (setq name (car (car simu-alist)))
6469 (setq menu-alist (cons (vector name
6470 (list 'spice-set-simulator name)
6471 :style 'radio :selected
6472 ; (list 'equal 'spice-simulator name)
6473 (list 'equal '(spice-get-simulator) name)
6475 menu-alist))
6476 (setq simu-alist (cdr simu-alist)))
6477 (setq menu-alist
6478 (cons '["Add Simulator..."
6479 (customize-variable 'spice-simulator-alist) t]
6480 (cons "--" menu-alist)))
6481 (nreverse menu-alist))))
6482 (list
6483 "Waveform viewer"
6484 ["View" spice-run-waveform-viewer
6485 (and spice-waveform-viewer-alist-entry
6486 buffer-file-name)]
6487 ["Kill Waveform Viewer" spice-kill-waveform-viewer
6488 (condition-case ()
6489 (get-buffer-process
6490 (spice-waveform-buffer-name-function nil))
6491 (error nil))]
6492 "--"
6493 (append
6494 '("Waveform Viewer")
6495 ;; example code taken literally from vhdl-mode.el !
6496 ;; add menu entries for defined simulators
6497 (let ((wave-alist spice-waveform-viewer-alist) menu-alist name)
6498 (while wave-alist
6499 (setq name (car (car wave-alist)))
6500 (setq menu-alist (cons (vector name
6501 (list 'spice-set-waveform-viewer name)
6502 :style 'radio :selected
6503 ;(list 'equal 'spice-simulator name)
6504 (list 'equal
6505 '(spice-get-waveform-viewer)
6506 name))
6507 menu-alist))
6508 (setq wave-alist (cdr wave-alist)))
6509 (setq menu-alist
6510 (cons '["Add Waveform Viewer..."
6511 (customize-variable 'spice-waveform-viewer-alist) t]
6512 (cons "--" menu-alist)))
6513 (nreverse menu-alist))))
6514 "--"
6515 '("Passive Elements"
6516 ("Resistors"
6517 ["Spice2g6 Resistor" tempo-template-spice-spice2g6-resistor t]
6518 ["Spice3 Silicon Resistor" tempo-template-spice-spice3-semiconductor-resistor t]
6519 ["Eldo Resistor" tempo-template-spice-eldo-resistor (spice-standard-p 'eldo)]
6520 ["Eldo Expression Resistor" tempo-template-spice-eldo-expression-resistor (spice-standard-p 'eldo)]
6521 ["Eldo Silicon Resistor" tempo-template-spice-eldo-semiconductor-resistor (spice-standard-p 'eldo)]
6522 ["Hspice Resistor" tempo-template-spice-hspice-resistor (spice-standard-p 'hspice)]
6523 ["Layla Resistor" tempo-template-spice-layla-resistor (spice-standard-p 'layla)]
6525 ("Capacitors"
6526 ["Spice2g6 Capacitor" tempo-template-spice-spice2g6-capacitor t]
6527 ["Spice3 Silicon Capacitor" tempo-template-spice-spice3-semiconductor-capacitor t]
6528 ["Eldo Capacitor" tempo-template-spice-eldo-capacitor (spice-standard-p 'eldo)]
6529 ["Eldo Expression Capacitor" tempo-template-spice-eldo-expression-capacitor (spice-standard-p 'eldo)]
6530 ["Hspice Capacitor" tempo-template-spice-hspice-capacitor (spice-standard-p 'hspice)]
6531 ["Layla Capacitor" tempo-template-spice-layla-capacitor (spice-standard-p 'layla)]
6533 ("Inductors"
6534 ["Spice2g6 Inductor" tempo-template-spice-spice2g6-inductor t]
6535 ["Spice2g6 Coupled Inductors" tempo-template-spice-spice2g6-coupled-inductors t]
6536 ["Eldo Inductor" tempo-template-spice-eldo-inductor (spice-standard-p 'eldo)]
6537 ["Eldo Expression Inductor" tempo-template-spice-eldo-expression-inductor (spice-standard-p 'eldo)]
6538 ["Hspice Inductor" tempo-template-spice-hspice-inductor (spice-standard-p 'hspice)]
6539 ["Layla Inductor" tempo-template-spice-layla-inductor (spice-standard-p 'layla)]
6541 ("Transmission lines"
6542 ["Spice2g6 Lossless" tempo-template-spice-spice2g6-lossless-transmission t]
6543 ["Eldo Lossless" tempo-template-spice-eldo-lossless-transmission (spice-standard-p 'eldo)]
6544 ["Hspice Lossless" tempo-template-spice-hspice-lossless-transmission (spice-standard-p 'hspice)]
6545 ["Spice2g6 Lossy" tempo-template-spice-spice2g6-lossy-transmission t]
6546 ["Spice3 RC line" tempo-template-spice-spice3-rcline t]
6547 ["Eldo RC line" tempo-template-spice-eldo-rcline (spice-standard-p 'eldo)]
6550 '("Active Elements"
6551 ("Diodes"
6552 ["Spice2g6 Diode" tempo-template-spice-spice2g6-diode t]
6553 ["Eldo Diode" tempo-template-spice-eldo-diode (spice-standard-p 'eldo)]
6554 ["Hspice Diode" tempo-template-spice-hspice-diode (spice-standard-p 'hspice)]
6555 ["Layla Diode" tempo-template-spice-layla-diode (spice-standard-p 'layla)]
6557 ("Bipolars"
6558 ["Spice2g6 Bipolar" tempo-template-spice-spice2g6-bipolar t]
6559 ["Eldo Bipolar" tempo-template-spice-eldo-bipolar (spice-standard-p 'eldo)]
6560 ["Hspice Bipolar" tempo-template-spice-hspice-bipolar (spice-standard-p 'hspice)]
6562 ("Jfets & Mesfets"
6563 ["Spice2g6 Jfet" tempo-template-spice-spice2g6-jfet t]
6564 ["Spice2g6 Mesfet" tempo-template-spice-spice2g6-mesfet t]
6565 ["Eldo Jfet" tempo-template-spice-eldo-jfet (spice-standard-p 'eldo)]
6566 ["Hspice Jfet" tempo-template-spice-hspice-jfet (spice-standard-p 'hspice)]
6568 ("Mosfets"
6569 ["Spice2g6 Mosfet" tempo-template-spice-spice2g6-mosfet t]
6570 ["Eldo Mosfet" tempo-template-spice-eldo-mosfet (spice-standard-p 'eldo)]
6571 ["Hspice Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'hspice)]
6572 ["Layla Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'layla)]
6575 '("Controlled Sources"
6576 ["Spice2g6 VCVS" tempo-template-spice-spice2g6-vcvs t]
6577 ["Spice2g6 CCVS" tempo-template-spice-spice2g6-ccvs t]
6578 ["Spice2g6 VCCS" tempo-template-spice-spice2g6-vccs t]
6579 ["Spice2g6 CCCS" tempo-template-spice-spice2g6-ccvs t]
6581 '("Waveforms"
6582 ["PWL" (spice-pwl) t]
6583 ["pulse" tempo-template-spice-pulse t]
6584 ; ["ac" tempo-template-eldo-ac t]
6585 ["sine" tempo-template-spice-sine t]
6586 ["exp" tempo-template-spice-exp t]
6587 ["hspice sffm" tempo-template-spice-hspice-sffm (spice-standard-p 'hspice)]
6588 ["hspice am" tempo-template-spice-hspice-am (spice-standard-p 'hspice)]
6589 ["eldo pattern" tempo-template-spice-eldo-pattern (spice-standard-p 'eldo)]
6590 ["eldo noise" tempo-template-spice-eldo-noise (spice-standard-p 'eldo)]
6591 ["eldoRF four" tempo-template-spice-eldorf-four (spice-standard-p 'eldorf)]
6592 ["eldoRF fpulse" tempo-template-spice-eldorf-fpulse (spice-standard-p 'eldorf)]
6594 "--"
6595 '("Eldo Macromodels"
6596 ("Analog"
6597 ["SO Comparator" tempo-template-spice-eldo-comp (spice-standard-p 'eldo)]
6598 ["DO Comparator" tempo-template-spice-eldo-compd (spice-standard-p 'eldo)]
6599 ["SO Linear Opamp" tempo-template-spice-eldo-linear-opa0 (spice-standard-p 'eldo)]
6600 ["DO Linear Opamp" tempo-template-spice-eldo-linear-opa0d (spice-standard-p 'eldo)]
6601 ["SO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1 (spice-standard-p 'eldo)]
6602 ["DO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1d (spice-standard-p 'eldo)]
6603 ["SO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2 (spice-standard-p 'eldo)]
6604 ["DO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2d (spice-standard-p 'eldo)]
6605 ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
6606 ["Saturating Resistor" tempo-template-spice-eldo-satr (spice-standard-p 'eldo)]
6607 ["Voltage Limiter" tempo-template-spice-eldo-satv (spice-standard-p 'eldo)]
6608 ["Voltage cont. switch" tempo-template-spice-eldo-vswitch (spice-standard-p 'eldo)]
6609 ["Current cont. switch" tempo-template-spice-eldo-cswitch (spice-standard-p 'eldo)]
6610 ["Triangular to sine converter" tempo-template-spice-eldo-tri2sin (spice-standard-p 'eldo)]
6611 ["Staircase generator" tempo-template-spice-eldo-stairgen (spice-standard-p 'eldo)]
6612 ["Sawtooth generator" tempo-template-spice-eldo-sawgen (spice-standard-p 'eldo)]
6613 ["Triangle generator" tempo-template-spice-eldo-trigen (spice-standard-p 'eldo)]
6614 ["Amplitude modulator" tempo-template-spice-eldo-amm (spice-standard-p 'eldo)]
6615 ["Pulse amplitude modulator" tempo-template-spice-eldo-pam (spice-standard-p 'eldo)]
6616 ["Sample&Hold" tempo-template-spice-eldo-saho (spice-standard-p 'eldo)]
6617 ["Track&Hold" tempo-template-spice-eldo-trho (spice-standard-p 'eldo)]
6618 ["Peak Detector" tempo-template-spice-eldo-peakd (spice-standard-p 'eldo)]
6619 ["SO Level Detector" tempo-template-spice-eldo-levdso (spice-standard-p 'eldo)]
6620 ["DO Level Detector" tempo-template-spice-eldo-levddo (spice-standard-p 'eldo)]
6621 ["Log Amplifier" tempo-template-spice-eldo-logamp (spice-standard-p 'eldo)]
6622 ["Antilog Amplifier" tempo-template-spice-eldo-antilog (spice-standard-p 'eldo)]
6623 ["Differentiator" tempo-template-spice-eldo-diff (spice-standard-p 'eldo)]
6624 ["Integrator" tempo-template-spice-eldo-integ (spice-standard-p 'eldo)]
6625 ["Add/Sub/Mult/Div" tempo-template-spice-eldo-adder (spice-standard-p 'eldo)]
6627 ("Digital"
6628 ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
6629 ["Inverter" tempo-template-spice-eldo-inv (spice-standard-p 'eldo)]
6630 ["XOR gate" tempo-template-spice-eldo-xor (spice-standard-p 'eldo)]
6631 ["2 input AND gate" tempo-template-spice-eldo-and2 (spice-standard-p 'eldo)]
6632 ["2 input NAND gate" tempo-template-spice-eldo-nand2 (spice-standard-p 'eldo)]
6633 ["2 input OR gate" tempo-template-spice-eldo-or2 (spice-standard-p 'eldo)]
6634 ["2 input NOR gate" tempo-template-spice-eldo-nor2 (spice-standard-p 'eldo)]
6635 ["3 input AND gate" tempo-template-spice-eldo-and3 (spice-standard-p 'eldo)]
6636 ["3 input NAND gate" tempo-template-spice-eldo-nand3 (spice-standard-p 'eldo)]
6637 ["3 input OR gate" tempo-template-spice-eldo-or3 (spice-standard-p 'eldo)]
6638 ["3 input NOR gate" tempo-template-spice-eldo-nor3 (spice-standard-p 'eldo)]
6640 ("Mixed Signal"
6641 ["AD Converter" tempo-template-spice-eldo-adc (spice-standard-p 'eldo)]
6642 ["DA Converter" tempo-template-spice-eldo-dac (spice-standard-p 'eldo)]
6644 ("Switched Cap"
6645 ["Opamp" tempo-template-spice-eldo-switchcap-opa (spice-standard-p 'eldo)]
6646 ["Switch" tempo-template-spice-eldo-switch (spice-standard-p 'eldo)]
6649 "--"
6650 '("Layla Objects"
6651 ["Port" tempo-template-layla-port (spice-standard-p 'layla)]
6652 ["Performance" tempo-template-layla-performance (spice-standard-p 'layla)]
6653 ["Net" tempo-template-layla-net (spice-standard-p 'layla)]
6654 ["Bus" tempo-template-layla-bus (spice-standard-p 'layla)]
6655 ; ["ac" tempo-template-eldo-ac t]
6657 '("Layla Properties"
6658 ("Port"
6659 ["Port double" tempo-template-layla-port-double (spice-standard-p 'layla)]
6660 ["Port integer" tempo-template-layla-port-integer (spice-standard-p 'layla)]
6661 ["Port string" tempo-template-layla-port-string (spice-standard-p 'layla)]
6663 ("Placement"
6664 ["Placement double" tempo-template-layla-placement-double (spice-standard-p 'layla)]
6665 ["Placement integer" tempo-template-layla-placement-integer (spice-standard-p 'layla)]
6666 ["Placement string" tempo-template-layla-placement-string (spice-standard-p 'layla)]
6668 ("Symmetry"
6669 ["Symmetry double" tempo-template-layla-symmetry-double (spice-standard-p 'layla)]
6670 ["Symmetry integer" tempo-template-layla-symmetry-integer (spice-standard-p 'layla)]
6671 ["Symmetry string" tempo-template-layla-symmetry-string (spice-standard-p 'layla)]
6673 ("Net"
6674 ["Net double" tempo-template-layla-net-double (spice-standard-p 'layla)]
6675 ["Net integer" tempo-template-layla-net-integer (spice-standard-p 'layla)]
6676 ["Net string" tempo-template-layla-net-string (spice-standard-p 'layla)]
6678 ("Device"
6679 ["Device double" tempo-template-layla-device-double (spice-standard-p 'layla)]
6680 ["Device integer" tempo-template-layla-device-integer (spice-standard-p 'layla)]
6681 ["Device string" tempo-template-layla-device-string (spice-standard-p 'layla)]
6683 ("Bus"
6684 ["Bus double" tempo-template-layla-bus-double (spice-standard-p 'layla)]
6685 ["Bus integer" tempo-template-layla-bus-integer (spice-standard-p 'layla)]
6686 ["Bus string" tempo-template-layla-bus-string (spice-standard-p 'layla)]
6689 "--"
6690 (append
6691 '("Goto Section")
6692 (let ((section-alist spice-section-alist) menu-alist name str)
6693 (setq menu-alist
6694 (cons "--"
6695 (cons '["Changelog"
6696 (spice-goto-section "changelog")
6697 ; (setq menu-sec (current-time))
6698 (spice-cache-section-p "changelog")
6699 ] menu-alist)))
6700 (while section-alist
6701 (setq name (car (car section-alist)))
6702 (setq str (downcase (car (cdr (car section-alist)))))
6703 (setq menu-alist (cons (vector name
6704 (list 'spice-goto-section str)
6705 (list 'spice-section-p str)
6707 menu-alist))
6708 (setq section-alist (cdr section-alist)))
6709 (setq menu-alist
6710 (cons '["Specify..."
6711 spice-goto-section t]
6712 (cons "--" menu-alist)))
6713 (nreverse menu-alist))
6715 (append
6716 '("Add Section Header")
6717 (let ((section-alist spice-section-alist) menu-alist name str)
6718 (setq menu-alist
6719 (cons "--"
6720 (cons '["Changelog"
6721 (spice-add-section "Changelog")
6722 (not (spice-section-p "changelog"))] menu-alist)))
6723 (while section-alist
6724 (setq name (car (car section-alist)))
6725 (setq str (car (cdr (car section-alist))))
6726 (setq menu-alist (cons (vector name
6727 (list 'spice-add-section str)
6728 (list 'not (list 'spice-section-p (downcase str)))
6730 menu-alist))
6731 (setq section-alist (cdr section-alist)))
6732 (setq menu-alist
6733 (cons '["Specify..."
6734 spice-add-section t]
6735 (cons "--" menu-alist)))
6736 (nreverse menu-alist))
6739 (spice-common-menu-tail-entries))
6743 (defun spice-create-output-mode-menu ()
6744 "Create Spice-output Mode menu."
6745 (append
6746 (list
6747 "Spice-output"
6748 '("Edit"
6749 ["Fontify..." font-lock-fontify-buffer t]
6750 "--"
6751 ["Unload all other spice files" spice-unload-other-decks t]
6752 "--"
6753 ["Create <name>_guess.cir file" (spice-create-guess-nodeset-file "guess") (spice-output-p)]
6754 ["Create <name>_nodeset.cir file" (spice-create-guess-nodeset-file "nodeset") (spice-output-p)]
6757 (spice-common-menu-tail-entries))
6761 (defun spice-common-menu-tail-entries ()
6762 "Creat Common Spice and Spice-output Mode menu entries."
6763 (list
6764 "--"
6765 ;; customize sub menu
6766 '("Customize"
6767 ["Browse Spice Group" (customize-browse 'spice) t]
6768 ["Spice Standard" (customize-variable 'spice-standard) t]
6769 ["Spice Faces" (customize-group 'spice-faces) t]
6770 ["Section Header list" (customize-variable 'spice-section-alist) t]
6771 ;; "--"
6772 ;; ["Activate Customizations in Buffer" spice-activate-customizations t]
6773 ;; (not (equal spice-standard-local spice-standard))]
6775 ;; settings sub menu
6776 (append '("Settings")
6777 (when (fboundp 'speedbar)
6778 (list '["Speedbar" speedbar-frame-mode
6779 :style toggle
6780 :selected (and (boundp 'speedbar-frame)
6781 (frame-live-p speedbar-frame)
6782 (frame-visible-p speedbar-frame))]))
6783 (list
6784 '["Abbrevs" abbrev-mode :style toggle :selected abbrev-mode]
6785 '["List abbrevs" list-abbrevs abbrev-mode]
6786 '["Auto fill" auto-fill-mode :style toggle
6787 :selected auto-fill-function]))
6788 "--"
6789 ["About Spice-Mode" spice-about t]
6794 (defvar spice-menu-list nil
6795 "Spice Mode menu.") ; global variable
6797 (defvar spice-output-menu-list nil
6798 "Spice-output Mode menu.") ; global variable
6800 (require 'easymenu)
6802 (defun spice-menu-init ()
6803 "Initializes global vars for Spice menu's"
6804 (setq spice-menu-list (spice-create-mode-menu))
6805 (setq spice-output-menu-list (spice-create-output-mode-menu))
6808 (defun spice-update-mode-menu ()
6809 "Updates Spice mode menu for current buffer." ; assumes globals have
6810 ; been updated
6811 (interactive)
6812 (if (spice-output-p)
6813 (progn
6814 (easy-menu-remove spice-output-menu-list) ; for XEmacs
6815 ;; (setq spice-output-menu-list (spice-create-output-mode-menu))
6816 (easy-menu-add spice-output-menu-list) ; for XEmacs
6817 (easy-menu-define spice-output-menu spice-output-mode-map
6818 "Menu keymap for Spice-output Mode." spice-output-menu-list))
6819 (easy-menu-remove spice-menu-list) ; for XEmacs
6820 ;; (setq spice-menu-list (spice-create-mode-menu))
6821 (easy-menu-add spice-menu-list) ; for XEmacs
6822 (easy-menu-define spice-menu spice-mode-map
6823 "Menu keymap for Spice Mode." spice-menu-list)))
6826 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6827 ;; spice mode syntax table
6829 (defvar spice-mode-syntax-table nil
6830 "Syntax table used in spice-mode buffers.")
6832 (defun spice-mode-syntax-table-init ()
6833 "initialize syntax table from scratch."
6834 (setq spice-mode-syntax-table (make-syntax-table))
6835 (modify-syntax-entry ?$ "w" spice-mode-syntax-table)
6836 (modify-syntax-entry ?! "w" spice-mode-syntax-table)
6837 (modify-syntax-entry ?* "w" spice-mode-syntax-table) ; not < !!!!
6838 (if (spice-standard-p 'eldo)
6839 (progn (modify-syntax-entry ?# "w 13" spice-mode-syntax-table)
6840 (modify-syntax-entry ?c "w 2" spice-mode-syntax-table)
6841 (modify-syntax-entry ?e "w 4" spice-mode-syntax-table)))
6842 ;; (modify-syntax-entry ?\n "> b" spice-mode-syntax-table) ;; no no, comments are handled by spice-mode, not by syntax-table !!!
6843 (modify-syntax-entry ?\n "." spice-mode-syntax-table) ;; make it punctuation ?
6844 (modify-syntax-entry ?\" "\"" spice-mode-syntax-table) ;; font-lock prob
6845 ;; (modify-syntax-entry ?\" "w" spice-mode-syntax-table)
6846 (modify-syntax-entry ?. "w" spice-mode-syntax-table)
6847 (modify-syntax-entry ?, "w" spice-mode-syntax-table)
6848 (modify-syntax-entry ?_ "w" spice-mode-syntax-table)
6849 (modify-syntax-entry ?@ "w" spice-mode-syntax-table)
6850 (modify-syntax-entry ?/ "w" spice-mode-syntax-table)
6851 ;; (modify-syntax-entry ?< "(>" spice-mode-syntax-table) ; can be in symbols
6852 ;; (modify-syntax-entry ?> ")<" spice-mode-syntax-table) ; can be in symbols
6853 ;; (modify-syntax-entry ?+ "w" spice-mode-syntax-table) ; can be in expr
6854 ;; (modify-syntax-entry ?- "w" spice-mode-syntax-table) ; can be in expr
6855 ;; (modify-syntax-entry ?= "." spice-mode-syntax-table) ; can be in expr
6860 ;;; speedbar stuff
6863 (eval-and-compile
6864 (when (fboundp 'speedbar)
6866 (require 'speedbar)
6868 (defun spice-speedbar-init ()
6869 "Initialize speedbar."
6870 ;; general settings, depends on auto-mode-alist, so should be
6871 ;; called every time auto-mode-alist is modified (set
6872 ;; (make-local-variable 'speedbar-tag-hierarchy-method) nil)
6873 ;; SPICE file extensions (extracted from `auto-mode-alist')
6874 (let ((mode-alist auto-mode-alist))
6875 (while mode-alist
6876 (when (eq (cdr (car mode-alist)) 'spice-mode)
6877 (speedbar-add-supported-extension (car (car mode-alist))))
6878 (setq mode-alist (cdr mode-alist)))))
6881 (defun spice-speedbar (&optional arg)
6882 "Open/close speedbar."
6883 (interactive)
6884 (if (not (fboundp 'speedbar))
6885 (error "WARNING: Speedbar is only available in newer Emacs versions")
6886 (condition-case () ; due to bug in `speedbar-el' v0.7.2a
6887 (speedbar-frame-mode arg)
6888 (error "WARNING: Install included `speedbar.el' patch first"))))
6892 ;;; speedbar end
6895 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6896 ;;; Imenu: S-mouse3 in emacs to find spice objects quickly (xemacs ?)
6897 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6899 (require 'imenu)
6901 (defvar spice-imenu-generic-expression nil
6902 "Imenu generic expression for spice mode. See `imenu-generic-expression'.")
6904 (defconst spice-imenu-end-submenu-name "*End*"
6905 "label of End submenu in imenu")
6907 (defconst spice-imenu-libraries-submenu-name "*Libraries*"
6908 "label of Libraries submenu in imenu")
6910 (defun spice-imenu-init ()
6911 "initialize imenu generic expression and pass to imenu"
6912 (setq spice-imenu-generic-expression
6913 (append
6914 (list
6915 (list spice-imenu-end-submenu-name
6916 (concat
6918 "\\.\\(end\\)\\>"
6919 ) 1))
6920 (when (spice-standard-p 'layla)
6921 (list
6922 (list "*Nets*" (concat
6923 "^\\*?"
6924 "[\.]\\(net\\)\\s-+"
6925 "\\([a-z0-9]\\w*\\)\\>"
6926 ) 2)
6927 (list "*Ports*"
6928 (concat
6929 "^\\*?"
6930 "\\.\\(port\\)\\s-+"
6931 "\\([a-z0-9]\\w*\\)\\>"
6932 ) 2)
6933 (list "*Performances*"
6934 (concat
6935 "^\\*?"
6936 "\\.\\(performance\\)\\s-+"
6937 "\\([a-z]\\w*\\)\\>"
6938 ) 2)) ; list
6940 (list
6941 (list
6942 "*Misc*"
6943 (concat
6944 "^\\s-*\\.model\\s-+" spice-model-name spice-line-break
6945 "\\s-+\\("
6946 (regexp-opt spice-misc-model-type-names)
6947 "\\)\\>" )
6949 (list
6950 "*Diodes*"
6951 (concat "^\\s-*\\.model\\s-+" spice-model-name
6952 spice-line-break "\\s-+d\\>")
6954 (list
6955 "*Bipolars*"
6956 (concat "^\\s-*\\.model\\s-+" spice-model-name
6957 spice-line-break "\\s-+\\(npn\\|pnp\\)\\>")
6959 (list
6960 "*Mosfets*"
6961 (concat "^\\s-*\\.model\\s-+" spice-model-name
6962 spice-line-break "\\s-+\\(n\\|p\\)mos\\>")
6964 (list spice-imenu-libraries-submenu-name
6965 (concat spice-library-regexp-start
6966 spice-library-regexp-end)
6968 (list
6969 "*Analyses*"
6970 (concat "^\\s-*\\.\\("
6971 (regexp-opt spice-analyses)
6972 "\\)\\>")
6974 (list "*Sections*"
6975 spice-section-headings-regexp 2)
6976 (list nil
6977 (concat
6978 "^\\.\\(subckt\\s-+"
6979 (when (spice-standard-p 'eldo)
6980 "\\(lib\\s-+[^ \t\n]+\\s-+\\)?")
6981 "\\|macro\\s-+\\)"
6982 "\\([a-z]\\w*\\)\\>"
6983 ) (if (spice-standard-p 'eldo) 3 2))
6988 ;; ======================================================================
6989 ;; Support for compilation (simulation) - doesn't work 100% currently
6990 ;; and probably never will ...
6991 ;; ======================================================================
6993 (defun spice-simulation-buffer-name-function (arg)
6994 "Derives unique spice simulation buffer for simulator output"
6995 (concat "*Spice-simulation-" (buffer-name) "*"))
6998 (defun spice-get-simulator ()
6999 "Make an educated guess on what simulator a user likely wants to use"
7000 (if (and spice-simulator
7001 (assoc spice-simulator spice-simulator-alist))
7002 spice-simulator ;; is specified by user, take his choice
7003 (if (spice-standard-p 'eldo) "Eldo" ;; eldo
7004 (if (spice-standard-p 'hspice) "Hspice" ;; Hspice
7005 "Spice3")))) ;; fallback Spice3
7008 (defun spice-set-simulator-command ()
7009 (interactive)
7010 (setq compile-command
7011 (let ((commands-alist spice-simulator-alist)
7012 command)
7013 (while commands-alist
7014 (when (equal (spice-get-simulator) (nth 0 (car commands-alist)))
7015 (setq command
7016 (concat
7017 (nth 1 (car commands-alist)) " "
7018 spice-simulator-switches
7019 (unless
7020 (string-equal spice-simulator-switches "") " ")
7021 (file-name-nondirectory (if buffer-file-name
7022 buffer-file-name ""))
7023 (unless
7024 (string-equal (nth 2 (car commands-alist)) "") " ")
7025 (nth 2 (car commands-alist))
7027 (setq commands-alist (cdr commands-alist)))
7028 command)))
7030 (defun spice-set-simulator (name)
7031 (setq spice-simulator name)
7032 (spice-set-simulator-command))
7034 (require 'compile)
7036 (defvar spice-compilation-error-regexp-alist nil)
7037 (defvar spice-compilation-file-regexp-alist nil)
7039 (defun spice-compile ()
7040 "spice wrapper function for compile."
7041 (interactive)
7042 (spice-set-simulator-command)
7043 (call-interactively 'compile nil)
7046 (defun spice-compile-variables-init ()
7047 "build variable lists."
7048 (setq spice-compilation-error-regexp-alist
7049 (let ((commands-alist spice-simulator-alist)
7050 regexp-alist sublist)
7051 (while commands-alist
7052 (setq sublist (nth 3 (car commands-alist)))
7053 (unless (equal "" (car sublist))
7054 (setq regexp-alist
7055 (cons (append
7056 (list (nth 0 sublist)
7057 (if (= 0 (nth 1 sublist))
7058 (if spice-running-xemacs 9 nil)
7059 (nth 1 sublist))
7060 (if (numberp (nth 2 sublist))
7061 (nth 2 sublist)
7062 (if spice-running-xemacs 0
7063 (nth 2 sublist))))
7064 (list (nth 3 sublist))
7065 (if (nth 4 sublist)
7066 (if (stringp (nth 4 sublist))
7067 (list (nth 4 sublist))
7068 (list (eval (nth 4 sublist))))))
7069 regexp-alist)))
7070 (setq commands-alist (cdr commands-alist)))
7071 regexp-alist))
7072 ; (message "setting compilation file regexps command")
7073 (setq spice-compilation-file-regexp-alist
7074 (let ((commands-alist spice-simulator-alist)
7075 regexp-alist)
7076 (while commands-alist
7077 (unless (equal "" (car (nth 4 (car commands-alist))))
7078 (setq regexp-alist
7079 (append regexp-alist
7080 (list (nth 4 (car commands-alist))))))
7081 (setq commands-alist (cdr commands-alist)))
7082 regexp-alist))
7086 (defun spice-compile-init ()
7087 "Initialize for simulation(/compilation)."
7089 ;;------------------------------------------------------------
7090 ;; use Eldo/Hspice as compiler, on current buffer
7091 (make-local-variable 'compile-command)
7092 (make-local-variable 'compilation-read-command)
7093 (make-local-variable 'compilation-buffer-name-function)
7094 (make-local-variable 'compilation-error-regexp-alist)
7095 (make-local-variable 'compilation-file-regexp-alist)
7097 (setq compilation-read-command 't)
7098 (setq compilation-buffer-name-function
7099 'spice-simulation-buffer-name-function)
7101 ; (message "setting compilation error regexps command")
7102 (setq compilation-error-regexp-alist spice-compilation-error-regexp-alist
7103 compilation-file-regexp-alist spice-compilation-file-regexp-alist)
7107 (defvar spice-column 1
7108 "global variable to do column hack. Why ? Compile.el requires that
7109 every error is 'special', ie. different from the previous one. This is
7110 either the file is different, the line number is different or the column
7111 number is different. Prob: the file is always the same, the simulator
7112 guys never output the file name of the file that is being read, so that
7113 one doesn't change; the line number can not be found either; the column
7114 number is same problem; Solution: always take line number one, then take
7115 the column number 1 or 2 alternatingly, remember previous value here !
7117 This is ugly, I know, but it's the only way I could think of to find
7118 the errors in the simulation buffer with compile.el")
7121 (defun spice-linenum (f c)
7122 ;(message (format "calling linenum fun '%s'" f))
7123 (save-excursion
7124 (set-buffer compilation-last-buffer)
7125 ;(message (format "buffer '%s'" (buffer-name)))
7127 (list (point-marker) f 1 (if (= spice-column 1)
7128 (setq spice-column 2)
7129 (setq spice-column 1))))
7132 (defun spice-next-error (n)
7133 "Move point to the next error in the compilation buffer.
7134 Does NOT find the source line like \\[next-error] does, is defined
7135 in spice-mode since many simulators don't output errors with source line
7136 numbers included, so finding the error is still difficult."
7137 (interactive "p")
7138 (save-excursion
7139 (let (prev-buffer)
7140 (setq prev-buffer (buffer-name))
7141 (pop-to-buffer compilation-last-buffer)
7142 (compilation-next-error n)
7143 (recenter)
7144 (pop-to-buffer prev-buffer))))
7147 (defun spice-previous-error (n)
7148 "Move point to the previous error in the compilation buffer.
7149 Does NOT find the source line like \\[next-error] does, is defined
7150 in spice-mode since many simulators don't output errors with source line
7151 numbers included, so finding the error is still difficult."
7152 (interactive "p")
7153 (save-excursion
7154 (let (prev-buffer)
7155 (setq prev-buffer (buffer-name))
7156 (pop-to-buffer compilation-last-buffer)
7157 (compilation-previous-error n)
7158 (recenter)
7159 (pop-to-buffer prev-buffer))))
7162 ;;------------------------------------------------------------
7163 ;; Waveform viewer support
7164 ;;------------------------------------------------------------
7165 ;; This is work in progress; (user) interface might change
7167 (defun spice-waveform-buffer-name-function (arg)
7168 "check running process"
7169 (let ((name (if arg arg (buffer-name))))
7170 (concat "*Spice-waveform-" name "*")))
7173 (defun spice-set-waveform-viewer (name)
7174 (setq spice-waveform-viewer name)
7175 (spice-set-waveform-viewer-command))
7177 (defun spice-get-waveform-viewer ()
7178 "Make an educated guess on what waveform viewer a user likely would want"
7179 (if (and spice-waveform-viewer
7180 (assoc spice-waveform-viewer spice-waveform-viewer-alist))
7181 spice-waveform-viewer ;; is specified by user, take his choice
7182 (if (spice-standard-p 'eldo) "Xelga" ;; eldo's viewer is xelga
7183 (if (spice-standard-p 'hspice) "Awaves" ;; Hspice's viewer is awaves
7184 "Nutmeg")))) ;; fallback Spice3's viewer nutmeg ...
7187 (defun spice-waveform-viewer-derive-filename (arg)
7188 "Derive from the buffer file name the name of a derived file. If ARG is
7189 a string, it is a suffix to replace the buffer's suffix, if ARG is a list
7190 , , if ARG is a function, the function is called without arguments and it
7191 should return the derived filename, if ARG is nil, nil is returned, if ARG
7192 is t, the filename itself is returned unmodified."
7193 (cond ((stringp arg)
7194 (concat (file-name-sans-extension buffer-file-name) arg))
7195 ((listp arg)
7196 (let ((alist arg)
7197 filename)
7198 ;(message alist)
7199 (while alist
7200 (message (concat (file-name-sans-extension buffer-file-name) (car alist)))
7201 (setq
7202 filename
7203 (concat (file-name-sans-extension buffer-file-name) (car alist)))
7204 (setq alist (cdr alist)))
7205 filename))
7206 ((functionp arg)
7207 (funcall arg))
7208 (nil
7209 nil) ;; nil if nil ...
7211 buffer-file-name) ;; fallback if t ...
7215 (defvar spice-waveform-viewer-command ""
7216 "variable containing buffer local waveform viewer command")
7218 (defvar spice-waveform-viewer-filename nil
7219 "variable filename field of waveform viewer structure")
7221 (defvar spice-waveform-viewer-alist-entry nil
7222 "variable holding selected entry of waveform viewer")
7224 (defvar spice-waveform-viewer-read-command t
7225 "variable containing boolean indicating reading of buffer local waveform viewer command")
7227 (defvar spice-after-start-process-function nil
7228 "variable containing after start process function")
7230 (defun spice-set-waveform-viewer-command ()
7231 (interactive)
7232 (setq spice-waveform-viewer-alist-entry nil)
7233 (let ((commands-alist spice-waveform-viewer-alist))
7234 (while commands-alist
7235 (when (equal (spice-get-waveform-viewer)
7236 (nth 0 (car commands-alist)))
7237 (setq spice-waveform-viewer-alist-entry (car commands-alist))
7239 (setq commands-alist (cdr commands-alist)))))
7242 (defun spice-waveform-viewer-init ()
7243 "Initialize for waveform viewer."
7245 ;;------------------------------------------------------------
7246 (make-local-variable 'spice-waveform-viewer-command)
7247 (make-local-variable 'spice-waveform-viewer-read-command)
7248 (make-local-variable 'spice-waveform-viewer-filename)
7249 (make-local-variable 'spice-waveform-viewer-alist-entry)
7250 (make-local-variable 'spice-after-start-process-function)
7252 (setq spice-waveform-viewer-read-command 't)
7254 (spice-set-waveform-viewer-command))
7257 (defun spice-run-waveform-viewer ()
7258 "run the waveform viewer if it is not yet running."
7259 (interactive)
7260 (if (not buffer-file-name)
7261 (message "Can not run waveform viewer on unsaved file-less buffers.")
7262 (let (name command file)
7263 (setq name (nth 0 spice-waveform-viewer-alist-entry)
7264 command (concat (nth 1 spice-waveform-viewer-alist-entry)
7266 (nth 2 spice-waveform-viewer-alist-entry)
7268 (spice-waveform-viewer-derive-filename
7269 (nth 4 spice-waveform-viewer-alist-entry)))
7270 file (buffer-name))
7271 (spice-process-check file)
7272 (message "Starting waveform viewer %s" name)
7273 (funcall (nth 3 spice-waveform-viewer-alist-entry) name command file))
7274 ) ; if (else part)
7278 (defun spice-master-directory ()
7279 "Directory of master file."
7280 (abbreviate-file-name
7281 (expand-file-name
7282 (file-name-directory (buffer-file-name)))))
7285 (defun spice-run-silent (name command file)
7286 "Start process with (optional) second argument."
7287 (let ((dir (spice-master-directory)))
7288 (set-buffer (get-buffer-create "*spice silent*"))
7289 (erase-buffer)
7290 (if dir (cd dir))
7291 ; (message "cd to %s" dir)
7292 (let ((process (start-process (concat name " silent")
7293 (current-buffer) ; can be nil
7294 spice-shell
7295 spice-shell-command-option
7296 command)))
7297 (message "started %s" command)
7298 (if spice-after-start-process-function
7299 (funcall spice-after-start-process-function process))
7300 (process-kill-without-query process))))
7302 (defun spice-run-interactive (name command file)
7303 "Run waveform viewer interactively.
7304 Run command in a buffer (in comint-shell-mode) so that it accepts user
7305 interaction."
7306 (require 'comint)
7307 (let (; (default spice-command-default)
7308 (buffer (spice-waveform-buffer-name-function file))
7309 (process nil)
7310 (dir (spice-master-directory)))
7311 (spice-process-check file) ; Check that no process is running
7312 ; (setq spice-command-buffer (current-buffer))
7313 (with-output-to-temp-buffer buffer)
7314 (set-buffer buffer)
7315 (setq buffer-read-only nil)
7316 (if dir (cd dir))
7317 (insert "Running `" name "' on `" file "' with ``" command "''\n")
7318 (comint-exec buffer name spice-shell nil
7319 (list spice-shell-command-option command))
7320 (comint-mode)
7321 (setq mode-name name)
7322 ; (setq spice-command-default default)
7323 (setq process (get-buffer-process buffer))
7324 (if spice-after-start-process-function
7325 (funcall spice-after-start-process-function process))
7326 ; (spice-command-mode-line process) ; mode line setting
7327 ; (set-process-sentinel process 'spice-command-sentinel)
7328 (set-marker (process-mark process) (point-max))
7329 ;;; (setq compilation-in-progress (cons process compilation-in-progress))
7330 ; (spice-parse-reset)
7331 ; (setq spice-parse-function 'spice-parse-spice)
7332 ; (setq spice-sentinel-function 'spice-LaTeX-sentinel)
7335 (defun spice-command-mode-line (process)
7336 "Format the mode line for a buffer containing output from PROCESS."
7337 (setq mode-line-process (concat ": "
7338 (symbol-name (process-status process))))
7339 (set-buffer-modified-p (buffer-modified-p)))
7341 (defun spice-process-check (name)
7342 "Check if a process for the spice deck NAME already exist.
7343 If so, give the user the choice of aborting the process or the current
7344 command."
7345 (let ((process (get-buffer-process
7346 (spice-waveform-buffer-name-function name))))
7347 ; (message "checking %s for running process" (spice-waveform-buffer-name-function name))
7348 (cond ((null process))
7349 ((not (eq (process-status process) 'run)))
7350 ((yes-or-no-p (concat "Process `"
7351 (process-name process)
7352 "' for deck `"
7353 name
7354 "' running, kill it? "))
7355 (delete-process process))
7357 (error "Cannot have two processes for the spice deck")))))
7360 ;; ---- setting commands ?
7362 (defun spice-set-command ()
7363 "Sets both simulator an waveform viewer commands for current buffer."
7364 (interactive)
7365 (spice-set-simulator-command)
7366 (spice-set-waveform-viewer-command)
7370 ;;------------------------------------------------------------
7371 ;; File initialization support, code taken from eldo-mode and
7372 ;; modified/extended
7373 ;;------------------------------------------------------------
7375 ;; initialize empty file:
7376 (defun spice-initialize-empty-file ()
7377 "Create a standard template for a new/empty file.
7379 This is the default initialization function. If the user has specified
7380 an initialization function, by setting
7381 `spice-initialize-file-function', the user-specified function is
7382 called instead. This function first checks for the template file
7383 specified in `spice-initialization-file' which is inserted and a default
7384 changelog entry is added. If this file isn't readable, a default
7385 template is inserted depending on the submode (eldo, hspice or layla)
7386 that has been selected."
7387 (interactive "*") ; read-only check
7388 (if (file-readable-p spice-initialize-template-file) ;; template file
7389 (insert-file-contents spice-initialize-template-file)
7390 ;; this has been taken from eldo-mode and thus only applies if
7391 ;; eldo is selected
7392 (if (spice-standard-p 'eldo)
7393 (progn
7394 (insert
7395 (concat "# " (buffer-name) " "
7396 "\n.notrc\n.nocom"
7397 "\n\n"
7398 spice-default-header
7399 "\n\n"))
7400 (spice-add-section "LIBRARIES")
7401 (insert "\n\n\n")
7402 (spice-add-section "SIMULATION OPTIONS")
7403 (insert
7404 (concat "\n\n"
7405 ".options STAT=1 SIMUDIV=10 !Status reports\n"
7406 ".options noascii nomod \n"
7407 ".options eps=1e-7 itol=1e-6 gmin=1e-16 analog \n"
7408 ".options nobound_phase"
7409 ".width out=80 \n"
7410 ".temp=27 \n"
7411 "\n\n\n"))
7412 (spice-add-section "SUPPLIES/REFERENCES")
7413 (insert "\n\n.END\n\n\n\n")
7414 (spice-add-section "Changelog")
7415 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7417 (if (spice-standard-p 'hspice) ;; hspice specific options
7418 (progn
7419 (insert
7420 (concat "* " (buffer-name) " "
7421 "\n\n"
7422 spice-default-header
7423 "\n\n"))
7424 (spice-add-section "LIBRARIES")
7425 (insert "\n\n\n")
7426 (spice-add-section "SIMULATION OPTIONS")
7427 (insert
7428 (concat "\n\n"
7429 ".options nomod nopage opts \n"
7430 ".options itl1=5000 itl2=2500 itl3=20 itl4=20 itl5=0 \n"
7431 ".options numdgt=10 $ print 10 digits in output \n"
7432 ".width out=80 \n"
7433 ".temp=27 \n"
7434 "\n\n\n"))
7435 (spice-add-section "SUPPLIES/REFERENCES")
7436 (insert "\n\n.end\n\n\n\n")
7437 (spice-add-section "Changelog")
7438 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7440 (if (spice-standard-p 'layla) ;; layla specific options
7441 (progn
7442 (insert
7443 (concat "* " (buffer-name) " "
7444 "\n"
7445 spice-default-header
7446 "\n\n"))
7447 (spice-add-section "MAIN CIRCUIT")
7448 (insert "\n\n\n")
7449 (spice-add-section "PORTS")
7450 (insert "\n\n.end\n\n\n\n")
7451 (spice-add-section "Changelog")
7452 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7458 (spice-add-changelog-entry "File created") ; in any case
7463 ;;------------------------------------------------------------
7464 ;; Hacks to implement the find function menu bar for spice-mode
7465 ;; subckts/models Fortunately spice-mode only provides one means of
7466 ;; abstraction so the parsing is very easy. (only available in
7467 ;; XEmacs, remove this and spice-mode entry when compiling for emacs
7468 ;; to avoid warnings) This code has been taken from eldo-mode.el
7469 ;; (E. Rouat)
7470 ;;------------------------------------------------------------
7472 (eval-and-compile
7473 (when (fboundp 'function-menu)
7474 (require 'func-menu)
7476 (defconst fume-function-name-regexp-spice
7477 "^\\.\\(subckt\\|model\\|macro\\)\\s-+\\([a-z]\\w*\\)"
7478 "Expression to parse Spice subcircuit and model names.")
7480 (defun fume-find-next-spice-function-name (buffer)
7481 "Searches for the next spice subcircuit name in BUFFER."
7482 (set-buffer buffer)
7483 (setq case-fold-search 't) ;;otherwise func-menu bombs....
7484 (if (re-search-forward fume-function-name-regexp nil t)
7485 (let ((beg (match-beginning 2))
7486 (end (match-end 2)))
7487 (cons (buffer-substring beg end) beg))))
7488 ) ; when
7492 (defun spice-func-menu-init ()
7493 "Initialize function menu." ; buffer local stuff
7494 ;; hook in the spice-mode mode regular expression above into the
7495 ;; association list of regexps used by the function menu generator
7496 (setq fume-function-name-regexp-alist
7497 (purecopy
7498 (append
7499 fume-function-name-regexp-alist
7500 (list
7501 '(spice-mode . fume-function-name-regexp-spice)))))
7503 ;; hook in the search method above into the association list used by the
7504 ;; function menu generating code
7505 (setq fume-find-function-name-method-alist
7506 (purecopy
7507 (append
7508 fume-find-function-name-method-alist
7509 (list '(spice-mode . fume-find-next-spice-function-name)))))
7511 ;; Now activate func-menu - I hope that these settings don't
7512 ;; interfere with users settings
7513 (make-local-variable 'fume-menubar-menu-name)
7514 (make-local-variable 'fume-buffer-name)
7515 (make-local-variable 'fume-index-method)
7516 (setq fume-menubar-menu-name "Subckts"
7517 fume-buffer-name "*Subcircuits List*"
7518 fume-index-method 2)
7520 (when (and (featurep 'xemacs) (not (emacs-version>= 21 5)))
7521 (make-local-hook 'find-file-hooks))
7523 (add-hook 'find-file-hooks 'fume-add-menubar-entry)
7524 (define-key global-map '(shift button2) 'fume-mouse-function-goto)
7525 (fume-add-menubar-entry))
7528 ;; ======================================================================
7529 ;; Support for .subckt search !?
7530 ;; ======================================================================
7532 ;; What about searching from an included file, how to find the
7533 ;; top-level then ? think I've cracked it: .end identifies top-level
7534 ;; spice files so remember the last one to start search from if the
7535 ;; search fails
7537 ;; BUG: doesn't handle nested .subckt defs ! Reports first found match...
7539 (defun spice-search-included-files (subckt)
7540 (save-excursion
7541 (let ((mrk nil))
7542 (goto-char (point-min))
7543 (while (and
7544 (search-forward-regexp spice-library-regexp-start
7545 (point-max) t)
7546 (not mrk))
7547 (beginning-of-line)
7548 (if (looking-at (concat spice-library-regexp-start
7549 spice-library-regexp-end))
7550 (if (file-readable-p (substitute-in-file-name (match-string 3)))
7551 (setq mrk
7552 (spice-search-file-for-subckt
7553 (substitute-in-file-name (match-string 3)) subckt))
7554 (message "File '%s' isn't readable" (match-string 3))) ; if
7555 ) ; if
7556 (end-of-line)) ; while
7557 mrk) ; let
7558 ) ; save-
7562 (defvar spice-subckt-search-master-filename nil
7563 "latest top-level (identified by .end in file) .cir file used in
7564 subcircuit searches.")
7566 (defun spice-search-file-for-subckt (filename subckt)
7567 "Searches a file for a .subckt definition. Remembers
7568 `spice-subckt-search-master-filename' for future subckt searches."
7569 (save-excursion
7570 (set-buffer (find-file-noselect filename))
7571 (condition-case nil
7572 (let ((index-alist (imenu--make-index-alist t))
7573 (mrk nil))
7574 (if (assoc spice-imenu-end-submenu-name index-alist)
7575 (setq spice-subckt-search-master-filename buffer-file-name))
7576 (setq mrk (assoc-ignore-case subckt index-alist))
7577 (if mrk mrk
7578 (spice-search-included-files subckt))
7580 (error nil))))
7583 ;; History of subckt searches.
7584 (defvar spice-subckt-search-history nil
7585 "History of subcircuit searches.")
7587 (defun spice-guess-subckt-name ()
7588 "guesses name of subckt from context, multiple lines"
7589 (let ((subckt "")) ; (current-word)
7590 (save-excursion
7591 (beginning-of-line)
7592 (while (and (looking-at "^+")
7593 (not (forward-line -1))))
7594 (if (looking-at spice-xinstance-regexp)
7595 (progn
7596 ;; (message "Could it be '%s' ?" (match-string 3))
7597 (setq subckt (match-string 5))
7598 (remove-text-properties 0 (length subckt) '(face nil) subckt)
7599 ))) ; save-
7600 subckt))
7603 (defun spice-visit-subckt-def (mrk)
7604 "Helper function visiting buffer and mark specified."
7605 (if (eq (marker-buffer (cdr mrk))
7606 (current-buffer))
7607 (if (or
7608 spice-running-xemacs ; then push mark always
7609 (not (and transient-mark-mode mark-active))) ; emacs, check if active region
7610 (push-mark)))
7611 (pop-to-buffer (marker-buffer (cdr mrk)) t)
7612 (widen)
7613 (goto-char (cdr mrk)))
7616 (defun spice-search-subckt (subckt-args)
7617 "Searches for the .subckt definition with name under cursor, or any other
7618 name specified by user. Be CAREFUL using this command. Depending on the
7619 structure of your spice decks this might find wrong definitions. To AVOID any
7620 such problems always start searching from the TOP-LEVEL spice deck (ie. the
7621 file that is supplied to the simulator). If you start searching from an
7622 included file, potentially the definition is not found or it is found starting
7623 from ANOTHER top-level file (which could result in a completely wrong
7624 search result).
7625 This search command places the mark if search result is in the same file,
7626 return to the search start position by using C-u C-<SPC> or C-u C-@."
7627 (interactive
7628 (list (let* ((default-subckt (spice-guess-subckt-name))
7629 (input (read-from-minibuffer
7630 "Subcircuit name: "
7631 default-subckt nil nil
7632 spice-subckt-search-history)))
7633 (if (string= input "")
7634 (if (string= default-subckt "")
7635 (error "No subckt args given")
7636 default-subckt)
7637 input))))
7638 ;(message (format "name of subckt is %s" subckt-args))
7639 (let (mrk)
7640 (setq mrk (spice-search-file-for-subckt buffer-file-name subckt-args))
7641 ; (message (format "mark is %s" (cdr mrk)))
7642 (if (and (cdr mrk) (markerp (cdr mrk)))
7643 (spice-visit-subckt-def mrk)
7644 (progn
7645 (message "Couldn't find subcircuit '%s', retrying search in top-level file"
7646 subckt-args))) ; if
7647 (if (and (not mrk)
7648 spice-subckt-search-master-filename)
7649 (progn
7650 (setq mrk (spice-search-file-for-subckt
7651 spice-subckt-search-master-filename subckt-args))
7652 (if (and (cdr mrk) (markerp (cdr mrk)))
7653 (progn
7654 (spice-visit-subckt-def mrk)
7655 (message "Used top-level file '%s' to find '%s'"
7656 spice-subckt-search-master-filename subckt-args)
7658 (progn
7659 (message
7660 (format "Couldn't find subcircuit '%s', retry search in top-level file"
7661 subckt-args))
7662 ))))))
7665 ;; ======================================================================
7666 ;; loading of include files of current deck.
7668 (defun spice-load-include-files (&optional non-recursive)
7669 "Loads all files that are included in this deck. Makes it more easy
7670 to load a project. This loading occurs recursively. Files already
7671 loaded are not reloaded or scanned for .includes. This function is
7672 only guaranteed to work when all included files are not already loaded."
7673 (interactive)
7674 (let ((index-alist (imenu--make-index-alist t))
7675 l filename)
7676 (if (setq l (cdr (assoc spice-imenu-libraries-submenu-name index-alist))) ;; file contains include files/libraries
7677 (while l
7678 (setq filename (expand-file-name
7679 (substitute-in-file-name (car (car l)))))
7680 ;;(message "Trying to load %s" filename)
7681 (if (and (file-readable-p filename)
7682 (not
7683 (assoc filename ;; already loaded
7684 (mapcar
7685 (lambda (buffer)
7686 (cons (buffer-file-name buffer) buffer))
7687 (buffer-list)))))
7688 (save-excursion
7689 ;; (message "filename is %s" filename)
7690 (set-buffer (find-file-noselect filename))
7691 ;; (spice-mode) ? ref. discussion Manu
7692 (unless (or non-recursive
7693 (not (eq major-mode 'spice-mode)))
7694 (spice-load-include-files))))
7695 (setq l (cdr l))))))
7698 ;; ======================================================================
7699 ;; unloading of spice files except current deck.
7701 (defun spice-unload-other-decks ()
7702 "Kills all other spice files except current one. Makes it easy to
7703 unload a lot of spice files without restarting emacs."
7704 (interactive)
7705 (save-excursion
7706 (let ((current (current-buffer)))
7707 (mapcar
7708 (lambda (buffer)
7709 (set-buffer buffer)
7710 (if (and (eq major-mode 'spice-mode)
7711 (not (eq current buffer)))
7712 (progn
7713 (message "Killing %s" buffer)
7714 (kill-buffer buffer))))
7715 (buffer-list)))))
7718 ;; ======================================================================
7719 ;; folding for commented out regions ...
7720 ;;; taken from and adapted:
7721 ;;; Filename: foldingo.el
7722 ;;; Author: Christian Queinnec <Christian.Queinnec@lip6.fr>
7723 ;; This is work in progress; (user) interface might change
7725 (defvar spice-some-comment-regions-are-hidden nil
7726 "Keeps track if some comment regions are hidden.")
7727 (make-variable-buffer-local 'spice-some-comment-regions-are-hidden)
7729 (defvar spice-last-hide-comment-regions-tick nil
7730 "Keeps track when last time comment hiding was called.")
7731 (make-variable-buffer-local 'spice-last-hide-comment-regions-tick)
7733 (defun spice-hide-init ()
7734 "Initialize buffer local variables to make hiding of spice regions
7735 effective"
7736 ;; trick to make a comment-start/padding dependent regexp:
7737 (custom-initialize-reset 'spice-hide-line-prefix
7738 (car (get 'spice-hide-line-prefix
7739 'standard-value)))
7740 ;; make sure we have invisibility property working, local for a buffer
7741 (if (fboundp 'add-to-invisibility-spec)
7742 (add-to-invisibility-spec 'spice-mode))
7743 ;; (remove-from-invisibility-spec '(spice-mode . t))
7744 ;; local for buffers:
7745 (set (make-local-variable 'line-move-ignore-invisible) t)
7746 (if spice-auto-hide-comments
7747 (spice-hide-all-comments))
7750 (defun spice-hide (from to)
7751 "Not supported, don't use this."
7752 (interactive "*r")
7753 (spice-hide-region from to t))
7755 (defun spice-unhide (from to)
7756 "Not supported, don't use this."
7757 (interactive "*r")
7758 (spice-hide-region from to nil))
7760 (defun spice-hide-all-comments-p ()
7761 "Checks if there are comments that can be hidden...; assumes that if
7762 the user edited the file, new comments might have been created and
7763 thus hide all comments must be activated. This is not the best
7764 criterion, but it is safe."
7765 ;; (interactive)
7766 ;; (message "buffer tick is %s, last hide comment is %s"
7767 ;; (buffer-modified-tick) spice-last-hide-comment-regions-tick)
7768 (if (and
7769 spice-last-hide-comment-regions-tick ; can be nil
7770 (= spice-last-hide-comment-regions-tick (buffer-modified-tick)))
7771 nil t))
7773 (defun spice-hide-all-comments ()
7774 "Hides all commented out regions in the current spice deck. Allows
7775 to get a better overview of the deck if many lines are commented out.
7776 It relies on having all regions being commented out using the
7777 \"Comment Region\" menu entry that uses `comment-region'. The regexp
7778 used to match comment lines, `spice-hide-line-prefix', might identify
7779 standard spice comment lines used for documentation. To avoid
7780 problems, make sure documentation is not part of comments. For
7781 instance by using the doc starters available in the spice languages,
7782 or by making sure they are different from the comment lines generated
7783 with the menu entry, by placing two *'s when the default comment is
7784 only one *. If you want to unhide all the hidden comment lines, use
7785 `spice-unhide-all-comments'."
7786 (interactive)
7787 (spice-unhide-all-comments)
7788 (setq spice-last-hide-comment-regions-tick (buffer-modified-tick))
7789 (save-excursion
7790 (goto-char (point-min))
7791 ;; (message "beginning of buffer reached %s" (point))
7792 (forward-line)
7793 (while (search-forward-regexp (concat "^" spice-hide-line-prefix)
7794 (point-max) t)
7795 (beginning-of-line)
7796 ;; (message "reached %s" (point))
7797 (let ((beg (point))
7799 lines)
7800 ;; (message "found start of regexp %s" (point))
7801 (setq lines (forward-line))
7802 ;; (message "%s left" lines)
7803 ;; the empty lines following commented lines are also hidden
7804 (while (and (looking-at (concat "^\\(" spice-hide-line-prefix "\\|[ ]*$\\)"))
7805 (= (setq lines (forward-line)) 0))
7806 ;; (message "%s left" lines)
7808 (setq end (point))
7809 (spice-hide-region beg end t))))
7810 (set-spice-name)
7813 (defun spice-unhide-all-comments ()
7814 "Unhides all hidden comment regions."
7815 (interactive)
7816 (setq spice-some-comment-regions-are-hidden nil)
7817 (setq spice-last-hide-comment-regions-tick nil)
7818 (spice-hide-region (point-min) (point-max) nil)
7819 (set-spice-name)) ;; update mode-line
7821 (defun spice-hide-region (from to flag)
7822 "Hides or shows lines from FROM to TO, according to FLAG. If FLAG
7823 is nil then the text is shown, while if FLAG is t the text is hidden."
7824 (let ((inhibit-read-only t))
7825 (save-excursion
7826 (goto-char from)
7827 ; (foldingo-discard-overlays (point) to 'invisible 'spice-comment)
7828 (spice-discard-overlays from to 'spice-comment)
7829 (if flag
7830 (let ((overlay (make-overlay (point) to)))
7831 (spice-make-overlay-hidden overlay))))))
7833 (defun spice-make-overlay-hidden (overlay)
7834 ;; Make overlay hidden and intangible.
7835 ;; (overlay-put overlay 'intangible t)
7836 (overlay-put overlay 'invisible 'spice-mode)
7837 (overlay-put overlay 'spice-comment t)
7838 (setq spice-some-comment-regions-are-hidden t)
7839 ;; (overlay-put overlay 'intangible t)
7842 (defun spice-discard-overlays (from to prop)
7843 "discards overlays in region FROM to TO that have property PROP set."
7844 (let ((inhibit-read-only t))
7845 (save-excursion
7846 (goto-char from)
7847 (while (< (point) to)
7848 (let ((overlays (overlays-at (point))))
7849 (while overlays
7850 (let ((o (car overlays)))
7851 (if (overlay-get o prop)
7852 (delete-overlay o)))
7853 (setq overlays (cdr overlays))))
7854 (goto-char (next-overlay-change (point)))))))
7857 ;; ======================================================================
7858 ;; utility spice-mode-output functions
7860 (defun spice-check-output-mode ()
7861 "Check if current buffer is output file and return symbol or NIL."
7862 (save-excursion
7863 (goto-char (point-min))
7864 (if (looking-at "1\\*\\*\\*\\*\\*\\*\\*") ; eldo
7865 'eldo
7866 (if (or (looking-at "Using: ")
7867 (looking-at " \\*\\*\\*\\*\\*\\* Star-HSPICE")) ; hspice
7868 'hspice
7869 nil))))
7871 (defun spice-output-p ()
7872 "Check if current buffer is output file."
7873 (interactive)
7874 (if spice-output-local t nil))
7876 (defconst spice-output-sections-regexp
7877 (concat
7879 "\\(0\\*\\*\\*\\*\\| \\*\\*\\*\\*\\*\\*\\) *"
7880 "\\( [a-z0-9]\\w*\\(\\s-+\\w+\\)* \\)\\s-+\\(t[a-z]*\\) ?=.*$")
7881 "Regexp identifying spice output headers (both hspice and eldo).")
7883 (defvar spice-output-font-lock-keywords
7884 (list
7885 (list spice-output-sections-regexp
7886 '(1 font-lock-comment-face)
7887 '(2 spice-title-face)
7888 (list 4 spice-constant-face))
7889 (list "^[0-1] ?\\*.*$" 0 font-lock-comment-face)
7890 (list "^ \\(\\*\\*\\*\\*\\*?\\) \\(.*\\)$"
7891 '(1 font-lock-comment-face)
7892 '(2 font-lock-type-face))
7893 (list "^\\(FATAL \\)?ERROR.+$" 0 'font-lock-warning-face) ; eldo errors
7894 (list "^\\s-*\\(..?error..?[: ]\\).+$" 0 'font-lock-warning-face) ; hspice errors
7896 "List of regexps for font-lock in output mode."
7899 (defun spice-mode-output ()
7900 "Spice major mode start up function for spice output files. Experimental ;)"
7902 (setq buffer-read-only t) ; don't want to edit output files, do we
7903 ; common mistake in hspice output files!
7905 ;; use local keymap (for keys and menu)
7906 (use-local-map spice-output-mode-map)
7908 ;; set menu for local buffer
7909 (easy-menu-add spice-menu-list) ; for XEmacs
7910 (easy-menu-define spice-output-menu spice-output-mode-map
7911 "Menu keymap for Spice Output Mode." spice-output-menu-list)
7913 ;; font-lock local start-up
7914 (set (make-local-variable 'font-lock-defaults)
7915 (list 'spice-output-font-lock-keywords
7916 nil t (list (cons ?\" "w")))) ; nil, t (do multiline
7917 ; comments)
7919 ;; imenu buffer local init
7920 (set (make-local-variable 'imenu-case-fold-search) t)
7921 (set (make-local-variable 'imenu-generic-expression)
7922 (list (list "*Errors*"
7923 "^\\s-*\\(\\(..?error..?[: ]\\|\\(FATAL \\)?ERROR\\).+$\\)"
7925 (list nil ;; "*Sections*"
7926 spice-output-sections-regexp
7927 2)))
7931 (defun spice-output-filename ()
7932 "Determines output filename of current spice deck."
7933 (interactive)
7934 (let ((filename nil)
7935 (l spice-output-filename-alist))
7936 (while l
7937 (if (spice-standard-p (car (car l)))
7938 (progn
7939 (setq filename (eval (car (cdr (car l)))))
7940 ;; (message "Checking filename %s" filename)
7941 (if (file-readable-p filename)
7942 (setq l nil)
7943 (setq filename nil))))
7944 (setq l (cdr l)))
7945 filename))
7947 (defun spice-output-file-p ()
7948 "Checks if an output file is available for current spice deck."
7949 (interactive)
7950 (and (not spice-output-local)
7951 (buffer-file-name)
7952 (spice-output-filename)))
7954 (defun spice-load-output-file-internal (filename)
7955 "Loads output file into emacs and sets major mode"
7956 (interactive)
7957 (if (and
7958 (stringp filename)
7959 (file-readable-p filename))
7960 (progn
7961 (find-file-other-window filename)
7962 (spice-mode))))
7964 (defun spice-load-output-file ()
7965 "Loads output file into spice, calls `spice-load-output-file-internal'
7966 to do the actual work, this is called from the menu or key binding"
7967 (interactive)
7968 (let (filename)
7969 (setq filename (spice-output-filename))
7970 (spice-load-output-file-internal filename)))
7973 ;; ======================================================================
7974 ;; .guess statement auxiliary functions (eldo !)
7976 (defvar spice-guess-nodeset-statements nil
7977 "holds temp .guess/nodeset statements")
7979 (defun spice-derive-guess-nodeset-statements (from to)
7980 "Derives .guess/nodeset statements from DC operating point
7981 lines. This implements the hspice functionality of .ic0 files for
7982 eldo..."
7983 (save-excursion
7984 (let ( ;; (count 0)
7986 (goto-char (max from to))
7987 (setq m1 (make-marker))
7988 (set-marker m1 (point))
7989 (goto-char (min from to))
7990 (while (re-search-forward "^\\s-*\\(\\S-+\\)\\s-+\\([-0-9\.E+]+\\)"
7991 m1 t)
7992 (progn
7993 ;;(message "Inserting .guess...(%s)" (make-string (incf count) ?.))
7994 ;;(beginning-of-line)
7995 ;;(insert ".guess V(" (match-string 1) ") = " (match-string 2) "\n*")
7996 (setq spice-guess-nodeset-statements
7997 (append spice-guess-nodeset-statements
7998 (list (concat " V("
7999 (spice-match-string-no-properties 1)
8000 ") = "
8001 (spice-match-string-no-properties 2)))
8004 )))))
8006 (defun spice-create-guess-nodeset-file (str)
8007 "Creates a <buffer-file-name>_guess/nodeset.cir file from node
8008 voltage pairs in the current output file."
8009 (interactive)
8010 (setq spice-guess-nodeset-statements nil)
8011 (let (from to outbuf stats filename)
8012 (setq filename (file-name-nondirectory buffer-file-name))
8013 (save-excursion
8014 (goto-char (point-min))
8015 (setq from (re-search-forward "^\\s-+NODE\\s-+VOLTAGE\\s-*$" (point-max) t))
8016 (if from
8017 (setq to (re-search-forward "^$" (point-max) t)))
8018 (if (and from to)
8019 (spice-derive-guess-nodeset-statements from to)))
8020 (if (not spice-guess-nodeset-statements)
8021 (message "Didn't find 'node -- voltage' pairs in output file...")
8022 (setq outbuf
8023 (find-file-noselect (concat
8024 (file-name-sans-extension buffer-file-name)
8025 "_" str ".cir")))
8026 (switch-to-buffer-other-window outbuf)
8027 (erase-buffer)
8028 (insert "* ." str " statements derived from " filename " ["
8029 (format-time-string "%b %d %Y") " " (format-time-string "%T")
8030 "]\n\n")
8031 (setq stats spice-guess-nodeset-statements)
8032 (while stats
8033 (insert ".")
8034 (insert str)
8035 (insert " ")
8036 (insert (car stats))
8037 (insert "\n")
8038 (setq stats (cdr stats)))
8039 (insert "\n\n* ." str " statements derived "
8040 (format-time-string "%b %d %Y") " "
8041 (format-time-string "%T") "\n\n")
8042 (save-buffer)
8043 (goto-char (point-min))
8044 ) ; when
8045 ) ; let
8049 (defun spice-replace-with-guess-statements (from to)
8050 "replace with .guess statements."
8051 (interactive "*r")
8052 (spice-replace-with-guess-nodeset-statements "guess" from to))
8055 (defun spice-replace-with-nodeset-statements (from to)
8056 "replace with .nodeset statements."
8057 (interactive "*r")
8058 (spice-replace-with-guess-nodeset-statements "nodeset" from to))
8061 (defun spice-replace-with-guess-nodeset-statements (str from to)
8062 "Replaces selected region with .guess/nodeset statements."
8063 (interactive)
8064 (setq spice-guess-nodeset-statements nil)
8065 (if (and from to)
8066 (spice-derive-guess-nodeset-statements from to))
8067 (if (not spice-guess-nodeset-statements)
8068 (message "Didn't find any 'node -- voltage' pairs in region...")
8069 (let (stats)
8070 (kill-region from to)
8071 (setq stats spice-guess-nodeset-statements)
8072 (while stats
8073 (insert ".")
8074 (insert str)
8075 (insert " ")
8076 (insert (car stats))
8077 (insert "\n")
8078 (setq stats (cdr stats))))
8082 ;; ======================================================================
8083 ;; fill-prefix related functions
8085 (defvar spice-save-comment-line-break-function nil
8086 "*Mode specific variable to save previous line break function in.")
8088 (defun spice-comment-indent-new-line (&optional soft)
8089 "Spice mode comment-indent-new-line function, used by `auto-fill'. Sets
8090 `fill-prefix' depending on context: comment prefix if in comment with special
8091 layla handling (!); \"!\" doc prefix if in hspice mode; \"$\" doc prefix
8092 in eldo mode, otherwise uses \"+ \" prefix."
8093 (interactive)
8094 (let ((fpx fill-prefix) ; remember prefix
8095 (end (point))) ; don't look beyond point for doc starters
8096 (if (save-excursion
8097 (beginning-of-line)
8099 (looking-at (concat "\\([" comment-start
8100 (when (spice-standard-p 'layla)
8101 spice-continuation-prefix)
8102 (when (spice-standard-p 'hspice)
8103 "$")
8104 (when (spice-standard-p 'eldo)
8105 "!")
8106 "]+\\)"))
8107 (and
8108 (spice-standard-p 'hspice)
8109 (re-search-forward "\\s-\\([$]\\)" end t))
8110 (and
8111 (spice-standard-p 'eldo)
8112 (re-search-forward "\\s-\\([!]\\)" end t))))
8113 (setq fill-prefix (concat (spice-match-string-no-properties 1) " "))
8114 (setq fill-prefix (concat spice-continuation-prefix " ")))
8115 ;(comment-indent-new-line) ;;call standard comment-indent-new-line function
8116 (when spice-save-comment-line-break-function
8117 (funcall spice-save-comment-line-break-function))
8118 (setq fill-prefix fpx)))
8121 (defun spice-fill-context-prefix () ; ???
8122 "Calculates prefix from current position (move-to-left-margin), and
8123 returns it. Non-comment paragraphs can also be filled correctly."
8124 ;; (message "deriving fill prefix")
8125 (let ((result
8126 (if (or (looking-at (concat "\\([" comment-start
8127 (when (spice-standard-p 'layla)
8128 spice-continuation-prefix)
8129 "]+\\)"))
8130 (looking-at "\\([$!]+\\)"))
8131 (concat (spice-match-string-no-properties 1) " ")
8132 (concat spice-continuation-prefix " "))))
8133 ;; (message (format "result is '%s'" result))
8134 result))
8136 (defun spice-delete-indentation (&optional arg)
8137 "Wrapper for `delete-indentation', sets `fill-prefix' to adequate value."
8138 (interactive "*P")
8139 (let ((fillpfx fill-prefix))
8140 (beginning-of-line)
8141 (if arg (forward-line 1))
8142 (if (looking-at "\\([+$!*]+\\)") ;; don't check submodes here ?
8143 (setq fill-prefix (spice-match-string-no-properties 1)))
8144 (delete-indentation)
8145 (setq fill-prefix fillpfx)))
8148 ;; ======================================================================
8149 ;; msb fix (from cperl-mode.el)
8150 (defvar spice-msb-fixed nil) ;; global variable keeping track of addition
8152 (defun spice-msb-fix ()
8153 "Adds \"Spice Decks\" entry in msb menu, assumes that msb is already loaded"
8154 (setq spice-msb-fixed t)
8155 (let* ((l (length msb-menu-cond))
8156 (last (nth (1- l) msb-menu-cond))
8157 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
8158 (handle (1- (nth 1 last))))
8159 (setcdr precdr (list
8160 (list
8161 '(eq major-mode 'spice-mode)
8162 handle
8163 "Spice Decks (%d)")
8164 last))))
8167 ;; ======================================================================
8168 ;; utility spice-mode functions
8170 (defun spice-about ()
8171 (interactive)
8172 (sit-for 0)
8173 (message "spice-mode version %s, © %s" spice-version spice-developer))
8175 (defun set-spice-name ()
8176 "Set mode line name of spice mode"
8177 (setq mode-name "Spice"))
8179 ;; (defun set-spice-name ()
8180 ;; "Set mode line name of spice mode"
8181 ;; (setq mode-name
8182 ;; (concat
8183 ;; (when (not spice-output-local)
8184 ;; (concat
8185 ;; (when (spice-standard-p 'layla) "Layla")
8186 ;; (when (spice-standard-p 'mondriaan) "-Mdrn")
8187 ;; (when (spice-standard-p 'hspice)
8188 ;; (when (spice-standard-p 'layla) "/"))
8189 ;; (when (spice-standard-p 'hspice) "Hspice")
8190 ;; (when (spice-standard-p 'eldo)
8191 ;; (when (or (spice-standard-p 'hspice)
8192 ;; (spice-standard-p 'layla)) "/"))
8193 ;; (when (spice-standard-p 'eldo) "Eldo")
8194 ;; (when (spice-standard-p 'eldorf) "-RF")
8195 ;; (when (spice-standard-p 'eldovloga) "-VlA")
8196 ;; (when (spice-standard-p 'fasthenry)
8197 ;; (when (or (spice-standard-p 'eldo)
8198 ;; (spice-standard-p 'hspice)
8199 ;; (spice-standard-p 'layla)) "/"))
8200 ;; (when (spice-standard-p 'fasthenry) "FastHenry")
8201 ;; (when (spice-standard-p 'draccdl)
8202 ;; (when (or (spice-standard-p 'eldo)
8203 ;; (spice-standard-p 'hspice)
8204 ;; (spice-standard-p 'layla)
8205 ;; (spice-standard-p 'fasthenry)) "/"))
8206 ;; (when (spice-standard-p 'draccdl) "DracCDL")
8207 ;; (when (spice-standard-p 'spectre)
8208 ;; (when (or (spice-standard-p 'eldo)
8209 ;; (spice-standard-p 'hspice)
8210 ;; (spice-standard-p 'layla)
8211 ;; (spice-standard-p 'fasthenry)
8212 ;; (spice-standard-p 'draccdl)) "/"))
8213 ;; (when (spice-standard-p 'spectre) "Spectre")
8214 ;; (when (or (spice-standard-p 'fasthenry)
8215 ;; (spice-standard-p 'eldo)
8216 ;; (spice-standard-p 'hspice)
8217 ;; (spice-standard-p 'layla)
8218 ;; (spice-standard-p 'draccdl)
8219 ;; (spice-standard-p 'spectre)) "|")))
8220 ;; "Spice"
8221 ;; (when spice-output-local "-output")
8222 ;; (when spice-some-comment-regions-are-hidden " H+"))))
8225 (defun spice-check-spice-standard ()
8226 "checks if spice-standard is set to a correct value."
8227 ;; if mondriaan then also layla
8228 (when (spice-standard-p 'mondriaan)
8229 (unless (spice-standard-p 'layla)
8230 (error "Error: turn on Layla when you want to use Mondriaan")))
8231 ;; if eldoRf then also eldo
8232 (when (spice-standard-p 'eldorf)
8233 (unless (spice-standard-p 'eldo)
8234 (error "Error: turn on Eldo when you want to use Eldo RF")))
8235 ;; if eldo verilog-A then also eldo
8236 (when (spice-standard-p 'eldovloga)
8237 (unless (spice-standard-p 'eldo)
8238 (error "Error: turn on Eldo when you want to use Eldo Verilog-A")))
8241 ;; xemacs - emacs compatibility wrapper
8242 (defun spice-match-string-no-properties (num)
8243 "wrapper for no properties string matcher"
8244 (if spice-running-xemacs
8245 (match-string num)
8246 (match-string-no-properties num)))
8249 (defun spice-update-existing-buffers ()
8250 "updates all spice-mode buffers with new customization"
8251 (save-excursion
8252 (let ((current (current-buffer)))
8253 (mapcar
8254 (lambda (buffer)
8255 (set-buffer buffer)
8256 (if (and (eq major-mode 'spice-mode)
8257 (not (eq current buffer)))
8258 (progn
8259 (message "Activating customizations in %s" buffer)
8260 (spice-activate-customizations-local))))
8261 (buffer-list))))
8265 (defun spice-activate-customizations-local ()
8266 "Activates customization (of global variables) in current buffer"
8267 (if (spice-output-p)
8268 (use-local-map spice-output-mode-map)
8269 (use-local-map spice-mode-map))
8270 (set-spice-name)
8271 (spice-update-mode-menu)
8272 (set-syntax-table spice-mode-syntax-table)
8273 (if spice-use-func-menu
8274 (if (fboundp 'function-menu)
8275 (funcall 'spice-func-menu-init)))
8276 (if (not (spice-output-p))
8277 (setq imenu-generic-expression spice-imenu-generic-expression))
8278 (when spice-imenu-add-to-menubar
8279 (imenu-add-to-menubar "Index"))
8280 ;; rebuild menu:
8281 (setq imenu--index-alist nil)
8282 (imenu--make-index-alist t)
8283 (spice-compile-init)
8284 (spice-waveform-viewer-init)
8285 (if (fboundp 'font-lock-unset-defaults)
8286 (font-lock-unset-defaults))
8287 (font-lock-set-defaults)
8288 (if (not (and spice-running-xemacs font-lock-mode))
8289 (font-lock-fontify-buffer)
8290 (font-lock-mode)
8291 (font-lock-mode))
8295 (defun spice-activate-customizations-obsolete ()
8296 "Activate all customizations on local variables. Run this if you set
8297 the spice-standard variable to modify spice-mode's behaviour in the local
8298 buffer. It sets up the buffer local variables using the modified global
8299 variables of the customization buffer."
8300 (interactive)
8301 (if (spice-output-p)
8302 (use-local-map spice-output-mode-map)
8303 (use-local-map spice-mode-map))
8304 ;; (setq spice-standard-local spice-standard)
8305 (set-spice-name)
8306 (spice-menu-init)
8307 (spice-update-mode-menu)
8308 (spice-mode-syntax-table-init)
8309 (set-syntax-table spice-mode-syntax-table)
8310 (spice-keywords-init)
8311 (spice-font-lock-init)
8312 (if spice-use-func-menu
8313 (if (fboundp 'function-menu)
8314 (funcall 'spice-func-menu-init)))
8315 (spice-imenu-init)
8316 (if (not (spice-output-p))
8317 (setq imenu-generic-expression spice-imenu-generic-expression))
8318 ;; add imenu to menubar ?
8319 (when spice-imenu-add-to-menubar
8320 (imenu-add-to-menubar "Index"))
8321 (spice-compile-variables-init)
8322 (spice-compile-init)
8323 (spice-waveform-viewer-init)
8324 (if (fboundp 'font-lock-unset-defaults)
8325 (font-lock-unset-defaults))
8326 ;; (setq font-lock-defaults
8327 ;; (list 'spice-font-lock-keywords nil t (list (cons ?\" "w"))))
8328 (font-lock-set-defaults)
8329 (font-lock-fontify-buffer))
8332 ;; ======================================================================
8333 ;; spice-mode main entry point
8334 ;; ======================================================================
8335 ;;;###autoload
8336 (defun spice-mode ()
8337 "Major mode for editing spice decks in (X)Emacs.
8339 Entry to Spice mode calls the value of the variable `spice-mode-hook'
8340 with no args, if that value is non-nil after initialization is finished.
8342 Usage & Features:
8343 -----------------
8345 - Comprehensive menu
8347 - Highlighting of (extended) SPICE syntax, with (limited) ERROR notification
8348 Please setup spice-mode to recognize the correct syntax through
8349 customization of the `spice-standard' variable. You can use the menu
8350 entry Spice->Customize->Spice Standard to do this interactively.
8352 - Template insertion (abbrev/electrification) for many spice constructs,
8353 two alternatives are available: Abbrev minor mode and `tempo-complete-tag'
8354 + Abbrevs can be turned on and off via the Settings submenu.
8355 To see the available abbrevs, use `M-x list-abbrevs' or use the menu
8356 after enabling abbrev minor mode. To find out what key sequence
8357 triggers an expand do 'C-h w expand-abbrev'.
8358 + `tempo-complete-tag' is bound to <tab> - for example, type 'M<tab>'
8359 at the beginning of a line and you will be prompted with a complete
8360 Mosfet template. Most tags are pretty straightforward i.e 'C' for a
8361 capacitor, 'L' for an inductance etc...
8362 You can type `C-h v tempo-tags'for a complete list of tags and
8363 associated templates. Note: to insert a real <TAB>, use <C-q TAB> or
8364 <shift TAB>.
8366 - Comment & documentation string handling
8367 + the '*' symbol is used to comment out a whole line - that symbol has
8368 to be at the beginning of a line
8369 + the '!' and '$' symbols are used to document your netlist in eldo
8370 and hspice/layla mode respectively
8371 + menu entry to comment out region/uncomment region
8372 + key bindings for commenting/uncommenting a region as in `auctex-mode'.
8374 - Comment hiding support
8375 + Can hide all commented out regions in a buffer to improve readability
8376 + prefix string is customizable: `spice-hide-line-prefix'.
8377 + custom variable can be set to automatically hide all commented regions
8378 at load time (`spice-auto-hide-comments')
8379 + requires use of doc strings, otherwise also documentation might be
8380 hidden
8381 + When parts of the deck are hidden the string \"H+\" appears in the
8382 modeline.
8384 - Imenu (Index menu and/or shift right click in emacs if configured)
8385 + shows subcircuit definitions
8386 + shows .end statements in submenu
8387 + shows device models in submenus
8388 + shows libraries (.lib/.inc) in submenu
8389 + shows analyses in submenu
8390 + shows sections in submenu
8391 + shows output file sections in menu
8392 + shows LAYLA objects in submenus if layla submode has been enabled
8393 + can be added to the menubar by setting `spice-imenu-add-to-menubar'
8394 (uses `imenu-add-to-menubar' to add an Imenu entry to the menubar).
8396 - File browser using Speedbar (`speedbar') and/or index/sources menu
8398 - .inc/.include/.lib/.libfas access
8399 + through mouse-2 click (`ffap-at-mouse' or `spice-load-file-at-mouse')
8400 + using \\r (ie. <return>), (`ffap')
8401 + through menu entry all include/lib files of a deck can be loaded at
8402 once (`spice-load-include-files'), recursively.
8404 - Searching for .subckt defs: `spice-search-subckt' or `C-c C-s'
8405 + extracts subcircuit name from context
8406 + search history
8407 + mark is set where search has been started if the definition is found
8408 in the same file. Return to mark with `C-u C-<SPC>' (or `C-u C-@')
8409 as with interactive searches (fi `isearch-forward')
8410 + be careful when starting the search from an included file,
8411 correctness can not be guaranteed. Starting a search from
8412 a top-level .cir file gives correct results. The latest used
8413 top-level file is stored (a top-level file contains a .end
8414 statement !), and also searched if the subckt def is not found in
8415 a first pass (for instance when starting from an included file).
8417 - Postscript printing with fontification (through `ps-print' package).
8419 - Addition of Spice Deck submenu in msb mode, see `msb', `spice-msb-fix'.
8421 - Section support (as in eldo-mode):
8422 + add section headers, goto section through menu entries or interactive
8423 + customizable through `spice-section-alist', you can add your
8424 own section headers, alter the list of predefined sections, ...
8425 + Changelog addition through `spice-add-changelog-entry', or
8426 use `C-c a c'.
8428 - Simulator support
8429 + use `spice-simulator' and `spice-simulator-switches' to
8430 select your simulator from `spice-simulator-alist'.
8431 + Support for error parsing of spice3 (batch-mode, -b),
8432 hspice, eldo and spectre. Add your own in spice-mode or through
8433 customization in `.emacs'.
8434 + use local file variables to customize per file as follows:
8435 <<< test.cir >>>
8437 .end
8439 * Local Variables:
8440 * mode: spice
8441 * spice-simulator: \"Hspice\"
8442 * spice-simulator-switches: \"\"
8443 * eval: (spice-set-command)
8444 * End:
8445 <<< test.cir ends here >>>
8447 - Waveform viewer support (beta)
8448 + use `spice-waveform-viewer' and `spice-waveform-viewer-switches' to
8449 select your waveform from `spice-waveform-viewer-alist'.
8450 + Support for interactive (command-line) waveform viewer such as
8451 nutmeg, or batch (GUI) type waveform viewer such as xelga or gsi.
8453 - Output file support
8454 + can load output file from menu (checks if file exists and is readable)
8455 + imenu in output files shows output file sections
8456 + for eldo .chi files: can create <file>_guess.cir files automatically
8457 for inclusion in <file>.cir file through
8458 `spice-create-guess-nodeset-file'
8459 or `spice-replace-with-guess-nodeset-statements'; this speeds up DC
8460 convergence for AC analyses.
8462 - (Fully) customizable
8463 + can select spice compatibility mode:
8464 * spice2g6/3 (default)
8465 * hspice (default)
8466 * eldo (default), RF and verilog-A extensions
8467 * fasthenry (default)
8468 * Dracula CDL
8469 * LAYLA, Mondriaan extensions
8470 * any combination of the above (there are conflicts however, so not
8471 all keyword fontification is correct in the latter case)
8472 + spice-mode font-lock faces
8473 + spice-mode default initialization of empty/new files determined by
8474 `spice-initialize-empty-file', `spice-initialize-template-file',
8475 `spice-default-header' and `spice-initialize-file-function'.
8476 + see the customization examples in the `spice-mode.el' file header
8477 + You can adapt `spice-simulator-alist' for your local site in
8478 `spice-mode.el' or in `.emacs' through customization.
8479 + You can adapt `spice-waveform-viewer-alist' for your local site in
8480 `spice-mode.el' or in `.emacs' through customization.
8481 + You can adapt `spice-section-alist' for your local site in
8482 `spice-mode.el' or in `.emacs' through customization.
8484 - Auto fill minor mode support
8485 + can be turned on from the Settings menu
8486 + auto fill works both for element where the continuation character
8487 is a '+', as well as in comment/doc mode where the continuation
8488 character is a '*', '$' or a '!'.
8489 + uses `fill-column' to determine where to wrap the line
8490 + doesn't use `fill-prefix'. A context dependent prefix is calculated
8491 through the `spice-comment-indent-new-line' function. This function
8492 is used as `comment-line-break-function' instead of the default line
8493 break function (in emacs: `comment-indent-new-line').
8495 - Paragraph support: [a-z] starts dev lines, '+' continues dev lines,
8496 [*!$] start paragraphs.
8498 - Works under GNU Emacs20.6/21.[123], also tested under XEmacs21.1/21.4.5,
8499 requires fsf-compat package for XEmacs 21.4.5.
8502 Do not use a -*- Mode -*- line in a spice deck as the first card in
8503 the deck is defined to be the title card. Rather, autoload spice-mode
8504 through your .emacs file:
8506 (autoload 'spice-mode \"spice-mode\" \"Spice/Layla Editing Mode\" t)
8507 (setq auto-mode-alist (append (list (cons \"\\\\.sp$\" 'spice-mode)
8508 (cons \"\\\\.cir$\" 'spice-mode)
8509 (cons \"\\\\.cdl$\" 'spice-mode)
8510 (cons \"\\\\.chi$\" 'spice-mode) ; output
8511 (cons \"\\\\.mod$\" 'spice-mode)); models
8512 auto-mode-alist))
8514 Alternative methods are provided in the spice-mode.el file header.
8516 Key bindings in highlighted include file lines:
8517 -----------------------------------------------
8519 \\{spice-mode-mouse-map}
8521 Key bindings for other parts in the file:
8522 -----------------------------------------
8524 \\{spice-mode-map}
8526 ;;Key bindings for output files:
8527 ;;------------------------------
8529 ;;\\{spice-output-mode-map}
8532 (interactive)
8533 (kill-all-local-variables) ; important !
8535 (setq major-mode 'spice-mode)
8536 (setq mode-name "Spice")
8538 ;; remember if this file is an output type
8539 (set (make-local-variable 'spice-output-local) (spice-check-output-mode))
8541 ;; set mode name
8542 (set-spice-name)
8544 ;; build global syntax table
8545 (unless spice-mode-syntax-table
8546 (spice-mode-syntax-table-init))
8547 ;; set it for local buffer
8548 (set-syntax-table spice-mode-syntax-table)
8550 ;; initialize global spice keywords, required for output mode !
8551 (unless spice-keywords
8552 (spice-keywords-init))
8554 ;; global font-lock start-up
8555 (unless spice-font-lock-keywords
8556 (spice-font-lock-init))
8558 ;; create global Spice mode menu's: mode-menu and output-mode-menu
8559 (unless (and spice-menu-list spice-output-menu-list)
8560 (spice-menu-init))
8562 ;; global spice-imenu init (not output mode !)
8563 (unless spice-imenu-generic-expression
8564 (spice-imenu-init))
8566 ;; global vars for compile init
8567 (unless spice-compilation-error-regexp-alist
8568 (spice-compile-variables-init))
8570 (set (make-local-variable 'parse-sexp-ignore-comments) nil)
8572 (set (make-local-variable 'tempo-interactive) t)
8573 (set (make-local-variable 'require-final-newline) t) ; hspice empty deck errors
8575 (set (make-local-variable 'comment-start) "*")
8576 (set (make-local-variable 'comment-end) "")
8577 (set (make-local-variable 'comment-start-skip) "\*")
8578 (set (make-local-variable 'comment-multi-line) nil)
8580 ;;------------------------------------------------------------
8581 ;; initialize hiding functions, mix of global and buffer local settings
8582 (spice-hide-init)
8584 (if (spice-output-p)
8585 (spice-mode-output)
8587 ;; use local keymap (for keys and menu)
8588 (use-local-map spice-mode-map)
8590 ;; set menu for local buffer
8591 (easy-menu-add spice-menu-list) ; for XEmacs
8592 (easy-menu-define spice-menu spice-mode-map
8593 "Menu keymap for Spice Mode." spice-menu-list)
8595 ;; abbreviations table: buffer local
8596 (setq local-abbrev-table spice-mode-abbrev-table)
8598 ;; buffer local init
8599 (set (make-local-variable 'fill-prefix) nil) ; automatically derived
8600 ;; remove auto-fill-inhibit and added spice-comment-indent... function
8601 ;; (set (make-local-variable 'auto-fill-inhibit-regexp) "^\*[^\.\+].*")
8603 ;; buffer local init for indentation of comment
8604 (set (make-local-variable 'spice-save-comment-line-break-function)
8605 comment-line-break-function)
8606 (set (make-local-variable 'comment-line-break-function)
8607 'spice-comment-indent-new-line)
8608 (set (make-local-variable 'fill-column) 78) ;; was 80
8610 ;; support for paragraphs (is it useful?) ; this is really arbitrary
8611 ;; all buffer local
8612 ;; (set (make-local-variable 'paragraph-start) "^[!$*]-.*$")
8613 ;; (set (make-local-variable 'paragraph-separate) "^[!$*]-.*$")
8614 (set (make-local-variable 'paragraph-start)
8615 "\\([a-z\\.].*\\([\n][+].*\\)*\\|[$]...+\\|[!]...+\\|[ \t\f]*$\\|\\*...+\\|.*\\s-[$!].*$\\)")
8616 ;; (set (make-local-variable 'paragraph-separate) "[a-z$!*]")
8617 (set (make-local-variable 'paragraph-separate) "\\([ \t\f]*\\|.*\\s-[$!].*\\)$")
8618 (set (make-local-variable 'adaptive-fill-regexp) nil)
8619 (set (make-local-variable 'adaptive-fill-function) 'spice-fill-context-prefix)
8620 (set (make-local-variable 'adaptive-fill-first-line-regexp) "[*$!+]\\s-+")
8622 ;; Tempo tags - using 'tempo-local-tags' doesn't work (why??)
8623 (set (make-local-variable 'tempo-tags)
8624 (append spice-tempo-tags tempo-tags))
8626 ;; buffer local font lock
8627 (set (make-local-variable 'font-lock-defaults)
8628 (list 'spice-font-lock-keywords nil t (list (cons ?\" "w")))) ;; nil, t (do multiline comments)
8629 (set (make-local-variable 'font-lock-multiline) t)
8630 (font-lock-set-defaults)
8632 ;; imenu init:
8633 (set (make-local-variable 'imenu-case-fold-search) t)
8634 ;; buffer local imenu init
8635 (set (make-local-variable 'imenu-generic-expression)
8636 spice-imenu-generic-expression)
8638 ;; add speedbar (global, can be moved ?)
8639 (spice-speedbar-init)
8641 ;; func-menu stuff, all buffer local
8642 (if spice-use-func-menu
8643 (if (fboundp 'function-menu)
8644 (funcall 'spice-func-menu-init)))
8646 ;;------------------------------------------------------------
8647 ;; now hook in 'spice-colorize-libraries (eldo-mode.el)
8648 ;; all buffer local:
8649 ;;(make-local-hook 'font-lock-mode-hook)
8650 (when (and (featurep 'xemacs) (not (emacs-version>= 21 5)))
8651 (make-local-hook 'font-lock-after-fontify-buffer-hook)); doesn't exist in emacs 20
8652 ;;(add-hook 'font-lock-mode-hook 'spice-colorize-libraries-buffer t t)
8653 (add-hook 'font-lock-after-fontify-buffer-hook 'spice-colorize-libraries-buffer t t) ; not in emacs 20
8655 (when (and (featurep 'xemacs) (not (emacs-version>= 21 5)))
8656 (make-local-hook 'after-change-functions))
8657 (add-hook 'after-change-functions 'spice-colorize-libraries t t)
8658 (spice-colorize-libraries-buffer)
8660 ;;------------------------------------------------------------
8661 ;; compile buffer local init
8662 (spice-compile-init)
8664 ;;------------------------------------------------------------
8665 ;; buffer local init
8666 (spice-waveform-viewer-init)
8668 ;; if new file add a default template
8669 (if (and (= (buffer-size) 0)
8670 (not buffer-read-only)
8671 spice-initialize-empty-file
8672 (functionp spice-initialize-file-function))
8673 (funcall spice-initialize-file-function))
8675 ) ;; matches big if (normal spice or spice output mode)
8677 ;; build imenu, buffer local
8678 (imenu--make-index-alist t)
8680 ;; add imenu to menubar, buffer local
8681 (when spice-imenu-add-to-menubar
8682 (imenu-add-to-menubar "Index"))
8684 ;; msb fix, run only once
8685 (and (featurep 'msb) ;; have we got this feature ?
8686 msb-mode ;; is it on ?
8687 (boundp 'msb-menu-cond) ;; still using msb-menu-cond ?
8688 (not spice-msb-fixed) ;; haven't yet added spice decks category ?
8689 (spice-msb-fix)) ;; add category
8691 ;; open describe window, hope this doesn't annoy people too much...
8692 (if spice-show-describe-mode
8693 (save-excursion
8694 (describe-mode) ;; aha...
8695 (setq spice-show-describe-mode nil)) ;; but only once in a session !!
8697 (if spice-echo-intro
8698 (message "Spice mode %s. Type C-h m for documentation." ;; always
8699 spice-version))
8701 ;; run spice-mode hooks
8702 (run-hooks 'spice-mode-hook)
8706 ;; this is sometimes useful
8707 (provide 'spice-mode)
8709 ;;; spice-mode.el ends here
8711 ;;; Local Variables:
8712 ;;; mode:Emacs-lisp
8713 ;;; End: