delete some invalid and useless functions
[spice-mode.git] / spice-mode.el
blob35b40f1a6c730455ec90d3a3b025b7071ae21a0e
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/
17 ;; Please send suggestions and bug reports to
18 ;; mailto:Geert_VanderPlas@email.com
20 ;; Copyright (C) 1994, MIT Artificial Intelligence Lab
21 ;; Copyright (C) 1997- Emmanuel Rouat
22 ;; Copyright (C) 1999- Geert A. M. Van der Plas
24 ;; This file is free software; you can redistribute it and/or modify
25 ;; it under the terms of the GNU General Public License as published by
26 ;; the Free Software Foundation; either version 2, or (at your option)
27 ;; any later version.
29 ;; This file is distributed in the hope that it will be useful,
30 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
31 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 ;; GNU General Public License for more details.
34 ;; You should have received a copy of the GNU General Public License
35 ;; along with GNU Emacs; see the file COPYING. If not, write to
36 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
38 ;; INSTALL:
39 ;; ========
41 ;; byte compile spice-mode.el to spice-mode.elc (see `byte-compile-file')
42 ;; put these two files in an arbitrary, but accesible directory
43 ;; for example: $HOME/emacs, /usr/lib/emacs/site-lisp/ or
44 ;; /usr/local/lib/emacs/site-lisp/
46 ;; If you chose a non-standard place to put the files add the following
47 ;; line to your Emacs start-up file (`.emacs') or custom `site-start.el'
48 ;; file (replace <directory-name> by the directory where you placed
49 ;; spice-mode.el and spice-mode.elc):
50 ;; (setq load-path (cons (expand-file-name "<directory-name>") load-path))
52 ;; To use spice-mode, add either the following to your `.emacs' file. This
53 ;; assumes that you will use the .sp, .cir, .ckt, .mod, ... extensions for
54 ;; your spice source decks and output files:
55 ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
56 ;; (setq auto-mode-alist (append (list (cons "\\.sp$" 'spice-mode)
57 ;; (cons "\\.cir$" 'spice-mode)
58 ;; (cons "\\.ckt$" 'spice-mode)
59 ;; (cons "\\.mod$" 'spice-mode)
60 ;; (cons "\\.cdl$" 'spice-mode)
61 ;; (cons "\\.chi$" 'spice-mode) ;eldo outpt
62 ;; (cons "\\.inp$" 'spice-mode))
63 ;; auto-mode-alist))
65 ;; Other way to load spice mode (by Andrew Scott):
66 ;; ;;; Testing for spice-mode (Another spice mode, also works on Spice,
67 ;; ;;; Eldo, Layla; this one works on GNU Emacs-20.6 issues).
68 ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
69 ;; (add-to-list 'auto-mode-alist '("\\.cir$" . spice-mode))
70 ;; (add-to-list 'auto-mode-alist '("\\.ckt$" . spice-mode))
71 ;; (add-to-list 'auto-mode-alist '("\\.inp$" . spice-mode))
72 ;; (add-to-list 'auto-mode-alist '("\\.spout$" . spice-mode));hspice out
73 ;; (add-to-list 'auto-mode-alist '("\\.pdir$" . spice-mode))
74 ;; ;;; Intel formats
75 ;; (add-to-list 'auto-mode-alist '("\\.[sS][pP]$" . spice-mode))
76 ;; (add-to-list 'auto-mode-alist '("\\.[sm]?t0$" . spice-mode))
77 ;; (add-to-list 'auto-mode-alist '("\\.[h]?spice$" . spice-mode))
79 ;; CUSTOMIZATION:
80 ;; ==============
82 ;; use customization to modify the behaviour of spice-mode; add
83 ;; custom-set-variables to your `.emacs' file, for example:
84 ;; (custom-set-variables
85 ;; ; '(spice-initialize-file-function (quote geert-spice-file-header)) ;; use geert-spice-file-header function (not included in this file !)
86 ;; '(spice-initialize-empty-file t) ;; initialize empty/new spice file
87 ;; ; '(spice-standard '(spice2g6 (hspice eldo eldorf eldovloga layla))) ;; all 4 modes
88 ;; '(spice-standard (quote (spice2g6 (hspice eldo)))) ;; hspice and eldo
89 ;; '(spice-standard (quote (spice2g6 ()))) ;; spice2g6/3 only
90 ;; '(spice-simulator "Spice3") ;; default simulator
91 ;; '(spice-waveform-viewer "Nutmeg") ;; default waveform
92 ;; '(spice-highlight-keywords nil) ;; less highlighting
93 ;; '(spice-section-alist ;; add own sections
94 ;; ;; this is ugly, I know ;)
95 ;; (append (nth 1 (nth 0 (get 'spice-section-alist 'standard-value)))
96 ;; (list
97 ;; (list "My Header" "MY HEADER" nil)
98 ;; )))
99 ;; '(spice-show-describe-mode nil) ;; don't describe mode at startup
100 ;; )
102 ;; This can also be achieved interactively through customizations !
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
105 ;;; Commentary:
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 ;; The original spice-mode.el created by C. Vieri has been modified
109 ;; extensively. These changes have been heavily influenced by the eldo-mode.el
110 ;; of Emmanuel Rouat (the tempo-templates for one) and the vhdl-mode.el of
111 ;; Reto Zimmermann and Rodney J. Whitby (the font-locking, the
112 ;; customization, the menus, ...) Help in understanding 'advanced' Lisp
113 ;; was provided by G. Debyser <geert.debyser@advalvas.be>, our (Common) Lisp
114 ;; expert. Since version 0.97 a lot of input/ideas have been provided by
115 ;; Emmanuel Rouat. Just take a look and search for eldo-mode ;)
117 ;; This package provides an Emacs major mode for editing SPICE decks.
119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120 ;;; TODO:
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 ;; - customization group spice- needs to be improved
124 ;; activate customizations needs to be looked at (potentially removed)
125 ;; - fix problem imenu sometimes truncating filenames of include files
126 ;; by replacing the functionality with own function
127 ;; - improve Y instance handling. use builtin macromodels, and own development;; models
128 ;; - ...
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
131 ;;; BUGS:
132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
134 ;; - searching for .subckt could be buggy because of user's file structure
135 ;; - xinstance highlighting is buggy, and probably always will ?
136 ;; - font-lock expressions are incredibly complicated, and multiple spice
137 ;; formats are not handled correctly at the same time...
139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
141 ;; If you have any questions about this mode, feel free to contact me
142 ;; at the following address: geert_vanderplas@email.com. If I find the
143 ;; time, I can take a look at the problem
145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147 ;;; Code:
148 (defconst spice-version "1.2.25 (03 Jan 2007)"
149 "Current version of spice mode (spice2g6/spice3/hspice/eldo(rf&verilog-a)/fasthenry/layla/mondriaan/draccdl/spectre).")
151 (defconst spice-developer
152 "Geert Van der Plas & Emmanuel Rouat (<geert_vanderplas@email.com>, <emmanuel.rouat@wanadoo.fr>)"
153 "Current developers/maintainers of spice-mode.")
155 (defvar spice-tempo-tags nil
156 "List of templates used in spice mode.")
159 ;; help function
160 (defun spice-custom-set (variable value &rest functions)
161 "Set VARIABLE as VALUE in `custom-set-default' and call FUNCTIONS (if bound) afterwards."
162 (if (fboundp 'custom-set-default)
163 (custom-set-default variable value)
164 (set-default variable value))
165 (while functions
166 (when (fboundp (car functions)) (funcall (car functions)))
167 (setq functions (cdr functions))))
170 (defgroup spice nil
171 "Customizations for Spice mode."
172 :prefix "spice-"
173 :link '(url-link "http://spice-mode.4t.com/")
174 :group 'languages
178 ;;;###autoload
179 (defcustom spice-mode-hook nil
180 "*List of hook functions run by `spice-mode' (see `run-hooks')."
181 :type 'hook
182 :group 'spice)
185 ;;;###autoload
186 (defcustom spice-standard '(spice2g6 (hspice eldo eldorf eldovloga fasthenry))
187 "Spice standards used.
189 Basic standard:
190 Spice2g6 : Original Berkeley Spice (leave this always on!)
191 Additional standards:
192 Hspice (TM) : Commercial Spice, formerly Meta Software, now owned by Synopsys
193 Eldo (TM) : Commercial Spice, formerly Anacad, now owned by Mentor Graphics
194 EldoRf (TM) : RF Steady State analyses of Eldo (also turn on Eldo!)
195 EldoVlogA : Verilog-A extensions to Eldo netlist language (also turn on Eldo!)
196 FastHenry : Multipole-accelerated inductance analysis program from MIT
197 Layla : KULeuven LAYLA (layout synthesis) extensions to Spice format
198 Mondriaan : KULeuven MONDRIAAN (layout synthesis) extensions (also turn on Layla!)
199 DracCDL (TM): Dracula CDL extensions (Cadence LOGLVS netlists)
200 Spectre (TM): Spice compatibility of Spectre language (simulator language=spice decks)."
201 :type '(list (choice :tag "Basic standard"
202 (const :tag "Spice2g6" spice2g6))
203 (set :tag "Additional standards" :indent 2
204 (const :tag "Hspice" hspice)
205 (const :tag "Eldo" eldo)
206 (const :tag "Eldo RF" eldorf)
207 (const :tag "Eldo Verilog-A" eldovloga)
208 (const :tag "FastHenry" fasthenry)
209 (const :tag "Layla" layla)
210 (const :tag "Mondriaan" mondriaan)
211 (const :tag "DracCDL" draccdl)
212 (const :tag "Spectre Spice Compatibility" spectre)))
213 :set (lambda (variable value)
214 (spice-custom-set variable value
215 'spice-check-spice-standard
216 'spice-mode-syntax-table-init
217 'spice-keywords-init
218 'spice-font-lock-init
219 'spice-imenu-init
220 'spice-update-existing-buffers))
221 :group 'spice)
224 ;;;###autoload
225 (defcustom spice-imenu-add-to-menubar t
226 "Spice mode adds imenu (Index) item to menubar."
227 :group 'spice
228 :set (lambda (variable value)
229 (spice-custom-set variable value
230 'spice-update-existing-buffers))
231 :type 'boolean)
233 ;;;###autoload
234 (defcustom spice-show-describe-mode nil ; was t
235 "Spice mode runs `describe-mode' once at start of spice-mode."
236 :group 'spice
237 :type 'boolean)
239 ;;;###autoload
240 (defcustom spice-echo-intro t
241 "Spice mode echos introductory message on entry to spice-mode."
242 :group 'spice
243 :type 'boolean)
245 (defgroup spice-initialize-file nil
246 "Customizations for initialization of empty/new spice files."
247 :group 'spice)
249 ;;;###autoload
250 (defcustom spice-initialize-empty-file nil
251 "Spice initialize empty/new file setting."
252 :group 'spice-initialize-file
253 :type 'boolean)
255 ;;;###autoload
256 (defcustom spice-initialize-template-file "~/.spice-default"
257 "File containing the default header in new empty file.
258 See also `spice-initialize-empty-file'."
259 :group 'spice-initialize-file
260 :type 'file)
262 ;;;###autoload
263 (defcustom spice-default-header nil
264 "Default header for new Spice netlists, see also `spice-initialize-empty-file'."
265 :group 'spice-initialize-file
266 :type 'string)
268 ;;;###autoload
269 (defcustom spice-initialize-file-function 'spice-initialize-empty-file
270 "Optional initialize function for empty/new files,
272 See also `spice-initialize-empty-file'.
274 If a different function is specified it should insert a default
275 header/template in the current buffer. This function should check
276 which submode is in use with `spice-standard-p' and adapt its
277 output accordingly. It may also use the `spice-default-header'
278 variable and insert its contents into the buffer."
279 :group 'spice-initialize-file
280 :type 'function)
282 (defgroup spice-simulate nil
283 "Customizations for simulation."
284 :group 'spice)
287 (defcustom spice-simulator-alist
289 ;; Spice3; spice3 -b <file.cir>
291 ("Spice3" "spice3 -b" ""
292 ("\\s-*Error[\t ]+on[ \t]+line[\t ]+\\([0-9]+\\) +:.+"
293 0 1 nil (buffer-file-name))
294 ("Circuit: \\(.*\\)$" 1)) ; spice3 hack, is not the filename, but that's no prob
295 ;; Hspice; hspice <file.cir>
296 ;; **error**: only 1 connection at node 0:2
297 ("Hspice" "hspice" ""
298 ("\\s-*\\(..?error..?[: ]\\).+" 0 spice-linenum 1 (buffer-file-name))
299 ("[* ]* [iI]nput [fF]ile: +\\([^ \t]+\\).*$" 1))
300 ;; Eldo; eldo -i <file.cir>
301 ;; ERROR 503: MODEL "NMOS": Undeclared model reference.
302 ("Eldo" "eldo -i" ""
303 ("\\s-*\\(E[rR][rR][oO][rR] +[0-9]+:\\).*"
304 0 spice-linenum 1 (buffer-file-name))
305 ("Running \\(eldo\\).*$" 1)) ; eldo hack, true filename can not be found
306 ;; Spectre; spectre <file.cir>
307 ;; "viblok2.cir" 7: Unknown dot word `.param'.
308 ("Spectre" "spectre" ""
309 ("\\s-*\"\\([^ \t\n]+\\)\" +\\([0-9]+\\):.*"
310 1 2)
311 ("" 0)) ; filename is in regexp of error
312 ;;; Add your local simulators here:
315 "*List of available Spice simulators and their properties.
316 Each list entry specifies the following items for a simulator:
317 Simulator:
318 Simulator Name : name used in variable `spice-simulator' to choose
319 simulator
320 Simulate Command : command including options used for simulation program
321 Extra switches : extra switches for simulator, after filename
322 Error Message:
323 Regexp : regular expression to match error messages
324 File Subexp Index: index of subexpression that matches the file name
325 Line Subexp Index: index of subexpression that matches the line number.
326 use function `spice-linenum' when the line number
327 is not available
328 Col Subexp Index : index of subexpression that matches the column number
329 if not available but `spice-linenum' has been
330 supplied in the previous field, use 1
331 File Message:
332 Regexp : regular expression to match a file name message
333 File Subexp Index: index of subexpression that matches the file name
335 See also variable `spice-simulator-switches' to add options to the
336 simulate command.
338 Most simulators do not include the file name in the error message, but print
339 out a file name message in advance. In this case, set \"File Subexp Index\"
340 to 0 and fill out the \"File Message\" entries."
341 :type '(repeat (list :tag "Simulator" :indent 2
342 (string :tag "Simulator Name ")
343 (string :tag "Simulate Command ")
344 ;(string :tag "From Directory " "./")
345 (string :tag "Extra Switches ")
346 (list :tag "Error Message" :indent 4
347 (regexp :tag "Regexp ")
348 (integer :tag "File Subexp Index")
349 (integer :tag "Line Subexp Index"))
350 (list :tag "File Message" :indent 4
351 (regexp :tag "Regexp ")
352 (integer :tag "File Subexp Index"))))
353 :set (lambda (variable value)
354 (spice-custom-set variable value
355 'spice-menu-init
356 'spice-compile-variables-init
357 'spice-update-existing-buffers))
358 :group 'spice-simulate)
361 ;;;###autoload
362 (defcustom spice-simulator nil ; example: "Hspice"
363 "Spice command, used when compiling buffer with `compile-mode', see also `spice-simulator-switches'."
364 :group 'spice-simulate
365 :type 'string)
368 ;;;###autoload
369 (defcustom spice-simulator-switches "" ; example "-noconf"
370 "Spice command switches, used when compiling buffer with `compile-mode', see also `spice-simulator'."
371 :group 'spice-simulate
372 :type 'string)
375 (defcustom spice-waveform-viewer-alist
377 ;; Nutmeg; nutmeg <waveformdata.dat>
379 ("Nutmeg" "nutmeg" "" spice-run-interactive (".dat" ".ac0" ".tr0")) ; spice3 nutmeg viewer
380 ("Gwave" "gwave" "" spice-run-silent
381 (".raw" ".braw" ".ac0" ".tr0" ".sw0" ".W" ".N" ".acs")) ; gwave viewer
382 ("Xelga" "xelga" "" spice-run-silent ".cou") ; xelga eldo viewer
383 ("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...
385 ;; ("Awaves2" "echo_awaves" "" spice-run-silent nil) ; awaves hspice viewer
386 ;;; Add your local waveform viewers here:
389 "*List of available Waveform viewers and their properties.
390 Each list entry specifies the following items for a waveform viewer:
391 Waveform Viewer:
392 Wave Viewer Name : name used in variable `spice-waveform-viewer' to choose
393 a waveform viewer
394 Wave Viewer Command : command including options used for waveform viewer
395 Extra switches : extra switches for waveform viewer, after filename
397 See also variable `spice-waveform-viewer-switches' to add options to the
398 waveform viewer command."
399 :type '(repeat (list :tag "Waveform Viewer" :indent 2
400 (string :tag "Waveform Viewer Name ")
401 (string :tag "Waveform Viewing Command ")
402 (string :tag "Extra Switches ")
403 (choice :tag "How"
404 :value spice-run-silent
405 (function-item spice-run-silent)
406 (function-item spice-run-interactive)
407 (function :tag "Other"))
408 (choice (string :tag "Filename Suffix ")
409 (function :tag "Function Deriving Filename")
410 (repeat (list :tag "List of Filename Suffixes")))))
411 :set (lambda (variable value)
412 (spice-custom-set variable value
413 'spice-menu-init
414 'spice-update-existing-buffers))
415 :group 'spice-simulate)
418 ;;;###autoload
419 (defcustom spice-waveform-viewer nil ; example: "Nutmeg"
420 "Spice command, used when starting waveform viewer, see also `spice-waveform-viewer-switches'."
421 :group 'spice-simulate
422 :type 'string)
425 ;;;###autoload
426 (defcustom spice-waveform-viewer-switches "" ; example "-b"
427 "Spice waveform viewer command switches, see also `spice-waveform-viewer'."
428 :group 'spice-simulate
429 :type 'string)
432 (defgroup spice-commands nil
433 "Customizations for commands."
434 :group 'spice)
436 ;;;###autoload
437 (defcustom spice-shell
438 (if (memq system-type '(ms-dos emx windows-nt))
439 shell-file-name
440 "/bin/sh")
441 "*Name of shell used to parse spice commands."
442 :group 'spice-commands
443 :type 'file)
445 ;;;###autoload
446 (defcustom spice-shell-command-option
447 (cond ((memq system-type '(ms-dos emx windows-nt) )
448 (cond ((boundp 'shell-command-option)
449 shell-command-option)
450 ((boundp 'shell-command-switch)
451 shell-command-switch)
453 "/c")))
454 (t ;Unix & EMX (Emacs 19 port to OS/2)
455 "-c"))
456 "*Shell argument indicating that next argument is the command."
457 :group 'spice-commands
458 :type 'string)
461 (defgroup spice-hide nil
462 "Customizations for hiding of comments."
463 :group 'spice)
465 ;;;###autoload
466 (defcustom spice-hide-line-prefix
467 (if (featurep 'newcomment)
468 '(concat
469 (regexp-quote
470 (concat comment-start
471 (if (boundp 'comment-padding)
472 (if (integerp comment-padding)
473 (make-string comment-padding ? )
474 comment-padding)
475 " ")))
476 "[a-z\\*!$0-9+\\.]"))
477 "Regexp string describing lines that are commented out and will be hidden.
479 The regexp is matched to the beginning of a line, the ^ is added
480 automatically. The initialization of this variable is handled in
481 `spice-hide-init', which is after the setting of `comment-start'
482 and `comment-padding' variables."
483 :group 'spice-hide
484 :type 'string)
486 ;;;###autoload
487 (defcustom spice-auto-hide-comments nil
488 "*Boolean indicating automatic hiding of all commented regions at load time."
489 :group 'spice-hide
490 :type 'boolean)
493 (defgroup spice-section nil
494 "Customizations for sections."
495 :group 'spice)
497 ;; sections (entirely different implementation but sections idea has
498 ;; been taken from eldo-mode.el)
499 ;;;###autoload
500 (defcustom spice-section-alist
502 ;; Libraries
503 ("Libraries" "LIBRARIES" nil) ;
504 ;; Netlist
505 ("Netlist" "NETLIST" nil) ;
506 ;; Main Circuit
507 ("Main Circuit" "MAIN CIRCUIT" nil) ;
508 ;; Options
509 ("Options" "SIMULATION OPTIONS" nil) ;
510 ;; Supplies
511 ("Supplies" "SUPPLIES/REFERENCES" nil) ;
512 ;; Input Signals
513 ("Input Signals" "INPUT SIGNALS" nil) ;
514 ;; DC Analysis
515 ("DC Analysis" "DC ANALYSIS" nil) ;
516 ;; AC Analysis
517 ("AC Analysis" "AC ANALYSIS" nil) ;
518 ;; Transient Analysis
519 ("Transient Analysis" "TRANSIENT ANALYSIS" nil) ;
520 ;;; Add your site-local spice sections here:
523 "*List of valid sections in a Spice file and their options.
524 Each list entry specifies the following items for a section:
525 Section:
526 Section Name : name used in to select/create find section, make this
527 name short and descriptive.
528 Section String : string used in file to start section (usually all
529 uppercase variant of name).
530 Extra switches : extra switches for a section, unspecified for now."
531 :type '(repeat (list :tag "Section" :indent 2
532 (string :tag "Section Name ")
533 (string :tag "Section String ")
534 (sexp :tag "Extra Switches (nil)")))
535 :set (lambda (variable value)
536 (spice-custom-set variable value
537 'spice-keywords-init
538 'spice-font-lock-init
539 'spice-menu-init
540 'spice-imenu-init
541 'spice-update-existing-buffers))
542 :group 'spice-section)
545 (defgroup spice-faces nil
546 "Customizations for highlighting."
547 :group 'spice)
549 ;;;###autoload
550 (defcustom spice-highlight-keywords t
551 "*Non-nil means highlight SPICE keywords and other standardized words.
552 The following faces are used:
553 `spice-title-face' : title (first line in a spice file)
554 `spice-doc-face' : doc strings
555 `spice-analysis-face' : analyses
556 `spice-instance-name-face' : instance/element names
557 `spice-model-name-face' : subckt model names
558 `spice-layla-function-name-face': layla function names
559 `spice-include-file-face' : include files and libraries
560 `font-lock-keyword-face' : keywords
561 `font-lock-warning-face' : warnings
562 `font-lock-comment-face' : comment
563 `font-lock-function-name-face': subcircuit references / names of objects
564 `font-lock-type-face' : types
565 `font-lock-string-face' : strings & include files
566 `font-lock-constant-face' : simulator's options
567 `font-lock-variable-name-face': names of .param's & variables
568 NOTE: Activate the new setting in a spice buffer by re-fontifying it (menu
569 entry \"Fontify Buffer\")."
570 :type 'boolean
571 :group 'spice-faces)
573 ;; We try to use usual/standard font-lock faces, plus a few specific ones:
574 (custom-add-to-group
575 'spice-faces 'font-lock-comment-face 'custom-face)
576 (custom-add-to-group
577 'spice-faces 'font-lock-keyword-face 'custom-face)
578 (custom-add-to-group
579 'spice-faces 'font-lock-type-face 'custom-face)
580 (custom-add-to-group
581 'spice-faces 'font-lock-function-name-face 'custom-face)
582 (custom-add-to-group
583 'spice-faces 'font-lock-variable-name-face 'custom-face)
584 (custom-add-to-group
585 'spice-faces 'font-lock-warning-face 'custom-face)
586 (custom-add-to-group
587 'spice-faces 'font-lock-string-face 'custom-face)
590 (defgroup spice-output nil
591 "Customizations for spice output file handling."
592 :group 'spice)
594 ;;;###autoload
595 (defcustom spice-output-filename-alist
597 ;; Libraries
598 (eldo (concat (file-name-sans-extension (buffer-file-name)) ".chi")) ;
599 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".lis")) ;
600 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".spout")) ;
601 (hspice (concat (file-name-sans-extension (buffer-file-name)) ".hspout")) ;
602 (spice2g6 (concat (file-name-sans-extension (buffer-file-name)) ".out")) ;
604 "List of valid output names depending on selected spice standard.
606 Spice Standard : one of spice2g6, hspice, eldo or layla
607 Expression : expression calculating the output filename."
608 :type '(repeat (list :tag "Output Filenames" :indent 2
609 (symbol :tag "Spice Standard ")
610 (sexp :tag "Expression ")))
611 :group 'spice-output)
614 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
615 ;; buffer local vars for spice-mode
617 ;;(defvar spice-standard-local nil
618 ;; "buffer local version of spice-standard.")
620 (defvar spice-output-local nil
621 "Buffer local version of spice-output.")
623 (defun spice-standard-p (standard)
624 "Check if STANDARD is specified as used standard on local variable."
625 (or (eq standard (car spice-standard))
626 (memq standard (cadr spice-standard))))
629 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
630 ;; regexps for spice mode
632 (defconst spice-continuation-prefix "+"
633 "Continuation prefix for normal spice line.")
635 (defconst spice-line-break "\\(\n\\s-*\\+\\s-*\\)*"
636 "Regexp that matches a (possible) line break (\n+).")
638 (defconst spice-model-name "\\([a-z][^ \t\n=]*\\)" ; "\\([a-z]\\sw*[^ \t\n=]*\\)"
639 "Regexp that describes a syntactically correct model or subckt name.")
641 (defconst spice-library-regexp-start
642 "^\\.\\(inc\\|include\\|verilog\\|use_veriloga\\|lib\\(\\s-+key=\\w+\\)?\\|libfas\\|subckt\\s-+lib\\|model\\s-+lib\\)\\s-+[\"']?"
643 "Regexp that matches the beginning of library or include filename.")
645 (defconst spice-library-regexp-end
646 "\\([^ \t\n\"']*\\)"
647 "Regexp that matches the end of library or include filename.") ; doesn't catch end of buffer
649 (defconst spice-section-regexp-start "\\(^[*!$]\\s-*\\)"
650 "Spice mode section header start regexp.")
652 (defconst spice-spice2g6-keywords
654 "subckt"
655 "print" "plot"
656 "opt" ; opt is actually a spice3 keyword, not 2g6
657 "nodeset"
658 "model" "macro" "include" ; include is actually a spice3 keyword, not 2g6
659 "ends" "end"
661 "List of Spice2g6 keywords.")
663 (defconst spice-spice2g6-analyses
665 "tran" "op" "noise" "four" "disto" "dc" "ac"
667 "List of Spice2g6 analysis keywords.")
669 (defconst spice-spice2g6-analysis-modifiers
671 "dec" "lin" "oct" ;; the ubiquitous spice2g6 ac modifiers
672 "pol" "zer" "pz" "cur" "vol" ;; pz analysis spice3
673 "ac" ;; .sens analysis spice3
675 "List of Spice2g6 analysis modifier keywords.")
677 (defconst spice-eldo-keywords
679 "width" "use" "unprotect" "tvinclude" "topcell"
680 "table" "subdup" "solve" "sinus" "sigbus"
681 "setsoa" "setbus" "save" "restart" "ramp"
682 "protect" "probe" "plotbus"
683 "param" "overwrite_input" "optwind" "optpwl" "optnoise" "options"
684 "option" "optfour"
685 "notrc" "nocom" "modlogic"
686 "moddup" "meas" "mcmod" "lotgroup" "loop" "load"
687 "libfas" "lib" "init" "include" "ic" "hier" "guess" "global"
688 "extract" "endl" "enddata" "dspf_include" "distrib" "del"
689 "defwave" "defplotdig" "defmac" "data" "d2a" "comchar" "conso" "connect"
690 "chrsim" "chrent" "chrand" "checksoa" "checkbus" "alter" "addlib" "a2d"
692 "List of Eldo keywords.")
694 (defconst spice-eldo-colon-keywords
696 "param" "pin" "model"
698 "List of Eldo colon keywords.")
700 (defconst spice-eldo-macromodel-keywords
702 "opamp0" "opamp0d" "opamp1" "opamp1d" "opamp2" "opamp2d"
703 "satr" "satv" "vswitch" "cswitch"
704 "tri2sin" "stairgen" "sawgen" "trigen"
705 "amm" "pam"
706 "sa_ho" "tr_ho"
707 "pwm" "vco"
708 "peak_d" "lev_d"
709 "logamp" "expamp"
710 "diff" "integ"
711 "add" "sub" "mult" "div"
712 "sc_ideal" "sc_i" "sc_n" "sc_p" "sc_s1" "sc_s2"
713 "sc_sp1" "sc_sp2" "sc_b" "sc_u"
715 "List of Eldo macromodels.")
717 (defconst spice-eldo-analyses
719 "wcase" "tf" "temp"
720 "step" "snf" "sens" "pz"
721 "noisetran" "mc"
723 "List of Eldo analysis keywords.")
725 (defconst spice-eldo-analysis-modifiers
728 "List of Eldo analysis modifier keywords.")
730 (defconst spice-eldorf-keywords
732 "sst"
734 "List of Eldo RF keywords.")
736 (defconst spice-eldovloga-keywords
738 "verilog" "use_veriloga"
740 "List of Eldo Verilog-A keywords.")
742 (defconst spice-eldovloga-colon-keywords
744 "port" "generic"
746 "List of Eldo Verilog-A colon keywords.")
748 (defconst spice-eldorf-analyses
750 "sstac" "sstxf" "sstnoise"
752 "List of Eldo RF keywords.")
754 (defconst spice-hspice-keywords
756 "width" "unprot" "unprotect" "uic"
757 "title" "sys" "system" "save"
758 "sample" "prot" "protect"
759 "probe" "pc" "parameter"
760 "param" "options" "option"
761 "nomod"
762 "measure" "meas" "macro"
763 "load" "lib" "include" "inc" "ic" "graph" "global"
764 "eom" "enddata" "dellib" "delete"
765 "del" "dcvolt" "data" "control" "comment"
766 "alter"
767 "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
769 "List of Hspice keywords.")
771 (defconst spice-hspice-analyses
773 "disto"
774 "fft"
775 "tf" "temp"
776 "net" ;; S, Z, Y and H parameters
777 "sample"
778 "sens"
779 "pz"
780 "noise"
782 "List of Hspice analysis keywords.")
784 (defconst spice-hspice-analysis-modifiers
786 "sweep" "poi"
788 "List of Hspice analysis modifier keywords.")
790 (defconst spice-fasthenry-keywords
792 "units" "default" "external" "equiv"
794 "List of FastHenry keywords.")
796 (defconst spice-fasthenry-analyses
798 "freq"
800 "List of FastHenry analysis keywords.")
802 (defconst spice-fasthenry-analysis-modifiers
805 "List of FastHenry analysis modifier keywords.")
807 (defconst spice-layla-keywords
809 "stop" "start"
810 "port" "performance" "parameter"
811 "param" "options" "option"
812 "net"
813 "model" "matching"
814 "include" "inc"
815 "bus"
817 "List of Layla keywords.")
819 (defconst spice-mondriaan-keywords
821 "master" "routingarea" "routingchannel" "ports" "portgrid" "net"
823 "List of Mondriaan keywords.")
825 (defconst spice-draccdl-keywords
827 "bipolar" "busdelimiter" "capa" "caparea" "capval" "default" "dioarea"
828 "dioperi" "diode" "edifdelimiter" "busdelimiter" "equation" "equiv"
829 "gnonswap" "ldd" "mega" "nonswap" "nopin" "nosub" "pin" "pininfo"
830 "resi" "ressize" "resval" "reverse" "scale" "spice" "unspec"
831 "eom" "global" "param" "macro" "swap"
833 "List of Dracula CDL keywords.")
835 (defconst spice-spice2g6-types
837 "ac" "dc" "exp" "pulse" "pwl" "sffm" "sin"
839 "List of types in spice2g6.")
841 (defconst spice-hspice-types
843 "metal" "dielectric" "pec" "rectangle" "circle" "strip" "polygon" ;; ""
845 "List of types in hspice.")
847 (defconst spice-eldo-types
849 "pattern"
851 "List of source types in eldo.")
853 (defconst spice-eldorf-types
855 "fpulse" "four" "probe"
857 "List of source types in eldorf.")
859 (defconst spice-fasthenry-types
861 "point" "rect" "circle"
862 "user1" "user2" "user3" "user4" "user5" "user6" "user7"
864 "List of source types in fasthenry.")
866 (defconst spice-special-model-type-names
868 "d" "npn" "pnp" "nmos" "pmos"
870 "List of model type names which are excluded for imenu.")
872 (defconst spice-spice2g6-model-type-names
874 "r" "c" "urc" "ltra"
875 "njf" "pjf"
876 "nmf" "pmf"
877 "sw" "csw"
879 "List of model type names in spice2g6.")
881 (defconst spice-eldo-model-type-names
883 "res" "cap" "ind"
884 "rn" "rp" "lpnp"
886 "List of model type names extra in eldo.")
888 (defconst spice-eldo-vloga-model-type-names
890 "macro"
892 "List of model type names extra in Eldo Verilog-A.")
894 (defconst spice-hspice-model-type-names
896 "l" "core" "w" "plot"
898 "List of model type names extra in hspice.")
900 (defconst spice-spice2g6-output-keywords
901 '("print" "plot")
902 "List of output keywords in spice2g6.")
904 (defconst spice-spice2g6-output-types
905 '("ac" "dc" "tran")
906 "List of output types in spice2g6.")
908 (defconst spice-eldo-output-keywords
909 '("extract" "meas")
910 "List of output keywords in eldo.")
912 (defconst spice-eldo-output-types
913 '("dcac" "dcsweep" "dctran" "noise" "four" "sweep")
914 "List of output types in eldo.")
916 (defconst spice-eldorf-output-types
917 '("fsst" "tsst" "sstac" "sstxf" "ssnoise" )
918 "List of output types in eldo.")
920 (defconst spice-hspice-output-keywords
921 '("probe" "graph" "measure")
922 "List of output keywords in hspice.")
924 (defconst spice-hspice-output-types
925 '("noise" "disto")
926 "List of output types in hspice.")
928 (defconst spice-spice2g6-options-keywords
929 '("trytocompact")
930 "List of spice2g6/3 options keywords.")
932 (defconst spice-eldo-options-keywords
933 '("wsf" "wsfascii" "sda"
934 "precise" "spi3asc" "spi3bin" "spicedc" "spiout" "libfas" "nolib"
935 "ammeter" "msgbias" "nowarn" "ulogic" "aspec" "mod4pins" "modwl" "wl"
936 "captab" "coustep" "input" "lcapop" "list" "noascii" "ascii"
937 "autostop" "nobound_phase" "nocou" "node" "nomod" "nopage" "nosizechk"
938 "notrc" "trap" "smooth" "be" "gear" "newton" "iem" "analog" "digital"
939 "osr" "mixed" "pstran" "dptran" "itl6" "itl7" "itl8" "nmaxsize"
940 "noconvassist" "nolat" "pivrel" "pivtol" "qtrunc" "noconvassist"
941 "nolat" "pivrel" "pivtol" "qtrunc" "relvar" "splitc" "noswitch"
942 "unbound" "randmc" "usedefap" "engnot" "nodcpart" "probeop"
943 "noprobeop" "histlim" "wbulk" "noinit" "nonoise" "tempcouk" "nofnsiem"
944 "icdc" "icdev" "carlo_gauss" "cteprec" "d2dmvl9bit" "defconvmsg"
945 "maxnodeord" "notrclib" "motorola" "aex")
946 "List of eldo options keywords.")
948 (defconst spice-eldorf-options-keywords
949 '("sst_freqdiv")
950 "List of Eldo RF options keywords.")
952 (defconst spice-hspice-options-keywords
953 '("acct" "converge"
954 "absh" "acout" "cds" "scale" "cshdc" "alt999" "alt9999" "csdf"
955 "accurate" "dvdt" "measout" "acout" "brief" "cshunt" "gshunt" "probe"
956 "kcltest" "dctran" "di" "itl5" "list" "sda" "gshunt" "cshunt" "post"
957 "node" "noelck" "gshunt" "maxamp" "nomod" "aspec" "icsweep" "relh"
958 "nopage" "newtol" "reli" "notop" "parhier" "off" "spice" "wl"
959 "dvtr" "nxx" "seed" "risetime" "imax" "nopiv" "imin" "opts" "cscal"
960 "vntol" "absv" "pathnum" "badchr" "fmax" "plim" "diagnostic" "pivref"
961 "fscal" "autostop" "nowarn" "gscal" "search" "lscal" "bypass" "verify"
962 "sparse" "pivot" "pzabs" "cpu" "pztol" "fast" "interp" "h9007" "expli"
963 "ritol" "itlpz" "itrprt" "unwrap" "captab" "newtol" "dccap")
964 "List of hspice options keywords.")
966 (defconst spice-spice2g6-options-parameters
967 '("gmin" "reltol" "abstol" "vntol" "trtol" "chgtol" "pivtol" "pivrel"
968 "tnom" "temp" "lvlcod" "itl1" "itl2" "itl3" "itl4" "itl5" "defl"
969 "defw" "defad" "defas" "method")
970 "List of spice2g6/3 options parameters.")
972 (defconst spice-eldo-options-parameters
973 '("cptime" "msgnode" "zoomtime" "bsim3ver" "defnrd" "defnrs" "defpd" "defps"
974 "gramp" "scale" "scalebsim" "scalm" "soiback" "flicker_noise"
975 "thermal_noise" "cousmp" "limprobe" "ascii" "savetime" "simudiv"
976 "stat" "timediv" "maxord" "bloc" "epsdig" "absvar" "capanw" "chgtol"
977 "dvdt" "eps" "fluxtol" "freqsmp" "ft" "hmin" "hmax" "itol" "lvltim"
978 "maxnodes" "maxtran" "maxv" "netsize" "ngtol" "ratprint" "reltrunc"
979 "sample" "startsmp" "step" "trtol" "tuning" "vmin" "vntol" "xa"
980 "numdgt" "dcpart" "couresol" "defa2d" "defd2a" "vbcsat" "dclog" "epso"
981 "optype")
982 "List of eldo options parameters.")
984 (defconst spice-eldorf-options-parameters
985 '("sst_start" "sst_stop" "sst_nper"
986 "sst_npt" "sst_ovrsmp" "sst_spectrum" "sst_uic"
987 "sst_max_liniter" "sst_verbose")
988 "List of Eldo RF options parameters.")
990 (defconst spice-hspice-options-parameters
991 '("artist" "dcap" "absh" "absvar" "absi" "absv" "delmax" "absmos"
992 "dcfor" "dchold" "fs" "mentor" "absvdc" "dcon" "ft" "co" "reltol" ; "post"
993 "cvtol" "di" "dcstep" "imin" "ingold" "imax" "lennam" "psf" "maxamp"
994 "dv" "defl" "relh" "gmax" "relvar" "measdgt" "zuken" "defnrd" "reli"
995 "gmindc" "rmax" "defnrs" "relmos" "gramp" "rmin" "defpd" "relv"
996 "slopetol" "defps" "relvdc" "timeres" "limpts" "scalm" "relq" "numdgt"
997 "resmin" "optlst" "trtol" "genk" "pivot" "sparse" "lvltim" "klim"
998 "maxord" "post_version" "bkpsiz" "mu" "xmu" "warnlimit" "expli"
999 "bytol" "cptime" "epsmin" "mbypass" "expmax" "limtim" "vfloor")
1000 "List of hspice options parameters.")
1002 (defconst spice-layla-options-parameters
1003 '("begin_temp_iterations" "begin_acc_prob" "min_temp_scale_factor"
1004 "max_temp_scale_factor" "max_inner_loop_delta" "max_cost_delta"
1005 "min_range_scale_factor" "nr_temp_steps"
1006 "min_stable_inner_loops" "min_local_iterations" "max_local_iterations"
1007 "max_iterations" "bank_min_ar" "bank_max_ar" "bank_orientations"
1008 "bank_routing_space" "bus_sides" "bus_layer" "bus_port_width"
1009 "bus_port_height" "bus_port_distance" "bus_routing_space" "cap_min_ar"
1010 "cap_max_ar" "cap_orientations" "cap_routing_space" "cap_ar_step"
1011 "coil_orientations" "coil_routing_space" "alfa_area"
1012 "alfa_performance" "alfa_aspect_ratio" "alfa_overlap" "alfa_overlap_min"
1013 "alfa_overlap_max" "kappa_overlap" "device_min_ar" "device_max_ar"
1014 "device_orientations" "device_routing_space" "device_current"
1015 "diode_min_ar" "diode_max_ar" "diode_orientations"
1016 "diode_routing_space" "diode_current" "matching_compute_method"
1017 "dummy_min_ar" "dummy_max_ar" "dummy_orientations"
1018 "dummy_routing_space" "dummy_ar_step"
1019 "mos_min_ar" "mos_max_ar" "mos_orientations" "mos_routing_space"
1020 "mos_current" "prob_reshape" "prob_reorientation"
1021 "prob_symmetric_translation" "prob_symmetric_swap"
1022 "prob_symmetric_flip" "prob_symmetric_flip" "prob_symmetric_shift"
1023 "prob_independent_translation" "prob_independent_swap"
1024 "prob_independent_flip" "min_move_range" "net_compute_method"
1025 "write_init" "write_int" "int_write_interval" "write_fin" "write_final"
1026 "mentor_write_ipc" "gds2_write_ipc" "construct_net_performance"
1027 "construct_matching_performance" "aspect_ratio" "field_grow_factor"
1028 "field_aspect_ratio" "disable_symmetry" "disable_matching"
1029 "do_kul_routing" "kul_router_program" "kul_router_directives_file"
1030 "number_of_randomize_loops" "port_inherit_terminals" "bus_priority"
1031 "port_sides" "port_layer" "port_width" "port_height" "port_distance"
1032 "port_abutment" "port_routing_space" "port_no_routing" "port_current"
1033 "res_ar_step" "res_min_ar" "res_max_ar" "res_orientations"
1034 "res_routing_space" "res_width" "res_current" "disable_couple_flipping"
1035 "symmetry_max_offset_factor" "print_cost" "placement_name"
1036 "write_final_ample" "write_final_skill" "write_final_gds2_bin"
1037 "write_final_gds2_cells" "write_final_tud"
1038 "write_final_ample_generators" "write_final_ample_cells"
1039 "write_final_cif" "write_final_rose" "write_final_kul"
1040 "write_final_text"
1041 "write_int_ample" "write_int_skill" "write_int_gds2_bin"
1042 "write_int_gds2_cells" "write_int_tud" "write_int_ample_generators"
1043 "write_int_ample_cells" "write_int_cif" "write_int_rose"
1044 "write_int_kul" "write_int_text"
1045 "write_init_ample" "write_init_skill" "write_init_gds2_bin"
1046 "write_init_gds2_cells" "write_init_tud" "write_init_ample_generators"
1047 "write_init_ample_cells" "write_init_cif" "write_init_rose"
1048 "write_init_kul" "write_init_text" "time_out"
1049 "random_seed" "anneal_rs" )
1050 "List of LAYLA options parameters.")
1052 (defconst spice-layla-functions
1054 "bus_double_param" "bus_integer_param" "bus_string_param"
1055 "device_double_param" "device_integer_param" "device_string_param"
1056 "net_double_param" "net_integer_param" "net_string_param"
1057 "placement_double_param" "placement_integer_param" "placement_string_param"
1058 "port_double_param" "port_integer_param" "port_string_param"
1059 "symmetry_double_param" "symmetry_integer_param" "symmetry_string_param"
1061 "List of functions in Layla mode.")
1063 (defconst spice-draccdl-device-keywords
1064 '("nonswap" )
1065 "List of Dracula CDL device keywords.")
1067 (defconst spice-draccdl-device-parameters
1068 '("w" "l" "sub" "ea" ;; CDL parameters
1069 "x" "y") ;; added X&Y, dracula extracts them (not CDL!)
1070 "List of Dracula & CDL device parameters.")
1072 (defconst spice-spice2g6-entity-start-keywords
1074 "ends" "macro" "subckt"
1076 "List of spice2g6 entity start keywords.")
1078 (defconst spice-eldo-entity-start-keywords
1080 "endl"
1082 "List of eldo entity start keywords.")
1084 (defconst spice-hspice-entity-start-keywords
1086 "endl" "eom"
1087 "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
1089 "List of hspice entity start keywords.")
1091 (defconst spice-layla-entity-start-keywords
1093 "bus" "net" "symmetry" "performance" "port"
1095 "List of layla entity start keywords.")
1097 (defconst spice-mondriaan-entity-start-keywords
1099 "routingarea" "routingchannel" ;; "net" ; already in layla
1101 "List of mondriaan entity start keywords.")
1103 (defconst spice-draccdl-entity-start-keywords
1105 "eom"
1107 "List of DracCDL entity start keywords.")
1109 (defvar spice-keywords nil
1110 "List of spice mode keywords.")
1112 (defvar spice-colon-keywords nil
1113 "List of spice mode colon keywords.")
1115 (defvar spice-analyses nil
1116 "List of spice mode analyses.")
1118 (defvar spice-analysis-modifiers nil
1119 "List of spice mode analysis modifiers.")
1121 (defvar spice-types nil
1122 "List of spice mode standardized types.")
1124 (defvar spice-functions nil
1125 "List of spice mode functions.")
1127 (defvar spice-section-headings nil
1128 "List of spice mode section headings.")
1130 (defvar spice-misc-model-type-names nil
1131 "List of miscellaneous model type name.")
1133 (defvar spice-model-type-names nil
1134 "List of all model type name.")
1136 (defvar spice-output-keywords nil
1137 "List of all output keywords.")
1139 (defvar spice-output-types nil
1140 "List of all output types.")
1142 (defvar spice-options-keywords nil
1143 "List of all output options keywords.")
1145 (defvar spice-options-parameters nil
1146 "List of all output options parameters.")
1148 (defvar spice-entity-start-keywords nil
1149 "List of entity definition keywords.")
1151 (defvar spice-keywords-regexp nil
1152 "Regexp for keywords.")
1154 (defvar spice-colon-keywords-regexp nil
1155 "Regexp for colon keywords.")
1157 (defvar spice-analyses-regexp nil
1158 "Regexp for analyses.")
1160 (defvar spice-analysis-modifiers-regexp nil
1161 "Regexp for analysis modifiers.")
1163 (defvar spice-layla-keywords-regexp nil
1164 "Regexp for layla keywords.")
1166 (defvar spice-mondriaan-keywords-regexp nil
1167 "Regexp for mondriaan keywords.")
1169 (defvar spice-draccdl-keywords-regexp nil
1170 "Regexp for dracula CDL keywords.")
1172 (defvar spice-types-regexp nil
1173 "Regexp for spice mode types.")
1175 (defvar spice-functions-regexp nil
1176 "Regexp for spice mode functions (Layla).")
1178 (defvar spice-section-headings-regexp nil
1179 "Regexp for spice mode section headings.")
1181 (defvar spice-xinstance-regexp nil
1182 "Regexp for x instances.")
1184 (defvar spice-model-name-regexp nil
1185 "Regexp model names of elements.")
1187 (defvar spice-entity-start-regexp nil
1188 "Regexp for start of entity definition.")
1190 (require 'font-lock)
1192 (defvar spice-instance-name-face 'spice-instance-name-face
1193 "Face name to use spice instances.")
1195 (defface spice-instance-name-face
1196 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1197 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1198 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
1199 (((class color) (background dark)) (:foreground "Yellow" :bold t))
1200 (t (:bold t)))
1201 "Spice mode face used to highlight instances."
1202 :group 'spice-faces)
1204 (defvar spice-model-name-face 'spice-model-name-face
1205 "Face name to use spice instances.")
1207 (defface spice-model-name-face
1208 '((((class grayscale) (background light)) (:foreground "LightGray"))
1209 (((class grayscale) (background dark)) (:foreground "DimGray"))
1210 (((class color) (background light)) (:foreground "Red3"))
1211 (((class color) (background dark)) (:foreground "LightSteelBlue"))
1212 (t (:bold t)))
1213 "Spice mode face used to highlight models."
1214 :group 'spice-faces)
1216 (defvar spice-title-face 'spice-title-face
1217 "Face name for title string.")
1219 (defface spice-title-face
1220 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1221 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1222 (((class color) (background light))
1223 (:foreground "Yellow" :background "black" :bold t))
1224 (((class color) (background dark))
1225 (:foreground "green3":background "lightyellow" :bold t))
1226 (t (:bold t)))
1227 "Spice mode face used for title string."
1228 :group 'spice-faces)
1230 (defvar spice-layla-function-name-face 'spice-layla-function-name-face
1231 "Face name to use for layla function names.")
1233 (defface spice-layla-function-name-face
1234 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
1235 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
1236 (((class color) (background light))
1237 (:foreground "Darkgreen"))
1238 (((class color) (background dark)) (:foreground "green"))
1239 (t (:bold t)))
1240 "Spice mode face used to higlight layla functions."
1241 :group 'spice-faces)
1244 (defvar spice-analysis-face 'spice-analysis-face
1245 "Face name to highlight spice mode analysis commands.")
1247 (defface spice-analysis-face
1248 '((((class color) (background light)) (:foreground "Magenta" :bold t :underline t))
1249 (((class color) (background dark)) (:foreground "Lightgreen" :bold t :underline t))
1250 (t (:bold t)))
1251 "Spice mode face used to highlight analysis commands."
1252 :group 'spice-faces)
1254 (defvar spice-doc-face 'font-lock-string-face
1255 "Face name to use for doc strings.")
1257 (custom-add-to-group 'spice-faces 'font-lock-string-face 'custom-face)
1260 (defvar spice-constant-face 'font-lock-constant-face
1261 "Face name to use for constants.")
1263 (custom-add-to-group 'spice-faces 'font-lock-constant-face 'custom-face)
1265 (defvar spice-include-file-face 'font-lock-string-face
1266 "Face name to use for include files and libraries.")
1268 (custom-add-to-group 'spice-faces 'font-lock-string-face 'custom-face)
1270 (custom-add-to-group 'spice-faces 'font-lock-builtin-face 'custom-face)
1272 (defvar spice-builtin-face 'font-lock-builtin-face
1273 "Face name for builtin types.")
1275 (defun spice-keywords-init ()
1276 "Initialize reserved words."
1277 (setq spice-keywords
1278 (append spice-spice2g6-keywords
1279 (when (spice-standard-p 'hspice)
1280 spice-hspice-keywords)
1281 (when (spice-standard-p 'eldo)
1282 spice-eldo-keywords)
1283 (when (spice-standard-p 'eldorf)
1284 spice-eldorf-keywords)
1285 (when (spice-standard-p 'fasthenry)
1286 spice-fasthenry-keywords)))
1287 (setq spice-colon-keywords
1288 (append (when (spice-standard-p 'eldo)
1289 spice-eldo-colon-keywords)
1290 (when (spice-standard-p 'eldovloga)
1291 spice-eldovloga-colon-keywords)))
1292 (setq spice-analyses
1293 (append spice-spice2g6-analyses
1294 (when (spice-standard-p 'hspice)
1295 spice-hspice-analyses)
1296 (when (spice-standard-p 'eldo)
1297 spice-eldo-analyses)
1298 (when (spice-standard-p 'eldorf)
1299 spice-eldorf-analyses)
1300 (when (spice-standard-p 'fasthenry)
1301 spice-fasthenry-analyses)))
1302 (setq spice-analysis-modifiers
1303 (append spice-spice2g6-analysis-modifiers
1304 (when (spice-standard-p 'hspice)
1305 spice-hspice-analysis-modifiers)
1306 (when (spice-standard-p 'eldo)
1307 spice-eldo-analysis-modifiers)
1308 (when (spice-standard-p 'fasthenry)
1309 spice-fasthenry-analysis-modifiers)))
1310 (setq spice-misc-model-type-names
1311 (append spice-spice2g6-model-type-names
1312 (when (spice-standard-p 'hspice)
1313 spice-hspice-model-type-names)
1314 (when (spice-standard-p 'eldovloga)
1315 spice-eldo-vloga-model-type-names)
1316 (when (spice-standard-p 'eldo)
1317 spice-eldo-model-type-names)))
1318 (setq spice-output-keywords
1319 (append spice-spice2g6-output-keywords
1320 (when (spice-standard-p 'hspice)
1321 spice-hspice-output-keywords)
1322 (when (spice-standard-p 'eldo)
1323 spice-eldo-output-keywords)))
1324 (setq spice-output-types
1325 (append spice-spice2g6-output-types
1326 (when (spice-standard-p 'hspice)
1327 spice-hspice-output-types)
1328 (when (spice-standard-p 'eldo)
1329 spice-eldo-output-types)
1330 (when (spice-standard-p 'eldorf)
1331 spice-eldorf-output-types)))
1332 (setq spice-model-type-names
1333 (append spice-misc-model-type-names
1334 spice-special-model-type-names))
1335 (setq spice-types
1336 (append spice-spice2g6-types
1337 (when (spice-standard-p 'hspice)
1338 spice-hspice-types)
1339 (when (spice-standard-p 'eldo)
1340 spice-eldo-types)
1341 (when (spice-standard-p 'eldorf)
1342 spice-eldorf-types)
1343 (when (spice-standard-p 'fasthenry)
1344 spice-fasthenry-types)))
1345 (setq spice-options-keywords
1346 (append spice-spice2g6-options-keywords
1347 (when (spice-standard-p 'hspice)
1348 spice-hspice-options-keywords)
1349 (when (spice-standard-p 'eldo)
1350 spice-eldo-options-keywords)
1351 (when (spice-standard-p 'eldorf)
1352 spice-eldorf-options-keywords)))
1353 (setq spice-options-parameters
1354 (append spice-spice2g6-options-parameters
1355 (when (spice-standard-p 'hspice)
1356 spice-hspice-options-parameters)
1357 (when (spice-standard-p 'layla)
1358 spice-layla-options-parameters)
1359 (when (spice-standard-p 'eldo)
1360 spice-eldo-options-parameters)
1361 (when (spice-standard-p 'eldorf)
1362 spice-eldorf-options-parameters)))
1363 (setq spice-functions spice-layla-functions)
1364 (setq spice-section-headings (list "Changelog")) ; Changelog is special case
1365 (let ((section-alist spice-section-alist) heading)
1366 (while section-alist
1367 (setq heading (downcase (car (cdr (car section-alist)))))
1368 (setq spice-section-headings (append spice-section-headings
1369 (list heading)))
1370 (setq section-alist (cdr section-alist))))
1371 (setq spice-entity-start-keywords
1372 (append spice-spice2g6-entity-start-keywords
1373 (when (spice-standard-p 'hspice)
1374 spice-hspice-entity-start-keywords)
1375 (when (spice-standard-p 'layla)
1376 spice-layla-entity-start-keywords)
1377 (when (spice-standard-p 'mondriaan)
1378 spice-mondriaan-entity-start-keywords)
1379 (when (spice-standard-p 'draccdl)
1380 spice-draccdl-entity-start-keywords)
1381 (when (spice-standard-p 'eldo)
1382 spice-eldo-entity-start-keywords)))
1383 (setq spice-section-headings-regexp
1384 (concat spice-section-regexp-start "\\("
1385 (regexp-opt spice-section-headings) "\\)\\(.*\\)$"
1386 ; "\\s-*$" ; ??
1388 (setq spice-keywords-regexp
1389 (concat "^\\.\\("
1390 (regexp-opt spice-keywords)
1391 "\\)\\>"))
1392 (setq spice-colon-keywords-regexp
1393 (concat "\\<\\("
1394 (regexp-opt spice-colon-keywords)
1395 "\\)\\(:\\)"))
1396 (setq spice-analyses-regexp
1397 (concat "^\\s-*"
1398 "\\(\\.\\)\\("
1399 (regexp-opt spice-analyses)
1400 "\\)\\>"))
1401 (setq spice-analysis-modifiers-regexp
1402 (concat "\\<\\(" (regexp-opt spice-analysis-modifiers) "\\)\\>"))
1403 (setq spice-layla-keywords-regexp
1404 (concat "^\\s-*\\*?"
1405 "\\.\\("
1406 (regexp-opt spice-layla-keywords)
1407 "\\)\\>"))
1408 (setq spice-mondriaan-keywords-regexp
1409 (concat "^\\s-*\\*?"
1410 "\\.\\("
1411 (regexp-opt spice-mondriaan-keywords)
1412 "\\)\\>"))
1413 (setq spice-draccdl-keywords-regexp
1414 (concat "^\\s-*"
1415 "\\.\\("
1416 (regexp-opt spice-draccdl-keywords)
1417 "\\)\\>"))
1418 (setq spice-types-regexp
1419 (concat "\\<\\(" ;"\\(\\s-+\\|\n\\+\\s-*\\)\\<\\("
1420 (regexp-opt spice-types)
1421 "\\)\\>"))
1422 (setq spice-functions-regexp
1423 (concat "^\\s-*\\(\\*?\\.\\("
1424 (regexp-opt spice-functions)
1425 "\\)\\)\\>(\\([^,]+\\),\\([^,]+\\),[^,]+)"))
1426 ; old xinstance regexp
1427 ; "\\([ \t]+[^ $!(=\t\n][^ (=\t\n]*\\|\n[+]\\)*" ; $! are hspice & eldo's doc string starters
1428 (setq spice-xinstance-regexp
1429 (concat "^\\(x\\S-*\\)"
1430 "\\(\\([ \t]+[^ *"
1431 ;; "\\(\\([ \t]*[^ *" ;; should solve problem when no space between + and name, but fails horribly due to CPU hungry recursion in matcher....
1432 (when (spice-standard-p 'hspice) "$")
1433 (when (spice-standard-p 'eldo) "!")
1434 ":(=\t\n][^ :(=\t\n]*\\|[ \t]*\\(\n?[*"
1435 (when (spice-standard-p 'hspice) "$")
1436 (when (spice-standard-p 'eldo) "!")
1437 "].*\\)?\n[+]\\)*\\s-*\\)" ;; \\([a-z]\\w*\\)
1438 "\\<" spice-model-name "\\>"
1439 "\\(\\s-*\n\\|\\s-+[^=\n]\\)"
1442 (setq spice-model-name-regexp
1443 (concat "^\\([qmd]\\S-*\\)" ;; only bips, mos and diodes
1444 "\\([ \t]+[^ *" ;; first '*' was '+' ! but fails see spice-xinstance-regexp...
1445 (when (spice-standard-p 'hspice) "$")
1446 (when (spice-standard-p 'eldo) "!")
1447 "(=\t\n][^ (=\t\n]*\\|[ \t]*\\([*"
1448 (when (spice-standard-p 'hspice) "$")
1449 (when (spice-standard-p 'eldo) "!")
1450 "].*\\)?\n[+]\\)*\\s-*" ;; \\([a-z]\\w*\\)
1451 "\\<" spice-model-name "\\>"
1452 "\\(\\s-*\n\\|\\s-+[^=]\\)"
1454 (setq spice-entity-start-regexp
1455 (concat "^\\*?\\.\\("
1456 (regexp-opt spice-entity-start-keywords)
1457 "\\)")))
1460 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1461 ;; Font lock initialization
1462 (defvar spice-font-lock-keywords-0 nil
1463 ;; set in `spice-font-lock-init' because dependent on custom variables
1464 "For consideration as a value of `spice-font-lock-keywords'.
1465 This does highlighting of keywords and standard identifiers.")
1467 (defvar spice-font-lock-keywords-1 nil
1468 ;; set in `spice-font-lock-init' because dependent on custom variables
1469 "For consideration as a value of `spice-font-lock-keywords'.
1470 This does highlighting of keywords and standard identifiers.")
1472 (defvar spice-font-lock-keywords-2 nil
1473 ;; set in `spice-font-lock-init' because dependent on custom variables
1474 "For consideration as a value of `spice-font-lock-keywords'.
1475 This does highlighting of keywords and standard identifiers.")
1477 (defvar spice-font-lock-keywords-3 nil
1478 ;; set in `spice-font-lock-init' because dependent on custom variables
1479 "For consideration as a value of `spice-font-lock-keywords'.
1480 This does highlighting of keywords and standard identifiers.")
1482 (defvar spice-font-lock-keywords-4 nil
1483 ;; set in `spice-font-lock-init' because dependent on custom variables
1484 "For consideration as a value of `spice-font-lock-keywords'.
1485 This does highlighting of keywords and standard identifiers.")
1487 (defvar spice-font-lock-keywords-5 nil
1488 ;; set in `spice-font-lock-init' because dependent on custom variables
1489 "For consideration as a value of `spice-font-lock-keywords'.
1490 This does highlighting of keywords and standard identifiers.")
1492 (defvar spice-font-lock-keywords-6 nil
1493 ;; set in `spice-font-lock-init' because dependent on custom variables
1494 "For consideration as a value of `spice-font-lock-keywords'.
1495 This does highlighting of keywords and standard identifiers.")
1497 (defvar spice-font-lock-keywords-7 nil
1498 ;; set in `spice-font-lock-init' because dependent on custom variables
1499 "For consideration as a value of `spice-font-lock-keywords'.
1500 This does highlighting of keywords and standard identifiers.")
1502 (defvar spice-font-lock-keywords-8 nil
1503 ;; set in `spice-font-lock-init' because dependent on custom variables
1504 "For consideration as a value of `spice-font-lock-keywords'.
1505 This does highlighting of keywords and standard identifiers.")
1507 (defvar spice-font-lock-keywords-9 nil
1508 ;; set in `spice-font-lock-init' because dependent on custom variables
1509 "For consideration as a value of `spice-font-lock-keywords'.
1510 This does highlighting of keywords and standard identifiers.")
1512 (defvar spice-font-lock-keywords-10 nil
1513 ;; set in `spice-font-lock-init' because dependent on custom variables
1514 "For consideration as a value of `spice-font-lock-keywords'.
1515 This does highlighting of keywords and standard identifiers.")
1517 (defvar spice-font-lock-keywords-11 nil
1518 ;; set in `spice-font-lock-init' because dependent on custom variables
1519 "For consideration as a value of `spice-font-lock-keywords'.
1520 This does highlighting of keywords and standard identifiers.")
1522 (defvar spice-font-lock-keywords-12 nil
1523 ;; set in `spice-font-lock-init' because dependent on custom variables
1524 "For consideration as a value of `spice-font-lock-keywords'.
1525 This does highlighting of keywords and standard identifiers.")
1527 (defvar spice-font-lock-keywords-13 nil
1528 ;; set in `spice-font-lock-init' because dependent on custom variables
1529 "For consideration as a value of `spice-font-lock-keywords'.
1530 This does highlighting of keywords and standard identifiers.")
1533 ;; fast variable name matcher in parameter=value constructs
1534 (defun spice-match-variable-name (limit)
1535 "Match variable names with LIMIT."
1536 (let (pos found (start (point)))
1537 (setq found nil)
1538 (setq pos (search-forward "=" limit 'end)) ;
1539 (while (and pos
1540 (not found))
1541 (forward-word -1)
1542 (if (< (point) start) (goto-char pos))
1543 (if (looking-at "\\([a-z]\\w*\\)\\s-*\\(=\\)")
1544 (progn
1545 (goto-char pos)
1546 ;; (message (match-string 1))
1547 (setq found t))
1548 (progn
1549 (goto-char pos)
1550 (setq pos (search-forward "=" limit 'end)))))
1551 found))
1553 ;; font-lock aux functions
1554 (defun spice-match-eldo-colon-keywords (limit)
1555 "Match with LIMIT ((param|pin|model|port|generic):)."
1556 ;; latter two are eldo verilog-A
1557 (let (pos found (start (point)))
1558 (setq found nil)
1559 (setq pos (search-forward ":" limit 'end)) ;
1560 (while pos
1561 (forward-word -1)
1562 (if (< (point) start) (goto-char pos))
1563 ;; (message "pos is %d" pos)
1564 (if (looking-at ;; "\\(\\(param\\|pin\\|model\\|port\\|generic\\):\\)")
1565 spice-colon-keywords-regexp)
1566 (progn
1567 (goto-char pos)
1568 (setq pos nil)
1569 (setq found t))
1570 (progn
1571 (goto-char pos)
1572 (setq pos (search-forward ":" limit 'end)))))
1573 found))
1575 ;; these are try outs to solve the font-locking of problematic xinstances:
1577 (defun spice-match-xinstances-dummy (limit)
1578 "Match xinstances with LIMIT."
1579 (let (min max pt)
1580 (setq pt (point))
1581 (goto-char (point-min))
1582 (setq min (point))
1583 (goto-char (point-max))
1584 (setq max (point))
1585 (with-current-buffer (get-buffer-create "*Matcher*")
1586 (goto-char (point-max))
1587 (insert (format "Point min is %s\n" min))
1588 (insert (format "Current point is %s\n" pt))
1589 (insert (format "Limit is %s\n" limit))
1590 (insert (format "Point max is %s\n" max))))
1591 nil)
1593 (defun spice-idle-font-lock (beg end)
1594 "Run font-lock on a region between BEG and END."
1595 (message "rerunning font-lock on %s:%s=%s" beg end (buffer-substring beg end))
1596 (save-excursion (font-lock-fontify-region beg end)))
1598 (defvar spice-previous-xinstance-match-result nil)
1599 (make-variable-buffer-local 'spice-previous-xinstance-match-result)
1601 (defun spice-match-in-xinstance (limit)
1602 "Check if in xinstance with LIMIT."
1603 (let ((pt (point)))
1604 (if (or (looking-at "^\\s-*[xX]")
1605 (re-search-backward "^[xX]" (point-min) t))
1606 (if (and (looking-at spice-xinstance-regexp)
1607 (or (> (match-end 5) pt)
1608 (not spice-previous-xinstance-match-result))
1610 (progn
1611 (message ".")
1612 (goto-char (match-end 5))
1613 (if (or (> pt (match-beginning 1))
1614 (< limit (match-end 5)))
1615 (progn
1616 (message "*")
1617 ;;(spice-idle-font-lock (match-beginning 1) (match-end 5))
1618 (run-with-idle-timer 1 nil 'spice-idle-font-lock
1619 (match-beginning 1) (match-end 5))
1621 ;; (if (> (match-end 5) limit)
1622 ;; (run-with-idle-timer 1 nil 'spice-idle-font-lock
1623 ;; (match-beginning 1) (match-end 5)))
1625 (goto-char pt)
1626 nil)
1627 nil)
1630 (defun spice-match-next-xinstance (limit)
1631 "Check if there is a next xinstance partly within LIMIT."
1632 (if (re-search-forward "^[xX]" limit 'end)
1633 (progn
1634 (backward-char 1)
1635 (if (looking-at spice-xinstance-regexp)
1636 (progn
1637 (message "+")
1638 (goto-char (match-end 5))
1640 (message "-")
1641 (forward-char 1)
1642 (spice-match-next-xinstance limit))
1644 nil))
1646 (defun spice-match-xinstance (limit)
1647 "Match xinstances with LIMIT."
1648 (if (spice-match-in-xinstance limit)
1650 (spice-match-next-xinstance limit)))
1652 (defun spice-match-xinstances-old (limit)
1653 "Match an xinstance with LIMIT."
1654 (setq spice-previous-xinstance-match-result (spice-match-xinstance limit))
1655 spice-previous-xinstance-match-result)
1657 ;; this xinstances matcher is a complete parser !
1659 (defun spice-match-xinstances (limit)
1660 "Match xinstance with LIMIT subckt name, this one parses the lines.
1662 Should work for all cases, infinite number of comment lines,
1663 continuation lines. Could fail when modifying an xinstance line
1664 though, hard to tell."
1665 (interactive)
1666 (let ((result nil) match-start)
1667 (while
1668 (and (not result)
1669 (re-search-forward "^\\(x\\S-*\\)" limit 'end)) ;; should be checked ?
1670 (setq match-start (match-data))
1671 ;;(message "match-start is %s" match-start)
1672 (while
1674 (and (looking-at "\\([ \t]+\\|\\s-*\n[+]\\s-*\\)\\(\\([a-z][^ :(=\t\n]*\\)\\|\\([^ *$!:(=\t\n][^ :(=\t\n]*\\)\\)\\(\\s-*\n\\|\\s-+[^=\n]\\)")
1675 (progn
1676 (goto-char (match-end 2))
1677 (setq result t)))
1678 (save-match-data
1679 (and
1680 (looking-at "\\(\\([ \t]+\\|\\s-*\n\\s-*\\)[$!*].*\\)")
1681 (progn
1682 (goto-char (match-end 1))
1683 t))))
1684 nil))
1685 (when result (set-match-data
1686 (append (list (car match-start) (car (cdr (match-data))))
1687 (cdr (cdr match-start)) (cdr (cdr (match-data))))))
1688 ;;(when result (message "Matched %s[%d]" (match-string 3) (match-end 3)))
1689 (when result (when (< limit (match-end 3)) (setq result nil)))
1690 result))
1692 (defvar spice-font-lock-keywords nil
1693 "Regular expressions to highlight in spice mode.")
1695 (defun spice-font-lock-init ()
1696 "Initialize fontification."
1697 ;; makes spice-font-lock-keywords valid
1698 ;; highlight title & titles after .alter & .title (hspice only)
1699 (setq spice-font-lock-keywords-0
1700 (append (list ;; first line of spice deck
1701 (list "\\`.+$" 0 spice-title-face)
1702 (list spice-section-headings-regexp
1703 '(1 font-lock-comment-face)
1704 '(2 spice-title-face)
1705 (list (regexp-opt-depth spice-section-headings-regexp)
1706 spice-doc-face 'keep t)))
1707 ;; hspice title in .alter or .title line
1708 (when (spice-standard-p 'hspice)
1709 (list
1710 (list "^\\.\\(alter\\|title\\)\\s-+\\(.+\\)$"
1711 2 spice-title-face)))))
1712 ;; highlight layla functions: .xx_yy_param(name,prop,val);
1713 (setq spice-font-lock-keywords-1
1714 (list
1715 (list spice-functions-regexp
1716 '(1 spice-layla-function-name-face)
1717 (list (- (regexp-opt-depth spice-functions-regexp) 1)
1718 font-lock-function-name-face)
1719 (list (regexp-opt-depth spice-functions-regexp)
1720 font-lock-variable-name-face)
1722 ;; highlight spice keywords (mainly .<keyword> & .<analysis>)
1723 (setq spice-font-lock-keywords-2
1724 (list ;; .opt, .nodeset, ...
1725 (list spice-keywords-regexp 0 font-lock-keyword-face)
1726 ;; '+' of continuation lines ? maybe over the top ...
1727 ;; (list (concat "^"
1728 ;; (when (spice-standard-p 'layla) "\\*?")
1729 ;; "\\+") 0 font-lock-keyword-face)
1730 ;; .op, .ac, .dc, .tran, ...
1731 (list spice-analyses-regexp
1732 '(1 font-lock-keyword-face)
1733 '(2 spice-analysis-face)
1734 (list spice-analysis-modifiers-regexp
1735 nil nil '(0 font-lock-type-face)))))
1737 (setq spice-font-lock-keywords-12
1738 ;; do dracula CDL stuff
1739 (list
1740 ;; add $ docs when they are followed by a space...
1741 (list (concat "\\<\\([$]\\)\\s-+\\(.*\\)$")
1742 (list 1 font-lock-comment-face)
1743 (list 2 spice-doc-face 'keep))
1744 ;; special models on element line
1745 (list (concat "\\([$]\\(?:ldd\\)?\\[\\)" spice-model-name "\\(\\]\\)")
1746 '(1 font-lock-keyword-face)
1747 '(2 spice-model-name-face)
1748 '(3 font-lock-keyword-face))
1749 ;; normal .model on element line
1750 (list (concat "\\([$]\\.model\\)\\s-*=\\s-*" spice-model-name)
1751 '(1 font-lock-keyword-face)
1752 '(2 spice-model-name-face))
1753 ;; element options behind $ syntax
1754 (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-keywords) "\\)")
1755 '(1 font-lock-keyword-face)
1756 '(2 font-lock-keyword-face))
1757 ;; element parameters behind $ syntax
1758 (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-parameters) "\\)\\s-*=")
1759 '(1 font-lock-keyword-face)
1760 '(2 font-lock-variable-name-face))
1761 ;; general '.' keywords
1762 (list spice-draccdl-keywords-regexp 0 font-lock-keyword-face)))
1764 ;; highlight layla specific keywords, also if *. syntax is used
1765 (setq spice-font-lock-keywords-3
1766 (append (list
1767 (list spice-layla-keywords-regexp 0 font-lock-keyword-face)
1768 (list "^\\(\\*\\)\\+" 1 font-lock-keyword-face))
1769 (when (spice-standard-p 'mondriaan)
1770 (list
1771 (list spice-mondriaan-keywords-regexp 0 font-lock-keyword-face)))))
1773 (setq spice-font-lock-keywords-13
1774 ;; do spectre stuff
1775 (list
1776 ;; * spectre: + syntax
1777 (list "^\\(\\*\\)\\s-+spectre:\\s-+" 1 font-lock-keyword-face)
1778 ;; // comments
1779 (list "//.*$" 0 font-lock-comment-face)
1780 ;; add simulator language=spice
1781 (list "^\\s-*\\(simulator\\)\\>"
1782 '(1 font-lock-keyword-face))))
1784 ;; varia: .end, spice instances and '*' comment lines and output lines
1785 (setq spice-font-lock-keywords-4
1786 (list
1787 ;; elements
1788 ;;'("^[a-z]\\S-*" . spice-instance-name-face)
1789 '("^[a-z][^ \t\n]+" . spice-instance-name-face)
1790 ;(list (concat "^\\*\\([^"
1791 ; (when (spice-standard-p 'layla) "+")
1792 ; "\n].*\\|\n\\)") 0 font-lock-comment-face)
1793 (list (concat "^\\*[^\n"
1794 (when (or (spice-standard-p 'hspice)
1795 (spice-standard-p 'draccdl)
1796 (spice-standard-p 'layla)) "$")
1797 (when (spice-standard-p 'eldo) "!")
1798 "]*") 0 font-lock-comment-face)
1799 (list (concat "^\\.\\(" (regexp-opt spice-output-keywords)
1800 "\\)\\s-*" spice-line-break "\\s-+\\("
1801 (regexp-opt spice-output-types) "\\)\\>")
1802 '(0 font-lock-type-face keep)) ;
1804 ;; highlight additional . unknowns (to detect stupid typing errors)
1805 (setq spice-font-lock-keywords-5
1806 (list '("^\\s-*\\.[^ \t\n]*" 0 font-lock-warning-face)))
1808 ;; highlight additional $ and ! comments, only eldo, hspice, draccdl and layla
1809 (setq spice-font-lock-keywords-6
1810 (list
1811 (list (concat "\\<\\(["
1812 (when (or (spice-standard-p 'hspice)
1813 (spice-standard-p 'draccdl)
1814 (spice-standard-p 'layla)) "$")
1815 (when (spice-standard-p 'eldo) "!")
1816 "]\\)\\(.*\\)$")
1817 (list 1 font-lock-comment-face)
1818 (list 2 spice-doc-face 'append) ;; needs at least 'append or 'keep
1820 (list (concat "\\<\\([*"
1821 (when (or (spice-standard-p 'hspice)
1822 (spice-standard-p 'draccdl)
1823 (spice-standard-p 'layla)) "$")
1824 (when (spice-standard-p 'eldo) "!")
1825 "]\\)")
1826 ;; elisp mode like quotes, for extra clarity
1827 (list "['\"]\\([^'\"]+\\)['\"]" nil nil
1828 (list 1 spice-constant-face 'prepend)))))
1830 ;; subcircuit instance names of x instances and model names of mos,bip&diode
1831 (setq spice-font-lock-keywords-7
1832 (list
1833 (list spice-xinstance-regexp 5 spice-model-name-face)
1834 ;; test xinstance function matcher
1835 ;;(list 'spice-match-xinstances
1836 ;; '(4 spice-model-name-face keep t)
1837 ;; '(5 font-lock-warning-face keep t))
1838 (list spice-model-name-regexp 4 spice-model-name-face)
1841 ;; highlight poly's of inductors and caps
1842 (setq spice-font-lock-keywords-8
1843 (list
1844 '("^[cl]\\w*\\s-+\\w[^ \t\n]*\\s-+\\w[^ \t\n]*\\s-+\\(poly\\)"
1845 1 font-lock-type-face)))
1847 ;; types, included files, libs and names of subcircuits, ports, libs, models
1848 (setq spice-font-lock-keywords-9
1849 (append
1850 ;; names and types of models/subckt, lib concept of eldo...
1851 (when (spice-standard-p 'eldo)
1852 (list
1853 (list (concat "^\\s-*\\.\\(model\\|subckt\\|macro\\)\\s-+"
1854 "\\(\\(lib\\)\\s-+[^ \t\n]+\\s-+\\)"
1855 spice-model-name)
1856 '(3 font-lock-keyword-face)
1857 '(4 font-lock-function-name-face))))
1858 (list
1859 ;; types
1860 (list "^[+vi.]" '(0 'default) ;; find v & i's and continuation and . lines
1861 (list spice-types-regexp nil nil '(1 font-lock-type-face)))
1862 ;; libs, inc's, ...
1863 (list (concat spice-library-regexp-start
1864 spice-library-regexp-end) 3 spice-include-file-face)
1865 ;; names of (defined) entities
1866 (list
1867 (concat spice-entity-start-regexp
1868 "\\(\\s-+\\([a-z]\\w*\\)\\s-*"
1869 "\\|\\s-*[\n][+]\\s-*\\([a-z]\\w*\\)\\s-*\\)")
1870 (1+ (regexp-opt-depth spice-entity-start-regexp))
1871 font-lock-function-name-face)
1872 ;; names and types of models
1873 (list (concat "^\\s-*\\.model\\s-+"
1874 spice-model-name
1875 spice-line-break "\\s-+\\("
1876 (regexp-opt spice-model-type-names) "\\)\\>")
1877 '(1 font-lock-function-name-face)
1878 '(3 font-lock-type-face))
1881 ;; highlight additional eldo reserved words
1882 (setq spice-font-lock-keywords-10
1883 (list
1884 ;; eldo's labels
1885 (list "\\<\\(label\\)\\s-*=\\s-*\\([^\"]\\w*\\)\\>"
1886 '(1 font-lock-type-face)
1887 '(2 font-lock-variable-name-face))
1888 ;; eldo's labels(2)
1889 (list "\\<\\(label\\)\\s-*=\\s-*\"\\([^\"]+\\)\""
1890 '(1 font-lock-type-face)
1891 '(2 font-lock-variable-name-face))
1892 ;; eldo's param,model&pin:
1893 ;;'("\\<\\(\\(param\\|pin\\|model\\):\\)" 0 font-lock-keyword-face)
1894 (list 'spice-match-eldo-colon-keywords
1895 (list 1 font-lock-keyword-face)
1896 '(2 'default))
1897 ;; eldo's builtin macro models
1898 (list (concat "^y\\w+\\s-+\\<\\("
1899 (regexp-opt spice-eldo-macromodel-keywords) "\\)\\>")
1900 '(1 spice-builtin-face))
1901 ;; eldo's y instances, type is second word on line
1902 (list (concat "^y\\w+\\s-+\\<" spice-model-name "\\>")
1903 1 spice-model-name-face)))
1904 ;; highlight property names property=value & strings (way at the end)
1905 (setq spice-font-lock-keywords-11
1906 (list
1907 ;; this is 1 second faster when loading 28 files, appx 10000 lines
1908 ;; .options keywords & parameters
1909 (list (concat "^\\s-*" ;; was "^"
1910 (when (spice-standard-p 'layla) "\\*?")
1911 "\\.opt\\(ion"
1912 (when (or (spice-standard-p 'hspice)
1913 (spice-standard-p 'layla))
1914 "\\(s\\)?")
1915 "\\)?\\s-+")
1916 '(0 font-lock-keyword-face) ;; not used, already colored
1917 (list (concat "\\<\\(\\("
1918 (regexp-opt spice-options-keywords)
1919 "\\)\\>\\|\\("
1920 (regexp-opt spice-options-parameters)
1921 "\\)\\s-*=\\)") nil nil
1922 (list 1 spice-constant-face)))
1923 ;; param=value
1924 ;; '("\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
1925 ;; this function matcher is much faster, it searches for '=' and then
1926 ;; returns the word in front of the '=', doesn't work in xemacs though
1927 ;;(if (string-match "XEmacs" emacs-version)
1928 ;; (list "\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
1929 (list 'spice-match-variable-name
1930 (list 1 font-lock-variable-name-face 'append)
1931 ;;(list 1 font-lock-variable-name-face)
1932 '(2 'default 'append)) ;; default is required for XEmacs
1933 ;; 'append is required for Xemacs 21.4.11 on Windows. Otherwise
1934 ;; the matcher overrules the previous highlighting (for instance when
1935 ;; this 'var=value' is after a doc starter...
1936 ;; )
1938 ;; changelog entries
1939 (list
1940 (concat
1941 "^[*"
1942 (when (or (spice-standard-p 'hspice)
1943 (spice-standard-p 'layla)) "$")
1944 (when (spice-standard-p 'eldo) "!")
1945 "]+\\s-+\\([A-Z].*[0-9]\\)\\s-+\\([a-zA-Z].*\\)<\\(.*@.*\\)>$")
1946 '(1 font-lock-string-face t)
1947 '(2 font-lock-type-face t)
1948 '(3 font-lock-variable-name-face t))
1950 ;; strings
1951 '("\"[^\"]*\"" 0 font-lock-string-face)
1953 ;; scale factors and powers or is this overkill ?
1954 (list (concat
1955 "\\<[-+]?[0-9.]+\\(\\("
1956 (regexp-opt '("T" "G" "Meg" "K" "mil" "m" "u" "M" "n" "p" "f"))
1957 "\\)[a-zA-Z]*\\)\\>")
1958 (list 2 spice-constant-face 'append))
1959 (list (concat
1960 "[0-9.]\\(e\\)[-+]?[0-9]+\\>")
1961 (list 1 spice-constant-face 'append))
1963 ;; set font-lock-keywords, all of 'em
1964 (setq spice-font-lock-keywords
1965 (append spice-font-lock-keywords-0 ;; title first
1966 (when (spice-standard-p 'layla)
1967 spice-font-lock-keywords-1)
1968 (when spice-highlight-keywords
1969 spice-font-lock-keywords-2)
1970 (when (and
1971 spice-highlight-keywords
1972 (spice-standard-p 'layla))
1973 spice-font-lock-keywords-3)
1974 (when (spice-standard-p 'spectre)
1975 spice-font-lock-keywords-13)
1976 (when (spice-standard-p 'draccdl)
1977 spice-font-lock-keywords-12)
1978 spice-font-lock-keywords-4
1979 (when spice-highlight-keywords
1980 spice-font-lock-keywords-5)
1981 (when (or (spice-standard-p 'layla)
1982 (spice-standard-p 'hspice)
1983 (spice-standard-p 'draccdl)
1984 (spice-standard-p 'eldo))
1985 spice-font-lock-keywords-6)
1986 spice-font-lock-keywords-7
1987 (when spice-highlight-keywords
1988 spice-font-lock-keywords-8)
1989 spice-font-lock-keywords-9
1990 (when (spice-standard-p 'eldo)
1991 spice-font-lock-keywords-10)
1992 (when spice-highlight-keywords
1993 spice-font-lock-keywords-11)
1997 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1998 ;;; Comments (taken from eldo-mode.el)
1999 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2001 ;; uncomment function, should work for any case now:
2002 (defun spice-uncomment-region (beg end)
2003 "Uncomment selected region - comment symbol is '*'.
2004 Doc comments (starting with '!') are unaffected."
2005 (interactive "*r")
2006 (comment-region beg end '(2))) ; 2 is arbitrary, can be any value
2009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2010 ;;; spice mode map
2011 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2013 ;; (require 'tempo) ; ? is this necessary
2015 (defvar spice-mode-map ()
2016 "Keymap used in spice-mode.")
2018 (if spice-mode-map
2020 (let ((map (make-sparse-keymap)))
2022 ;; key binding for template completion
2023 (define-key map "\t" 'tempo-complete-tag)
2024 ;; (define-key map "\S-\t" 'indent-for-tab-command)
2025 (define-key map [(shift tab)] 'indent-for-tab-command)
2026 (define-key map [(shift iso-lefttab)] 'indent-for-tab-command)
2028 ;; key bindings for compile
2029 (define-key map "\C-c\C-r" 'spice-compile) ;; r for run
2030 (define-key map "\C-c\C-k" 'kill-compilation)
2032 ;; replace global binding
2033 (define-key map "\C-x`" 'spice-next-error)
2035 ;; key bindings for waveform viewer
2036 (define-key map "\C-c\C-v" 'spice-run-waveform-viewer)
2038 ;; key bindings for output file loading
2039 (define-key map "\C-c\C-o" 'spice-load-output-file)
2041 ;; key bindings for include file loading
2042 (define-key map "\C-c\C-l" 'spice-load-include-files)
2044 ;; comment region, use auctex-mode bindings...
2045 (define-key map "\C-c\C-c" 'comment-region)
2046 ;;(define-key map "\C-c:" 'spice-uncomment-region) ;; \C-u\C-c\C-c
2048 ;; .subckt search
2049 (define-key map "\C-c\C-s" 'spice-search-subckt)
2051 ;; join lines
2052 (define-key map "\M-^" 'spice-delete-indentation)
2054 ;; key bindings for hiding/unhidding comments
2055 (define-key map "\C-c;" 'spice-hide-all-comments)
2056 (define-key map "\C-c:" 'spice-unhide-all-comments)
2058 ;; changelog addition
2059 (define-key map "\C-c\C-ac" 'spice-add-changelog-entry)
2061 (setq spice-mode-map map)))
2064 (defvar spice-output-mode-map ()
2065 "Keymap used in Spice-output mode.")
2067 (if spice-output-mode-map
2069 (let ((map (make-sparse-keymap)))
2070 ;; nothing for now ...
2072 (setq spice-output-mode-map map)))
2075 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2076 ;;; libraries & include files (taken & adapted from eldo-mode.el, E. Rouat)
2077 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2079 ;;------------------------------------------------------------
2080 ;; Mouse bindings (only used by 'spice-load-file-at-mouse')
2081 ;; I separate this from spice-mode-map so that this particular
2082 ;; mouse binding doesn't interfere with other bindings
2084 (defvar spice-mode-mouse-map nil
2085 "Map containing mouse bindings for spice-mode.")
2087 (if spice-mode-mouse-map
2089 (let ((map (make-sparse-keymap)))
2090 (set-keymap-parent map spice-mode-map)
2091 ;; mouse button bindings
2092 ;;(define-key map "\r" 'ffap)
2093 (define-key map "\r" 'spice-load-file-at-point)
2094 (define-key map [mouse-2] 'spice-load-file-at-mouse)
2095 (define-key map [S-mouse-2] 'mouse-yank-at-click)
2096 (setq spice-mode-mouse-map map)))
2099 ;; overlays and extents are a mess. Depending on emacs/xemacs versions the
2100 ;; following code might actually work. What is known now is that this
2101 ;; works in: emacs 20.7, 21.1 and 21.2 (Linux versions have been tested),
2102 ;; xemacs 21.1 (Windows) and xemacs 21.5 (Linux). You need
2103 ;; fsf-compat package for xemacs 21.4.5 (Linux). Anyone still following this ?
2106 (defun spice-colorize-libraries (beg end old-len)
2107 "Colorize libraries and included files when the mouse passes over them.
2109 Clicking on the middle-mouse button loads them in a buffer.
2110 BEWARE, this feature was hard to implement, and
2111 contains (non-fatal) bugs, primarily because Emacs 20 does not
2112 have the same support for this as XEmacs has."
2113 (save-excursion
2114 (save-match-data
2115 (let (end-point)
2116 (goto-char end)
2117 (end-of-line)
2118 (setq end-point (point))
2119 (goto-char beg)
2120 (beginning-of-line) ; scan entire line !
2121 ;; delete overlays existing on this line
2122 (let ((overlays (overlays-in (point) end-point)))
2123 (while overlays
2124 (if (and (overlay-get (car overlays) 'detachable)
2125 (overlay-get (car overlays) 'spice-library))
2126 (delete-overlay (car overlays))
2128 (setq overlays (cdr overlays)))) ; let
2129 ; make new ones, could reuse deleted one ?
2130 (while (search-forward-regexp spice-library-regexp-start end-point t)
2131 (let (start-lib extent)
2132 (setq start-lib (point))
2133 (search-forward-regexp spice-library-regexp-end end-point) ; (let ((end-lib (point)))
2134 ))))))
2137 (defun spice-colorize-libraries-buffer ()
2138 "Colorize spice libraries in buffer."
2139 (interactive)
2140 ;; (message "running colorize libraries buffer")
2141 ;; delete overlays
2142 (let ((overlays (overlays-in (point-min) (point-max))))
2143 (while overlays
2144 (if (and
2145 (overlay-get (car overlays) 'detachable)
2146 (overlay-get (car overlays) 'spice-library))
2147 (delete-overlay (car overlays)))
2148 (setq overlays (cdr overlays)))) ; let
2149 ;; remake overlays
2150 (spice-colorize-libraries (point-min) (point-max) nil))
2153 ;; ffap needs wrapper to detect end of buffer condition
2154 (defun spice-load-file-at-point ()
2155 "Wrapper for ffap. But if at end of buffer inserts a newline instead."
2156 (interactive)
2157 (if (looking-at "\\'")
2158 (newline) ;; assumes \r is bound to load file...
2159 (ffap)))
2162 ;; ffap-at-mouse isn't available in xemacs < 21
2163 ;; so define this function to do more or less the same (primarily
2164 ;; wraps ffap-at-mouse, except for xemacs 20)...
2165 (defun spice-load-file-at-mouse (event)
2166 "Loads file under button 2 click EVENT. Checks if file is readable."
2167 (interactive "@e")
2168 (if (fboundp 'ffap-at-mouse)
2169 (ffap-at-mouse event) ;; use ffap-at-mouse if available
2170 (save-excursion ;; implement a spice specific ffap-at-mouse
2171 (mouse-set-point event)
2172 (beginning-of-line)
2173 (if (looking-at (concat spice-library-regexp-start
2174 spice-library-regexp-end))
2175 (if (file-readable-p (substitute-in-file-name (match-string 3)))
2176 (find-file (substitute-in-file-name (match-string 3)))
2177 (progn
2178 (message "File '%s' isn't readable, use shift-mouse2 to paste in this field" (match-string 3))))
2179 ))))
2182 ;;------------------------------------------------------------
2183 ;; Changelog and sections support (taken from eldo-mode, trying
2184 ;; to be compatible :)
2185 ;;------------------------------------------------------------
2187 (defun spice-doc-char ()
2188 "Return doc char that's valid in the selected spice submode."
2189 (cond
2190 ((and (spice-standard-p 'eldo)
2191 (spice-standard-p 'hspice))
2192 "*") ; if both eldo and hspice is turned on
2193 ((spice-standard-p 'eldo)
2194 "!") ; only eldo
2195 ((spice-standard-p 'hspice)
2196 "$") ; only hspice
2198 "*"))) ; everything else
2201 (defun spice-find-changelog-point ()
2202 "Find adequate position to place Changelog entries.
2203 Just before .end or if not found at end of buffer."
2204 (save-excursion
2205 (goto-char (point-min))
2206 (let ((pos (re-search-forward
2207 "^\\.end\\b" nil t)))
2208 (if pos (progn (forward-line 1)
2209 (point))
2210 (point-max)))))
2213 (defun spice-add-changelog-entry (changelog-entry)
2214 "Find changelog section (create it if not found) and add an entry for today."
2215 (interactive "sChangelog entry: ")
2216 (goto-char (point-min))
2217 (if (not (re-search-forward
2218 (concat spice-section-regexp-start "Changelog") nil t))
2219 (spice-add-section "Changelog" (spice-find-changelog-point)))
2221 (spice-goto-section "Changelog")
2222 ; (forward-line 2)
2223 (let ((string (concat (spice-doc-char)
2224 (if (equal (spice-doc-char) "*") "* " " ")
2225 (substring (current-time-string) 0 11)
2226 (substring (current-time-string) -4) " "
2227 (user-full-name) " <" user-mail-address ">")))
2228 (if (not (search-forward string nil t))
2229 (insert "\n" string "\n\n")
2230 (forward-line 2))
2231 (insert (spice-doc-char)
2232 (if (equal (spice-doc-char) "*") "*" "")
2233 " - " changelog-entry "\n")))
2236 (defun spice-goto-section (section)
2237 "Move point to the beginning of the specified section; If the section is not found, leave point at previous location."
2238 (interactive "ssection: ")
2239 (let ((pos (point)))
2240 (goto-char (point-min))
2241 (if (not (re-search-forward
2242 (concat spice-section-regexp-start section "\\b") nil t))
2243 (progn (message "Couldn't find section %s" section)
2244 (goto-char pos))
2245 (progn
2246 (forward-line 2)
2247 (recenter))))) ;; added recenter
2250 (defun spice-comment-bar (&optional aligned)
2251 "Insert solid comment bar from column zero to end of line.
2252 If optional argument is provided, bar will be added from current
2253 column."
2254 (interactive)
2255 (if (not aligned) (beginning-of-line) )
2256 (insert "*")
2257 (insert-char ?- (- (1- fill-column) (current-column)))
2258 (insert "\n"))
2261 (defun spice-add-section (section &optional arg)
2262 "Add a SECTION in buffer at (optional) point ARG."
2263 (interactive "ssection: ")
2264 (if arg
2265 (goto-char arg))
2266 (spice-comment-bar)
2267 (insert
2268 (concat (spice-doc-char) "\t" section " \n"))
2269 (spice-comment-bar)
2270 ;; (unless (assoc section spice-section-alist)
2271 ;; ;; new entry
2272 ;; (custom-set-variables
2273 ;; (quote (spice-section-alist
2274 ;; (append spice-section-alist
2275 ;; (list (list section (upcase section) nil))))))
2276 ;; )
2280 (defvar spice-cache-section-alist nil)
2282 (defun spice-cache-section-p (section)
2283 "Check for all sections in file and remembers if they were present or not."
2284 (save-excursion
2285 (setq spice-cache-section-alist nil)
2286 (goto-char (point-min))
2287 (while (re-search-forward spice-section-headings-regexp nil t)
2288 (setq spice-cache-section-alist
2289 (cons (cons (downcase (match-string-no-properties 2)) t)
2290 spice-cache-section-alist)))
2291 (spice-section-p section)))
2294 (defun spice-section-p (section)
2295 "Check if named section is in file.
2297 Returns t if found, nil otherwise, uses cache generated with the
2298 `spice-cache-section-p' function."
2299 (assoc section spice-cache-section-alist))
2302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2303 ;;; Templates (extensive, long code...)
2304 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2306 (require 'tempo)
2308 ;;; element templates
2310 ;; resistors
2311 (tempo-define-template
2312 "spice-spice2g6-resistor"
2313 '("R"
2314 (p "[name]: ") '(just-one-space)
2315 (p "[pos node]: ") '(just-one-space)
2316 (p "[neg node]: ") '(just-one-space)
2317 (p "[val]: "))
2318 ;; "spice2g6 resistor"
2320 "tempo template for spice2g6 resistor"
2321 'spice-tempo-tags)
2324 (tempo-define-template
2325 "spice-spice3-semiconductor-resistor"
2326 '("R"
2327 (p "[name]: ") '(just-one-space)
2328 (p "[pos node]: ") '(just-one-space)
2329 (p "[neg node]: ") '(just-one-space)
2330 (p "<value>: " value) '(just-one-space)
2331 (p "<mname>: " mname) '(just-one-space)
2332 (p "<length>: " l 'noinsert)
2333 (if (string-equal (tempo-lookup-named 'l) "")
2334 () (list 'l "L=" '(s l)))
2335 '(just-one-space)
2336 (p "<width>: " w 'noinsert)
2337 (if (string-equal (tempo-lookup-named 'w) "")
2338 () (list 'l "W=" '(s w)))
2339 '(just-one-space)
2340 (p "<temp>: " temp 'noinsert)
2341 (if (string-equal (tempo-lookup-named 'temp) "")
2342 () (list 'l "TEMP=" '(s temp)))
2343 '(just-one-space)
2345 ;; "spice3 semiconductor resistor"
2346 "RSS"
2347 "tempo template for spice3 semiconductor resistor"
2348 'spice-tempo-tags)
2351 (tempo-define-template
2352 "spice-eldo-resistor"
2353 '("R"
2354 (p "[name]: ") '(just-one-space)
2355 (p "[pos node]: ") '(just-one-space)
2356 (p "[neg node]: ") '(just-one-space)
2357 (p "<mname>: " mname) '(just-one-space)
2358 (if (string-equal (tempo-lookup-named 'mname) "")
2359 (list 'l "r=" '(p "[val]: "))
2360 (list 'l '(p "[val]: "))) '(just-one-space)
2361 (p "<temp coef 1>: " tc1 'noinsert)
2362 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2363 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2364 '(just-one-space)
2365 (if (and (tempo-lookup-named 'tc2)
2366 (not (string-equal (tempo-lookup-named 'tc2) "")))
2367 (list 'l "TC2=" '(s tc2)))
2368 '(just-one-space)
2369 (p "<ac resistance>: " ac 'noinsert)
2370 (if (string-equal (tempo-lookup-named 'ac) "")
2371 () (list 'l "AC=" '(s ac)))
2372 '(just-one-space)
2373 (p "<temp>: " temp 'noinsert)
2374 (if (string-equal (tempo-lookup-named 'temp) "")
2375 () (list 'l "T=" '(s temp)))
2376 '(just-one-space)
2377 (p "<m>: " m 'noinsert)
2378 (if (string-equal (tempo-lookup-named 'm) "")
2379 () (list 'l "M=" '(s m)))
2380 '(just-one-space)
2381 (p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)
2382 (if (string-equal (tempo-lookup-named 'nonoise) "y")
2383 (list 'l "NONOISE"))
2384 '(just-one-space)
2385 (p "<kf>: " kf 'noinsert)
2386 (if (string-equal (tempo-lookup-named 'kf) "")
2387 () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
2388 '(just-one-space)
2389 (if (and (tempo-lookup-named 'af)
2390 (not (string-equal (tempo-lookup-named 'af) "")))
2391 (list 'l '(s af)))
2392 '(just-one-space)
2394 ;; "eldo resistor"
2395 "RE"
2396 "tempo template for eldo resistor"
2397 'spice-tempo-tags)
2400 (tempo-define-template
2401 "spice-eldo-expression-resistor"
2402 '("R"
2403 (p "[name]: ") '(just-one-space)
2404 (p "[pos node]: ") '(just-one-space)
2405 (p "[neg node]: ") '(just-one-space)
2406 (p "[VALUE | TABLE]: " type 'noinsert) '(just-one-space)
2407 (if (string-equal (tempo-lookup-named 'type) "VALUE")
2408 (list 'l "VALUE={" '(p "[val, enter expression without {}]: ") "}")
2409 (list 'l "TABLE={" '(p "[table of values, enter table without {}]: ") "}"))
2410 '(just-one-space)
2411 (if (string-equal (tempo-lookup-named 'type) "VALUE")
2412 (list 'l '(p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)))
2413 (if (and (tempo-lookup-named 'nonoise)
2414 (string-equal (tempo-lookup-named 'nonoise) "y"))
2415 (list 'l "NONOISE"))
2416 '(just-one-space)
2417 (p "<kf>: " kf 'noinsert)
2418 (if (string-equal (tempo-lookup-named 'kf) "")
2419 () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
2420 '(just-one-space)
2421 (if (and (tempo-lookup-named 'af)
2422 (not (string-equal (tempo-lookup-named 'af) "")))
2423 (list 'l '(s af)))
2425 ;; "eldo expression resistor"
2426 "REE"
2427 "tempo template for eldo expression resistor"
2428 'spice-tempo-tags)
2431 (tempo-define-template
2432 "spice-eldo-semiconductor-resistor"
2433 '("P"
2434 (p "[name]: ") '(just-one-space)
2435 (p "[pos node]: ") '(just-one-space)
2436 (p "[neg node]: ") '(just-one-space)
2437 (p "[mname]: " mname) '(just-one-space)
2438 (p "<res>: " r 'noinsert)
2439 (if (string-equal (tempo-lookup-named 'r) "")
2440 () (list 'l "R=" '(s r)))
2441 '(just-one-space)
2442 (p "<length>: " l 'noinsert)
2443 (if (string-equal (tempo-lookup-named 'l) "")
2444 () (list 'l "L=" '(s l)))
2445 '(just-one-space)
2446 (p "<contact offset length>: " cl 'noinsert)
2447 (if (string-equal (tempo-lookup-named 'cl) "")
2448 () (list 'l "CL=" '(s cl)))
2449 '(just-one-space)
2450 (p "<width>: " w 'noinsert)
2451 (if (string-equal (tempo-lookup-named 'w) "")
2452 () (list 'l "W=" '(s w)))
2453 '(just-one-space)
2454 (p "<contact offset width>: " cw 'noinsert)
2455 (if (string-equal (tempo-lookup-named 'cw) "")
2456 () (list 'l "CW=" '(s cw)))
2457 '(just-one-space)
2458 (p "<area>: " area 'noinsert)
2459 (if (string-equal (tempo-lookup-named 'area) "")
2460 () (list 'l "AREA=" '(s area)))
2461 '(just-one-space)
2462 (p "<init cond (voltage, voltage)>: " ic 'noinsert)
2463 (if (string-equal (tempo-lookup-named 'ic) "")
2464 () (list 'l "IC=" '(s ic)))
2465 '(just-one-space)
2467 ;; "eldo semiconductor resistor"
2468 "RES"
2469 "tempo template for eldo semiconductor resistor"
2470 'spice-tempo-tags)
2473 (tempo-define-template
2474 "spice-hspice-resistor"
2475 '("R"
2476 (p "[name]: ") '(just-one-space)
2477 (p "[pos node]: ") '(just-one-space)
2478 (p "[neg node]: ") '(just-one-space)
2479 (p "<mname>: " mname) '(just-one-space)
2480 (if (string-equal (tempo-lookup-named 'mname) "")
2481 (list 'l "R=" '(p "[val]: "))
2482 (list 'l '(p "<val>: " val 'noinsert)
2483 '(if (not (string-equal (tempo-lookup-named 'val) ""))
2484 (list 'l "R=" '(s val))))) '(just-one-space)
2485 (p "<temp coef 1>: " tc1 'noinsert)
2486 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2487 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2488 '(just-one-space)
2489 (if (and (tempo-lookup-named 'tc2)
2490 (not (string-equal (tempo-lookup-named 'tc2) "")))
2491 (list 'l "TC2=" '(s tc2)))
2492 '(just-one-space)
2493 (p "<scale>: " scale 'noinsert)
2494 (if (string-equal (tempo-lookup-named 'scale) "")
2495 () (list 'l "SCALE=" '(s scale)))
2496 '(just-one-space)
2497 (p "<m>: " m 'noinsert)
2498 (if (string-equal (tempo-lookup-named 'm) "")
2499 () (list 'l "M=" '(s m)))
2500 '(just-one-space)
2501 (p "<ac resistance>: " ac 'noinsert)
2502 (if (string-equal (tempo-lookup-named 'ac) "")
2503 () (list 'l "AC=" '(s ac)))
2504 '(just-one-space)
2505 (p "<diff temp>: " dtemp 'noinsert)
2506 (if (string-equal (tempo-lookup-named 'dtemp) "")
2507 () (list 'l "DTEMP=" '(s dtemp)))
2508 '(just-one-space)
2509 (p "<length>: " l 'noinsert)
2510 (if (string-equal (tempo-lookup-named 'l) "")
2511 () (list 'l "L=" '(s l)))
2512 '(just-one-space)
2513 (p "<width>: " w 'noinsert)
2514 (if (string-equal (tempo-lookup-named 'w) "")
2515 () (list 'l "W=" '(s w)))
2516 '(just-one-space)
2517 (p "<cap>: " c 'noinsert)
2518 (if (string-equal (tempo-lookup-named 'c) "")
2519 () (list 'l "C=" '(s c)))
2520 '(just-one-space)
2522 ;; "hspice resistor"
2523 "RH"
2524 "template for hspice resistor tempo templates"
2525 'spice-tempo-tags)
2528 (tempo-define-template
2529 "spice-layla-resistor"
2530 '("R"
2531 (p "[name]: ") '(just-one-space)
2532 (p "[pos node]: ") '(just-one-space)
2533 (p "[neg node]: ") '(just-one-space)
2534 ; (p "<mname>: ") '(just-one-space)
2535 (p "[value]: ") '(just-one-space)
2536 (p "<width>: " w 'noinsert)
2537 (if (string-equal (tempo-lookup-named 'w) "")
2538 () (list 'l "width=" '(s w)))
2539 '(just-one-space)
2540 "\n+ type=\""
2541 (p "[type (no quotes)]: ") "\""
2542 '(just-one-space)
2543 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
2544 (if (string-equal (tempo-lookup-named 'symmetry) "")
2545 () (list 'l "symmetry=\"" '(s symmetry) "\""))
2546 '(just-one-space)
2547 (p "<matching (no quotes)>: " matching 'noinsert)
2548 (if (string-equal (tempo-lookup-named 'matching) "")
2549 () (list 'l "matching=\"" '(s matching) "\""))
2550 '(just-one-space)
2551 (p "<couple>: " couple 'noinsert)
2552 (if (string-equal (tempo-lookup-named 'couple) "")
2553 () (list 'l "couple=" '(s couple)))
2554 '(just-one-space)
2555 (p "<array (no quotes)>: " array 'noinsert)
2556 (if (string-equal (tempo-lookup-named 'array) "")
2557 () (list 'l "array=\"" '(s array) "\""))
2558 '(just-one-space)
2559 (p "<orientations (no quotes)>: " orientations 'noinsert)
2560 (if (string-equal (tempo-lookup-named 'orientations) "")
2561 () (list 'l "orientations=\"" '(s orientations) "\""))
2562 '(just-one-space)
2563 (p "<unit_value>: " unit_value 'noinsert)
2564 (if (string-equal (tempo-lookup-named 'unit_value) "")
2565 () (list 'l "unit_value=" '(s unit_value)))
2566 '(just-one-space)
2567 (p "<current>: " current 'noinsert)
2568 (if (string-equal (tempo-lookup-named 'current) "")
2569 () (list 'l "current=" '(s current)))
2570 '(just-one-space)
2571 (p "<power>: " power 'noinsert)
2572 (if (string-equal (tempo-lookup-named 'power) "")
2573 () (list 'l "power=" '(s power)))
2574 '(just-one-space)
2575 (p "<min_ar>: " min_ar 'noinsert)
2576 (if (string-equal (tempo-lookup-named 'min_ar) "")
2577 () (list 'l "min_ar=" '(s min_ar)))
2578 '(just-one-space)
2579 (p "<max_ar>: " max_ar 'noinsert)
2580 (if (string-equal (tempo-lookup-named 'max_ar) "")
2581 () (list 'l "max_ar=" '(s max_ar)))
2582 '(just-one-space)
2583 (p "<routing_space>: " routing_space 'noinsert)
2584 (if (string-equal (tempo-lookup-named 'routing_space) "")
2585 () (list 'l "routing_space=" '(s routing_space)))
2586 '(just-one-space)
2588 ;; "layla resistor"
2589 "RL"
2590 "tempo template for layla resistor"
2591 'spice-tempo-tags)
2594 ;; capacitors
2595 (tempo-define-template
2596 "spice-spice2g6-capacitor"
2597 '("C"
2598 (p "[name]: ") '(just-one-space)
2599 (p "[pos node]: ") '(just-one-space)
2600 (p "[neg node]: ") '(just-one-space)
2601 (p "[val]: ") '(just-one-space)
2602 (p "<initial cond (voltage)>: " ic 'noinsert)
2603 (if (string-equal (tempo-lookup-named 'ic) "")
2604 () (list 'l "ic=" '(s ic)))
2606 ;; "spice2g6 capacitor"
2608 "tempo template for spice2g6 capacitor"
2609 'spice-tempo-tags)
2612 (tempo-define-template
2613 "spice-spice3-semiconductor-capacitor"
2614 '("C"
2615 (p "[name]: ") '(just-one-space)
2616 (p "[pos node]: ") '(just-one-space)
2617 (p "[neg node]: ") '(just-one-space)
2618 (p "<value>: " value) '(just-one-space)
2619 (p "<mname>: " mname) '(just-one-space)
2620 (p "<length>: " l 'noinsert)
2621 (if (string-equal (tempo-lookup-named 'l) "")
2622 () (list 'l "L=" '(s l)))
2623 '(just-one-space)
2624 (p "<width>: " w 'noinsert)
2625 (if (string-equal (tempo-lookup-named 'w) "")
2626 () (list 'l "W=" '(s w)))
2627 '(just-one-space)
2628 (p "<initial conditions (Voltage)>: " ic 'noinsert)
2629 (if (string-equal (tempo-lookup-named 'ic) "")
2630 () (list 'l "IC=" '(s ic)))
2631 '(just-one-space)
2633 ;; "spice3 semiconductor capacitor"
2634 "CSS"
2635 "tempo template for spice3 semiconductor capacitor"
2636 'spice-tempo-tags)
2639 (tempo-define-template
2640 "spice-eldo-capacitor"
2641 '("C"
2642 (p "[name]: ") '(just-one-space)
2643 (p "[pos node]: ") '(just-one-space)
2644 (p "[neg node]: ") '(just-one-space)
2645 (p "<mname | POLY>: " mname) '(just-one-space)
2646 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2647 (list 'l '(p "[val and poly coefficients]: "))
2648 (list 'l '(p "[val]: ")))
2649 '(just-one-space)
2650 (p "<m>: " m 'noinsert)
2651 (if (string-equal (tempo-lookup-named 'm) "")
2652 () (list 'l "M=" '(s m)))
2653 '(just-one-space)
2654 (p "<length>: " l 'noinsert)
2655 (if (string-equal (tempo-lookup-named 'l) "")
2656 () (list 'l "L=" '(s l)))
2657 '(just-one-space)
2658 (p "<width>: " w 'noinsert)
2659 (if (string-equal (tempo-lookup-named 'w) "")
2660 () (list 'l "W=" '(s w)))
2661 '(just-one-space)
2662 (p "<diff temp>: " dtemp 'noinsert)
2663 (if (string-equal (tempo-lookup-named 'dtemp) "")
2664 () (list 'l "DTEMP=" '(s dtemp)))
2665 '(just-one-space)
2666 (p "<temp coef 1>: " tc1 'noinsert)
2667 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2668 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2669 '(just-one-space)
2670 (if (and (tempo-lookup-named 'tc2)
2671 (not (string-equal (tempo-lookup-named 'tc2) "")))
2672 (list 'l "TC2=" '(s tc2)))
2673 '(just-one-space)
2674 (p "<initial cond (voltage)>: " ic 'noinsert)
2675 (if (string-equal (tempo-lookup-named 'ic) "")
2676 () (list 'l "IC=" '(s ic)))
2678 ;; "eldo capacitor"
2679 "CE"
2680 "tempo template for eldo capacitor"
2681 'spice-tempo-tags)
2684 (tempo-define-template
2685 "spice-eldo-expression-capacitor"
2686 '("C"
2687 (p "[name]: ") '(just-one-space)
2688 (p "[pos node]: ") '(just-one-space)
2689 (p "[neg node]: ") '(just-one-space)
2690 (p "<temp coef 1>: " tc1 'noinsert)
2691 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2692 (list 'l "TC1=" '(s tc1)))
2693 '(just-one-space)
2694 (p "<temp coef 2>: " tc2 'noinsert)
2695 (if (string-equal (tempo-lookup-named 'tc2) "") ()
2696 (list 'l "TC2=" '(s tc2)))
2697 '(just-one-space)
2698 (p "<temp coef 3>: " tc3 'noinsert)
2699 (if (string-equal (tempo-lookup-named 'tc3) "") ()
2700 (list 'l "TC3=" '(s tc3)))
2701 '(just-one-space)
2702 "VALUE={"
2703 (p "[val enter expression without {}]: ")
2706 ;; "eldo expression capacitor"
2707 "CEE"
2708 "tempo template for eldo expression capacitor"
2709 'spice-tempo-tags)
2712 (tempo-define-template
2713 "spice-hspice-capacitor"
2714 '("C"
2715 (p "[name]: ") '(just-one-space)
2716 (p "[pos node]: ") '(just-one-space)
2717 (p "[neg node]: ") '(just-one-space)
2718 (p "<mname | POLY>: " mname) '(just-one-space)
2719 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2720 (list 'l '(p "[val and poly coefficients]: " val))
2721 (if (string-equal (tempo-lookup-named 'mname) "")
2722 (list 'l "C=" '(p "[val or expression]: " val))
2723 (list 'l "C=" '(p "[val]: " val))))
2724 '(just-one-space)
2725 (if (and (not (string-equal (tempo-lookup-named 'mname) "POLY"))
2726 (char-equal (string-to-char (tempo-lookup-named 'val))
2727 (string-to-char "'")))
2728 (list 'l '(p "<ctype>: " ctype 'noinsert)))
2729 (if (and (tempo-lookup-named 'ctype)
2730 (not (string-equal (tempo-lookup-named 'ctype) "")))
2731 (list 'l "CTYPE=" '(s ctype)))
2732 '(just-one-space)
2733 (p "<temp coef 1>: " tc1 'noinsert)
2734 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2735 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2736 '(just-one-space)
2737 (if (and (tempo-lookup-named 'tc2)
2738 (not (string-equal (tempo-lookup-named 'tc2) "")))
2739 (list 'l "TC2=" '(s tc2)))
2740 '(just-one-space)
2741 (p "<scale>: " scale 'noinsert)
2742 (if (string-equal (tempo-lookup-named 'scale) "")
2743 () (list 'l "SCALE=" '(s scale)))
2744 '(just-one-space)
2745 (p "<initial cond (voltage)>: " ic 'noinsert)
2746 (if (string-equal (tempo-lookup-named 'ic) "")
2747 () (list 'l "IC=" '(s ic)))
2748 '(just-one-space)
2749 (p "<m>: " m 'noinsert)
2750 (if (string-equal (tempo-lookup-named 'm) "")
2751 () (list 'l "M=" '(s m)))
2752 '(just-one-space)
2753 (p "<width>: " w 'noinsert)
2754 (if (string-equal (tempo-lookup-named 'w) "")
2755 () (list 'l "W=" '(s w)))
2756 '(just-one-space)
2757 (p "<length>: " l 'noinsert)
2758 (if (string-equal (tempo-lookup-named 'l) "")
2759 () (list 'l "L=" '(s l)))
2760 '(just-one-space)
2761 (p "<diff temp>: " dtemp 'noinsert)
2762 (if (string-equal (tempo-lookup-named 'dtemp) "")
2763 () (list 'l "DTEMP=" '(s dtemp)))
2764 '(just-one-space)
2766 ;; "hspice capacitor"
2767 "CH"
2768 "tempo template for hspice capacitor"
2769 'spice-tempo-tags)
2772 (tempo-define-template
2773 "spice-layla-capacitor"
2774 '("C"
2775 (p "[name]: ") '(just-one-space)
2776 (p "[pos node]: ") '(just-one-space)
2777 (p "[neg node]: ") '(just-one-space)
2778 (p "[value]: ") '(just-one-space)
2779 (p "<units_ver>: " units_ver 'noinsert)
2780 (if (string-equal (tempo-lookup-named 'units_ver) "")
2781 () (list 'l "units_ver=" '(s units_ver)))
2782 '(just-one-space)
2783 (p "<units_hor>: " units_hor 'noinsert)
2784 (if (string-equal (tempo-lookup-named 'units_hor) "")
2785 () (list 'l "units_hor=" '(s units_hor)))
2786 '(just-one-space)
2787 "\n+ type=\""
2788 (p "[type (no quotes)]: ") "\""
2789 '(just-one-space)
2790 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
2791 (if (string-equal (tempo-lookup-named 'symmetry) "")
2792 () (list 'l "symmetry=\"" '(s symmetry) "\""))
2793 '(just-one-space)
2794 (p "<matching (no quotes)>: " matching 'noinsert)
2795 (if (string-equal (tempo-lookup-named 'matching) "")
2796 () (list 'l "matching=\"" '(s matching) "\""))
2797 '(just-one-space)
2798 (p "<couple>: " couple 'noinsert)
2799 (if (string-equal (tempo-lookup-named 'couple) "")
2800 () (list 'l "couple=" '(s couple)))
2801 '(just-one-space)
2802 (p "<array (no quotes)>: " array 'noinsert)
2803 (if (string-equal (tempo-lookup-named 'array) "")
2804 () (list 'l "array=\"" '(s array) "\""))
2805 '(just-one-space)
2806 (p "<orientations (no quotes)>: " orientations 'noinsert)
2807 (if (string-equal (tempo-lookup-named 'orientations) "")
2808 () (list 'l "orientations=\"" '(s orientations) "\""))
2809 '(just-one-space)
2810 (p "<unit_value>: " unit_value 'noinsert)
2811 (if (string-equal (tempo-lookup-named 'unit_value) "")
2812 () (list 'l "unit_value=" '(s unit_value)))
2813 '(just-one-space)
2814 (p "<power>: " power 'noinsert)
2815 (if (string-equal (tempo-lookup-named 'power) "")
2816 () (list 'l "power=" '(s power)))
2817 '(just-one-space)
2818 (p "<min_ar>: " min_ar 'noinsert)
2819 (if (string-equal (tempo-lookup-named 'min_ar) "")
2820 () (list 'l "min_ar=" '(s min_ar)))
2821 '(just-one-space)
2822 (p "<max_ar>: " max_ar 'noinsert)
2823 (if (string-equal (tempo-lookup-named 'max_ar) "")
2824 () (list 'l "max_ar=" '(s max_ar)))
2825 '(just-one-space)
2826 (p "<routing_space>: " routing_space 'noinsert)
2827 (if (string-equal (tempo-lookup-named 'routing_space) "")
2828 () (list 'l "routing_space=" '(s routing_space)))
2829 '(just-one-space)
2831 ;; "layla capacitor"
2832 "CL"
2833 "tempo template for layla capacitor"
2834 'spice-tempo-tags)
2837 ;; inductors
2838 (tempo-define-template
2839 "spice-spice2g6-inductor"
2840 '("L"
2841 (p "[name]: ") '(just-one-space)
2842 (p "[pos node]: ") '(just-one-space)
2843 (p "[neg node]: ") '(just-one-space)
2844 (p "[val]: ") '(just-one-space)
2845 (p "<initial cond (current)>: " ic 'noinsert)
2846 (if (string-equal (tempo-lookup-named 'ic) "")
2847 () (list 'l "ic=" '(s ic)))
2849 ;; "spice2g6 inductor"
2851 "tempo template for spice2g6 inductor"
2852 'spice-tempo-tags)
2855 (tempo-define-template
2856 "spice-eldo-inductor"
2857 '("L"
2858 (p "[name]: ") '(just-one-space)
2859 (p "[pos node]: ") '(just-one-space)
2860 (p "[neg node]: ") '(just-one-space)
2861 (p "<mname | POLY>: " mname) '(just-one-space)
2862 (if (string-equal (tempo-lookup-named 'mname) "POLY")
2863 (list 'l '(p "[val and poly coefficients]: "))
2864 (list 'l '(p "[val]: ")))
2865 '(just-one-space)
2866 (p "<initial cond (current)>: " ic 'noinsert)
2867 (if (string-equal (tempo-lookup-named 'ic) "")
2868 () (list 'l "ic=" '(s ic)))
2870 ;; "eldo inductor"
2871 "LE"
2872 "tempo template for eldo inductor"
2873 'spice-tempo-tags)
2876 (tempo-define-template
2877 "spice-eldo-expression-inductor"
2878 '("L"
2879 (p "[name]: ") '(just-one-space)
2880 (p "[pos node]: ") '(just-one-space)
2881 (p "[neg node]: ") '(just-one-space)
2882 "VALUE={"
2883 (p "[val enter expression without {}]: ")
2886 ;; "eldo expression inductor"
2887 "LEE"
2888 "tempo template for eldo expression inductor"
2889 'spice-tempo-tags)
2892 (tempo-define-template
2893 "spice-hspice-inductor"
2894 '("L"
2895 (p "[name]: ") '(just-one-space)
2896 (p "[pos node]: ") '(just-one-space)
2897 (p "[neg node]: ") '(just-one-space)
2898 (p "<POLY | NT>: " poly 'noinsert) '(just-one-space)
2899 (cond ((string-equal (tempo-lookup-named 'poly) "POLY")
2900 (list 'l "POLY " '(p "[value and coefficients]: ")))
2901 ((string-equal (tempo-lookup-named 'poly) "NT")
2902 (list 'l "NT=" '(p "[number of turns]: " nt)))
2904 (list 'l "L=" '(p "[value or expression]: " val)))
2906 '(just-one-space)
2907 (if (and (tempo-lookup-named 'val)
2908 (char-equal (string-to-char (tempo-lookup-named 'val))
2909 (string-to-char "'")))
2910 (list 'l '(p "<ltype>: " ltype 'noinsert)))
2911 (if (and (tempo-lookup-named 'ltype)
2912 (not (string-equal (tempo-lookup-named 'ltype) "")))
2913 (list 'l "LTYPE=" '(s ltype)))
2914 '(just-one-space)
2915 (p "<temp coef 1>: " tc1 'noinsert)
2916 (if (string-equal (tempo-lookup-named 'tc1) "") ()
2917 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
2918 '(just-one-space)
2919 (if (and (tempo-lookup-named 'tc2)
2920 (not (string-equal (tempo-lookup-named 'tc2) "")))
2921 (list 'l "TC2=" '(s tc2)))
2922 '(just-one-space)
2923 (p "<scale>: " scale 'noinsert)
2924 (if (string-equal (tempo-lookup-named 'scale) "")
2925 () (list 'l "SCALE=" '(s scale)))
2926 '(just-one-space)
2927 (p "<initial cond (current)>: " ic 'noinsert)
2928 (if (string-equal (tempo-lookup-named 'ic) "")
2929 () (list 'l "IC=" '(s ic)))
2930 '(just-one-space)
2931 (p "<m>: " m 'noinsert)
2932 (if (string-equal (tempo-lookup-named 'm) "")
2933 () (list 'l "M=" '(s m)))
2934 '(just-one-space)
2935 (p "<diff temp>: " dtemp 'noinsert)
2936 (if (string-equal (tempo-lookup-named 'dtemp) "")
2937 () (list 'l "DTEMP=" '(s dtemp)))
2938 '(just-one-space)
2939 (p "<res>: " r 'noinsert)
2940 (if (string-equal (tempo-lookup-named 'r) "")
2941 () (list 'l "R=" '(s r)))
2942 '(just-one-space)
2944 ;; "hspice inductor"
2945 "LH"
2946 "tempo template for hspice inductor"
2947 'spice-tempo-tags)
2950 (tempo-define-template
2951 "spice-layla-inductor"
2952 '("L"
2953 (p "[name]: ") '(just-one-space)
2954 (p "[pos node]: ") '(just-one-space)
2955 (p "[neg node]: ") '(just-one-space)
2956 (p "<value>: ") '(just-one-space)
2957 (p "<outer radius>: " radius 'noinsert)
2958 (if (string-equal (tempo-lookup-named 'radius) "")
2959 () (list 'l "radius=" '(s radius)))
2960 '(just-one-space)
2961 (p "<width>: " w 'noinsert)
2962 (if (string-equal (tempo-lookup-named 'w) "")
2963 () (list 'l "w=" '(s w)))
2964 '(just-one-space)
2965 (p "<number of turns>: " n 'noinsert)
2966 (if (string-equal (tempo-lookup-named 'n) "")
2967 () (list 'l "n=" '(s n)))
2968 '(just-one-space)
2969 (p "<space>: " space 'noinsert)
2970 (if (string-equal (tempo-lookup-named 'space) "")
2971 () (list 'l "space=" '(s space)))
2972 '(just-one-space)
2973 (p "<end_fraction [0-1]>: " end_fraction 'noinsert)
2974 (if (string-equal (tempo-lookup-named 'end_fraction) "")
2975 () (list 'l "end_fraction=" '(s end_fraction)))
2976 '(just-one-space)
2977 "\n+ type=\""
2978 (p "[type (no quotes)]: ") "\""
2979 '(just-one-space)
2980 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
2981 (if (string-equal (tempo-lookup-named 'symmetry) "")
2982 () (list 'l "symmetry=\"" '(s symmetry) "\""))
2983 '(just-one-space)
2984 (p "<matching (no quotes)>: " matching 'noinsert)
2985 (if (string-equal (tempo-lookup-named 'matching) "")
2986 () (list 'l "matching=\"" '(s matching) "\""))
2987 '(just-one-space)
2988 (p "<couple>: " couple 'noinsert)
2989 (if (string-equal (tempo-lookup-named 'couple) "")
2990 () (list 'l "couple=" '(s couple)))
2991 '(just-one-space)
2992 (p "<array (no quotes)>: " array 'noinsert)
2993 (if (string-equal (tempo-lookup-named 'array) "")
2994 () (list 'l "array=\"" '(s array) "\""))
2995 '(just-one-space)
2996 (p "<orientations (no quotes)>: " orientations 'noinsert)
2997 (if (string-equal (tempo-lookup-named 'orientations) "")
2998 () (list 'l "orientations=\"" '(s orientations) "\""))
2999 '(just-one-space)
3000 (p "<power>: " power 'noinsert)
3001 (if (string-equal (tempo-lookup-named 'power) "")
3002 () (list 'l "power=" '(s power)))
3003 '(just-one-space)
3004 (p "<min_ar>: " min_ar 'noinsert)
3005 (if (string-equal (tempo-lookup-named 'min_ar) "")
3006 () (list 'l "min_ar=" '(s min_ar)))
3007 '(just-one-space)
3008 (p "<max_ar>: " max_ar 'noinsert)
3009 (if (string-equal (tempo-lookup-named 'max_ar) "")
3010 () (list 'l "max_ar=" '(s max_ar)))
3011 '(just-one-space)
3012 (p "<routing_space>: " routing_space 'noinsert)
3013 (if (string-equal (tempo-lookup-named 'routing_space) "")
3014 () (list 'l "routing_space=" '(s routing_space)))
3015 '(just-one-space)
3017 ;; "layla inductor"
3018 "LL"
3019 "tempo template for layla inductor"
3020 'spice-tempo-tags)
3023 ;; coupled inductors
3024 (tempo-define-template
3025 "spice-spice2g6-coupled-inductors"
3026 '("K"
3027 (p "[name]: ") '(just-one-space)
3028 (p "[first inductor]: ") '(just-one-space)
3029 (p "[second inductor]: ") '(just-one-space)
3030 (p "[coupling coefficient]: ")
3032 ;; "spice2g6 inductor coupling"
3034 "tempo template for spice2g6 coupled inductors"
3035 'spice-tempo-tags)
3038 ;; lossless transmission lines
3039 (tempo-define-template
3040 "spice-spice2g6-lossless-transmission"
3041 '("T"
3042 (p "[name]: ") '(just-one-space)
3043 (p "[out port1]: ") '(just-one-space)
3044 (p "[ref port1]: ") '(just-one-space)
3045 (p "[out port2]: ") '(just-one-space)
3046 (p "[ref port2]: ") '(just-one-space)
3047 "Z0=" (p "[char impedance]: ") '(just-one-space)
3048 (p "<time delay in seconds>: " td 'noinsert)
3049 (if (string-equal (tempo-lookup-named 'td) "")
3050 (list 'l '(p "<freq>: " freq 'noinsert)) (list 'l "td=" '(s td)))
3051 '(just-one-space)
3052 (if (and (tempo-lookup-named 'freq)
3053 (not (string-equal (tempo-lookup-named 'freq) "")))
3054 (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
3055 '(just-one-space)
3056 (if (and (tempo-lookup-named 'nrmlen)
3057 (not (string-equal (tempo-lookup-named 'nrmlen) "")))
3058 (list 'l "nl=" '(s nrmlen)))
3059 '(just-one-space)
3060 (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
3061 (if (string-equal (tempo-lookup-named 'ic) "")
3062 () (list 'l "ic=" '(s ic)))
3064 ;;"spice2g6 lossless transmission line"
3066 "tempo template for spice2g6 lossless transmission line"
3067 'spice-tempo-tags)
3070 (tempo-define-template
3071 "spice-hspice-lossless-transmission"
3072 '("T"
3073 (p "[name]: ") '(just-one-space)
3074 (p "[out port1]: ") '(just-one-space)
3075 (p "[ref port1]: ") '(just-one-space)
3076 (p "[out port2]: ") '(just-one-space)
3077 (p "[ref port2]: ") '(just-one-space)
3078 "Z0=" (p "[char impedance]: ") '(just-one-space)
3079 (p "<time delay in seconds per meter>: " td 'noinsert)
3080 (if (string-equal (tempo-lookup-named 'td) "")
3081 (list 'l '(p "<freq>: " freq 'noinsert))
3082 (list 'l "td=" '(s td) '(p "<length [1m]>: " l 'noinsert)))
3083 '(just-one-space)
3084 (if (and (tempo-lookup-named 'l)
3085 (not (string-equal (tempo-lookup-named 'l) "")))
3086 (list 'l "l=" '(s l)))
3087 '(just-one-space)
3088 (if (and (tempo-lookup-named 'freq)
3089 (not (string-equal (tempo-lookup-named 'freq) "")))
3090 (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
3091 '(just-one-space)
3092 (if (and (tempo-lookup-named 'nrmlen)
3093 (not (string-equal (tempo-lookup-named 'nrmlen) "")))
3094 (list 'l "nl=" '(s nrmlen)))
3095 '(just-one-space)
3096 (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
3097 (if (string-equal (tempo-lookup-named 'ic) "")
3098 () (list 'l "ic=" '(s ic)))
3100 ;;"hspice lossless transmission line"
3101 "TH"
3102 "tempo template for hspice lossless transmission line"
3103 'spice-tempo-tags)
3106 ;; lossy transmission lines
3107 (tempo-define-template
3108 "spice-spice2g6-lossy-transmission"
3109 '("O"
3110 (p "[name]: ") '(just-one-space)
3111 (p "[out port1]: ") '(just-one-space)
3112 (p "[ref port1]: ") '(just-one-space)
3113 (p "[out port2]: ") '(just-one-space)
3114 (p "[ref port2]: ") '(just-one-space)
3115 (p "[mname]: ") '(just-one-space)
3117 ;;"spice2g6 lossy transmission line"
3119 "tempo template for spice2g6 lossy transmission line"
3120 'spice-tempo-tags)
3123 (tempo-define-template
3124 "spice-spice3-rcline"
3125 '("U"
3126 (p "[name]: ") '(just-one-space)
3127 (p "[in port]: ") '(just-one-space)
3128 (p "[out port]: ") '(just-one-space)
3129 (p "[ref port]: ") '(just-one-space)
3130 (p "[mname]: ") '(just-one-space)
3131 "L="
3132 (p "[length (m)]: ") '(just-one-space)
3133 (p "<lumps>: " lumps 'noinsert)
3134 (if (string-equal (tempo-lookup-named 'lumps) "")
3135 () (list 'l "N=" '(s lumps)))
3136 '(just-one-space)
3138 ;;"spice3 lossy transmission line"
3139 "RCLS"
3140 "tempo template for spice2g6 lossy transmission line"
3141 'spice-tempo-tags)
3144 (tempo-define-template
3145 "spice-eldo-rcline"
3146 '("R"
3147 (p "[name]: ") '(just-one-space)
3148 (p "[pos node]: ") '(just-one-space)
3149 (p "[neg node]: ") '(just-one-space)
3150 (p "[mname]: " mname) '(just-one-space)
3151 (p "<res>: " r 'noinsert)
3152 (if (string-equal (tempo-lookup-named 'r) "")
3153 () (list 'l "R=" '(s r)))
3154 '(just-one-space)
3155 (p "<temp coef 1>: " tc1 'noinsert)
3156 (if (string-equal (tempo-lookup-named 'tc1) "") ()
3157 (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
3158 '(just-one-space)
3159 (if (and (tempo-lookup-named 'tc2)
3160 (not (string-equal (tempo-lookup-named 'tc2) "")))
3161 (list 'l "TC2=" '(s tc2)))
3162 '(just-one-space)
3163 (p "<cap>: " c 'noinsert)
3164 (if (string-equal (tempo-lookup-named 'c) "")
3165 () (list 'l "C=" '(s c)))
3166 '(just-one-space)
3167 (p "<length>: " l 'noinsert)
3168 (if (string-equal (tempo-lookup-named 'l) "")
3169 () (list 'l "L=" '(s l)))
3170 '(just-one-space)
3171 (p "<width>: " w 'noinsert)
3172 (if (string-equal (tempo-lookup-named 'w) "")
3173 () (list 'l "W=" '(s w)))
3174 '(just-one-space)
3175 (p "<m>: " m 'noinsert)
3176 (if (string-equal (tempo-lookup-named 'm) "")
3177 () (list 'l "M=" '(s m)))
3178 '(just-one-space)
3179 (p "<diff temp>: " dtemp 'noinsert)
3180 (if (string-equal (tempo-lookup-named 'dtemp) "")
3181 () (list 'l "DTEMP=" '(s dtemp)))
3182 '(just-one-space)
3183 (p "<scale>: " scale 'noinsert)
3184 (if (string-equal (tempo-lookup-named 'scale) "")
3185 () (list 'l "SCALE=" '(s scale)))
3186 '(just-one-space)
3188 ;;"eldo rcline"
3189 "RCLE"
3190 "tempo template for eldo rcline"
3191 'spice-tempo-tags)
3194 ;; active elements
3196 ;; diodes
3197 (tempo-define-template
3198 "spice-spice2g6-diode"
3199 '("D"
3200 (p "[name]: ") '(just-one-space)
3201 (p "[positive node]: ") '(just-one-space)
3202 (p "[negative node]: ") '(just-one-space)
3203 (p "[mname]: ") '(just-one-space)
3204 (p "<area>: ") '(just-one-space)
3205 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3206 (if (and (tempo-lookup-named 'off)
3207 (string-equal (tempo-lookup-named 'off) "y"))
3208 (list 'l "OFF"))
3209 '(just-one-space)
3210 (p "<initial cond (diode voltage)>: " ic 'noinsert)
3211 (if (string-equal (tempo-lookup-named 'ic) "")
3212 () (list 'l "IC=" '(s ic)))
3213 '(just-one-space)
3214 (p "<temp>: " temp 'noinsert)
3215 (if (string-equal (tempo-lookup-named 'temp) "")
3216 () (list 'l "TEMP=" '(s temp)))
3217 '(just-one-space)
3219 ;;"spice2g6 diode"
3221 "tempo template for spice2g6 diode"
3222 'spice-tempo-tags)
3225 (tempo-define-template
3226 "spice-eldo-diode"
3227 '("D"
3228 (p "[name]: ") '(just-one-space)
3229 (p "[positive node]: ") '(just-one-space)
3230 (p "[negative node]: ") '(just-one-space)
3231 (p "[mname]: ") '(just-one-space)
3232 (p "<area>: " area 'noinsert) '(just-one-space)
3233 (if (string-equal (tempo-lookup-named 'area) "")
3234 () (list 'l "AREA=" '(s area)))
3235 '(just-one-space)
3236 (p "<perimeter>: " peri 'noinsert)
3237 (if (string-equal (tempo-lookup-named 'peri) "")
3238 () (list 'l "PERI=" '(s peri)))
3239 '(just-one-space)
3240 (p "<temp>: " temp 'noinsert)
3241 (if (string-equal (tempo-lookup-named 'temp) "")
3242 () (list 'l "TEMP=" '(s temp)))
3243 '(just-one-space)
3244 (p "<off [y/n]>: " off 'noinsert)
3245 (if (and (tempo-lookup-named 'off)
3246 (string-equal (tempo-lookup-named 'off) "y"))
3247 (list 'l "OFF"))
3248 '(just-one-space)
3249 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3250 (if (and (tempo-lookup-named 'nonoise)
3251 (string-equal (tempo-lookup-named 'nonoise) "y"))
3252 (list 'l "NONOISE"))
3253 '(just-one-space)
3255 ;;"eldo diode"
3256 "DE"
3257 "tempo template for eldo diode"
3258 'spice-tempo-tags)
3261 (tempo-define-template
3262 "spice-hspice-diode"
3263 '("D"
3264 (p "[name]: ") '(just-one-space)
3265 (p "[positive node]: ") '(just-one-space)
3266 (p "[negative node]: ") '(just-one-space)
3267 (p "[mname]: ") '(just-one-space)
3268 (p "<area>: " area 'noinsert) '(just-one-space)
3269 (if (string-equal (tempo-lookup-named 'area) "")
3270 (list 'l '(p "<width>: " w 'noinsert))
3271 (list 'l "AREA=" '(s area) '(p "<perimeter>: " peri 'noinsert)))
3272 '(just-one-space)
3273 (if (and (tempo-lookup-named 'peri)
3274 (not (string-equal (tempo-lookup-named 'peri) "")))
3275 (list 'l "PJ=" '(s peri)))
3276 '(just-one-space)
3277 (if (string-equal (tempo-lookup-named 'area) "")
3278 (list 'l '(p "<length>: " l 'noinsert)))
3279 '(just-one-space)
3280 (if (and (tempo-lookup-named 'l)
3281 (not (string-equal (tempo-lookup-named 'l) "")))
3282 () (list 'l "L=" '(s l)))
3283 '(just-one-space)
3284 (p "<width poly cap>: " wp 'noinsert)
3285 (if (string-equal (tempo-lookup-named 'wp) "")
3286 () (list 'l "WP=" '(s wp)))
3287 '(just-one-space)
3288 (p "<length poly cap>: " lp 'noinsert)
3289 (if (string-equal (tempo-lookup-named 'lp) "")
3290 () (list 'l "LP=" '(s lp)))
3291 '(just-one-space)
3292 (p "<width metal cap>: " wm 'noinsert)
3293 (if (string-equal (tempo-lookup-named 'wm) "")
3294 () (list 'l "WM=" '(s wm)))
3295 '(just-one-space)
3296 (p "<length metal cap>: " lm 'noinsert)
3297 (if (string-equal (tempo-lookup-named 'lm) "")
3298 () (list 'l "LM=" '(s lm)))
3299 '(just-one-space)
3300 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3301 (if (and (tempo-lookup-named 'off)
3302 (string-equal (tempo-lookup-named 'off) "y"))
3303 (list 'l "OFF"))
3304 '(just-one-space)
3305 (p "<initial cond (voltage)>: " ic 'noinsert)
3306 (if (string-equal (tempo-lookup-named 'ic) "")
3307 () (list 'l "IC=" '(s ic)))
3308 '(just-one-space)
3309 (p "<m>: " m 'noinsert)
3310 (if (string-equal (tempo-lookup-named 'm) "")
3311 () (list 'l "M=" '(s m)))
3312 '(just-one-space)
3313 (p "<diff temp>: " dtemp 'noinsert)
3314 (if (string-equal (tempo-lookup-named 'dtemp) "")
3315 () (list 'l "DTEMP=" '(s dtemp)))
3316 '(just-one-space)
3318 ;;"hspice diode"
3319 "DH"
3320 "tempo template for hspice diode"
3321 'spice-tempo-tags)
3324 (tempo-define-template
3325 "spice-layla-diode"
3326 '("D"
3327 (p "[name]: ") '(just-one-space)
3328 (p "[positive node]: ") '(just-one-space)
3329 (p "[negative node]: ") '(just-one-space)
3330 ; (p "<mname>: ") '(just-one-space)
3331 (p "[area]: ") '(just-one-space)
3332 (p "<units_ver>: " units_ver 'noinsert)
3333 (if (string-equal (tempo-lookup-named 'units_ver) "")
3334 () (list 'l "units_ver=" '(s units_ver)))
3335 '(just-one-space)
3336 (p "<units_hor>: " units_hor 'noinsert)
3337 (if (string-equal (tempo-lookup-named 'units_hor) "")
3338 () (list 'l "units_hor=" '(s units_hor)))
3339 '(just-one-space)
3340 "\n+ type=\""
3341 (p "[type (no quotes)]: ") "\""
3342 '(just-one-space)
3343 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
3344 (if (string-equal (tempo-lookup-named 'symmetry) "")
3345 () (list 'l "symmetry=\"" '(s symmetry) "\""))
3346 '(just-one-space)
3347 (p "<matching (no quotes)>: " matching 'noinsert)
3348 (if (string-equal (tempo-lookup-named 'matching) "")
3349 () (list 'l "matching=\"" '(s matching) "\""))
3350 '(just-one-space)
3351 (p "<couple>: " couple 'noinsert)
3352 (if (string-equal (tempo-lookup-named 'couple) "")
3353 () (list 'l "couple=" '(s couple)))
3354 '(just-one-space)
3355 (p "<array (no quotes)>: " array 'noinsert)
3356 (if (string-equal (tempo-lookup-named 'array) "")
3357 () (list 'l "array=\"" '(s array) "\""))
3358 '(just-one-space)
3359 (p "<orientations (no quotes)>: " orientations 'noinsert)
3360 (if (string-equal (tempo-lookup-named 'orientations) "")
3361 () (list 'l "orientations=\"" '(s orientations) "\""))
3362 '(just-one-space)
3363 (p "<unit_value>: " unit_value 'noinsert)
3364 (if (string-equal (tempo-lookup-named 'unit_value) "")
3365 () (list 'l "unit_value=" '(s unit_value)))
3366 '(just-one-space)
3367 (p "<current>: " current 'noinsert)
3368 (if (string-equal (tempo-lookup-named 'current) "")
3369 () (list 'l "current=" '(s current)))
3370 '(just-one-space)
3371 (p "<power>: " power 'noinsert)
3372 (if (string-equal (tempo-lookup-named 'power) "")
3373 () (list 'l "power=" '(s power)))
3374 '(just-one-space)
3375 (p "<min_ar>: " min_ar 'noinsert)
3376 (if (string-equal (tempo-lookup-named 'min_ar) "")
3377 () (list 'l "min_ar=" '(s min_ar)))
3378 '(just-one-space)
3379 (p "<max_ar>: " max_ar 'noinsert)
3380 (if (string-equal (tempo-lookup-named 'max_ar) "")
3381 () (list 'l "max_ar=" '(s max_ar)))
3382 '(just-one-space)
3383 (p "<routing_space>: " routing_space 'noinsert)
3384 (if (string-equal (tempo-lookup-named 'routing_space) "")
3385 () (list 'l "routing_space=" '(s routing_space)))
3386 '(just-one-space)
3388 ;;"layla diode"
3389 "DL"
3390 "tempo template for layla diode"
3391 'spice-tempo-tags)
3394 ;; bipolars
3395 (tempo-define-template
3396 "spice-spice2g6-bipolar"
3397 '("Q"
3398 (p "[name]: ") '(just-one-space)
3399 (p "[collector node]: ") '(just-one-space)
3400 (p "[base node]: ") '(just-one-space)
3401 (p "[emitter node]: ") '(just-one-space)
3402 (p "<substrate node>: ") '(just-one-space)
3403 (p "[mname]: ") '(just-one-space)
3404 (p "<area>: ") '(just-one-space)
3405 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3406 (if (and (tempo-lookup-named 'off)
3407 (string-equal (tempo-lookup-named 'off) "y"))
3408 (list 'l "OFF"))
3409 '(just-one-space)
3410 (p "<initial cond (vbe, vce)>: " ic 'noinsert)
3411 (if (string-equal (tempo-lookup-named 'ic) "")
3412 () (list 'l "IC=" '(s ic)))
3413 '(just-one-space)
3414 (p "<temp>: " temp 'noinsert)
3415 (if (string-equal (tempo-lookup-named 'temp) "")
3416 () (list 'l "TEMP=" '(s temp)))
3417 '(just-one-space)
3419 ;;"spice2g6 bipolar"
3421 "tempo template for spice2g6 bipolar"
3422 'spice-tempo-tags)
3425 (tempo-define-template
3426 "spice-eldo-bipolar"
3427 '("Q"
3428 (p "[name]: ") '(just-one-space)
3429 (p "[collector node]: ") '(just-one-space)
3430 (p "[base node]: ") '(just-one-space)
3431 (p "[emitter node]: ") '(just-one-space)
3432 (p "<substrate node>: ") '(just-one-space)
3433 (p "[mname]: ") '(just-one-space)
3434 (p "<area>: " area 'noinsert) '(just-one-space)
3435 (if (string-equal (tempo-lookup-named 'area) "")
3436 () (list 'l "AREA=" '(s area)))
3437 '(just-one-space)
3438 (p "<rel base area>: " areab 'noinsert)
3439 (if (string-equal (tempo-lookup-named 'areab) "")
3440 () (list 'l "AREAB=" '(s areab)))
3441 '(just-one-space)
3442 (p "<rel collector area>: " areac 'noinsert)
3443 (if (string-equal (tempo-lookup-named 'areac) "")
3444 () (list 'l "AREAC=" '(s areac)))
3445 '(just-one-space)
3446 (p "<temp>: " temp 'noinsert)
3447 (if (string-equal (tempo-lookup-named 'temp) "")
3448 () (list 'l "T=" '(s temp)))
3449 '(just-one-space)
3450 (p "<m>: " m 'noinsert)
3451 (if (string-equal (tempo-lookup-named 'm) "")
3452 () (list 'l "M=" '(s m)))
3453 '(just-one-space)
3454 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3455 (if (and (tempo-lookup-named 'off)
3456 (string-equal (tempo-lookup-named 'off) "y"))
3457 (list 'l "OFF"))
3458 '(just-one-space)
3459 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3460 (if (and (tempo-lookup-named 'nonoise)
3461 (string-equal (tempo-lookup-named 'nonoise) "y"))
3462 (list 'l "NONOISE"))
3463 '(just-one-space)
3465 ;;"eldo bipolar"
3466 "QE"
3467 "tempo template for eldo bipolar"
3468 'spice-tempo-tags)
3471 (tempo-define-template
3472 "spice-hspice-bipolar"
3473 '("Q"
3474 (p "[name]: ") '(just-one-space)
3475 (p "[collector node]: ") '(just-one-space)
3476 (p "[base node]: ") '(just-one-space)
3477 (p "[emitter node]: ") '(just-one-space)
3478 (p "<substrate node>: ") '(just-one-space)
3479 (p "[mname]: ") '(just-one-space)
3480 (p "<area>: " area 'noinsert) '(just-one-space)
3481 (if (string-equal (tempo-lookup-named 'area) "")
3482 () (list 'l "AREA=" '(s area)))
3483 '(just-one-space)
3484 (p "<rel base area>: " areab 'noinsert)
3485 (if (string-equal (tempo-lookup-named 'areab) "")
3486 () (list 'l "AREAB=" '(s areab)))
3487 '(just-one-space)
3488 (p "<rel collector area>: " areac 'noinsert)
3489 (if (string-equal (tempo-lookup-named 'areac) "")
3490 () (list 'l "AREAC=" '(s areac)))
3491 '(just-one-space)
3492 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3493 (if (and (tempo-lookup-named 'off)
3494 (string-equal (tempo-lookup-named 'off) "y"))
3495 (list 'l "OFF"))
3496 '(just-one-space)
3497 (p "<init vbe>: " vbe 'noinsert)
3498 (if (string-equal (tempo-lookup-named 'vbe) "")
3499 () (list 'l "VBE=" '(s vbe)))
3500 '(just-one-space)
3501 (p "<init vce>: " vce 'noinsert)
3502 (if (string-equal (tempo-lookup-named 'vce) "")
3503 () (list 'l "VCE=" '(s vce)))
3504 '(just-one-space)
3505 (p "<m>: " m 'noinsert)
3506 (if (string-equal (tempo-lookup-named 'm) "")
3507 () (list 'l "M=" '(s m)))
3508 '(just-one-space)
3509 (p "<diff temp>: " dtemp 'noinsert)
3510 (if (string-equal (tempo-lookup-named 'dtemp) "")
3511 () (list 'l "DTEMP=" '(s dtemp)))
3512 '(just-one-space)
3514 ;;"hspice bipolar"
3515 "QH"
3516 "tempo template for hspice bipolar"
3517 'spice-tempo-tags)
3520 ;; jfets
3521 (tempo-define-template
3522 "spice-spice2g6-jfet"
3523 '("J"
3524 (p "[name]: ") '(just-one-space)
3525 (p "[drain node]: ") '(just-one-space)
3526 (p "[gate node]: ") '(just-one-space)
3527 (p "[source node]: ") '(just-one-space)
3528 (p "[mname]: ") '(just-one-space)
3529 (p "<area>: ") '(just-one-space)
3530 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3531 (if (and (tempo-lookup-named 'off)
3532 (string-equal (tempo-lookup-named 'off) "y"))
3533 (list 'l "OFF"))
3534 '(just-one-space)
3535 (p "<initial cond (vds, vgs)>: " ic 'noinsert)
3536 (if (string-equal (tempo-lookup-named 'ic) "")
3537 () (list 'l "IC=" '(s ic)))
3538 '(just-one-space)
3539 (p "<temp>: " temp 'noinsert)
3540 (if (string-equal (tempo-lookup-named 'temp) "")
3541 () (list 'l "TEMP=" '(s temp)))
3542 '(just-one-space)
3544 ;;"spice2g6 jfet"
3546 "tempo template for spice2g6 jfet"
3547 'spice-tempo-tags)
3550 (tempo-define-template
3551 "spice-eldo-jfet"
3552 '("J"
3553 (p "[name]: ") '(just-one-space)
3554 (p "[drain node]: ") '(just-one-space)
3555 (p "[gate node]: ") '(just-one-space)
3556 (p "[source 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 "<length>: " l 'noinsert)
3563 (if (string-equal (tempo-lookup-named 'l) "")
3564 () (list 'l "L=" '(s l)))
3565 '(just-one-space)
3566 (p "<width>: " w 'noinsert)
3567 (if (string-equal (tempo-lookup-named 'w) "")
3568 () (list 'l "W=" '(s w)))
3569 '(just-one-space)
3570 (p "<temp>: " temp 'noinsert)
3571 (if (string-equal (tempo-lookup-named 'temp) "")
3572 () (list 'l "T=" '(s temp)))
3573 '(just-one-space)
3574 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3575 (if (and (tempo-lookup-named 'off)
3576 (string-equal (tempo-lookup-named 'off) "y"))
3577 (list 'l "OFF"))
3578 '(just-one-space)
3579 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3580 (if (and (tempo-lookup-named 'nonoise)
3581 (string-equal (tempo-lookup-named 'nonoise) "y"))
3582 (list 'l "NONOISE"))
3583 '(just-one-space)
3585 ;;"eldo jfet"
3586 "JE"
3587 "tempo template for eldo jfet"
3588 'spice-tempo-tags)
3591 (tempo-define-template
3592 "spice-hspice-jfet"
3593 '("J"
3594 (p "[name]: ") '(just-one-space)
3595 (p "[drain node]: ") '(just-one-space)
3596 (p "[gate node]: ") '(just-one-space)
3597 (p "[source node]: ") '(just-one-space)
3598 (p "[mname]: ") '(just-one-space)
3599 (p "<area>: " area 'noinsert)
3600 (if (string-equal (tempo-lookup-named 'area) "")
3601 (list 'l '(p "<length>: " l 'noinsert) '(p "<width>: " w 'noinsert))
3602 (list 'l "AREA=" '(s area)))
3603 '(just-one-space)
3604 (if (and (tempo-lookup-named 'l)
3605 (not (string-equal (tempo-lookup-named 'l) "")))
3606 (list 'l "L=" '(s l)))
3607 '(just-one-space)
3608 (if (and (tempo-lookup-named 'w)
3609 (not (string-equal (tempo-lookup-named 'w) "")))
3610 (list 'l "W=" '(s w)))
3611 '(just-one-space)
3612 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3613 (if (and (tempo-lookup-named 'off)
3614 (string-equal (tempo-lookup-named 'off) "y"))
3615 (list 'l "OFF"))
3616 '(just-one-space)
3617 (p "<initial cond (vds,vgs)>: " ic 'noinsert)
3618 (if (string-equal (tempo-lookup-named 'ic) "")
3619 () (list 'l "IC=" '(s ic)))
3620 '(just-one-space)
3621 (p "<m>: " m 'noinsert)
3622 (if (string-equal (tempo-lookup-named 'm) "")
3623 () (list 'l "M=" '(s m)))
3624 '(just-one-space)
3625 (p "<diff temp>: " dtemp 'noinsert)
3626 (if (string-equal (tempo-lookup-named 'dtemp) "")
3627 () (list 'l "DTEMP=" '(s dtemp)))
3628 '(just-one-space)
3630 ;;"hspice jfet"
3631 "JH"
3632 "tempo template for hspice jfet"
3633 'spice-tempo-tags)
3636 ;; mosfets
3637 (tempo-define-template
3638 "spice-spice2g6-mosfet"
3639 '("M"
3640 (p "[name]: ") '(just-one-space)
3641 (p "[drain node]: ") '(just-one-space)
3642 (p "[gate node]: ") '(just-one-space)
3643 (p "[source node]: ") '(just-one-space)
3644 (p "[bulk node]: ") '(just-one-space)
3645 (p "[mname]: ") '(just-one-space)
3646 (p "<length>: " l 'noinsert)
3647 (if (string-equal (tempo-lookup-named 'l) "")
3648 () (list 'l "L=" '(s l)))
3649 '(just-one-space)
3650 (p "<width>: " w 'noinsert)
3651 (if (string-equal (tempo-lookup-named 'w) "")
3652 () (list 'l "W=" '(s w)))
3653 '(just-one-space)
3654 (p "<area drain>: " ad 'noinsert)
3655 (if (string-equal (tempo-lookup-named 'ad) "")
3656 () (list 'l "AD=" '(s ad)))
3657 '(just-one-space)
3658 (p "<area source>: " as 'noinsert)
3659 (if (string-equal (tempo-lookup-named 'as) "")
3660 () (list 'l "AS=" '(s as)))
3661 '(just-one-space)
3662 (p "<perimeter drain>: " pd 'noinsert)
3663 (if (string-equal (tempo-lookup-named 'pd) "")
3664 () (list 'l "PD=" '(s pd)))
3665 '(just-one-space)
3666 (p "<perimeter source>: " ps 'noinsert)
3667 (if (string-equal (tempo-lookup-named 'ps) "")
3668 () (list 'l "PS=" '(s ps)))
3669 '(just-one-space)
3670 (p "<number of drain contacts>: " nrd 'noinsert)
3671 (if (string-equal (tempo-lookup-named 'nrd) "")
3672 () (list 'l "NRD=" '(s nrd)))
3673 '(just-one-space)
3674 (p "<number of source contacts>: " nrs 'noinsert)
3675 (if (string-equal (tempo-lookup-named 'nrs) "")
3676 () (list 'l "NRS=" '(s nrs)))
3677 '(just-one-space)
3678 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3679 (if (and (tempo-lookup-named 'off)
3680 (string-equal (tempo-lookup-named 'off) "y"))
3681 (list 'l "OFF"))
3682 '(just-one-space)
3683 (p "<initial cond (vds, vgs, vgs)>: " ic 'noinsert)
3684 (if (string-equal (tempo-lookup-named 'ic) "")
3685 () (list 'l "IC=" '(s ic)))
3686 '(just-one-space)
3688 ;;"spice2g6 mosfet"
3690 "tempo template for spice2g6 mosfet"
3691 'spice-tempo-tags)
3694 (tempo-define-template
3695 "spice-eldo-mosfet"
3696 '("M"
3697 (p "[name]: ") '(just-one-space)
3698 (p "[drain node]: ") '(just-one-space)
3699 (p "[gate node]: ") '(just-one-space)
3700 (p "[source node]: ") '(just-one-space)
3701 (p "[bulk node]: ") '(just-one-space)
3702 (p "<optional nodes>: ") '(just-one-space)
3703 "MOD="
3704 (p "[mname]: ") '(just-one-space)
3705 (p "<length>: " l 'noinsert)
3706 (if (string-equal (tempo-lookup-named 'l) "")
3707 () (list 'l "L=" '(s l)))
3708 '(just-one-space)
3709 (p "<width>: " w 'noinsert)
3710 (if (string-equal (tempo-lookup-named 'w) "")
3711 () (list 'l "W=" '(s w)))
3712 '(just-one-space)
3713 (p "<area drain>: " ad 'noinsert)
3714 (if (string-equal (tempo-lookup-named 'ad) "")
3715 () (list 'l "AD=" '(s ad)))
3716 '(just-one-space)
3717 (p "<area source>: " as 'noinsert)
3718 (if (string-equal (tempo-lookup-named 'as) "")
3719 () (list 'l "AS=" '(s as)))
3720 '(just-one-space)
3721 (p "<perimeter drain>: " pd 'noinsert)
3722 (if (string-equal (tempo-lookup-named 'pd) "")
3723 () (list 'l "PD=" '(s pd)))
3724 '(just-one-space)
3725 (p "<perimeter source>: " ps 'noinsert)
3726 (if (string-equal (tempo-lookup-named 'ps) "")
3727 () (list 'l "PS=" '(s ps)))
3728 '(just-one-space)
3729 (p "<geometry model>: " geo 'noinsert)
3730 (if (string-equal (tempo-lookup-named 'geo) "")
3731 () (list 'l "GEO=" '(s geo)))
3732 '(just-one-space)
3733 (p "<number of drain contacts>: " nrd 'noinsert)
3734 (if (string-equal (tempo-lookup-named 'nrd) "")
3735 () (list 'l "NRD=" '(s nrd)))
3736 '(just-one-space)
3737 (p "<number of source contacts>: " nrs 'noinsert)
3738 (if (string-equal (tempo-lookup-named 'nrs) "")
3739 () (list 'l "NRS=" '(s nrs)))
3740 '(just-one-space)
3741 (p "<m>: " m 'noinsert)
3742 (if (string-equal (tempo-lookup-named 'm) "")
3743 () (list 'l "M=" '(s m)))
3744 '(just-one-space)
3745 (p "<extra drain contact resistance>: " rdc 'noinsert)
3746 (if (string-equal (tempo-lookup-named 'rdc) "")
3747 () (list 'l "RDC=" '(s rdc)))
3748 '(just-one-space)
3749 (p "<extra source contact resistance>: " rsc 'noinsert)
3750 (if (string-equal (tempo-lookup-named 'rsc) "")
3751 () (list 'l "RSC=" '(s rsc)))
3752 '(just-one-space)
3753 (p "<temp>: " temp 'noinsert)
3754 (if (string-equal (tempo-lookup-named 'temp) "")
3755 () (list 'l "T=" '(s temp)))
3756 '(just-one-space)
3757 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3758 (if (and (tempo-lookup-named 'off)
3759 (string-equal (tempo-lookup-named 'off) "y"))
3760 (list 'l "OFF"))
3761 '(just-one-space)
3762 (p "<nonoise [y/n]>: " nonoise 'noinsert)
3763 (if (and (tempo-lookup-named 'nonoise)
3764 (string-equal (tempo-lookup-named 'nonoise) "y"))
3765 (list 'l "NONOISE"))
3766 '(just-one-space)
3768 ;;"eldo mosfet"
3769 "ME"
3770 "tempo template for eldo mosfet"
3771 'spice-tempo-tags)
3774 (tempo-define-template
3775 "spice-hspice-mosfet"
3776 '("M"
3777 (p "[name]: ") '(just-one-space)
3778 (p "[drain node]: ") '(just-one-space)
3779 (p "[gate node]: ") '(just-one-space)
3780 (p "[source node]: ") '(just-one-space)
3781 (p "[bulk node]: ") '(just-one-space)
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 "<number of drain contacts>: " nrd 'noinsert)
3808 (if (string-equal (tempo-lookup-named 'nrd) "")
3809 () (list 'l "NRD=" '(s nrd)))
3810 '(just-one-space)
3811 (p "<number of source contacts>: " nrs 'noinsert)
3812 (if (string-equal (tempo-lookup-named 'nrs) "")
3813 () (list 'l "NRS=" '(s nrs)))
3814 '(just-one-space)
3815 (p "<extra drain contact resistance>: " rdc 'noinsert)
3816 (if (string-equal (tempo-lookup-named 'rdc) "")
3817 () (list 'l "RDC=" '(s rdc)))
3818 '(just-one-space)
3819 (p "<extra source contact resistance>: " rsc 'noinsert)
3820 (if (string-equal (tempo-lookup-named 'rsc) "")
3821 () (list 'l "RSC=" '(s rsc)))
3822 '(just-one-space)
3823 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3824 (if (and (tempo-lookup-named 'off)
3825 (string-equal (tempo-lookup-named 'off) "y"))
3826 (list 'l "OFF"))
3827 '(just-one-space)
3828 (p "<init cond (vds,vgs,vbs)>: " ic 'noinsert)
3829 (if (string-equal (tempo-lookup-named 'ic) "")
3830 () (list 'l "IC=" '(s ic)))
3831 '(just-one-space)
3832 (p "<diff temp>: " dtemp 'noinsert)
3833 (if (string-equal (tempo-lookup-named 'dtemp) "")
3834 () (list 'l "DTEMP=" '(s dtemp)))
3835 '(just-one-space)
3836 (p "<geometry model>: " geo 'noinsert)
3837 (if (string-equal (tempo-lookup-named 'geo) "")
3838 () (list 'l "GEO=" '(s geo)))
3839 '(just-one-space)
3840 (p "<m>: " m 'noinsert)
3841 (if (string-equal (tempo-lookup-named 'm) "")
3842 () (list 'l "M=" '(s m)))
3843 '(just-one-space)
3844 (p "<delvto>: " delvto 'noinsert)
3845 (if (string-equal (tempo-lookup-named 'delvto) "")
3846 () (list 'l "DELVTO=" '(s delvto)))
3847 '(just-one-space)
3849 ;;"hspice mosfet"
3850 "MH"
3851 "tempo template for hspice mosfet"
3852 'spice-tempo-tags)
3855 (tempo-define-template
3856 "spice-layla-mosfet"
3857 '("M"
3858 (p "[name]: ") '(just-one-space)
3859 (p "[drain node]: ") '(just-one-space)
3860 (p "[gate node]: ") '(just-one-space)
3861 (p "[source node]: ") '(just-one-space)
3862 (p "[bulk node]: ") '(just-one-space)
3863 (p "[mname]: ") '(just-one-space)
3864 (p "<length>: " l 'noinsert)
3865 (if (string-equal (tempo-lookup-named 'l) "")
3866 () (list 'l "L=" '(s l)))
3867 '(just-one-space)
3868 (p "<width>: " w 'noinsert)
3869 (if (string-equal (tempo-lookup-named 'w) "")
3870 () (list 'l "W=" '(s w)))
3871 '(just-one-space)
3872 "\n+ type=\""
3873 (p "[type (no quotes)]: ") "\""
3874 '(just-one-space)
3875 (p "<symmetry (no quotes)>: " symmetry 'noinsert)
3876 (if (string-equal (tempo-lookup-named 'symmetry) "")
3877 () (list 'l "symmetry=\"" '(s symmetry) "\""))
3878 '(just-one-space)
3879 (p "<matching (no quotes)>: " matching 'noinsert)
3880 (if (string-equal (tempo-lookup-named 'matching) "")
3881 () (list 'l "matching=\"" '(s matching) "\""))
3882 '(just-one-space)
3883 (p "<couple>: " couple 'noinsert)
3884 (if (string-equal (tempo-lookup-named 'couple) "")
3885 () (list 'l "couple=" '(s couple)))
3886 '(just-one-space)
3887 (p "<array (no quotes)>: " array 'noinsert)
3888 (if (string-equal (tempo-lookup-named 'array) "")
3889 () (list 'l "array=\"" '(s array) "\""))
3890 '(just-one-space)
3891 (p "<orientations (no quotes)>: " orientations 'noinsert)
3892 (if (string-equal (tempo-lookup-named 'orientations) "")
3893 () (list 'l "orientations=\"" '(s orientations) "\""))
3894 '(just-one-space)
3895 (p "<unit_value>: " unit_value 'noinsert)
3896 (if (string-equal (tempo-lookup-named 'unit_value) "")
3897 () (list 'l "unit_value=" '(s unit_value)))
3898 '(just-one-space)
3899 (p "<current>: " current 'noinsert)
3900 (if (string-equal (tempo-lookup-named 'current) "")
3901 () (list 'l "current=" '(s current)))
3902 '(just-one-space)
3903 (p "<power>: " power 'noinsert)
3904 (if (string-equal (tempo-lookup-named 'power) "")
3905 () (list 'l "power=" '(s power)))
3906 '(just-one-space)
3907 (p "<min_ar>: " min_ar 'noinsert)
3908 (if (string-equal (tempo-lookup-named 'min_ar) "")
3909 () (list 'l "min_ar=" '(s min_ar)))
3910 '(just-one-space)
3911 (p "<max_ar>: " max_ar 'noinsert)
3912 (if (string-equal (tempo-lookup-named 'max_ar) "")
3913 () (list 'l "max_ar=" '(s max_ar)))
3914 '(just-one-space)
3915 (p "<routing_space>: " routing_space 'noinsert)
3916 (if (string-equal (tempo-lookup-named 'routing_space) "")
3917 () (list 'l "routing_space=" '(s routing_space)))
3918 '(just-one-space)
3920 ;;"layla mosfet"
3921 "ML"
3922 "tempo template for layla mosfet"
3923 'spice-tempo-tags)
3926 ;; mesfets
3927 (tempo-define-template
3928 "spice-spice2g6-mesfet"
3929 '("Z"
3930 (p "[name]: ") '(just-one-space)
3931 (p "[drain node]: ") '(just-one-space)
3932 (p "[gate node]: ") '(just-one-space)
3933 (p "[source node]: ") '(just-one-space)
3934 (p "[mname]: ") '(just-one-space)
3935 (p "<area>: ") '(just-one-space)
3936 (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
3937 (if (and (tempo-lookup-named 'off)
3938 (string-equal (tempo-lookup-named 'off) "y"))
3939 (list 'l "OFF"))
3940 '(just-one-space)
3941 (p "<initial cond (vds, vgs)>: " ic 'noinsert)
3942 (if (string-equal (tempo-lookup-named 'ic) "")
3943 () (list 'l "IC=" '(s ic)))
3944 '(just-one-space)
3946 ;;"spice2g6 mesfet"
3948 "tempo template for spice2g6 mesfet"
3949 'spice-tempo-tags)
3952 ;; subcircuit defs
3953 (tempo-define-template
3954 "spice-spice2g6-subckt"
3955 '(".subckt "
3956 (p "[subckt name]: " lname) 'r 'n 'n
3957 ".ends " (s lname) '>)
3958 "SUB"
3959 "template for inserting a subckt definition"
3960 'spice-tempo-tags)
3963 ;; Controlled sources
3965 ;; Voltage sources
3967 (tempo-define-template
3968 "spice-spice2g6-vcvs"
3969 '("E"
3970 (p "[name]: ") '(just-one-space)
3971 (p "[positive node]: ") '(just-one-space)
3972 (p "[negative node]: ") '(just-one-space)
3973 (p "[positive controling node]: ") '(just-one-space)
3974 (p "[negative controling node]: ") '(just-one-space)
3975 (p "[gain]: ") '(just-one-space)
3977 "VCVS"
3978 "template for inserting a voltage controled voltage source"
3979 'spice-tempo-tags)
3981 (tempo-define-template
3982 "spice-spice2g6-ccvs"
3983 '("H"
3984 (p "[name]: ") '(just-one-space)
3985 (p "[positive node]: ") '(just-one-space)
3986 (p "[negative node]: ") '(just-one-space)
3987 (p "[voltage source]: ") '(just-one-space)
3988 (p "[gain]: ") '(just-one-space)
3990 "CCVS"
3991 "template for inserting a current controled voltage source"
3992 'spice-tempo-tags)
3995 ;; Current sources
3997 (tempo-define-template
3998 "spice-spice2g6-vccs"
3999 '("G"
4000 (p "[name]: ") '(just-one-space)
4001 (p "[positive node]: ") '(just-one-space)
4002 (p "[negative node]: ") '(just-one-space)
4003 (p "[positive controling node]: ") '(just-one-space)
4004 (p "[negative controling node]: ") '(just-one-space)
4005 (p "[transadmitance]: ") '(just-one-space)
4007 "VCCS"
4008 "template for inserting a voltage controled current source"
4009 'spice-tempo-tags)
4011 (tempo-define-template
4012 "spice-spice2g6-cccs"
4013 '("F"
4014 (p "[name]: ") '(just-one-space)
4015 (p "[positive node]: ") '(just-one-space)
4016 (p "[negative node]: ") '(just-one-space)
4017 (p "[voltage source]: ") '(just-one-space)
4018 (p "[gain]: ") '(just-one-space)
4020 "CCCS"
4021 "template for inserting a current controled current source"
4022 'spice-tempo-tags)
4025 ;; Waveforms
4027 (tempo-define-template
4028 "spice-pulse"
4029 '("pulse("
4030 (p "[start value]: ") " "
4031 (p "[pulsed value]: ") " "
4032 (p "[delay]: ") " "
4033 (p "[rise time]: ") " "
4034 (p "[fall time]: ") " "
4035 (p "[pulse duration]: ") " "
4036 (p "[period]: ")
4037 ")"'n)
4038 "PU"
4039 "template for inserting an Pulse waveform"
4040 'spice-tempo-tags)
4042 (tempo-define-template
4043 "spice-sine"
4044 '("sin("
4045 (p "[Offset]: ") " "
4046 (p "[Amplitude]: ") " "
4047 (p "[Frequency]: ") " "
4048 (p "[Delay]: ") " "
4049 (p "[Damping factor]: ")
4050 (p "[Phase delay]: ") '(just-one-space)
4051 ")"'n)
4052 "sin"
4053 "template for inserting a Sine function"
4054 'spice-tempo-tags)
4056 (tempo-define-template
4057 "spice-exp"
4058 '("exp("
4059 (p "[start value]: ") " "
4060 (p "[target value]: ") " "
4061 (p "[rise delay]: ") " "
4062 (p "[tau1]: ") " "
4063 (p "[fall delay]: ") " "
4064 (p "[tau2]: ")
4065 ")"'n)
4066 "exp"
4067 "template for inserting an EXP waveform"
4068 'spice-tempo-tags)
4070 ;;(tempo-define-template
4071 ;; "spice-pwl"
4072 ;; '("pwl("
4073 ;; (p "[start time]: ") " "
4074 ;; (p "[start value]: ") " "
4075 ;; ")"'n)
4076 ;; "pwl"
4077 ;; "template for inserting an PWL waveform")
4079 (load "skeleton")
4080 (define-skeleton spice-pwl
4081 "Skeleton for Piece Wise Linear waveform"
4082 "Time/value doublet: "
4083 "pwl(" str
4084 ( "Next doublet: (%s) "
4085 " "str )
4086 resume:
4088 'spice-tempo-tags)
4091 (tempo-define-template
4092 "hspice-sffm"
4093 '("sffm("
4094 (p "[offset value]: ") " "
4095 (p "[amplitude value]: ") " "
4096 (p "[carrier frequency]: ") " "
4097 (p "[modulation index]: ") " "
4098 (p "[signal frequency]: ")
4099 ")"'n)
4100 "sffm"
4101 "template for inserting an HSPICE SFFM waveform"
4102 'spice-tempo-tags)
4104 (tempo-define-template
4105 "hspice-am"
4106 '("am("
4107 (p "[signal amplitude]: ") " "
4108 (p "[offset constant]: ") " "
4109 (p "[modulation frequency]: ") " "
4110 (p "[carrier frequency]: ") " "
4111 (p "[delay time]: ")
4112 ")"'n)
4113 "am"
4114 "template for inserting an HSPICE AM waveform"
4115 'spice-tempo-tags)
4117 (tempo-define-template
4118 "spice-ac"
4119 '("ac("
4120 (p "[magnitude]: ") " "
4121 (p "[phase]: ")
4122 ")"'n)
4123 "ac"
4124 "template for inserting an AC waveform"
4125 'spice-tempo-tags)
4127 (tempo-define-template
4128 "spice-eldo-pattern"
4129 '("pattern "
4130 (p "[Vhi]: ") " "
4131 (p "[Vlo]: ") " "
4132 (p "[delay]: ") " "
4133 (p "[rise time]: ") " "
4134 (p "[fall time]: ") " "
4135 (p "[Bit duration]: ") " "
4136 (p "[Bits]: ")
4138 "eldo-pattern"
4139 "template for inserting an ELDO Pattern function"
4140 'spice-tempo-tags)
4142 (tempo-define-template
4143 "spice-eldo-noise"
4144 '("noise("
4145 (p "[White noise level]: ") " "
4146 (p "[Flicker noise level]: ") " "
4147 (p "[Alpha]: ") " "
4148 (p "[Cut-off freq]: ") " "
4149 (p "[Filter order]: ")
4150 ")"'n)
4151 "noise"
4152 "template for inserting an ELDO NOISE waveform"
4153 'spice-tempo-tags)
4155 (tempo-define-template
4156 "spice-eldorf-fpulse"
4157 '("fpulse("
4158 (p "[initial value]: ") " "
4159 (p "[pulse value]: ") " "
4160 (p "[delay time]: ") " "
4161 (p "[rise time]: ") " "
4162 (p "[fall time]: ") " "
4163 (p "[pulse duration]: ") " "
4164 (p "[FUND1|FUND2|FUND3 (of .sst)]: ")
4165 ")"'n)
4166 "eldorf-fpulse"
4167 "template for inserting an Eldo-RF fpulse waveform"
4168 'spice-tempo-tags)
4170 (tempo-define-template
4171 "spice-eldorf-four"
4172 '("four" '(just-one-space)
4173 (p "[FUND1]: ")
4174 (p "<FUND2>: " fund2 'noinsert)
4175 (if (string-equal (tempo-lookup-named 'fund2) "")
4177 (list 'l " " '(s fund2) '(p "<FUND3>: " fund3 'noinsert)))
4178 (if (string-equal (tempo-lookup-named 'fund3) "")
4180 (list 'l " " '(s fund3)))
4181 '(just-one-space)
4182 (p "[MA|RI|DB|PMA|PDB|PDBM]: ") '(just-one-space)
4184 (p "[int_val1]: ")
4185 (p "<int_val2>: " int_val2 'noinsert)
4186 (if (string-equal (tempo-lookup-named 'int_val2) "")
4188 (list 'l "," '(s int_val2) '(p "<int_val3>: " int_val3 'noinsert)))
4189 (if (string-equal (tempo-lookup-named 'int_val3) "")
4191 (list 'l "," '(s int_val3)))
4192 ")" '(just-one-space)
4193 (p "[real_val1]: ") '(just-one-space)
4194 (p "[real_val2]: ") '(just-one-space)
4196 "eldorf-four"
4197 "template for inserting an Eldo-RF Fpulse waveform"
4198 'spice-tempo-tags)
4200 ;; Eldo Extracts
4202 (tempo-define-template
4203 "spice-eldo-phmag"
4204 '(".EXTRACT AC label=\"Phase margin\" xycond(vp("
4205 (p "[Node]: " lname)
4206 "),vdb(" (s lname) ")<0.0)+180 "
4208 "phmag"
4209 "template for extracting the phase margin"
4210 'spice-tempo-tags)
4212 (tempo-define-template
4213 "spice-eldo-gmag"
4214 '(".EXTRACT AC label=\"Gain margin\" -xycond(vdb("
4215 (p "[Node]: " lname)
4216 "),vp(" (s lname) ")<-180) "
4218 "gmag"
4219 "template for extracting the gain margin"
4220 'spice-tempo-tags)
4222 (tempo-define-template
4223 "spice-eldo-fc"
4224 '(".EXTRACT AC label=\"Cut freq\" xdown(vdb("
4225 (p "[Node]: " lname)
4226 "),yval(vdb(" (s lname) "),1)-3) "
4228 "fc"
4229 "template for extracting the cut frequency"
4230 'spice-tempo-tags)
4232 (tempo-define-template
4233 "spice-eldo-ugfc"
4234 '(".EXTRACT AC label=\"Unity gain freq\" xdown(vdb("
4235 (p "[Node]: " lname)
4236 "),0) "
4238 "ugfc"
4239 "template for extracting the unity gain frequency"
4240 'spice-tempo-tags)
4242 (tempo-define-template
4243 "spice-eldo-period"
4244 '(".EXTRACT TRAN xdown(v("
4245 (p "[Node]: " lname)
4246 "),"
4247 (p "[threshold]: " vth)
4249 (p "[estimation time]: " t)
4250 ",end)"
4251 "-xdown(v(" (s lname) "),"(s vth) ","(s t) ",start) !period"
4253 "period"
4254 "template for extracting the period of a signal"
4255 'spice-tempo-tags)
4257 (tempo-define-template
4258 "spice-eldo-period-macro"
4259 '(".DEFMAC period(a,th,time)=xdown(a,th,time,end)"
4260 "-xdown(a,th,time,start)"
4262 "period"
4263 "macro for extracting the period of signal a"
4264 'spice-tempo-tags)
4266 (tempo-define-template
4267 "spice-eldo-duty-macro"
4268 '(".DEFMAC duty_cycle(a,th,time)=(xdown(a,th,time,end)"
4269 "-xup(a,th,time,end))/(xdown(a,th,time,end)-xdown(a,th,time,start))*100"
4271 "duty"
4272 "macro for extracting the duty cycle of signal a"
4273 'spice-tempo-tags)
4275 (tempo-define-template
4276 "spice-eldo-settling-macro"
4277 '(".DEFMAC settling(xaxis,a,ratio,Tstart,Tfinal)=xycond(xaxis,(a>(yval(a,Tfinal)*(1+ratio)))"
4278 " || (a<(yval(a,Tfinal)*(1-ratio))),Tfinal,Tstart) - Tstart"
4280 "settling"
4281 "macro for extracting the settling cycle of signal A, within ±ratio of value of A at time Tfinal"
4282 'spice-tempo-tags)
4285 ;; Eldo Macromodels
4287 (tempo-define-template
4288 "spice-eldo-comp"
4289 '("COMP"
4290 (p "[Instance name]: ") " "
4291 (p "[Positive input]: ") " "
4292 (p "[Negative input]: ") " "
4293 (p "[Output]: ") " "
4294 (p "[Model name]: ") " "
4295 (p "<Vhigh>: " vhi 'noinsert)
4296 (if (string-equal (tempo-lookup-named 'vhi) "")
4297 (list 'l "VHI=5.0") ;; default value
4298 (list 'l "VHI=" '(s vhi)))
4299 '(just-one-space)
4300 (p "<Vlow>: " vlo 'noinsert)
4301 (if (string-equal (tempo-lookup-named 'vlo) "")
4302 (list 'l "VLO=0.0") ;; default value
4303 (list 'l "VLO=" '(s vlo)))
4304 '(just-one-space)
4305 (p "<Input offset>: " voff 'noinsert)
4306 (if (string-equal (tempo-lookup-named 'voff) "")
4307 (list 'l "VOFF=0.0") ;; default value
4308 (list 'l "VOFF=" '(s voff)))
4309 '(just-one-space)
4310 (p "<Hysteresis voltage>: " vdef 'noinsert)
4311 (if (string-equal (tempo-lookup-named 'vdef) "")
4312 (list 'l "VDEF=0.0") ;; default value
4313 (list 'l "VDEF=" '(s vdef)))
4314 '(just-one-space)
4315 (p "<Commutation time>: " tcom 'noinsert)
4316 (if (string-equal (tempo-lookup-named 'tcom) "")
4317 (list 'l "TCOM=1ns") ;; default value
4318 (list 'l "TCOM=" '(s tcom)))
4319 '(just-one-space)
4320 (p "<Transit time>: " tpd 'noinsert)
4321 (if (string-equal (tempo-lookup-named 'tpd) "")
4322 (list 'l "TPD=0.0") ;; default value
4323 (list 'l "TPD=" '(s tpd)))
4324 '(just-one-space)
4326 "comp"
4327 "template for inserting an ELDO Single output comparator"
4328 'spice-tempo-tags)
4330 (tempo-define-template
4331 "spice-eldo-compd"
4332 '("COMPD"
4333 (p "[Instance name]: ") " "
4334 (p "[Positive input]: ") " "
4335 (p "[Negative input]: ") " "
4336 (p "[Positive Output]: ") " "
4337 (p "[Negative Output]: ") " "
4338 (p "[Model name]: ") " "
4339 (p "<Vhigh>: " vhi 'noinsert)
4340 (if (string-equal (tempo-lookup-named 'vhi) "")
4341 (list 'l "VHI=5.0") ;; default value
4342 (list 'l "VHI=" '(s vhi)))
4343 '(just-one-space)
4344 (p "<Vlow>: " vlo 'noinsert)
4345 (if (string-equal (tempo-lookup-named 'vlo) "")
4346 (list 'l "VLO=0.0") ;; default value
4347 (list 'l "VLO=" '(s vlo)))
4348 '(just-one-space)
4349 (p "<Input offset>: " voff 'noinsert)
4350 (if (string-equal (tempo-lookup-named 'voff) "")
4351 (list 'l "VOFF=0.0") ;; default value
4352 (list 'l "VOFF=" '(s voff)))
4353 '(just-one-space)
4354 (p "<Hysteresis voltage>: " vdef 'noinsert)
4355 (if (string-equal (tempo-lookup-named 'vdef) "")
4356 (list 'l "VDEF=0.0") ;; default value
4357 (list 'l "VDEF=" '(s vdef)))
4358 '(just-one-space)
4359 (p "<Commutation time>: " tcom 'noinsert)
4360 (if (string-equal (tempo-lookup-named 'tcom) "")
4361 (list 'l "TCOM=1ns") ;; default value
4362 (list 'l "TCOM=" '(s tcom)))
4363 '(just-one-space)
4364 (p "<Transit time>: " tpd 'noinsert)
4365 (if (string-equal (tempo-lookup-named 'tpd) "")
4366 (list 'l "TPD=0.0") ;; default value
4367 (list 'l "TPD=" '(s tpd)))
4368 '(just-one-space)
4370 "compd"
4371 "template for inserting an ELDO Differential output comparator"
4372 'spice-tempo-tags)
4374 (tempo-define-template
4375 "spice-eldo-linear-opa0"
4376 '("Y"
4377 (p "[Instance name]: ") " OPAMP0 "
4378 (p "[Positive input]: ") " "
4379 (p "[Negative input]: ") " "
4380 (p "[Output]: ") " "
4381 (p "[Ground]: ") " param: "
4382 (p "<Gain>: " gain 'noinsert)
4383 (if (string-equal (tempo-lookup-named 'gain) "")
4384 (list 'l "GAIN=1e5") ;; default value
4385 (list 'l "GAIN=" '(s gain)))
4386 '(just-one-space)
4387 (p "<Input impedance>: " rin 'noinsert)
4388 (if (string-equal (tempo-lookup-named 'rin) "")
4389 (list 'l "RIN=1e7") ;; default value
4390 (list 'l "RIN=" '(s rin)))
4391 '(just-one-space)
4393 "opa0"
4394 "template for inserting an ELDO single output linear opamp"
4395 'spice-tempo-tags)
4397 (tempo-define-template
4398 "spice-eldo-linear-opa0d"
4399 '("Y"
4400 (p "[Instance name]: ") " OPAMP0D "
4401 (p "[Positive input]: ") " "
4402 (p "[Negative input]: ") " "
4403 (p "[Positive Output]: ") " "
4404 (p "[Negative Output]: ") " "
4405 (p "[Ground]: ") " param: "
4406 (p "<Gain>: " gain 'noinsert)
4407 (if (string-equal (tempo-lookup-named 'gain) "")
4408 (list 'l "GAIN=1e5") ;; default value
4409 (list 'l "GAIN=" '(s gain)))
4410 '(just-one-space)
4411 (p "<Input impedance>: " rin 'noinsert)
4412 (if (string-equal (tempo-lookup-named 'rin) "")
4413 (list 'l "RIN=1e7") ;; default value
4414 (list 'l "RIN=" '(s rin)))
4415 '(just-one-space)
4417 "opa0d"
4418 "template for inserting an ELDO differential output linear opamp"
4419 'spice-tempo-tags)
4422 (tempo-define-template
4423 "spice-eldo-linear-opa1"
4424 '("Y"
4425 (p "[Instance name]: ") " OPAMP1 "
4426 (p "[Positive input]: ") " "
4427 (p "[Negative input]: ") " "
4428 (p "[Output]: ") " "
4429 (p "[Ground]: ") " param: "
4430 (p "<Gain>: " gain 'noinsert)
4431 (if (string-equal (tempo-lookup-named 'gain) "")
4432 (list 'l "GAIN=1e5") ;; default value
4433 (list 'l "GAIN=" '(s gain)))
4434 '(just-one-space)
4435 (p "<Input offset>: " voff 'noinsert)
4436 (if (string-equal (tempo-lookup-named 'voff) "")
4437 (list 'l "VOFF=0.0") ;; default value
4438 (list 'l "VOFF=" '(s voff)))
4439 '(just-one-space)
4440 (p "<Dominant pole>: " p1 'noinsert)
4441 (if (string-equal (tempo-lookup-named 'p1) "")
4442 (list 'l "P1=100") ;; default value
4443 (list 'l "P1=" '(s p1)))
4444 '(just-one-space)
4445 (p "<Input impedance>: " rin 'noinsert)
4446 (if (string-equal (tempo-lookup-named 'rin) "")
4447 (list 'l "RIN=1e7") ;; default value
4448 (list 'l "RIN=" '(s rin)))
4449 '(just-one-space)
4451 "opa1"
4452 "template for inserting an ELDO single output 1-pole linear opamp"
4453 'spice-tempo-tags)
4455 (tempo-define-template
4456 "spice-eldo-linear-opa1d"
4457 '("Y"
4458 (p "[Instance name]: ") " OPAMP1D "
4459 (p "[Positive input]: ") " "
4460 (p "[Negative input]: ") " "
4461 (p "[Positive Output]: ") " "
4462 (p "[Negative Output]: ") " "
4463 (p "[Ground]: ") " param: "
4464 (p "<Gain>: " gain 'noinsert)
4465 (if (string-equal (tempo-lookup-named 'gain) "")
4466 (list 'l "GAIN=1e5") ;; default value
4467 (list 'l "GAIN=" '(s gain)))
4468 '(just-one-space)
4469 (p "<Input offset>: " voff 'noinsert)
4470 (if (string-equal (tempo-lookup-named 'voff) "")
4471 (list 'l "VOFF=0.0") ;; default value
4472 (list 'l "VOFF=" '(s voff)))
4473 '(just-one-space)
4474 (p "<Dominant pole>: " p1 'noinsert)
4475 (if (string-equal (tempo-lookup-named 'p1) "")
4476 (list 'l "P1=100") ;; default value
4477 (list 'l "P1=" '(s p1)))
4478 '(just-one-space)
4479 (p "<Input impedance>: " rin 'noinsert)
4480 (if (string-equal (tempo-lookup-named 'rin) "")
4481 (list 'l "RIN=1e7") ;; default value
4482 (list 'l "RIN=" '(s rin)))
4483 '(just-one-space)
4484 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
4485 (if (string-equal (tempo-lookup-named 'cmrr) "")
4486 (list 'l "CMRR=0.0") ;; default value
4487 (list 'l "CMRR=" '(s cmrr)))
4488 '(just-one-space)
4490 "opa1d"
4491 "template for inserting an ELDO differential output 1-pole linear opamp"
4492 'spice-tempo-tags)
4494 (tempo-define-template
4495 "spice-eldo-linear-opa2"
4496 '("Y"
4497 (p "[Instance name]: ") " OPAMP2 "
4498 (p "[Positive input]: ") " "
4499 (p "[Negative input]: ") " "
4500 (p "[Output]: ") " "
4501 (p "[Ground]: ") " param: "
4502 (p "<Gain>: " gain 'noinsert)
4503 (if (string-equal (tempo-lookup-named 'gain) "")
4504 (list 'l "GAIN=1e5") ;; default value
4505 (list 'l "GAIN=" '(s gain)))
4506 '(just-one-space)
4507 (p "<Input offset>: " voff 'noinsert)
4508 (if (string-equal (tempo-lookup-named 'voff) "")
4509 (list 'l "VOFF=0.0") ;; default value
4510 (list 'l "VOFF=" '(s voff)))
4511 '(just-one-space)
4512 (p "<Dominant pole>: " p1 'noinsert)
4513 (if (string-equal (tempo-lookup-named 'p1) "")
4514 (list 'l "P1=100") ;; default value
4515 (list 'l "P1=" '(s p1)))
4516 '(just-one-space)
4517 (p "<Non-dominant pole>: " p2 'noinsert)
4518 (if (string-equal (tempo-lookup-named 'p2) "")
4519 (list 'l "P2=1e6") ;; default value
4520 (list 'l "P2=" '(s p2)))
4521 '(just-one-space)
4522 (p "<Input impedance>: " rin 'noinsert)
4523 (if (string-equal (tempo-lookup-named 'rin) "")
4524 (list 'l "RIN=1e7") ;; default value
4525 (list 'l "RIN=" '(s rin)))
4526 '(just-one-space)
4528 "opa2"
4529 "template for inserting an ELDO single output 2-pole linear opamp"
4530 'spice-tempo-tags)
4532 (tempo-define-template
4533 "spice-eldo-linear-opa2d"
4534 '("Y"
4535 (p "[Instance name]: ") " OPAMP2D "
4536 (p "[Positive input]: ") " "
4537 (p "[Negative input]: ") " "
4538 (p "[Positive Output]: ") " "
4539 (p "[Negative Output]: ") " "
4540 (p "[Ground]: ") " param: "
4541 (p "<Gain>: " gain 'noinsert)
4542 (if (string-equal (tempo-lookup-named 'gain) "")
4543 (list 'l "GAIN=1e5") ;; default value
4544 (list 'l "GAIN=" '(s gain)))
4545 '(just-one-space)
4546 (p "<Input offset>: " voff 'noinsert)
4547 (if (string-equal (tempo-lookup-named 'voff) "")
4548 (list 'l "VOFF=0.0") ;; default value
4549 (list 'l "VOFF=" '(s voff)))
4550 '(just-one-space)
4551 (p "<Dominant pole>: " p1 'noinsert)
4552 (if (string-equal (tempo-lookup-named 'p1) "")
4553 (list 'l "P1=100") ;; default value
4554 (list 'l "P1=" '(s p1)))
4555 '(just-one-space)
4556 (p "<Non-dominant pole>: " p2 'noinsert)
4557 (if (string-equal (tempo-lookup-named 'p2) "")
4558 (list 'l "P2=1e6") ;; default value
4559 (list 'l "P2=" '(s p2)))
4560 '(just-one-space)
4561 (p "<Input impedance>: " rin 'noinsert)
4562 (if (string-equal (tempo-lookup-named 'rin) "")
4563 (list 'l "RIN=1e7") ;; default value
4564 (list 'l "RIN=" '(s rin)))
4565 '(just-one-space)
4566 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
4567 (if (string-equal (tempo-lookup-named 'cmrr) "")
4568 (list 'l "CMRR=0.0") ;; default value
4569 (list 'l "CMRR=" '(s cmrr)))
4570 '(just-one-space)
4572 "opa2d"
4573 "template for inserting an ELDO differential output 2-pole linear opamp"
4574 'spice-tempo-tags)
4577 (tempo-define-template
4578 "spice-eldo-delay"
4579 '("DEL"
4580 (p "[Instance name]: ") " "
4581 (p "[Input]: ") " "
4582 (p "[Output]: ") " "
4583 (p "[Delay value]: ") " "
4585 "del"
4586 "template for inserting an ELDO delay"
4587 'spice-tempo-tags)
4589 (tempo-define-template
4590 "spice-eldo-satr"
4591 '("Y"
4592 (p "[Instance name]: ") " SATR "
4593 (p "[Input]: ") " "
4594 (p "[Output]: ") " param: "
4595 (p "<Value of resistance>: " r 'noinsert)
4596 (if (string-equal (tempo-lookup-named 'r) "")
4597 (list 'l "R=1") ;; default value
4598 (list 'l "R=" '(s r)))
4599 '(just-one-space)
4600 (p "<Max current>: " imax 'noinsert)
4601 (if (string-equal (tempo-lookup-named 'imax) "")
4602 (list 'l "IMAX=1") ;; default value
4603 (list 'l "IMAX=" '(s imax)))
4604 '(just-one-space)
4605 (p "<Slew rate(V/µs)>: " sr 'noinsert)
4606 (if (string-equal (tempo-lookup-named 'sr) "")
4607 (list 'l "SR=0") ;; default value
4608 (list 'l "SR=" '(s sr)))
4609 '(just-one-space)
4610 (p "<Dominant pole>: " p1 'noinsert)
4611 (if (string-equal (tempo-lookup-named 'p1) "")
4612 (list 'l "P1=1e6") ;; default value
4613 (list 'l "P1=" '(s p1)))
4614 '(just-one-space)
4615 (p "<resistance of low-pass filter>: " r1 'noinsert)
4616 (if (string-equal (tempo-lookup-named 'r1) "")
4617 (list 'l "R1=30") ;; default value
4618 (list 'l "R1=" '(s r1)))
4620 "satr"
4621 "template for inserting an ELDO saturating resistor"
4622 'spice-tempo-tags)
4624 (tempo-define-template
4625 "spice-eldo-satv"
4626 '("Y"
4627 (p "[Instance name]: ") " SATV "
4628 (p "[Positive input]: ") " "
4629 (p "[Negative input]: ") " "
4630 (p "[Positive Output]: ") " "
4631 (p "[Negative Output]: ") " param: "
4632 (p "<VMax>: " vmax 'noinsert)
4633 (if (string-equal (tempo-lookup-named 'vmax) "")
4634 (list 'l "VMAX=5.0") ;; default value
4635 (list 'l "VMAX=" '(s vmax)))
4636 '(just-one-space)
4637 (p "<VMin>: " vmin 'noinsert)
4638 (if (string-equal (tempo-lookup-named 'vmin) "")
4639 (list 'l "VMIN=-5.0") ;; default value
4640 (list 'l "VMIN=" '(s vmin)))
4641 '(just-one-space)
4642 (p "<Positive saturation voltage>: " vsatp 'noinsert)
4643 (if (string-equal (tempo-lookup-named 'vsatp) "")
4644 (list 'l "VSATP=4.75") ;; default value
4645 (list 'l "VSATP=" '(s vsatp)))
4646 '(just-one-space)
4647 (p "<Negative saturation voltage>: " vsatn 'noinsert)
4648 (if (string-equal (tempo-lookup-named 'vsatn) "")
4649 (list 'l "VSATN=-4.75") ;; default value
4650 (list 'l "VSATN=" '(s vsatn)))
4651 '(just-one-space)
4652 (p "<Slope at VSATP>: " pslope 'noinsert)
4653 (if (string-equal (tempo-lookup-named 'pslope) "")
4654 (list 'l "PSLOPE=0.25") ;; default value
4655 (list 'l "PSLOPE=" '(s pslope)))
4656 '(just-one-space)
4657 (p "<Slope at VSATN>: " nslope 'noinsert)
4658 (if (string-equal (tempo-lookup-named 'nslope) "")
4659 (list 'l "NSLOPE=0.25") ;; default value
4660 (list 'l "NSLOPE=" '(s nslope)))
4662 "satv"
4663 "template for inserting an ELDO voltage limitor"
4664 'spice-tempo-tags)
4666 (tempo-define-template
4667 "spice-eldo-vswitch"
4668 '("Y"
4669 (p "[Instance name]: ") " VSWITCH "
4670 (p "[Input]: ") " "
4671 (p "[Output]: ") " "
4672 (p "[Positive controlling node]: ") " "
4673 (p "[Negative controlling node]: ") " param: "
4674 (p "<Level (1/2)>: " level 'noinsert)
4675 (if (string-equal (tempo-lookup-named 'level) "")
4676 (list 'l "LEVEL=1") ;; default value
4677 (list 'l "LEVEL=2" ))
4678 '(just-one-space)
4679 (p "<Voltage for 'ON' state>: " von 'noinsert)
4680 (if (string-equal (tempo-lookup-named 'von) "")
4681 (list 'l "VON=0.95") ;; default value
4682 (list 'l "VON=" '(s von)))
4683 '(just-one-space)
4684 (p "<Voltage for 'OFF' state>: " voff 'noinsert)
4685 (if (string-equal (tempo-lookup-named 'voff) "")
4686 (list 'l "VOFF=0.05") ;; default value
4687 (list 'l "VOFF=" '(s voff)))
4688 '(just-one-space)
4689 (p "<RON resistance>: " ron 'noinsert)
4690 (if (string-equal (tempo-lookup-named 'ron) "")
4691 (list 'l "RON=1e-2") ;; default value
4692 (list 'l "RON=" '(s ron)))
4693 '(just-one-space)
4694 (p "<ROFF resistance>: " roff 'noinsert)
4695 (if (string-equal (tempo-lookup-named 'roff) "")
4696 (list 'l "ROFF=1e10") ;; default value
4697 (list 'l "ROFF=" '(s roff)))
4699 "vswitch"
4700 "template for inserting an ELDO voltage controled switch"
4701 'spice-tempo-tags)
4703 (tempo-define-template
4704 "spice-eldo-cswitch"
4705 '("Y"
4706 (p "[Instance name]: ") " CSWITCH "
4707 (p "[Input]: ") " "
4708 (p "[Output]: ") " IC: "
4709 (p "[Controlling current]: ") " param: "
4710 (p "<Level (1/2)>: " level 'noinsert)
4711 (if (string-equal (tempo-lookup-named 'level) "")
4712 (list 'l "LEVEL=1") ;; default value
4713 (list 'l "LEVEL=2" ))
4714 '(just-one-space)
4715 (p "<Current for 'ON' state>: " ion 'noinsert)
4716 (if (string-equal (tempo-lookup-named 'ion) "")
4717 (list 'l "ION=0.95") ;; default value
4718 (list 'l "ION=" '(s ion)))
4719 '(just-one-space)
4720 (p "<Current for 'OFF' state>: " ioff 'noinsert)
4721 (if (string-equal (tempo-lookup-named 'ioff) "")
4722 (list 'l "IOFF=0.05") ;; default value
4723 (list 'l "IOFF=" '(s ioff)))
4724 '(just-one-space)
4725 (p "<RON resistance>: " ron 'noinsert)
4726 (if (string-equal (tempo-lookup-named 'ron) "")
4727 (list 'l "RON=1e-2") ;; default value
4728 (list 'l "RON=" '(s ron)))
4729 '(just-one-space)
4730 (p "<ROFF resistance>: " roff 'noinsert)
4731 (if (string-equal (tempo-lookup-named 'roff) "")
4732 (list 'l "ROFF=1e10") ;; default value
4733 (list 'l "ROFF=" '(s roff)))
4735 "cswitch"
4736 "template for inserting an ELDO current controled switch"
4737 'spice-tempo-tags)
4739 (tempo-define-template
4740 "spice-eldo-tri2sin"
4741 '("Y"
4742 (p "[Instance name]: ") " TRI2SIN "
4743 (p "[Positive input]: ") " "
4744 (p "[Negative input]: ") " "
4745 (p "[Positive output]: ") " "
4746 (p "[Negative output]: ") " param: "
4747 (p "<Level (1/2)>: " level 'noinsert)
4748 (if (string-equal (tempo-lookup-named 'level) "")
4749 (list 'l "LEVEL=1") ;; default value
4750 (list 'l "LEVEL=" '(s level)))
4751 '(just-one-space)
4752 (p "<Gain>: " gain 'noinsert)
4753 (if (string-equal (tempo-lookup-named 'gain) "")
4754 (list 'l "GAIN=1e5") ;; default value
4755 (list 'l "GAIN=" '(s gain)))
4756 '(just-one-space)
4757 (p "<Input offset>: " voff 'noinsert)
4758 (if (string-equal (tempo-lookup-named 'voff) "")
4759 (list 'l "VOFF=0.0") ;; default value
4760 (list 'l "VOFF=" '(s voff)))
4761 '(just-one-space)
4762 (p "<Upper input voltage limit >: " vu 'noinsert)
4763 (if (string-equal (tempo-lookup-named 'vu) "")
4764 (list 'l "VU=1") ;; default value
4765 (list 'l "VU=" '(s vu)))
4766 '(just-one-space)
4767 (p "<Lower input voltage limit >: " vl 'noinsert)
4768 (if (string-equal (tempo-lookup-named 'vl) "")
4769 (list 'l "VL=1") ;; default value
4770 (list 'l "VL=" '(s vl)))
4772 "tri2sin"
4773 "template for inserting an ELDO triangular to sine wave converter"
4774 'spice-tempo-tags)
4776 (tempo-define-template
4777 "spice-eldo-stairgen"
4778 '("Y"
4779 (p "[Instance name]: ") " STAIRGEN "
4780 (p "[Positive input]: ") " "
4781 (p "[Negative input]: ") " param: "
4782 (p "<Start voltage>: " vstart 'noinsert)
4783 (if (string-equal (tempo-lookup-named 'vstart) "")
4784 (list 'l "VSTART=0.0") ;; default value
4785 (list 'l "VSTART=" '(s vstart)))
4786 '(just-one-space)
4787 (p "<Step voltage>: " vdelta 'noinsert)
4788 (if (string-equal (tempo-lookup-named 'vdelta) "")
4789 (list 'l "VDELTA=0.1") ;; default value
4790 (list 'l "VDELTA=" '(s vdelta)))
4791 '(just-one-space)
4792 (p "<Number of steps>: " nstep 'noinsert)
4793 (if (string-equal (tempo-lookup-named 'nstep) "")
4794 (list 'l "NSTEP=10") ;; default value
4795 (list 'l "NSTEP=" '(s nstep)))
4796 '(just-one-space)
4797 (p "<Period>: " tdu 'noinsert)
4798 (if (string-equal (tempo-lookup-named 'tdu) "")
4799 (list 'l "TDU=1e-4") ;; default value
4800 (list 'l "TDU=" '(s tdu)))
4801 '(just-one-space)
4802 (p "<Slew rate (V/µs)>: " slr 'noinsert)
4803 (if (string-equal (tempo-lookup-named 'slr) "")
4804 (list 'l "SLR=1") ;; default value
4805 (list 'l "SLR=" '(s slr)))
4807 "stairgen"
4808 "template for inserting an ELDO staircase waveform generator"
4809 'spice-tempo-tags)
4811 (tempo-define-template
4812 "spice-eldo-sawgen"
4813 '("Y"
4814 (p "[Instance name]: ") " SAWGEN "
4815 (p "[Positive input]: ") " "
4816 (p "[Negative input]: ") " param: "
4817 (p "<Start voltage>: " v0 'noinsert)
4818 (if (string-equal (tempo-lookup-named 'v0) "")
4819 (list 'l "V0=0.0") ;; default value
4820 (list 'l "V0=" '(s v0)))
4821 '(just-one-space)
4822 (p "<Voltage magnitude>: " v1 'noinsert)
4823 (if (string-equal (tempo-lookup-named 'v1) "")
4824 (list 'l "V1=5.0") ;; default value
4825 (list 'l "V1=" '(s v1)))
4826 '(just-one-space)
4827 (p "<Period>: " tdu 'noinsert)
4828 (if (string-equal (tempo-lookup-named 'tdu) "")
4829 (list 'l "TDU=1e-4") ;; default value
4830 (list 'l "TDU=" '(s tdu)))
4831 '(just-one-space)
4832 (p "<Delay>: " tdel 'noinsert)
4833 (if (string-equal (tempo-lookup-named 'tdel) "")
4834 (list 'l "TDEL=0.0") ;; default value
4835 (list 'l "TDEL=" '(s tdel)))
4837 "sawgen"
4838 "template for inserting an ELDO sawtooth waveform generator"
4839 'spice-tempo-tags)
4841 (tempo-define-template
4842 "spice-eldo-trigen"
4843 '("Y"
4844 (p "[Instance name]: ") " TRIGEN "
4845 (p "[Positive input]: ") " "
4846 (p "[Negative input]: ") " param: "
4847 (p "<Start voltage>: " v0 'noinsert)
4848 (if (string-equal (tempo-lookup-named 'v0) "")
4849 (list 'l "V0=0.0") ;; default value
4850 (list 'l "V0=" '(s v0)))
4851 '(just-one-space)
4852 (p "<Voltage magnitude>: " v1 'noinsert)
4853 (if (string-equal (tempo-lookup-named 'v1) "")
4854 (list 'l "V1=5.0") ;; default value
4855 (list 'l "V1=" '(s v1)))
4856 '(just-one-space)
4857 (p "<First edge duration>: " rdu 'noinsert)
4858 (if (string-equal (tempo-lookup-named 'rdu) "")
4859 (list 'l "RDU=1e-4") ;; default value
4860 (list 'l "RDU=" '(s rdu)))
4861 '(just-one-space)
4862 (p "<Second edge duration>: " fdu 'noinsert)
4863 (if (string-equal (tempo-lookup-named 'fdu) "")
4864 (list 'l "FDU=1e-4") ;; default value
4865 (list 'l "FDU=" '(s fdu)))
4866 '(just-one-space)
4867 (p "<Delay>: " tdel 'noinsert)
4868 (if (string-equal (tempo-lookup-named 'tdel) "")
4869 (list 'l "TDEL=0.0") ;; default value
4870 (list 'l "TDEL=" '(s tdel)))
4872 "trigen"
4873 "template for inserting an ELDO triangular waveform generator"
4874 'spice-tempo-tags)
4876 (tempo-define-template
4877 "spice-eldo-amm"
4878 '("Y"
4879 (p "[Instance name]: ") " AMM "
4880 (p "[Positive input]: ") " "
4881 (p "[Negative input]: ") " "
4882 (p "[Positive Output]: ") " "
4883 (p "[Negative Output]: ") " param: "
4884 (p "<Level (1/2)>: " level 'noinsert)
4885 (if (string-equal (tempo-lookup-named 'level) "")
4886 (list 'l "LEVEL=1") ;; default value
4887 (list 'l "LEVEL=" '(s level)))
4888 '(just-one-space)
4889 (p "<Slewrate (V/µs)>: " slr 'noinsert)
4890 (if (string-equal (tempo-lookup-named 'slr) "")
4891 (list 'l "SLR=10") ;; default value
4892 (list 'l "SLR=" '(s slr)))
4893 '(just-one-space)
4894 (p "<Offset voltage>: " voff 'noinsert)
4895 (if (string-equal (tempo-lookup-named 'voff) "")
4896 (list 'l "VOFF=0.0") ;; default value
4897 (list 'l "VOFF=" '(s voff)))
4898 '(just-one-space)
4899 (p "<Carrier frequency>: " fc 'noinsert)
4900 (if (string-equal (tempo-lookup-named 'fc) "")
4901 (list 'l "FC=1e6") ;; default value
4902 (list 'l "FC=" '(s fc)))
4903 '(just-one-space)
4904 (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
4905 (if (string-equal (tempo-lookup-named 'nsam) "")
4906 (list 'l "NSAM=10") ;; default value
4907 (list 'l "NSAM=" '(s nsam)))
4909 "amm"
4910 "template for inserting an ELDO amplitude modulator"
4911 'spice-tempo-tags)
4913 (tempo-define-template
4914 "spice-eldo-pam"
4915 '("Y"
4916 (p "[Instance name]: ") " PAM "
4917 (p "[Positive input]: ") " "
4918 (p "[Negative input]: ") " "
4919 (p "[Positive Output]: ") " "
4920 (p "[Negative Output]: ") " param: "
4921 (p "<Level (1/2)>: " level 'noinsert)
4922 (if (string-equal (tempo-lookup-named 'level) "")
4923 (list 'l "LEVEL=1") ;; default value
4924 (list 'l "LEVEL=" '(s level)))
4925 '(just-one-space)
4926 (p "<Slewrate (V/µs)>: " slr 'noinsert)
4927 (if (string-equal (tempo-lookup-named 'slr) "")
4928 (list 'l "SLR=10") ;; default value
4929 (list 'l "SLR=" '(s slr)))
4930 '(just-one-space)
4931 (p "<Offset voltage>: " voff 'noinsert)
4932 (if (string-equal (tempo-lookup-named 'voff) "")
4933 (list 'l "VOFF=0.0") ;; default value
4934 (list 'l "VOFF=" '(s voff)))
4935 '(just-one-space)
4936 (p "<Carrier frequency>: " fc 'noinsert)
4937 (if (string-equal (tempo-lookup-named 'fc) "")
4938 (list 'l "FC=1e6") ;; default value
4939 (list 'l "FC=" '(s fc)))
4940 '(just-one-space)
4941 (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
4942 (if (string-equal (tempo-lookup-named 'nsam) "")
4943 (list 'l "NSAM=10") ;; default value
4944 (list 'l "NSAM=" '(s nsam)))
4946 "pam"
4947 "template for inserting an ELDO pulse amplitude modulator"
4948 'spice-tempo-tags)
4951 (tempo-define-template
4952 "spice-eldo-saho"
4953 '("Y"
4954 (p "[Instance name]: ") " SA_HO "
4955 (p "[Positive input]: ") " "
4956 (p "[Negative input]: ") " "
4957 (p "[Positive Output]: ") " "
4958 (p "[Negative Output]: ") " param: "
4959 (p "<Sampling frequency>: " fs 'noinsert)
4960 (if (string-equal (tempo-lookup-named 'fs) "")
4961 (list 'l "FS=1e6") ;; default value
4962 (list 'l "FS=" '(s fs)))
4963 '(just-one-space)
4964 (p "<Acquisition time>: " tacq 'noinsert)
4965 (if (string-equal (tempo-lookup-named 'tacq) "")
4966 (list 'l "TACQ=1e-9") ;; default value
4967 (list 'l "TACQ=" '(s tacq)))
4968 '(just-one-space)
4969 (p "<Droop voltage>: " dv 'noinsert)
4970 (if (string-equal (tempo-lookup-named 'dv) "")
4971 (list 'l "DV=20mv") ;; default value
4972 (list 'l "DV=" '(s dv)))
4973 '(just-one-space)
4975 "saho"
4976 "template for inserting an ELDO sample&hold"
4977 'spice-tempo-tags)
4979 (tempo-define-template
4980 "spice-eldo-trho"
4981 '("Y"
4982 (p "[Instance name]: ") " TR_HO "
4983 (p "[Positive input]: ") " "
4984 (p "[Negative input]: ") " "
4985 (p "[Positive Output]: ") " "
4986 (p "[Negative Output]: ") " "
4987 (p "[Controlling node]: ") " param: "
4988 (p "<Threshold voltage for CRT>: " vth 'noinsert)
4989 (if (string-equal (tempo-lookup-named 'vth) "")
4990 (list 'l "VTH=0.5") ;; default value
4991 (list 'l "VTH=" '(s vth)))
4992 '(just-one-space)
4993 (p "<Acquisition time>: " tacq 'noinsert)
4994 (if (string-equal (tempo-lookup-named 'tacq) "")
4995 (list 'l "TACQ=1e-9") ;; default value
4996 (list 'l "TACQ=" '(s tacq)))
4998 "trho"
4999 "template for inserting an ELDO track&hold"
5000 'spice-tempo-tags)
5003 (tempo-define-template
5004 "spice-eldo-peakd"
5005 '("Y"
5006 (p "[Instance name]: ") " PEAK_D "
5007 (p "[Positive input]: ") " "
5008 (p "[Negative input]: ") " "
5009 (p "[Positive Output]: ") " "
5010 (p "[Negative Output]: ") " "
5011 (p "[Controlling node]: ") " param: "
5012 (p "<Level (1/2)>: " level 'noinsert)
5013 (if (string-equal (tempo-lookup-named 'level) "")
5014 (list 'l "LEVEL=1") ;; default value
5015 (list 'l "LEVEL=2" ))
5016 '(just-one-space)
5017 (p "<Threshold voltage for CRT>: " vth 'noinsert)
5018 (if (string-equal (tempo-lookup-named 'vth) "")
5019 (list 'l "VTH=0.5") ;; default value
5020 (list 'l "VTH=" '(s vth)))
5021 '(just-one-space)
5022 (p "<Threshold voltage for reset on output>: " res 'noinsert)
5023 (if (string-equal (tempo-lookup-named 'res) "")
5024 (list 'l "RES=0.5") ;; default value
5025 (list 'l "RES=" '(s res)))
5026 '(just-one-space)
5027 (p "<Output slewrate (V/µs)>: " slr 'noinsert)
5028 (if (string-equal (tempo-lookup-named 'slr) "")
5029 (list 'l "SLR=1.0") ;; default value
5030 (list 'l "SLR=" '(s slr)))
5031 '(just-one-space)
5032 (p "<Output slewrate on reset>: " rslr 'noinsert)
5033 (if (string-equal (tempo-lookup-named 'rslr) "")
5034 (list 'l "RSLR=1.0") ;; default value
5035 (list 'l "RSLR=" '(s rslr)))
5037 "peakd"
5038 "template for inserting an ELDO peak detector"
5039 'spice-tempo-tags)
5042 (tempo-define-template
5043 "spice-eldo-levdso"
5044 '("Y"
5045 (p "[Instance name]: ") " LEV_D "
5046 (p "[Positive input]: ") " "
5047 (p "[Negative input]: ") " "
5048 (p "[Positive Output]: ") " "
5049 (p "[Negative Output]: ") " param: "
5050 (p "<Rise time (µs)>: " tr 'noinsert)
5051 (if (string-equal (tempo-lookup-named 'tr) "")
5052 (list 'l "TR=1.0") ;; default value
5053 (list 'l "TR=" '(s tr)))
5054 '(just-one-space)
5055 (p "<Fall time (µs)>: " tf 'noinsert)
5056 (if (string-equal (tempo-lookup-named 'tf) "")
5057 (list 'l "TF=1.0") ;; default value
5058 (list 'l "TF=" '(s tf)))
5059 '(just-one-space)
5060 (p "<Transit time (s)>: " tpd 'noinsert)
5061 (if (string-equal (tempo-lookup-named 'tpd) "")
5062 (list 'l "TPD=0.0") ;; default value
5063 (list 'l "TPD=" '(s tpd)))
5064 '(just-one-space)
5065 (p "<Lower voltage level>: " v0 'noinsert)
5066 (if (string-equal (tempo-lookup-named 'v0) "")
5067 (list 'l "V0=0.0") ;; default value
5068 (list 'l "V0=" '(s v0)))
5069 '(just-one-space)
5070 (p "<Higher voltage level>: " v1 'noinsert)
5071 (if (string-equal (tempo-lookup-named 'v1) "")
5072 (list 'l "V1=1.0") ;; default value
5073 (list 'l "V1=" '(s v1)))
5074 '(just-one-space)
5075 (p "<Input offset voltage>: " voff 'noinsert)
5076 (if (string-equal (tempo-lookup-named 'voff) "")
5077 (list 'l "VOFF=0.0") ;; default value
5078 (list 'l "VOFF=" '(s voff)))
5079 '(just-one-space)
5080 (p "<Lower reference voltage>: " vrl 'noinsert)
5081 (if (string-equal (tempo-lookup-named 'vrl) "")
5082 (list 'l "VRL=-0.1") ;; default value
5083 (list 'l "VRL=" '(s vrl)))
5084 '(just-one-space)
5085 (p "<Higher reference voltage>: " vru 'noinsert)
5086 (if (string-equal (tempo-lookup-named 'vru) "")
5087 (list 'l "VRU=0.1") ;; default value
5088 (list 'l "VRU=" '(s vru)))
5090 "levdso"
5091 "template for inserting an ELDO single-output level detector"
5092 'spice-tempo-tags)
5095 (tempo-define-template
5096 "spice-eldo-levddo"
5097 '("Y"
5098 (p "[Instance name]: ") " LEV_D "
5099 (p "[Positive input]: ") " "
5100 (p "[Negative input]: ") " "
5101 (p "[Positive Output]: ") " "
5102 (p "[Negative Output]: ") " "
5103 (p "[Reference node]: ") " param: "
5104 (p "<Rise time (µs)>: " tr 'noinsert)
5105 (if (string-equal (tempo-lookup-named 'tr) "")
5106 (list 'l "TR=1.0") ;; default value
5107 (list 'l "TR=" '(s tr)))
5108 '(just-one-space)
5109 (p "<Fall time (µs)>: " tf 'noinsert)
5110 (if (string-equal (tempo-lookup-named 'tf) "")
5111 (list 'l "TF=1.0") ;; default value
5112 (list 'l "TF=" '(s tf)))
5113 '(just-one-space)
5114 (p "<Transit time (s)>: " tpd 'noinsert)
5115 (if (string-equal (tempo-lookup-named 'tpd) "")
5116 (list 'l "TPD=0.0") ;; default value
5117 (list 'l "TPD=" '(s tpd)))
5118 '(just-one-space)
5119 (p "<Lower voltage level>: " v0 'noinsert)
5120 (if (string-equal (tempo-lookup-named 'v0) "")
5121 (list 'l "V0=0.0") ;; default value
5122 (list 'l "V0=" '(s v0)))
5123 '(just-one-space)
5124 (p "<Higher voltage level>: " v1 'noinsert)
5125 (if (string-equal (tempo-lookup-named 'v1) "")
5126 (list 'l "V1=1.0") ;; default value
5127 (list 'l "V1=" '(s v1)))
5128 '(just-one-space)
5129 (p "<Input offset voltage>: " voff 'noinsert)
5130 (if (string-equal (tempo-lookup-named 'voff) "")
5131 (list 'l "VOFF=0.0") ;; default value
5132 (list 'l "VOFF=" '(s voff)))
5133 '(just-one-space)
5134 (p "<Lower reference voltage>: " vrl 'noinsert)
5135 (if (string-equal (tempo-lookup-named 'vrl) "")
5136 (list 'l "VRL=-0.1") ;; default value
5137 (list 'l "VRL=" '(s vrl)))
5138 '(just-one-space)
5139 (p "<Higher reference voltage>: " vru 'noinsert)
5140 (if (string-equal (tempo-lookup-named 'vru) "")
5141 (list 'l "VRU=0.1") ;; default value
5142 (list 'l "VRU=" '(s vru)))
5144 "levddo"
5145 "template for inserting an ELDO differential-output level detector"
5146 'spice-tempo-tags)
5149 (tempo-define-template
5150 "spice-eldo-logamp"
5151 '("Y"
5152 (p "[Instance name]: ") " LOGAMP "
5153 (p "[Input]: ") " "
5154 (p "[Output]: ") " param: "
5155 (p "<Gain>: " gain 'noinsert)
5156 (if (string-equal (tempo-lookup-named 'gain) "")
5157 (list 'l "K=1.0") ;; default value
5158 (list 'l "K=" '(s gain)))
5159 '(just-one-space)
5160 (p "<Log function argument>: " e 'noinsert)
5161 (if (string-equal (tempo-lookup-named 'e) "")
5162 (list 'l "E=1") ;; default value
5163 (list 'l "E=" '(s vmin)))
5164 '(just-one-space)
5165 (p "<Vmax>: " vmax 'noinsert)
5166 (if (string-equal (tempo-lookup-named 'vmax) "")
5167 (list 'l "VMAX=5.0") ;; default value
5168 (list 'l "VMAX=" '(s vmax)))
5169 '(just-one-space)
5170 (p "<Vmin>: " vmin 'noinsert)
5171 (if (string-equal (tempo-lookup-named 'vmin) "")
5172 (list 'l "VMIN=-5.0") ;; default value
5173 (list 'l "VMIN=" '(s vmin)))
5174 '(just-one-space)
5175 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5176 (if (string-equal (tempo-lookup-named 'vsatp) "")
5177 (list 'l "VSATP=4.75") ;; default value
5178 (list 'l "VSATP=" '(s vsatp)))
5179 '(just-one-space)
5180 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5181 (if (string-equal (tempo-lookup-named 'vsatn) "")
5182 (list 'l "VSATN=-4.75") ;; default value
5183 (list 'l "VSATN=" '(s vsatn)))
5184 '(just-one-space)
5185 (p "<Slope at VSATP>: " pslope 'noinsert)
5186 (if (string-equal (tempo-lookup-named 'pslope) "")
5187 (list 'l "PSLOPE=0.25") ;; default value
5188 (list 'l "PSLOPE=" '(s pslope)))
5189 '(just-one-space)
5190 (p "<Slope at VSATN>: " nslope 'noinsert)
5191 (if (string-equal (tempo-lookup-named 'nslope) "")
5192 (list 'l "NSLOPE=0.25") ;; default value
5193 (list 'l "NSLOPE=" '(s nslope)))
5195 "logamp"
5196 "template for inserting an ELDO logarithmic amplifier"
5197 'spice-tempo-tags)
5199 (tempo-define-template
5200 "spice-eldo-antilog"
5201 '("Y"
5202 (p "[Instance name]: ") " EXPAMP "
5203 (p "[Input]: ") " "
5204 (p "[Output]: ") " param: "
5205 (p "<Gain>: " k 'noinsert)
5206 (if (string-equal (tempo-lookup-named 'k) "")
5207 (list 'l "K=1.0") ;; default value
5208 (list 'l "K=" '(s k)))
5209 '(just-one-space)
5210 (p "<Exp function argument>: " e 'noinsert)
5211 (if (string-equal (tempo-lookup-named 'e) "")
5212 (list 'l "E=1") ;; default value
5213 (list 'l "E=" '(s vmin)))
5214 '(just-one-space)
5215 (p "<Base of power function>: " base 'noinsert)
5216 (if (string-equal (tempo-lookup-named 'base) "")
5217 (list 'l "BASE={EXP(1)}") ;; default value
5218 (list 'l "BASE=" '(s base)))
5219 '(just-one-space)
5220 (p "<Vmax>: " vmax 'noinsert)
5221 (if (string-equal (tempo-lookup-named 'vmax) "")
5222 (list 'l "VMAX=5.0") ;; default value
5223 (list 'l "VMAX=" '(s vmax)))
5224 '(just-one-space)
5225 (p "<Vmin>: " vmin 'noinsert)
5226 (if (string-equal (tempo-lookup-named 'vmin) "")
5227 (list 'l "VMIN=-5.0") ;; default value
5228 (list 'l "VMIN=" '(s vmin)))
5229 '(just-one-space)
5230 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5231 (if (string-equal (tempo-lookup-named 'vsatp) "")
5232 (list 'l "VSATP=4.75") ;; default value
5233 (list 'l "VSATP=" '(s vsatp)))
5234 '(just-one-space)
5235 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5236 (if (string-equal (tempo-lookup-named 'vsatn) "")
5237 (list 'l "VSATN=-4.75") ;; default value
5238 (list 'l "VSATN=" '(s vsatn)))
5239 '(just-one-space)
5240 (p "<Slope at VSATP>: " pslope 'noinsert)
5241 (if (string-equal (tempo-lookup-named 'pslope) "")
5242 (list 'l "PSLOPE=0.25") ;; default value
5243 (list 'l "PSLOPE=" '(s pslope)))
5244 '(just-one-space)
5245 (p "<Slope at VSATN>: " nslope 'noinsert)
5246 (if (string-equal (tempo-lookup-named 'nslope) "")
5247 (list 'l "NSLOPE=0.25") ;; default value
5248 (list 'l "NSLOPE=" '(s nslope)))
5250 "expamp"
5251 "template for inserting an ELDO anti-logarithmic amplifier"
5252 'spice-tempo-tags)
5254 (tempo-define-template
5255 "spice-eldo-diff"
5256 '("Y"
5257 (p "[Instance name]: ") " DIFF "
5258 (p "[Input]: ") " "
5259 (p "[Output]: ") " param: "
5260 (p "<Time constant>: " k 'noinsert)
5261 (if (string-equal (tempo-lookup-named 'k) "")
5262 (list 'l "K=1") ;; default value
5263 (list 'l "K=" '(s k)))
5264 '(just-one-space)
5265 (p "<DC value>: " c0 'noinsert)
5266 (if (string-equal (tempo-lookup-named 'c0) "")
5267 (list 'l "C0=1") ;; default value
5268 (list 'l "C0=" '(s c0)))
5269 '(just-one-space)
5270 (p "<Slewrate (V/s)>: " slr 'noinsert)
5271 (if (string-equal (tempo-lookup-named 'slr) "")
5272 (list 'l "SLR=1e9") ;; default value
5273 (list 'l "SLR=" '(s slr)))
5275 "diff"
5276 "template for inserting an ELDO differentiator"
5277 'spice-tempo-tags)
5279 (tempo-define-template
5280 "spice-eldo-integ"
5281 '("Y"
5282 (p "[Instance name]: ") " INTEG "
5283 (p "[Input]: ") " "
5284 (p "[Output]: ") " param: "
5285 (p "<Time constant>: " k 'noinsert)
5286 (if (string-equal (tempo-lookup-named 'k) "")
5287 (list 'l "K=1") ;; default value
5288 (list 'l "K=" '(s k)))
5289 '(just-one-space)
5290 (p "<DC value>: " c0 'noinsert)
5291 (if (string-equal (tempo-lookup-named 'c0) "")
5292 (list 'l "C0=1") ;; default value
5293 (list 'l "C0=" '(s c0)))
5295 "integ"
5296 "template for inserting an ELDO integrator"
5297 'spice-tempo-tags)
5299 (tempo-define-template
5300 "spice-eldo-adder"
5301 '("Y"
5302 (p "[Instance name]: ") " "
5303 (p "<ADD/SUB/MULT/DIV>: ") " "
5304 (p "[Input 2]: ") " "
5305 (p "[Output]: ") " param: "
5306 (p "<Vmax>: " vmax 'noinsert)
5307 (if (string-equal (tempo-lookup-named 'vmax) "")
5308 (list 'l "VMAX=5.0") ;; default value
5309 (list 'l "VMAX=" '(s vmax)))
5310 '(just-one-space)
5311 (p "<Vmin>: " vmin 'noinsert)
5312 (if (string-equal (tempo-lookup-named 'vmin) "")
5313 (list 'l "VMIN=-5.0") ;; default value
5314 (list 'l "VMIN=" '(s vmin)))
5315 '(just-one-space)
5316 (p "<Positive saturation voltage>: " vsatp 'noinsert)
5317 (if (string-equal (tempo-lookup-named 'vsatp) "")
5318 (list 'l "VSATP=4.75") ;; default value
5319 (list 'l "VSATP=" '(s vsatp)))
5320 '(just-one-space)
5321 (p "<Negative saturation voltage>: " vsatn 'noinsert)
5322 (if (string-equal (tempo-lookup-named 'vsatn) "")
5323 (list 'l "VSATN=-4.75") ;; default value
5324 (list 'l "VSATN=" '(s vsatn)))
5325 '(just-one-space)
5326 (p "<Slope at VSATP>: " pslope 'noinsert)
5327 (if (string-equal (tempo-lookup-named 'pslope) "")
5328 (list 'l "PSLOPE=0.25") ;; default value
5329 (list 'l "PSLOPE=" '(s pslope)))
5330 '(just-one-space)
5331 (p "<Slope at VSATN>: " nslope 'noinsert)
5332 (if (string-equal (tempo-lookup-named 'nslope) "")
5333 (list 'l "NSLOPE=0.25") ;; default value
5334 (list 'l "NSLOPE=" '(s nslope)))
5336 "add"
5337 "template for inserting an ELDO adder/subtrator/multiplier/divider"
5338 'spice-tempo-tags)
5340 ;; -------------------
5341 ;; Digital Macromodels
5342 ;; -------------------
5344 (tempo-define-template
5345 "spice-eldo-inv"
5346 '("INV"
5347 (p "[Instance name]: ") " "
5348 (p "[First input]: ") " "
5349 (p "[Second input]: ") " "
5350 (p "[Output]: ") " "
5351 (p "[Model name]: ") " "
5352 (p "<Vhigh>: " vhi 'noinsert)
5353 (if (string-equal (tempo-lookup-named 'vhi) "")
5354 (list 'l "VHI=5.0") ;; default value
5355 (list 'l "VHI=" '(s vhi)))
5356 '(just-one-space)
5357 (p "<Vlow>: " vlo 'noinsert)
5358 (if (string-equal (tempo-lookup-named 'vlo) "")
5359 (list 'l "VLO=0.0") ;; default value
5360 (list 'l "VLO=" '(s vlo)))
5361 '(just-one-space)
5362 (p "<Threshold input voltage>: " vth 'noinsert)
5363 (if (string-equal (tempo-lookup-named 'vth) "")
5364 (list 'l "VTH=2.5") ;; default value
5365 (list 'l "VTH=" '(s vth)))
5366 '(just-one-space)
5367 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5368 (if (string-equal (tempo-lookup-named 'vthi) "")
5369 (list 'l "") ;; default value
5370 (list 'l "VTHI=" '(s vthi)))
5371 '(just-one-space)
5372 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5373 (if (string-equal (tempo-lookup-named 'vtlo) "")
5374 (list 'l "") ;; default value
5375 (list 'l "VTLO=" '(s vtlo)))
5376 '(just-one-space)
5377 (p "<Transit time>: " tpd 'noinsert)
5378 (if (string-equal (tempo-lookup-named 'tpd) "")
5379 (list 'l "TPD=1.0ns") ;; default value
5380 (list 'l "TPD=" '(s tpd)))
5381 '(just-one-space)
5382 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5383 (if (string-equal (tempo-lookup-named 'tpdup) "")
5384 (list 'l "") ;; default value
5385 (list 'l "TPDUP=" '(s tpdup)))
5386 '(just-one-space)
5387 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5388 (if (string-equal (tempo-lookup-named 'tpdown) "")
5389 (list 'l "") ;; default value
5390 (list 'l "TPDOWN=" '(s tpdown)))
5391 '(just-one-space)
5392 (p "<Input capacitance>: " cin 'noinsert)
5393 (if (string-equal (tempo-lookup-named 'cin) "")
5394 (list 'l "CIN=0.0") ;; default value
5395 (list 'l "CIN=" '(s cin)))
5396 '(just-one-space)
5398 "inv"
5399 "template for inserting an ELDO INVERTER gate macromodel"
5400 'spice-tempo-tags)
5402 (tempo-define-template
5403 "spice-eldo-xor"
5404 '("XOR"
5405 (p "[Instance name]: ") " "
5406 (p "[First input]: ") " "
5407 (p "[Second input]: ") " "
5408 (p "[Output]: ") " "
5409 (p "[Model name]: ") " "
5410 (p "<Vhigh>: " vhi 'noinsert)
5411 (if (string-equal (tempo-lookup-named 'vhi) "")
5412 (list 'l "VHI=5.0") ;; default value
5413 (list 'l "VHI=" '(s vhi)))
5414 '(just-one-space)
5415 (p "<Vlow>: " vlo 'noinsert)
5416 (if (string-equal (tempo-lookup-named 'vlo) "")
5417 (list 'l "VLO=0.0") ;; default value
5418 (list 'l "VLO=" '(s vlo)))
5419 '(just-one-space)
5420 (p "<Threshold input voltage>: " vth 'noinsert)
5421 (if (string-equal (tempo-lookup-named 'vth) "")
5422 (list 'l "VTH=2.5") ;; default value
5423 (list 'l "VTH=" '(s vth)))
5424 '(just-one-space)
5425 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5426 (if (string-equal (tempo-lookup-named 'vthi) "")
5427 (list 'l "") ;; default value
5428 (list 'l "VTHI=" '(s vthi)))
5429 '(just-one-space)
5430 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5431 (if (string-equal (tempo-lookup-named 'vtlo) "")
5432 (list 'l "") ;; default value
5433 (list 'l "VTLO=" '(s vtlo)))
5434 '(just-one-space)
5435 (p "<Transit time>: " tpd 'noinsert)
5436 (if (string-equal (tempo-lookup-named 'tpd) "")
5437 (list 'l "TPD=1.0ns") ;; default value
5438 (list 'l "TPD=" '(s tpd)))
5439 '(just-one-space)
5440 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5441 (if (string-equal (tempo-lookup-named 'tpdup) "")
5442 (list 'l "") ;; default value
5443 (list 'l "TPDUP=" '(s tpdup)))
5444 '(just-one-space)
5445 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5446 (if (string-equal (tempo-lookup-named 'tpdown) "")
5447 (list 'l "") ;; default value
5448 (list 'l "TPDOWN=" '(s tpdown)))
5449 '(just-one-space)
5450 (p "<Input capacitance>: " cin 'noinsert)
5451 (if (string-equal (tempo-lookup-named 'cin) "")
5452 (list 'l "CIN=0.0") ;; default value
5453 (list 'l "CIN=" '(s cin)))
5454 '(just-one-space)
5456 "xor"
5457 "template for inserting an ELDO Exclusive-OR gate macromodel"
5458 'spice-tempo-tags)
5460 (tempo-define-template
5461 "spice-eldo-and2"
5462 '("AND"
5463 (p "[Instance name]: ") " "
5464 (p "[First input]: ") " "
5465 (p "[Second input]: ") " "
5466 (p "[Output]: ") " "
5467 (p "[Model name]: ") " "
5468 (p "<Vhigh>: " vhi 'noinsert)
5469 (if (string-equal (tempo-lookup-named 'vhi) "")
5470 (list 'l "VHI=5.0") ;; default value
5471 (list 'l "VHI=" '(s vhi)))
5472 '(just-one-space)
5473 (p "<Vlow>: " vlo 'noinsert)
5474 (if (string-equal (tempo-lookup-named 'vlo) "")
5475 (list 'l "VLO=0.0") ;; default value
5476 (list 'l "VLO=" '(s vlo)))
5477 '(just-one-space)
5478 (p "<Threshold input voltage>: " vth 'noinsert)
5479 (if (string-equal (tempo-lookup-named 'vth) "")
5480 (list 'l "VTH=2.5") ;; default value
5481 (list 'l "VTH=" '(s vth)))
5482 '(just-one-space)
5483 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5484 (if (string-equal (tempo-lookup-named 'vthi) "")
5485 (list 'l "") ;; default value
5486 (list 'l "VTHI=" '(s vthi)))
5487 '(just-one-space)
5488 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5489 (if (string-equal (tempo-lookup-named 'vtlo) "")
5490 (list 'l "") ;; default value
5491 (list 'l "VTLO=" '(s vtlo)))
5492 '(just-one-space)
5493 (p "<Transit time>: " tpd 'noinsert)
5494 (if (string-equal (tempo-lookup-named 'tpd) "")
5495 (list 'l "TPD=1.0ns") ;; default value
5496 (list 'l "TPD=" '(s tpd)))
5497 '(just-one-space)
5498 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5499 (if (string-equal (tempo-lookup-named 'tpdup) "")
5500 (list 'l "") ;; default value
5501 (list 'l "TPDUP=" '(s tpdup)))
5502 '(just-one-space)
5503 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5504 (if (string-equal (tempo-lookup-named 'tpdown) "")
5505 (list 'l "") ;; default value
5506 (list 'l "TPDOWN=" '(s tpdown)))
5507 '(just-one-space)
5508 (p "<Input capacitance>: " cin 'noinsert)
5509 (if (string-equal (tempo-lookup-named 'cin) "")
5510 (list 'l "CIN=0.0") ;; default value
5511 (list 'l "CIN=" '(s cin)))
5512 '(just-one-space)
5514 "and"
5515 "template for inserting an ELDO 2 input AND gate macromodel"
5516 'spice-tempo-tags)
5519 (tempo-define-template
5520 "spice-eldo-nand2"
5521 '("NAND"
5522 (p "[Instance name]: ") " "
5523 (p "[First input]: ") " "
5524 (p "[Second input]: ") " "
5525 (p "[Output]: ") " "
5526 (p "[Model name]: ") " "
5527 (p "<Vhigh>: " vhi 'noinsert)
5528 (if (string-equal (tempo-lookup-named 'vhi) "")
5529 (list 'l "VHI=5.0") ;; default value
5530 (list 'l "VHI=" '(s vhi)))
5531 '(just-one-space)
5532 (p "<Vlow>: " vlo 'noinsert)
5533 (if (string-equal (tempo-lookup-named 'vlo) "")
5534 (list 'l "VLO=0.0") ;; default value
5535 (list 'l "VLO=" '(s vlo)))
5536 '(just-one-space)
5537 (p "<Threshold input voltage>: " vth 'noinsert)
5538 (if (string-equal (tempo-lookup-named 'vth) "")
5539 (list 'l "VTH=2.5") ;; default value
5540 (list 'l "VTH=" '(s vth)))
5541 '(just-one-space)
5542 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5543 (if (string-equal (tempo-lookup-named 'vthi) "")
5544 (list 'l "") ;; default value
5545 (list 'l "VTHI=" '(s vthi)))
5546 '(just-one-space)
5547 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5548 (if (string-equal (tempo-lookup-named 'vtlo) "")
5549 (list 'l "") ;; default value
5550 (list 'l "VTLO=" '(s vtlo)))
5551 '(just-one-space)
5552 (p "<Transit time>: " tpd 'noinsert)
5553 (if (string-equal (tempo-lookup-named 'tpd) "")
5554 (list 'l "TPD=1.0ns") ;; default value
5555 (list 'l "TPD=" '(s tpd)))
5556 '(just-one-space)
5557 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5558 (if (string-equal (tempo-lookup-named 'tpdup) "")
5559 (list 'l "") ;; default value
5560 (list 'l "TPDUP=" '(s tpdup)))
5561 '(just-one-space)
5562 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5563 (if (string-equal (tempo-lookup-named 'tpdown) "")
5564 (list 'l "") ;; default value
5565 (list 'l "TPDOWN=" '(s tpdown)))
5566 '(just-one-space)
5567 (p "<Input capacitance>: " cin 'noinsert)
5568 (if (string-equal (tempo-lookup-named 'cin) "")
5569 (list 'l "CIN=0.0") ;; default value
5570 (list 'l "CIN=" '(s cin)))
5571 '(just-one-space)
5573 "nand"
5574 "template for inserting an ELDO 2 input NAND gate macromodel"
5575 'spice-tempo-tags)
5577 (tempo-define-template
5578 "spice-eldo-or2"
5579 '("OR"
5580 (p "[Instance name]: ") " "
5581 (p "[First input]: ") " "
5582 (p "[Second input]: ") " "
5583 (p "[Output]: ") " "
5584 (p "[Model name]: ") " "
5585 (p "<Vhigh>: " vhi 'noinsert)
5586 (if (string-equal (tempo-lookup-named 'vhi) "")
5587 (list 'l "VHI=5.0") ;; default value
5588 (list 'l "VHI=" '(s vhi)))
5589 '(just-one-space)
5590 (p "<Vlow>: " vlo 'noinsert)
5591 (if (string-equal (tempo-lookup-named 'vlo) "")
5592 (list 'l "VLO=0.0") ;; default value
5593 (list 'l "VLO=" '(s vlo)))
5594 '(just-one-space)
5595 (p "<Threshold input voltage>: " vth 'noinsert)
5596 (if (string-equal (tempo-lookup-named 'vth) "")
5597 (list 'l "VTH=2.5") ;; default value
5598 (list 'l "VTH=" '(s vth)))
5599 '(just-one-space)
5600 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5601 (if (string-equal (tempo-lookup-named 'vthi) "")
5602 (list 'l "") ;; default value
5603 (list 'l "VTHI=" '(s vthi)))
5604 '(just-one-space)
5605 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5606 (if (string-equal (tempo-lookup-named 'vtlo) "")
5607 (list 'l "") ;; default value
5608 (list 'l "VTLO=" '(s vtlo)))
5609 '(just-one-space)
5610 (p "<Transit time>: " tpd 'noinsert)
5611 (if (string-equal (tempo-lookup-named 'tpd) "")
5612 (list 'l "TPD=1.0ns") ;; default value
5613 (list 'l "TPD=" '(s tpd)))
5614 '(just-one-space)
5615 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5616 (if (string-equal (tempo-lookup-named 'tpdup) "")
5617 (list 'l "") ;; default value
5618 (list 'l "TPDUP=" '(s tpdup)))
5619 '(just-one-space)
5620 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5621 (if (string-equal (tempo-lookup-named 'tpdown) "")
5622 (list 'l "") ;; default value
5623 (list 'l "TPDOWN=" '(s tpdown)))
5624 '(just-one-space)
5625 (p "<Input capacitance>: " cin 'noinsert)
5626 (if (string-equal (tempo-lookup-named 'cin) "")
5627 (list 'l "CIN=0.0") ;; default value
5628 (list 'l "CIN=" '(s cin)))
5629 '(just-one-space)
5631 "or"
5632 "template for inserting an ELDO 2 input OR gate macromodel"
5633 'spice-tempo-tags)
5635 (tempo-define-template
5636 "spice-eldo-nor2"
5637 '("NOR"
5638 (p "[Instance name]: ") " "
5639 (p "[First input]: ") " "
5640 (p "[Second input]: ") " "
5641 (p "[Output]: ") " "
5642 (p "[Model name]: ") " "
5643 (p "<Vhigh>: " vhi 'noinsert)
5644 (if (string-equal (tempo-lookup-named 'vhi) "")
5645 (list 'l "VHI=5.0") ;; default value
5646 (list 'l "VHI=" '(s vhi)))
5647 '(just-one-space)
5648 (p "<Vlow>: " vlo 'noinsert)
5649 (if (string-equal (tempo-lookup-named 'vlo) "")
5650 (list 'l "VLO=0.0") ;; default value
5651 (list 'l "VLO=" '(s vlo)))
5652 '(just-one-space)
5653 (p "<Threshold input voltage>: " vth 'noinsert)
5654 (if (string-equal (tempo-lookup-named 'vth) "")
5655 (list 'l "VTH=2.5") ;; default value
5656 (list 'l "VTH=" '(s vth)))
5657 '(just-one-space)
5658 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5659 (if (string-equal (tempo-lookup-named 'vthi) "")
5660 (list 'l "") ;; default value
5661 (list 'l "VTHI=" '(s vthi)))
5662 '(just-one-space)
5663 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5664 (if (string-equal (tempo-lookup-named 'vtlo) "")
5665 (list 'l "") ;; default value
5666 (list 'l "VTLO=" '(s vtlo)))
5667 '(just-one-space)
5668 (p "<Transit time>: " tpd 'noinsert)
5669 (if (string-equal (tempo-lookup-named 'tpd) "")
5670 (list 'l "TPD=1.0ns") ;; default value
5671 (list 'l "TPD=" '(s tpd)))
5672 '(just-one-space)
5673 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5674 (if (string-equal (tempo-lookup-named 'tpdup) "")
5675 (list 'l "") ;; default value
5676 (list 'l "TPDUP=" '(s tpdup)))
5677 '(just-one-space)
5678 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5679 (if (string-equal (tempo-lookup-named 'tpdown) "")
5680 (list 'l "") ;; default value
5681 (list 'l "TPDOWN=" '(s tpdown)))
5682 '(just-one-space)
5683 (p "<Input capacitance>: " cin 'noinsert)
5684 (if (string-equal (tempo-lookup-named 'cin) "")
5685 (list 'l "CIN=0.0") ;; default value
5686 (list 'l "CIN=" '(s cin)))
5687 '(just-one-space)
5689 "nor"
5690 "template for inserting an ELDO 2 input NOR gate macromodel"
5691 'spice-tempo-tags)
5694 (tempo-define-template
5695 "spice-eldo-and3"
5696 '("AND3"
5697 (p "[Instance name]: ") " "
5698 (p "[First input]: ") " "
5699 (p "[Second input]: ") " "
5700 (p "[Output]: ") " "
5701 (p "[Model name]: ") " "
5702 (p "<Vhigh>: " vhi 'noinsert)
5703 (if (string-equal (tempo-lookup-named 'vhi) "")
5704 (list 'l "VHI=5.0") ;; default value
5705 (list 'l "VHI=" '(s vhi)))
5706 '(just-one-space)
5707 (p "<Vlow>: " vlo 'noinsert)
5708 (if (string-equal (tempo-lookup-named 'vlo) "")
5709 (list 'l "VLO=0.0") ;; default value
5710 (list 'l "VLO=" '(s vlo)))
5711 '(just-one-space)
5712 (p "<Threshold input voltage>: " vth 'noinsert)
5713 (if (string-equal (tempo-lookup-named 'vth) "")
5714 (list 'l "VTH=2.5") ;; default value
5715 (list 'l "VTH=" '(s vth)))
5716 '(just-one-space)
5717 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5718 (if (string-equal (tempo-lookup-named 'vthi) "")
5719 (list 'l "") ;; default value
5720 (list 'l "VTHI=" '(s vthi)))
5721 '(just-one-space)
5722 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5723 (if (string-equal (tempo-lookup-named 'vtlo) "")
5724 (list 'l "") ;; default value
5725 (list 'l "VTLO=" '(s vtlo)))
5726 '(just-one-space)
5727 (p "<Transit time>: " tpd 'noinsert)
5728 (if (string-equal (tempo-lookup-named 'tpd) "")
5729 (list 'l "TPD=1.0ns") ;; default value
5730 (list 'l "TPD=" '(s tpd)))
5731 '(just-one-space)
5732 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5733 (if (string-equal (tempo-lookup-named 'tpdup) "")
5734 (list 'l "") ;; default value
5735 (list 'l "TPDUP=" '(s tpdup)))
5736 '(just-one-space)
5737 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5738 (if (string-equal (tempo-lookup-named 'tpdown) "")
5739 (list 'l "") ;; default value
5740 (list 'l "TPDOWN=" '(s tpdown)))
5741 '(just-one-space)
5742 (p "<Input capacitance>: " cin 'noinsert)
5743 (if (string-equal (tempo-lookup-named 'cin) "")
5744 (list 'l "CIN=0.0") ;; default value
5745 (list 'l "CIN=" '(s cin)))
5746 '(just-one-space)
5748 "and3"
5749 "template for inserting an ELDO 3 input AND gate macromodel"
5750 'spice-tempo-tags)
5753 (tempo-define-template
5754 "spice-eldo-nand3"
5755 '("NAND3"
5756 (p "[Instance name]: ") " "
5757 (p "[First input]: ") " "
5758 (p "[Second input]: ") " "
5759 (p "[Output]: ") " "
5760 (p "[Model name]: ") " "
5761 (p "<Vhigh>: " vhi 'noinsert)
5762 (if (string-equal (tempo-lookup-named 'vhi) "")
5763 (list 'l "VHI=5.0") ;; default value
5764 (list 'l "VHI=" '(s vhi)))
5765 '(just-one-space)
5766 (p "<Vlow>: " vlo 'noinsert)
5767 (if (string-equal (tempo-lookup-named 'vlo) "")
5768 (list 'l "VLO=0.0") ;; default value
5769 (list 'l "VLO=" '(s vlo)))
5770 '(just-one-space)
5771 (p "<Threshold input voltage>: " vth 'noinsert)
5772 (if (string-equal (tempo-lookup-named 'vth) "")
5773 (list 'l "VTH=2.5") ;; default value
5774 (list 'l "VTH=" '(s vth)))
5775 '(just-one-space)
5776 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5777 (if (string-equal (tempo-lookup-named 'vthi) "")
5778 (list 'l "") ;; default value
5779 (list 'l "VTHI=" '(s vthi)))
5780 '(just-one-space)
5781 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5782 (if (string-equal (tempo-lookup-named 'vtlo) "")
5783 (list 'l "") ;; default value
5784 (list 'l "VTLO=" '(s vtlo)))
5785 '(just-one-space)
5786 (p "<Transit time>: " tpd 'noinsert)
5787 (if (string-equal (tempo-lookup-named 'tpd) "")
5788 (list 'l "TPD=1.0ns") ;; default value
5789 (list 'l "TPD=" '(s tpd)))
5790 '(just-one-space)
5791 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5792 (if (string-equal (tempo-lookup-named 'tpdup) "")
5793 (list 'l "") ;; default value
5794 (list 'l "TPDUP=" '(s tpdup)))
5795 '(just-one-space)
5796 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5797 (if (string-equal (tempo-lookup-named 'tpdown) "")
5798 (list 'l "") ;; default value
5799 (list 'l "TPDOWN=" '(s tpdown)))
5800 '(just-one-space)
5801 (p "<Input capacitance>: " cin 'noinsert)
5802 (if (string-equal (tempo-lookup-named 'cin) "")
5803 (list 'l "CIN=0.0") ;; default value
5804 (list 'l "CIN=" '(s cin)))
5805 '(just-one-space)
5807 "nand3"
5808 "template for inserting an ELDO 3 input NAND gate macromodel"
5809 'spice-tempo-tags)
5811 (tempo-define-template
5812 "spice-eldo-or3"
5813 '("OR3"
5814 (p "[Instance name]: ") " "
5815 (p "[First input]: ") " "
5816 (p "[Second input]: ") " "
5817 (p "[Output]: ") " "
5818 (p "[Model name]: ") " "
5819 (p "<Vhigh>: " vhi 'noinsert)
5820 (if (string-equal (tempo-lookup-named 'vhi) "")
5821 (list 'l "VHI=5.0") ;; default value
5822 (list 'l "VHI=" '(s vhi)))
5823 '(just-one-space)
5824 (p "<Vlow>: " vlo 'noinsert)
5825 (if (string-equal (tempo-lookup-named 'vlo) "")
5826 (list 'l "VLO=0.0") ;; default value
5827 (list 'l "VLO=" '(s vlo)))
5828 '(just-one-space)
5829 (p "<Threshold input voltage>: " vth 'noinsert)
5830 (if (string-equal (tempo-lookup-named 'vth) "")
5831 (list 'l "VTH=2.5") ;; default value
5832 (list 'l "VTH=" '(s vth)))
5833 '(just-one-space)
5834 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5835 (if (string-equal (tempo-lookup-named 'vthi) "")
5836 (list 'l "") ;; default value
5837 (list 'l "VTHI=" '(s vthi)))
5838 '(just-one-space)
5839 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5840 (if (string-equal (tempo-lookup-named 'vtlo) "")
5841 (list 'l "") ;; default value
5842 (list 'l "VTLO=" '(s vtlo)))
5843 '(just-one-space)
5844 (p "<Transit time>: " tpd 'noinsert)
5845 (if (string-equal (tempo-lookup-named 'tpd) "")
5846 (list 'l "TPD=1.0ns") ;; default value
5847 (list 'l "TPD=" '(s tpd)))
5848 '(just-one-space)
5849 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5850 (if (string-equal (tempo-lookup-named 'tpdup) "")
5851 (list 'l "") ;; default value
5852 (list 'l "TPDUP=" '(s tpdup)))
5853 '(just-one-space)
5854 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5855 (if (string-equal (tempo-lookup-named 'tpdown) "")
5856 (list 'l "") ;; default value
5857 (list 'l "TPDOWN=" '(s tpdown)))
5858 '(just-one-space)
5859 (p "<Input capacitance>: " cin 'noinsert)
5860 (if (string-equal (tempo-lookup-named 'cin) "")
5861 (list 'l "CIN=0.0") ;; default value
5862 (list 'l "CIN=" '(s cin)))
5863 '(just-one-space)
5865 "or3"
5866 "template for inserting an ELDO 3 input OR gate macromodel"
5867 'spice-tempo-tags)
5869 (tempo-define-template
5870 "spice-eldo-nor3"
5871 '("NOR3"
5872 (p "[Instance name]: ") " "
5873 (p "[First input]: ") " "
5874 (p "[Second input]: ") " "
5875 (p "[Output]: ") " "
5876 (p "[Model name]: ") " "
5877 (p "<Vhigh>: " vhi 'noinsert)
5878 (if (string-equal (tempo-lookup-named 'vhi) "")
5879 (list 'l "VHI=5.0") ;; default value
5880 (list 'l "VHI=" '(s vhi)))
5881 '(just-one-space)
5882 (p "<Vlow>: " vlo 'noinsert)
5883 (if (string-equal (tempo-lookup-named 'vlo) "")
5884 (list 'l "VLO=0.0") ;; default value
5885 (list 'l "VLO=" '(s vlo)))
5886 '(just-one-space)
5887 (p "<Threshold input voltage>: " vth 'noinsert)
5888 (if (string-equal (tempo-lookup-named 'vth) "")
5889 (list 'l "VTH=2.5") ;; default value
5890 (list 'l "VTH=" '(s vth)))
5891 '(just-one-space)
5892 (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
5893 (if (string-equal (tempo-lookup-named 'vthi) "")
5894 (list 'l "") ;; default value
5895 (list 'l "VTHI=" '(s vthi)))
5896 '(just-one-space)
5897 (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
5898 (if (string-equal (tempo-lookup-named 'vtlo) "")
5899 (list 'l "") ;; default value
5900 (list 'l "VTLO=" '(s vtlo)))
5901 '(just-one-space)
5902 (p "<Transit time>: " tpd 'noinsert)
5903 (if (string-equal (tempo-lookup-named 'tpd) "")
5904 (list 'l "TPD=1.0ns") ;; default value
5905 (list 'l "TPD=" '(s tpd)))
5906 '(just-one-space)
5907 (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
5908 (if (string-equal (tempo-lookup-named 'tpdup) "")
5909 (list 'l "") ;; default value
5910 (list 'l "TPDUP=" '(s tpdup)))
5911 '(just-one-space)
5912 (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
5913 (if (string-equal (tempo-lookup-named 'tpdown) "")
5914 (list 'l "") ;; default value
5915 (list 'l "TPDOWN=" '(s tpdown)))
5916 '(just-one-space)
5917 (p "<Input capacitance>: " cin 'noinsert)
5918 (if (string-equal (tempo-lookup-named 'cin) "")
5919 (list 'l "CIN=0.0") ;; default value
5920 (list 'l "CIN=" '(s cin)))
5921 '(just-one-space)
5923 "nor3"
5924 "template for inserting an ELDO 3 input NOR gate macromodel"
5925 'spice-tempo-tags)
5927 ;; -------------------------
5928 ;; Mixed signal Macromodels
5929 ;; -------------------------
5931 (tempo-define-template
5932 "spice-eldo-adc"
5933 '("ADC"
5934 (p "[Instance name]: ") " "
5935 (p "[Clock]: ") " "
5936 (p "[Analog input]: ") " "
5937 (p "[Digital Outputs from MSB to LSB]: ") " "
5938 (p "<Edge (1/-1)>: " edge 'noinsert)
5939 (if (string-equal (tempo-lookup-named 'edge) "")
5940 (list 'l "EDGE=1") ;; default value
5941 (list 'l "EDGE=-1"))
5942 '(just-one-space)
5943 (p "<Threshold clock voltage>: " vth 'noinsert)
5944 (if (string-equal (tempo-lookup-named 'vth) "")
5945 (list 'l "VTH=2.5") ;; default value
5946 (list 'l "VTH=" '(s vth)))
5947 '(just-one-space)
5948 (p "<Vhigh>: " vhi 'noinsert)
5949 (if (string-equal (tempo-lookup-named 'vhi) "")
5950 (list 'l "VHI=5.0") ;; default value
5951 (list 'l "VHI=" '(s vhi)))
5952 '(just-one-space)
5953 (p "<Vlow>: " vlo 'noinsert)
5954 (if (string-equal (tempo-lookup-named 'vlo) "")
5955 (list 'l "VLO=0.0") ;; default value
5956 (list 'l "VLO=" '(s vlo)))
5957 '(just-one-space)
5958 (p "<Analog input lower voltage>: " vinf 'noinsert)
5959 (if (string-equal (tempo-lookup-named 'vinf) "")
5960 (list 'l "VINF=0.0") ;; default value
5961 (list 'l "VTHI=" '(s vinf)))
5962 '(just-one-space)
5963 (p "<Analog input higher voltage>: " vsup 'noinsert)
5964 (if (string-equal (tempo-lookup-named 'vsup) "")
5965 (list 'l "VSUP=5.0") ;; default value
5966 (list 'l "VSUP=" '(s vsup)))
5967 '(just-one-space)
5968 (p "<Output bits commutation time>: " tcom 'noinsert)
5969 (if (string-equal (tempo-lookup-named 'tcom) "")
5970 (list 'l "TCOM=1.0ns") ;; default value
5971 (list 'l "TCOM=" '(s tcom)))
5972 '(just-one-space)
5973 (p "<Transit time>: " tpd 'noinsert)
5974 (if (string-equal (tempo-lookup-named 'tpd) "")
5975 (list 'l "TPD=10ns") ;; default value
5976 (list 'l "TPD=" '(s tpd)))
5977 '(just-one-space)
5979 "adc"
5980 "template for inserting an ELDO Analog to Digital Converter macromodel"
5981 'spice-tempo-tags)
5983 (tempo-define-template
5984 "spice-eldo-dac"
5985 '("DAC"
5986 (p "[Instance name]: ") " "
5987 (p "[Clock]: ") " "
5988 (p "[Digital inputs from MSB to LSB]: ") " "
5989 (p "[Analog output]: ") " "
5990 (p "<Edge (1/-1)>: " edge 'noinsert)
5991 (if (string-equal (tempo-lookup-named 'edge) "")
5992 (list 'l "EDGE=1") ;; default value
5993 (list 'l "EDGE=-1"))
5994 '(just-one-space)
5995 (p "<Threshold clock voltage>: " vth 'noinsert)
5996 (if (string-equal (tempo-lookup-named 'vth) "")
5997 (list 'l "VTH=2.5") ;; default value
5998 (list 'l "VTH=" '(s vth)))
5999 '(just-one-space)
6000 (p "<Threshold input voltage>: " vtin 'noinsert)
6001 (if (string-equal (tempo-lookup-named 'vtin) "")
6002 (list 'l "VTIN=2.5") ;; default value
6003 (list 'l "VTIN=" '(s vtin)))
6004 '(just-one-space)
6005 (p "<Analog Output Vhigh>: " vhi 'noinsert)
6006 (if (string-equal (tempo-lookup-named 'vhi) "")
6007 (list 'l "VHI=5.0") ;; default value
6008 (list 'l "VHI=" '(s vhi)))
6009 '(just-one-space)
6010 (p "<Analog Output Vlow>: " vlo 'noinsert)
6011 (if (string-equal (tempo-lookup-named 'vlo) "")
6012 (list 'l "VLO=0.0") ;; default value
6013 (list 'l "VLO=" '(s vlo)))
6014 '(just-one-space)
6015 (p "<Transit time>: " tpd 'noinsert)
6016 (if (string-equal (tempo-lookup-named 'tpd) "")
6017 (list 'l "TPD=10ns") ;; default value
6018 (list 'l "TPD=" '(s tpd)))
6019 '(just-one-space)
6020 (p "<Output slope (V/s)>: " sl 'noinsert)
6021 (if (string-equal (tempo-lookup-named 'sl) "")
6022 (list 'l "SL=10e8") ;; default value
6023 (list 'l "SL=" '(s tcom)))
6024 '(just-one-space)
6026 "DAC"
6027 "template for inserting an ELDO Digital to Analog Converter macromodel"
6028 'spice-tempo-tags)
6030 ;; -------------------------
6031 ;; Switched cap Macromodels
6032 ;; -------------------------
6034 (tempo-define-template
6035 "spice-eldo-switchcap-opa"
6036 '("OPA"
6037 (p "[Instance name]: ") " "
6038 (p "[Positive input]: ") " "
6039 (p "[Negative input]: ") " "
6040 (p "[Positive Output]: ") " "
6041 (p "[Negative Output]: ") " "
6042 (p "[Model name]: ") " "
6043 (p "<Input offset>: " voff 'noinsert)
6044 (if (string-equal (tempo-lookup-named 'voff) "")
6045 (list 'l "VOFF=0.0") ;; default value
6046 (list 'l "VOFF=" '(s voff)))
6047 '(just-one-space)
6048 (p "<Slew rate (V/s)>: " sl 'noinsert)
6049 (if (string-equal (tempo-lookup-named 'sl) "")
6050 (list 'l "SL=1e6") ;; default value
6051 (list 'l "SL=" '(s voff)))
6052 '(just-one-space)
6053 (p "<Gain>: " gain 'noinsert)
6054 (if (string-equal (tempo-lookup-named 'gain) "")
6055 (list 'l "GAIN=1e5") ;; default value
6056 (list 'l "GAIN=" '(s gain)))
6057 '(just-one-space)
6058 (p "<Input capacitance>: " cin 'noinsert)
6059 (if (string-equal (tempo-lookup-named 'cin) "")
6060 (list 'l "CIN=0") ;; default value
6061 (list 'l "CIN=" '(s cin)))
6062 '(just-one-space)
6063 (p "<Output resistance>: " rs 'noinsert)
6064 (if (string-equal (tempo-lookup-named 'rs) "")
6065 (list 'l "RS=10e6") ;; default value
6066 (list 'l "RS=" '(s rs)))
6067 '(just-one-space)
6068 (p "<Symmetrical saturation voltage>: " vsat 'noinsert)
6069 (if (string-equal (tempo-lookup-named 'vsat) "")
6070 (list 'l "VSAT=5.0") ;; default value
6071 (list 'l "VSAT=" '(s vsat)))
6072 '(just-one-space)
6073 (p "<Asymmetrical saturation voltage>: " vsatm 'noinsert)
6074 (if (string-equal (tempo-lookup-named 'vsatm) "")
6075 (list 'l "VSATM=5.0") ;; default value
6076 (list 'l "VSATM=" '(s vsatm)))
6077 '(just-one-space)
6078 (p "<Cutoff frequency (double stage only)>: " fc 'noinsert)
6079 (if (string-equal (tempo-lookup-named 'fc) "")
6080 (list 'l "FC=1k") ;; default value
6081 (list 'l "FC=" '(s fc)))
6082 '(just-one-space)
6083 (p "<Non-dominant pole (single stage only)>: " fndp 'noinsert)
6084 (if (string-equal (tempo-lookup-named 'fndp) "")
6085 (list 'l "FNDP=1k") ;; default value
6086 (list 'l "FNDP=" '(s fndp)))
6087 '(just-one-space)
6088 (p "<Max current>: " imax 'noinsert)
6089 (if (string-equal (tempo-lookup-named 'imax) "")
6090 (list 'l "IMAX=100mA") ;; default value
6091 (list 'l "IMAX=" '(s imax)))
6092 '(just-one-space)
6093 (p "<Common mode rejection ratio>: " cmrr 'noinsert)
6094 (if (string-equal (tempo-lookup-named 'cmrr) "")
6095 (list 'l "CMRR=0.0") ;; default value
6096 (list 'l "CMRR=" '(s cmrr)))
6098 "opa"
6099 "template for inserting an ELDO differential single or double stage opamp"
6100 'spice-tempo-tags
6103 (tempo-define-template
6104 "spice-eldo-switch"
6105 '("S"
6106 (p "[Instance name]: ") " "
6107 (p "[Controlling node]: ") " "
6108 (p "[Node 1]: ") " "
6109 (p "[Node 2]: ") " "
6110 (p "[Model name]: ") " "
6111 (p "<RON resistance>: " ron 'noinsert)
6112 (if (string-equal (tempo-lookup-named 'ron) "")
6113 (list 'l "RON=1k") ;; default value
6114 (list 'l "RON=" '(s ron)))
6115 '(just-one-space)
6116 (p "<Overlap capacitance>: " crec 'noinsert)
6117 (if (string-equal (tempo-lookup-named 'crec) "")
6118 (list 'l "CREC=0") ;; default value
6119 (list 'l "CREC=" '(s crec)))
6121 "switch"
6122 "template for inserting an ELDO switch macromodel"
6123 'spice-tempo-tags
6127 ;; Layla constructs
6129 (tempo-define-template
6130 "layla-port"
6131 '(".port "
6132 (p "[Name of port]: ") " "
6133 (p "[Name of net]: ") " "
6135 "layla-port"
6136 "template for inserting a Layla port"
6137 'spice-tempo-tags)
6139 (tempo-define-template
6140 "layla-performance"
6141 '(".performance "
6142 (p "[Name of performance]: ") " "
6143 (p "[Nominal value]: ") " \n+"
6144 (p "[Weight (alfa)]: ") " "
6145 ; (p "[Weight (alfa)]: ") " "
6147 "layla-performance"
6148 "template for inserting a Layla performance"
6149 'spice-tempo-tags)
6151 (tempo-define-template
6152 "layla-net"
6153 '(".net "
6154 (p "[Name of net]: ") " "
6156 "layla-net"
6157 "template for inserting a Layla net"
6158 'spice-tempo-tags)
6160 (tempo-define-template
6161 "layla-bus"
6162 '(".bus "
6163 (p "[Name of bus]: ") " "
6165 "layla-bus"
6166 "template for inserting a Layla bus"
6167 'spice-tempo-tags)
6169 (defmacro spice-layla-function-template (name type)
6170 "Create a layla tempo define for NAME and TYPE."
6171 `(let (p_prompt)
6172 (setq p_prompt (concat "[Name of " ,name "]: "))
6173 (tempo-define-template
6174 (concat "layla-" ,name "-" ,type)
6175 (list (concat "." ,name "_" ,type "_param(")
6176 (list 'p p_prompt) ", "
6177 '(p "[Name of parameter]: ") ", "
6178 '(p "[Value of parameter]: ") ")"
6180 (concat "layla-" ,name "-" ,type)
6181 (concat "template for inserting a " ,type " parameter for a Layla " ,name)
6182 'spice-tempo-tags)))
6184 (spice-layla-function-template "bus" "double")
6185 (spice-layla-function-template "bus" "integer")
6186 (spice-layla-function-template "bus" "string")
6187 (spice-layla-function-template "device" "double")
6188 (spice-layla-function-template "device" "integer")
6189 (spice-layla-function-template "device" "string")
6190 (spice-layla-function-template "net" "double")
6191 (spice-layla-function-template "net" "integer")
6192 (spice-layla-function-template "net" "string")
6193 (spice-layla-function-template "placement" "double")
6194 (spice-layla-function-template "placement" "integer")
6195 (spice-layla-function-template "placement" "string")
6196 (spice-layla-function-template "port" "double")
6197 (spice-layla-function-template "port" "integer")
6198 (spice-layla-function-template "port" "string")
6199 (spice-layla-function-template "symmetry" "double")
6200 (spice-layla-function-template "symmetry" "integer")
6201 (spice-layla-function-template "symmetry" "string")
6204 ;;------------------------------------------------------------
6205 ;; Abbrev hook bindings (taken from eldo-mode)
6207 (defvar spice-mode-abbrev-table nil
6208 "Abbrev table to use in `spice-mode' buffers.")
6210 ;; the table, global init inline here:
6211 (if spice-mode-abbrev-table
6213 (let ((ac abbrevs-changed))
6214 (define-abbrev-table 'spice-mode-abbrev-table ())
6215 ;; passive elements:
6217 ;; resistors
6218 (define-abbrev spice-mode-abbrev-table "r" "" 'tempo-template-spice-spice2g6-resistor)
6219 (define-abbrev spice-mode-abbrev-table "rss" "" 'tempo-template-spice-spice3-semiconductor-resistor)
6220 (define-abbrev spice-mode-abbrev-table "re" "" 'tempo-template-spice-eldo-resistor)
6221 (define-abbrev spice-mode-abbrev-table "ree" "" 'tempo-template-spice-eldo-expression-resistor)
6222 (define-abbrev spice-mode-abbrev-table "res" "" 'tempo-template-spice-eldo-semiconductor-resistor)
6223 (define-abbrev spice-mode-abbrev-table "rh" "" 'tempo-template-spice-hspice-resistor)
6224 (define-abbrev spice-mode-abbrev-table "rl" "" 'tempo-template-spice-layla-resistor)
6226 ;; capacitors
6227 (define-abbrev spice-mode-abbrev-table "c" "" 'tempo-template-spice-spice2g6-capacitor)
6228 (define-abbrev spice-mode-abbrev-table "css" "" 'tempo-template-spice-spice3-semiconductor-capacitor)
6229 (define-abbrev spice-mode-abbrev-table "ce" "" 'tempo-template-spice-eldo-capacitor)
6230 (define-abbrev spice-mode-abbrev-table "cee" "" 'tempo-template-spice-eldo-expression-capacitor)
6231 (define-abbrev spice-mode-abbrev-table "ch" "" 'tempo-template-spice-hspice-capacitor)
6232 (define-abbrev spice-mode-abbrev-table "cl" "" 'tempo-template-spice-layla-capacitor)
6234 ;; inductors
6235 (define-abbrev spice-mode-abbrev-table "l" "" 'tempo-template-spice-spice2g6-inductor)
6236 (define-abbrev spice-mode-abbrev-table "le" "" 'tempo-template-spice-eldo-inductor)
6237 (define-abbrev spice-mode-abbrev-table "lee" "" 'tempo-template-spice-eldo-expression-inductor)
6238 (define-abbrev spice-mode-abbrev-table "lh" "" 'tempo-template-spice-hspice-inductor)
6239 (define-abbrev spice-mode-abbrev-table "ll" "" 'tempo-template-spice-layla-inductor)
6241 ;; coupled inductors
6242 (define-abbrev spice-mode-abbrev-table "k" "" 'tempo-template-spice-spice2g6-coupled-inductors)
6244 ;; lossless transmission lines
6245 (define-abbrev spice-mode-abbrev-table "t" "" 'tempo-template-spice-spice2g6-lossless-transmission)
6246 (define-abbrev spice-mode-abbrev-table "te" "" 'tempo-template-spice-spice2g6-lossless-transmission)
6247 (define-abbrev spice-mode-abbrev-table "th" "" 'tempo-template-spice-hspice-lossless-transmission)
6249 ;; lossy transmission lines
6250 (define-abbrev spice-mode-abbrev-table "o" "" 'tempo-template-spice-spice2g6-lossy-transmission)
6251 ; spice3 rcline
6252 (define-abbrev spice-mode-abbrev-table "rcls" "" 'tempo-template-spice-spice3-rcline)
6253 ; eldo rc-line
6254 (define-abbrev spice-mode-abbrev-table "rcle" "" 'tempo-template-spice-eldo-rcline)
6255 ; eldo lossy transmission line
6256 ; not implemented
6258 ;; active elements:
6260 ;; diodes
6261 (define-abbrev spice-mode-abbrev-table "d" "" 'tempo-template-spice-spice2g6-diode)
6262 (define-abbrev spice-mode-abbrev-table "de" "" 'tempo-template-spice-eldo-diode)
6263 (define-abbrev spice-mode-abbrev-table "dh" "" 'tempo-template-spice-hspice-diode)
6264 (define-abbrev spice-mode-abbrev-table "dl" "" 'tempo-template-spice-layla-diode)
6266 ;; bipolars
6267 (define-abbrev spice-mode-abbrev-table "q" "" 'tempo-template-spice-spice2g6-bipolar)
6268 (define-abbrev spice-mode-abbrev-table "qe" "" 'tempo-template-spice-eldo-bipolar)
6269 (define-abbrev spice-mode-abbrev-table "qh" "" 'tempo-template-spice-hspice-bipolar)
6272 ;; jfets
6273 (define-abbrev spice-mode-abbrev-table "j" "" 'tempo-template-spice-spice2g6-jfet)
6274 (define-abbrev spice-mode-abbrev-table "je" "" 'tempo-template-spice-eldo-jfet)
6275 (define-abbrev spice-mode-abbrev-table "jh" "" 'tempo-template-spice-hspice-jfet)
6278 ;; mosfets
6279 (define-abbrev spice-mode-abbrev-table "m" "" 'tempo-template-spice-spice2g6-mosfet)
6280 (define-abbrev spice-mode-abbrev-table "me" "" 'tempo-template-spice-eldo-mosfet)
6281 (define-abbrev spice-mode-abbrev-table "mh" "" 'tempo-template-spice-hspice-mosfet)
6282 (define-abbrev spice-mode-abbrev-table "ml" "" 'tempo-template-spice-layla-mosfet)
6285 ;; mesfets
6286 (define-abbrev spice-mode-abbrev-table "z" "" 'tempo-template-spice-spice2g6-mesfet)
6288 ;; subcircuits
6289 (define-abbrev spice-mode-abbrev-table "sub" "" 'tempo-template-spice-spice2g6-subckt)
6291 ;; controlled sources
6292 (define-abbrev spice-mode-abbrev-table "vcvs" "" 'tempo-template-spice-spice2g6-vcvs)
6293 (define-abbrev spice-mode-abbrev-table "e" "" 'tempo-template-spice-spice2g6-vcvs)
6294 (define-abbrev spice-mode-abbrev-table "ccvs" "" 'tempo-template-spice-spice2g6-ccvs)
6295 (define-abbrev spice-mode-abbrev-table "h" "" 'tempo-template-spice-spice2g6-ccvs)
6296 (define-abbrev spice-mode-abbrev-table "vccs" "" 'tempo-template-spice-spice2g6-vccs)
6297 (define-abbrev spice-mode-abbrev-table "g" "" 'tempo-template-spice-spice2g6-vccs)
6298 (define-abbrev spice-mode-abbrev-table "cccs" "" 'tempo-template-spice-spice2g6-cccs)
6299 (define-abbrev spice-mode-abbrev-table "f" "" 'tempo-template-spice-spice2g6-cccs)
6301 ;; transient signals
6302 (define-abbrev spice-mode-abbrev-table "pwl" "" '(spice-pwl))
6303 (define-abbrev spice-mode-abbrev-table "pu" "" 'tempo-template-spice-pulse)
6304 ;(define-abbrev spice-mode-abbrev-table "'su" "" 'tempo-template-spice-subckt)
6305 ;(define-abbrev spice-mode-abbrev-table "'ac" "" 'tempo-template-spice-ac)
6306 (define-abbrev spice-mode-abbrev-table "sin" "" 'tempo-template-spice-sine)
6307 ;(define-abbrev spice-mode-abbrev-table "'sffm" "" 'tempo-template-spice-hspice-sffm)
6308 (define-abbrev spice-mode-abbrev-table "exp" "" 'tempo-template-spice-exp)
6309 (define-abbrev spice-mode-abbrev-table "noi" "" 'tempo-template-spice-eldo-noise)
6310 (define-abbrev spice-mode-abbrev-table "pat" "" 'tempo-template-spice-eldo-pattern)
6312 ;; behavioral models
6313 ;; eldo
6314 (define-abbrev spice-mode-abbrev-table "comp" "" 'tempo-template-spice-eldo-comp)
6315 (define-abbrev spice-mode-abbrev-table "compd" "" 'tempo-template-spice-eldo-compd)
6316 (define-abbrev spice-mode-abbrev-table "opa0" "" 'tempo-template-spice-eldo-linear-opa0)
6317 (define-abbrev spice-mode-abbrev-table "opa0d" "" 'tempo-template-spice-eldo-linear-opa0d)
6318 (define-abbrev spice-mode-abbrev-table "opa1" "" 'tempo-template-spice-eldo-linear-opa0)
6319 (define-abbrev spice-mode-abbrev-table "opa1d" "" 'tempo-template-spice-eldo-linear-opa0d)
6320 (define-abbrev spice-mode-abbrev-table "opa2" "" 'tempo-template-spice-eldo-linear-opa0)
6321 (define-abbrev spice-mode-abbrev-table "opa2d" "" 'tempo-template-spice-eldo-linear-opa0d)
6323 ;; extracts
6324 (define-abbrev spice-mode-abbrev-table "phmag" "" 'tempo-template-spice-eldo-phmag)
6325 (define-abbrev spice-mode-abbrev-table "gmag" "" 'tempo-template-spice-eldo-gmag)
6326 (define-abbrev spice-mode-abbrev-table "fc" "" 'tempo-template-spice-eldo-fc)
6327 (define-abbrev spice-mode-abbrev-table "ugfc" "" 'tempo-template-spice-eldo-ugfc)
6328 (define-abbrev spice-mode-abbrev-table "tf" "" 'tempo-template-spice-eldo-period)
6329 (define-abbrev spice-mode-abbrev-table "tfm" "" 'tempo-template-spice-eldo-period-macro)
6330 (define-abbrev spice-mode-abbrev-table "dc" "" 'tempo-template-spice-eldo-duty-macro)
6331 (define-abbrev spice-mode-abbrev-table "he" "" 'tempo-template-spice-eldo-circuit-header)
6332 (setq abbrevs-changed ac)))
6335 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6336 ;;; Menus
6337 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6339 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6340 ;; Spice menu (using `easy-menu.el')
6342 (defun spice-create-mode-menu ()
6343 "Create Spice Mode menu."
6344 (append
6345 (list
6346 "Spice"
6347 '("Edit"
6348 ["Comment Region" comment-region (and (mark) (not buffer-read-only))]
6349 ["Uncomment Region" spice-uncomment-region (and (mark) (not buffer-read-only))]
6350 ["Comment bar" (spice-comment-bar 't) (not buffer-read-only)]
6351 ["Fill Paragraph (Break Line)" fill-paragraph (not buffer-read-only)]
6352 ["Join line" spice-delete-indentation (not buffer-read-only)]
6353 "--"
6354 ["Fontify..." font-lock-flush t]
6355 "--"
6356 ["(Re)activate File links..." spice-colorize-libraries-buffer t]
6357 ["Load include/lib files..." spice-load-include-files (assoc spice-imenu-libraries-submenu-name imenu--index-alist)]
6358 ["Load output file" spice-load-output-file (spice-output-file-p)]
6359 ["Unload all other spice files" spice-unload-other-decks t]
6360 "--"
6361 ["Replace with .guess stats" spice-replace-with-guess-statements (and (mark) (not buffer-read-only))]
6362 ["Replace with .nodeset stats" spice-replace-with-nodeset-statements (and (mark) (not buffer-read-only))]
6363 "--"
6364 ["Hide Comment Regions" spice-hide-all-comments (spice-hide-all-comments-p)]
6365 ["Unhide Comment Regions" spice-unhide-all-comments spice-some-comment-regions-are-hidden]
6366 "--"
6367 ["Search .subckt def" spice-search-subckt t]
6368 "--"
6369 ["Add Changelog Entry" spice-add-changelog-entry (not buffer-read-only)]
6371 (list
6372 "Simulate"
6373 ;; ["Simulate" compile t]
6374 ["Simulate" spice-compile (and buffer-file-name (not (spice-output-p)))]
6375 ["Stop Simulation" kill-compilation (condition-case ()
6376 (get-buffer-process
6377 (compilation-find-buffer))
6378 (error nil))]
6379 "--"
6380 ["Next Error..." spice-next-error t]
6381 ["Previous Error..." spice-previous-error t]
6382 "--"
6383 (append
6384 '("Simulator")
6385 ;; example code taken literally from vhdl-mode.el !
6386 ;; add menu entries for defined simulators
6387 (let ((simu-alist spice-simulator-alist) menu-alist name)
6388 (while simu-alist
6389 (setq name (car (car simu-alist)))
6390 (setq menu-alist (cons (vector name
6391 (list 'spice-set-simulator name)
6392 :style 'radio :selected
6393 ; (list 'equal 'spice-simulator name)
6394 (list 'equal '(spice-get-simulator) name)
6396 menu-alist))
6397 (setq simu-alist (cdr simu-alist)))
6398 (setq menu-alist
6399 (cons '["Add Simulator..."
6400 (customize-variable 'spice-simulator-alist) t]
6401 (cons "--" menu-alist)))
6402 (nreverse menu-alist))))
6403 (list
6404 "Waveform viewer"
6405 ["View" spice-run-waveform-viewer
6406 (and spice-waveform-viewer-alist-entry
6407 buffer-file-name)]
6408 ["Kill Waveform Viewer" spice-kill-waveform-viewer
6409 (condition-case ()
6410 (get-buffer-process
6411 (spice-waveform-buffer-name-function nil))
6412 (error nil))]
6413 "--"
6414 (append
6415 '("Waveform Viewer")
6416 ;; example code taken literally from vhdl-mode.el !
6417 ;; add menu entries for defined simulators
6418 (let ((wave-alist spice-waveform-viewer-alist) menu-alist name)
6419 (while wave-alist
6420 (setq name (car (car wave-alist)))
6421 (setq menu-alist (cons (vector name
6422 (list 'spice-set-waveform-viewer name)
6423 :style 'radio :selected
6424 ;(list 'equal 'spice-simulator name)
6425 (list 'equal
6426 '(spice-get-waveform-viewer)
6427 name))
6428 menu-alist))
6429 (setq wave-alist (cdr wave-alist)))
6430 (setq menu-alist
6431 (cons '["Add Waveform Viewer..."
6432 (customize-variable 'spice-waveform-viewer-alist) t]
6433 (cons "--" menu-alist)))
6434 (nreverse menu-alist))))
6435 "--"
6436 '("Passive Elements"
6437 ("Resistors"
6438 ["Spice2g6 Resistor" tempo-template-spice-spice2g6-resistor t]
6439 ["Spice3 Silicon Resistor" tempo-template-spice-spice3-semiconductor-resistor t]
6440 ["Eldo Resistor" tempo-template-spice-eldo-resistor (spice-standard-p 'eldo)]
6441 ["Eldo Expression Resistor" tempo-template-spice-eldo-expression-resistor (spice-standard-p 'eldo)]
6442 ["Eldo Silicon Resistor" tempo-template-spice-eldo-semiconductor-resistor (spice-standard-p 'eldo)]
6443 ["Hspice Resistor" tempo-template-spice-hspice-resistor (spice-standard-p 'hspice)]
6444 ["Layla Resistor" tempo-template-spice-layla-resistor (spice-standard-p 'layla)]
6446 ("Capacitors"
6447 ["Spice2g6 Capacitor" tempo-template-spice-spice2g6-capacitor t]
6448 ["Spice3 Silicon Capacitor" tempo-template-spice-spice3-semiconductor-capacitor t]
6449 ["Eldo Capacitor" tempo-template-spice-eldo-capacitor (spice-standard-p 'eldo)]
6450 ["Eldo Expression Capacitor" tempo-template-spice-eldo-expression-capacitor (spice-standard-p 'eldo)]
6451 ["Hspice Capacitor" tempo-template-spice-hspice-capacitor (spice-standard-p 'hspice)]
6452 ["Layla Capacitor" tempo-template-spice-layla-capacitor (spice-standard-p 'layla)]
6454 ("Inductors"
6455 ["Spice2g6 Inductor" tempo-template-spice-spice2g6-inductor t]
6456 ["Spice2g6 Coupled Inductors" tempo-template-spice-spice2g6-coupled-inductors t]
6457 ["Eldo Inductor" tempo-template-spice-eldo-inductor (spice-standard-p 'eldo)]
6458 ["Eldo Expression Inductor" tempo-template-spice-eldo-expression-inductor (spice-standard-p 'eldo)]
6459 ["Hspice Inductor" tempo-template-spice-hspice-inductor (spice-standard-p 'hspice)]
6460 ["Layla Inductor" tempo-template-spice-layla-inductor (spice-standard-p 'layla)]
6462 ("Transmission lines"
6463 ["Spice2g6 Lossless" tempo-template-spice-spice2g6-lossless-transmission t]
6464 ["Eldo Lossless" tempo-template-spice-eldo-lossless-transmission (spice-standard-p 'eldo)]
6465 ["Hspice Lossless" tempo-template-spice-hspice-lossless-transmission (spice-standard-p 'hspice)]
6466 ["Spice2g6 Lossy" tempo-template-spice-spice2g6-lossy-transmission t]
6467 ["Spice3 RC line" tempo-template-spice-spice3-rcline t]
6468 ["Eldo RC line" tempo-template-spice-eldo-rcline (spice-standard-p 'eldo)]
6471 '("Active Elements"
6472 ("Diodes"
6473 ["Spice2g6 Diode" tempo-template-spice-spice2g6-diode t]
6474 ["Eldo Diode" tempo-template-spice-eldo-diode (spice-standard-p 'eldo)]
6475 ["Hspice Diode" tempo-template-spice-hspice-diode (spice-standard-p 'hspice)]
6476 ["Layla Diode" tempo-template-spice-layla-diode (spice-standard-p 'layla)]
6478 ("Bipolars"
6479 ["Spice2g6 Bipolar" tempo-template-spice-spice2g6-bipolar t]
6480 ["Eldo Bipolar" tempo-template-spice-eldo-bipolar (spice-standard-p 'eldo)]
6481 ["Hspice Bipolar" tempo-template-spice-hspice-bipolar (spice-standard-p 'hspice)]
6483 ("Jfets & Mesfets"
6484 ["Spice2g6 Jfet" tempo-template-spice-spice2g6-jfet t]
6485 ["Spice2g6 Mesfet" tempo-template-spice-spice2g6-mesfet t]
6486 ["Eldo Jfet" tempo-template-spice-eldo-jfet (spice-standard-p 'eldo)]
6487 ["Hspice Jfet" tempo-template-spice-hspice-jfet (spice-standard-p 'hspice)]
6489 ("Mosfets"
6490 ["Spice2g6 Mosfet" tempo-template-spice-spice2g6-mosfet t]
6491 ["Eldo Mosfet" tempo-template-spice-eldo-mosfet (spice-standard-p 'eldo)]
6492 ["Hspice Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'hspice)]
6493 ["Layla Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'layla)]
6496 '("Controlled Sources"
6497 ["Spice2g6 VCVS" tempo-template-spice-spice2g6-vcvs t]
6498 ["Spice2g6 CCVS" tempo-template-spice-spice2g6-ccvs t]
6499 ["Spice2g6 VCCS" tempo-template-spice-spice2g6-vccs t]
6500 ["Spice2g6 CCCS" tempo-template-spice-spice2g6-ccvs t]
6502 '("Waveforms"
6503 ["PWL" (spice-pwl) t]
6504 ["pulse" tempo-template-spice-pulse t]
6505 ; ["ac" tempo-template-eldo-ac t]
6506 ["sine" tempo-template-spice-sine t]
6507 ["exp" tempo-template-spice-exp t]
6508 ["hspice sffm" tempo-template-spice-hspice-sffm (spice-standard-p 'hspice)]
6509 ["hspice am" tempo-template-spice-hspice-am (spice-standard-p 'hspice)]
6510 ["eldo pattern" tempo-template-spice-eldo-pattern (spice-standard-p 'eldo)]
6511 ["eldo noise" tempo-template-spice-eldo-noise (spice-standard-p 'eldo)]
6512 ["eldoRF four" tempo-template-spice-eldorf-four (spice-standard-p 'eldorf)]
6513 ["eldoRF fpulse" tempo-template-spice-eldorf-fpulse (spice-standard-p 'eldorf)]
6515 "--"
6516 '("Eldo Macromodels"
6517 ("Analog"
6518 ["SO Comparator" tempo-template-spice-eldo-comp (spice-standard-p 'eldo)]
6519 ["DO Comparator" tempo-template-spice-eldo-compd (spice-standard-p 'eldo)]
6520 ["SO Linear Opamp" tempo-template-spice-eldo-linear-opa0 (spice-standard-p 'eldo)]
6521 ["DO Linear Opamp" tempo-template-spice-eldo-linear-opa0d (spice-standard-p 'eldo)]
6522 ["SO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1 (spice-standard-p 'eldo)]
6523 ["DO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1d (spice-standard-p 'eldo)]
6524 ["SO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2 (spice-standard-p 'eldo)]
6525 ["DO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2d (spice-standard-p 'eldo)]
6526 ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
6527 ["Saturating Resistor" tempo-template-spice-eldo-satr (spice-standard-p 'eldo)]
6528 ["Voltage Limiter" tempo-template-spice-eldo-satv (spice-standard-p 'eldo)]
6529 ["Voltage cont. switch" tempo-template-spice-eldo-vswitch (spice-standard-p 'eldo)]
6530 ["Current cont. switch" tempo-template-spice-eldo-cswitch (spice-standard-p 'eldo)]
6531 ["Triangular to sine converter" tempo-template-spice-eldo-tri2sin (spice-standard-p 'eldo)]
6532 ["Staircase generator" tempo-template-spice-eldo-stairgen (spice-standard-p 'eldo)]
6533 ["Sawtooth generator" tempo-template-spice-eldo-sawgen (spice-standard-p 'eldo)]
6534 ["Triangle generator" tempo-template-spice-eldo-trigen (spice-standard-p 'eldo)]
6535 ["Amplitude modulator" tempo-template-spice-eldo-amm (spice-standard-p 'eldo)]
6536 ["Pulse amplitude modulator" tempo-template-spice-eldo-pam (spice-standard-p 'eldo)]
6537 ["Sample&Hold" tempo-template-spice-eldo-saho (spice-standard-p 'eldo)]
6538 ["Track&Hold" tempo-template-spice-eldo-trho (spice-standard-p 'eldo)]
6539 ["Peak Detector" tempo-template-spice-eldo-peakd (spice-standard-p 'eldo)]
6540 ["SO Level Detector" tempo-template-spice-eldo-levdso (spice-standard-p 'eldo)]
6541 ["DO Level Detector" tempo-template-spice-eldo-levddo (spice-standard-p 'eldo)]
6542 ["Log Amplifier" tempo-template-spice-eldo-logamp (spice-standard-p 'eldo)]
6543 ["Antilog Amplifier" tempo-template-spice-eldo-antilog (spice-standard-p 'eldo)]
6544 ["Differentiator" tempo-template-spice-eldo-diff (spice-standard-p 'eldo)]
6545 ["Integrator" tempo-template-spice-eldo-integ (spice-standard-p 'eldo)]
6546 ["Add/Sub/Mult/Div" tempo-template-spice-eldo-adder (spice-standard-p 'eldo)]
6548 ("Digital"
6549 ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
6550 ["Inverter" tempo-template-spice-eldo-inv (spice-standard-p 'eldo)]
6551 ["XOR gate" tempo-template-spice-eldo-xor (spice-standard-p 'eldo)]
6552 ["2 input AND gate" tempo-template-spice-eldo-and2 (spice-standard-p 'eldo)]
6553 ["2 input NAND gate" tempo-template-spice-eldo-nand2 (spice-standard-p 'eldo)]
6554 ["2 input OR gate" tempo-template-spice-eldo-or2 (spice-standard-p 'eldo)]
6555 ["2 input NOR gate" tempo-template-spice-eldo-nor2 (spice-standard-p 'eldo)]
6556 ["3 input AND gate" tempo-template-spice-eldo-and3 (spice-standard-p 'eldo)]
6557 ["3 input NAND gate" tempo-template-spice-eldo-nand3 (spice-standard-p 'eldo)]
6558 ["3 input OR gate" tempo-template-spice-eldo-or3 (spice-standard-p 'eldo)]
6559 ["3 input NOR gate" tempo-template-spice-eldo-nor3 (spice-standard-p 'eldo)]
6561 ("Mixed Signal"
6562 ["AD Converter" tempo-template-spice-eldo-adc (spice-standard-p 'eldo)]
6563 ["DA Converter" tempo-template-spice-eldo-dac (spice-standard-p 'eldo)]
6565 ("Switched Cap"
6566 ["Opamp" tempo-template-spice-eldo-switchcap-opa (spice-standard-p 'eldo)]
6567 ["Switch" tempo-template-spice-eldo-switch (spice-standard-p 'eldo)]
6570 "--"
6571 '("Layla Objects"
6572 ["Port" tempo-template-layla-port (spice-standard-p 'layla)]
6573 ["Performance" tempo-template-layla-performance (spice-standard-p 'layla)]
6574 ["Net" tempo-template-layla-net (spice-standard-p 'layla)]
6575 ["Bus" tempo-template-layla-bus (spice-standard-p 'layla)]
6576 ; ["ac" tempo-template-eldo-ac t]
6578 '("Layla Properties"
6579 ("Port"
6580 ["Port double" tempo-template-layla-port-double (spice-standard-p 'layla)]
6581 ["Port integer" tempo-template-layla-port-integer (spice-standard-p 'layla)]
6582 ["Port string" tempo-template-layla-port-string (spice-standard-p 'layla)]
6584 ("Placement"
6585 ["Placement double" tempo-template-layla-placement-double (spice-standard-p 'layla)]
6586 ["Placement integer" tempo-template-layla-placement-integer (spice-standard-p 'layla)]
6587 ["Placement string" tempo-template-layla-placement-string (spice-standard-p 'layla)]
6589 ("Symmetry"
6590 ["Symmetry double" tempo-template-layla-symmetry-double (spice-standard-p 'layla)]
6591 ["Symmetry integer" tempo-template-layla-symmetry-integer (spice-standard-p 'layla)]
6592 ["Symmetry string" tempo-template-layla-symmetry-string (spice-standard-p 'layla)]
6594 ("Net"
6595 ["Net double" tempo-template-layla-net-double (spice-standard-p 'layla)]
6596 ["Net integer" tempo-template-layla-net-integer (spice-standard-p 'layla)]
6597 ["Net string" tempo-template-layla-net-string (spice-standard-p 'layla)]
6599 ("Device"
6600 ["Device double" tempo-template-layla-device-double (spice-standard-p 'layla)]
6601 ["Device integer" tempo-template-layla-device-integer (spice-standard-p 'layla)]
6602 ["Device string" tempo-template-layla-device-string (spice-standard-p 'layla)]
6604 ("Bus"
6605 ["Bus double" tempo-template-layla-bus-double (spice-standard-p 'layla)]
6606 ["Bus integer" tempo-template-layla-bus-integer (spice-standard-p 'layla)]
6607 ["Bus string" tempo-template-layla-bus-string (spice-standard-p 'layla)]
6610 "--"
6611 (append
6612 '("Goto Section")
6613 (let ((section-alist spice-section-alist) menu-alist name str)
6614 (setq menu-alist
6615 (cons "--"
6616 (cons '["Changelog"
6617 (spice-goto-section "changelog")
6618 ; (setq menu-sec (current-time))
6619 (spice-cache-section-p "changelog")
6620 ] menu-alist)))
6621 (while section-alist
6622 (setq name (car (car section-alist)))
6623 (setq str (downcase (car (cdr (car section-alist)))))
6624 (setq menu-alist (cons (vector name
6625 (list 'spice-goto-section str)
6626 (list 'spice-section-p str)
6628 menu-alist))
6629 (setq section-alist (cdr section-alist)))
6630 (setq menu-alist
6631 (cons '["Specify..."
6632 spice-goto-section t]
6633 (cons "--" menu-alist)))
6634 (nreverse menu-alist))
6636 (append
6637 '("Add Section Header")
6638 (let ((section-alist spice-section-alist) menu-alist name str)
6639 (setq menu-alist
6640 (cons "--"
6641 (cons '["Changelog"
6642 (spice-add-section "Changelog")
6643 (not (spice-section-p "changelog"))] menu-alist)))
6644 (while section-alist
6645 (setq name (car (car section-alist)))
6646 (setq str (car (cdr (car section-alist))))
6647 (setq menu-alist (cons (vector name
6648 (list 'spice-add-section str)
6649 (list 'not (list 'spice-section-p (downcase str)))
6651 menu-alist))
6652 (setq section-alist (cdr section-alist)))
6653 (setq menu-alist
6654 (cons '["Specify..."
6655 spice-add-section t]
6656 (cons "--" menu-alist)))
6657 (nreverse menu-alist))
6660 (spice-common-menu-tail-entries))
6664 (defun spice-create-output-mode-menu ()
6665 "Create Spice-output Mode menu."
6666 (append
6667 (list
6668 "Spice-output"
6669 '("Edit"
6670 ["Fontify..." font-lock-flush t]
6671 "--"
6672 ["Unload all other spice files" spice-unload-other-decks t]
6673 "--"
6674 ["Create <name>_guess.cir file" (spice-create-guess-nodeset-file "guess") (spice-output-p)]
6675 ["Create <name>_nodeset.cir file" (spice-create-guess-nodeset-file "nodeset") (spice-output-p)]
6678 (spice-common-menu-tail-entries))
6682 (defun spice-common-menu-tail-entries ()
6683 "Creat Common Spice and Spice-output Mode menu entries."
6684 (list
6685 "--"
6686 ;; customize sub menu
6687 '("Customize"
6688 ["Browse Spice Group" (customize-browse 'spice) t]
6689 ["Spice Standard" (customize-variable 'spice-standard) t]
6690 ["Spice Faces" (customize-group 'spice-faces) t]
6691 ["Section Header list" (customize-variable 'spice-section-alist) t]
6692 ;; "--"
6693 ;; ["Activate Customizations in Buffer" spice-activate-customizations t]
6694 ;; (not (equal spice-standard-local spice-standard))]
6696 ;; settings sub menu
6697 (append '("Settings")
6698 (when (fboundp 'speedbar)
6699 (list '["Speedbar" speedbar-frame-mode
6700 :style toggle
6701 :selected (and (boundp 'speedbar-frame)
6702 (frame-live-p speedbar-frame)
6703 (frame-visible-p speedbar-frame))]))
6704 (list
6705 '["Abbrevs" abbrev-mode :style toggle :selected abbrev-mode]
6706 '["List abbrevs" list-abbrevs abbrev-mode]
6707 '["Auto fill" auto-fill-mode :style toggle
6708 :selected auto-fill-function]))
6709 "--"
6710 ["About Spice-Mode" spice-about t]
6715 (defvar spice-menu-list nil
6716 "Spice Mode menu.") ; global variable
6718 (defvar spice-output-menu-list nil
6719 "Spice-output Mode menu.") ; global variable
6721 (require 'easymenu)
6723 (defun spice-menu-init ()
6724 "Initialize global vars for Spice menu's."
6725 (setq spice-menu-list (spice-create-mode-menu))
6726 (setq spice-output-menu-list (spice-create-output-mode-menu))
6729 (defun spice-update-mode-menu ()
6730 "Update Spice mode menu for current buffer. assumes globals have been updated."
6731 (interactive)
6732 (if (spice-output-p)
6733 (easy-menu-define spice-output-menu spice-output-mode-map
6734 "Menu keymap for Spice-output Mode." spice-output-menu-list)
6735 (easy-menu-define spice-menu spice-mode-map
6736 "Menu keymap for Spice Mode." spice-menu-list)))
6739 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6740 ;; spice mode syntax table
6742 (defvar spice-mode-syntax-table nil
6743 "Syntax table used in spice-mode buffers.")
6745 (defun spice-mode-syntax-table-init ()
6746 "Initialize syntax table from scratch."
6747 (setq spice-mode-syntax-table (make-syntax-table))
6748 (modify-syntax-entry ?$ "w" spice-mode-syntax-table)
6749 (modify-syntax-entry ?! "w" spice-mode-syntax-table)
6750 (modify-syntax-entry ?* "w" spice-mode-syntax-table) ; not < !!!!
6751 (if (spice-standard-p 'eldo)
6752 (progn (modify-syntax-entry ?# "w 13" spice-mode-syntax-table)
6753 (modify-syntax-entry ?c "w 2" spice-mode-syntax-table)
6754 (modify-syntax-entry ?e "w 4" spice-mode-syntax-table)))
6755 ;; (modify-syntax-entry ?\n "> b" spice-mode-syntax-table) ;; no no, comments are handled by spice-mode, not by syntax-table !!!
6756 (modify-syntax-entry ?\n "." spice-mode-syntax-table) ;; make it punctuation ?
6757 (modify-syntax-entry ?\" "\"" spice-mode-syntax-table) ;; font-lock prob
6758 ;; (modify-syntax-entry ?\" "w" spice-mode-syntax-table)
6759 (modify-syntax-entry ?. "w" spice-mode-syntax-table)
6760 (modify-syntax-entry ?, "w" spice-mode-syntax-table)
6761 (modify-syntax-entry ?_ "w" spice-mode-syntax-table)
6762 (modify-syntax-entry ?@ "w" spice-mode-syntax-table)
6763 (modify-syntax-entry ?/ "w" spice-mode-syntax-table)
6764 ;; (modify-syntax-entry ?< "(>" spice-mode-syntax-table) ; can be in symbols
6765 ;; (modify-syntax-entry ?> ")<" spice-mode-syntax-table) ; can be in symbols
6766 ;; (modify-syntax-entry ?+ "w" spice-mode-syntax-table) ; can be in expr
6767 ;; (modify-syntax-entry ?- "w" spice-mode-syntax-table) ; can be in expr
6768 ;; (modify-syntax-entry ?= "." spice-mode-syntax-table) ; can be in expr
6773 ;;; speedbar stuff
6776 (eval-and-compile
6777 (when (fboundp 'speedbar)
6779 (require 'speedbar)
6781 (defun spice-speedbar-init ()
6782 "Initialize speedbar."
6783 ;; general settings, depends on auto-mode-alist, so should be
6784 ;; called every time auto-mode-alist is modified (set
6785 ;; (make-local-variable 'speedbar-tag-hierarchy-method) nil)
6786 ;; SPICE file extensions (extracted from `auto-mode-alist')
6787 (let ((mode-alist auto-mode-alist))
6788 (while mode-alist
6789 (when (eq (cdr (car mode-alist)) 'spice-mode)
6790 (speedbar-add-supported-extension (car (car mode-alist))))
6791 (setq mode-alist (cdr mode-alist)))))
6794 (defun spice-speedbar (&optional arg)
6795 "Open/close speedbar."
6796 (interactive)
6797 (if (not (fboundp 'speedbar))
6798 (error "WARNING: Speedbar is only available in newer Emacs versions")
6799 (condition-case () ; due to bug in `speedbar-el' v0.7.2a
6800 (speedbar-frame-mode arg)
6801 (error "WARNING: Install included `speedbar.el' patch first"))))
6805 ;;; speedbar end
6808 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6809 ;;; Imenu: S-mouse3 in emacs to find spice objects quickly
6810 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6812 (require 'imenu)
6814 (defvar spice-imenu-generic-expression nil
6815 "Imenu generic expression for spice mode. See `imenu-generic-expression'.")
6817 (defconst spice-imenu-end-submenu-name "*End*"
6818 "Label of End submenu in imenu.")
6820 (defconst spice-imenu-libraries-submenu-name "*Libraries*"
6821 "Label of Libraries submenu in imenu.")
6823 (defun spice-imenu-init ()
6824 "Initialize imenu generic expression and pass to imenu."
6825 (setq spice-imenu-generic-expression
6826 (append
6827 (list
6828 (list spice-imenu-end-submenu-name
6829 (concat
6831 "\\.\\(end\\)\\>"
6832 ) 1))
6833 (when (spice-standard-p 'layla)
6834 (list
6835 (list "*Nets*" (concat
6836 "^\\*?"
6837 "[\.]\\(net\\)\\s-+"
6838 "\\([a-z0-9]\\w*\\)\\>"
6839 ) 2)
6840 (list "*Ports*"
6841 (concat
6842 "^\\*?"
6843 "\\.\\(port\\)\\s-+"
6844 "\\([a-z0-9]\\w*\\)\\>"
6845 ) 2)
6846 (list "*Performances*"
6847 (concat
6848 "^\\*?"
6849 "\\.\\(performance\\)\\s-+"
6850 "\\([a-z]\\w*\\)\\>"
6851 ) 2)) ; list
6853 (list
6854 (list
6855 "*Misc*"
6856 (concat
6857 "^\\s-*\\.model\\s-+" spice-model-name spice-line-break
6858 "\\s-+\\("
6859 (regexp-opt spice-misc-model-type-names)
6860 "\\)\\>" )
6862 (list
6863 "*Diodes*"
6864 (concat "^\\s-*\\.model\\s-+" spice-model-name
6865 spice-line-break "\\s-+d\\>")
6867 (list
6868 "*Bipolars*"
6869 (concat "^\\s-*\\.model\\s-+" spice-model-name
6870 spice-line-break "\\s-+\\(npn\\|pnp\\)\\>")
6872 (list
6873 "*Mosfets*"
6874 (concat "^\\s-*\\.model\\s-+" spice-model-name
6875 spice-line-break "\\s-+\\(n\\|p\\)mos\\>")
6877 (list spice-imenu-libraries-submenu-name
6878 (concat spice-library-regexp-start
6879 spice-library-regexp-end)
6881 (list
6882 "*Analyses*"
6883 (concat "^\\s-*\\.\\("
6884 (regexp-opt spice-analyses)
6885 "\\)\\>")
6887 (list "*Sections*"
6888 spice-section-headings-regexp 2)
6889 (list nil
6890 (concat
6891 "^\\.\\(subckt\\s-+"
6892 (when (spice-standard-p 'eldo)
6893 "\\(lib\\s-+[^ \t\n]+\\s-+\\)?")
6894 "\\|macro\\s-+\\)"
6895 "\\([a-z]\\w*\\)\\>"
6896 ) (if (spice-standard-p 'eldo) 3 2))
6901 ;; ======================================================================
6902 ;; Support for compilation (simulation) - doesn't work 100% currently
6903 ;; and probably never will ...
6904 ;; ======================================================================
6906 (defun spice-simulation-buffer-name-function (arg)
6907 "Derive unique spice simulation buffer for simulator output."
6908 (concat "*Spice-simulation-" (buffer-name) "*"))
6911 (defun spice-get-simulator ()
6912 "Make an educated guess on what simulator a user likely wants to use."
6913 (if (and spice-simulator
6914 (assoc spice-simulator spice-simulator-alist))
6915 spice-simulator ;; is specified by user, take his choice
6916 (if (spice-standard-p 'eldo) "Eldo" ;; eldo
6917 (if (spice-standard-p 'hspice) "Hspice" ;; Hspice
6918 "Spice3")))) ;; fallback Spice3
6921 (defun spice-set-simulator-command ()
6922 "Construct a spice simulator command."
6923 (interactive)
6924 (setq compile-command
6925 (let ((commands-alist spice-simulator-alist)
6926 command)
6927 (while commands-alist
6928 (when (equal (spice-get-simulator) (nth 0 (car commands-alist)))
6929 (setq command
6930 (concat
6931 (nth 1 (car commands-alist)) " "
6932 spice-simulator-switches
6933 (unless
6934 (string-equal spice-simulator-switches "") " ")
6935 (file-name-nondirectory (if buffer-file-name
6936 buffer-file-name ""))
6937 (unless
6938 (string-equal (nth 2 (car commands-alist)) "") " ")
6939 (nth 2 (car commands-alist))
6941 (setq commands-alist (cdr commands-alist)))
6942 command)))
6944 (defun spice-set-simulator (name)
6945 "Set spice simulator NAME."
6946 (setq spice-simulator name)
6947 (spice-set-simulator-command))
6949 (require 'compile)
6951 (defvar spice-compilation-error-regexp-alist nil)
6952 (defvar spice-compilation-file-regexp-alist nil)
6954 (defun spice-compile ()
6955 "Spice wrapper function for compile."
6956 (interactive)
6957 (spice-set-simulator-command)
6958 (call-interactively 'compile nil)
6961 (defun spice-compile-variables-init ()
6962 "Build variable lists."
6963 (setq spice-compilation-error-regexp-alist
6964 (let ((commands-alist spice-simulator-alist)
6965 regexp-alist sublist)
6966 (while commands-alist
6967 (setq sublist (nth 3 (car commands-alist)))
6968 (unless (equal "" (car sublist))
6969 (setq regexp-alist
6970 (cons (append
6971 (list (nth 0 sublist)
6972 (if (= 0 (nth 1 sublist))
6974 (nth 1 sublist))
6975 (nth 2 sublist))
6976 (list (nth 3 sublist))
6977 (if (nth 4 sublist)
6978 (if (stringp (nth 4 sublist))
6979 (list (nth 4 sublist))
6980 (list (eval (nth 4 sublist))))))
6981 regexp-alist)))
6982 (setq commands-alist (cdr commands-alist)))
6983 regexp-alist))
6984 ; (message "setting compilation file regexps command")
6985 (setq spice-compilation-file-regexp-alist
6986 (let ((commands-alist spice-simulator-alist)
6987 regexp-alist)
6988 (while commands-alist
6989 (unless (equal "" (car (nth 4 (car commands-alist))))
6990 (setq regexp-alist
6991 (append regexp-alist
6992 (list (nth 4 (car commands-alist))))))
6993 (setq commands-alist (cdr commands-alist)))
6994 regexp-alist))
6998 (defun spice-compile-init ()
6999 "Initialize for simulation(/compilation)."
7001 ;;------------------------------------------------------------
7002 ;; use Eldo/Hspice as compiler, on current buffer
7003 (make-local-variable 'compile-command)
7004 (make-local-variable 'compilation-read-command)
7005 (make-local-variable 'compilation-buffer-name-function)
7006 (make-local-variable 'compilation-error-regexp-alist)
7007 (make-local-variable 'compilation-file-regexp-alist)
7009 (setq compilation-read-command 't)
7010 (setq compilation-buffer-name-function
7011 'spice-simulation-buffer-name-function)
7013 ; (message "setting compilation error regexps command")
7014 (setq compilation-error-regexp-alist spice-compilation-error-regexp-alist
7015 compilation-file-regexp-alist spice-compilation-file-regexp-alist)
7019 (defvar spice-column 1
7020 "Global variable to do column hack.
7022 Why ? Compile.el requires that every error is 'special', ie.
7023 different from the previous one. This is either the file is
7024 different, the line number is different or the column number is
7025 different. Prob: the file is always the same, the simulator guys
7026 never output the file name of the file that is being read, so
7027 that one doesn't change; the line number can not be found either;
7028 the column number is same problem; Solution: always take line
7029 number one, then take the column number 1 or 2 alternatingly,
7030 remember previous value here !
7032 This is ugly, I know, but it's the only way I could think of to find
7033 the errors in the simulation buffer with compile.el")
7036 (defun spice-linenum (f c)
7037 "Dirty hack function for `spice-column' global varible."
7038 ;;(message (format "calling linenum fun '%s'" f))
7039 (with-current-buffer compilation-last-buffer
7040 ;;(message (format "buffer '%s'" (buffer-name)))
7042 (list (point-marker) f 1
7043 (if (= spice-column 1)
7044 (setq spice-column 2)
7045 (setq spice-column 1))))
7048 (defun spice-next-error (n)
7049 "Move point to the next error N in the compilation buffer.
7050 Does NOT find the source line like \\[next-error] does, is defined
7051 in spice-mode since many simulators don't output errors with source line
7052 numbers included, so finding the error is still difficult."
7053 (interactive "p")
7054 (save-excursion
7055 (let (prev-buffer)
7056 (setq prev-buffer (buffer-name))
7057 (pop-to-buffer compilation-last-buffer)
7058 (compilation-next-error n)
7059 (recenter)
7060 (pop-to-buffer prev-buffer))))
7063 (defun spice-previous-error (n)
7064 "Move point to the previous error N in the compilation buffer.
7065 Does NOT find the source line like \\[next-error] does, is defined
7066 in spice-mode since many simulators don't output errors with source line
7067 numbers included, so finding the error is still difficult."
7068 (interactive "p")
7069 (save-excursion
7070 (let (prev-buffer)
7071 (setq prev-buffer (buffer-name))
7072 (pop-to-buffer compilation-last-buffer)
7073 (compilation-previous-error n)
7074 (recenter)
7075 (pop-to-buffer prev-buffer))))
7078 ;;------------------------------------------------------------
7079 ;; Waveform viewer support
7080 ;;------------------------------------------------------------
7081 ;; This is work in progress; (user) interface might change
7083 (defun spice-waveform-buffer-name-function (arg)
7084 "Check running process."
7085 (let ((name (if arg arg (buffer-name))))
7086 (concat "*Spice-waveform-" name "*")))
7089 (defun spice-set-waveform-viewer (name)
7090 (setq spice-waveform-viewer name)
7091 (spice-set-waveform-viewer-command))
7093 (defun spice-get-waveform-viewer ()
7094 "Make an educated guess on what waveform viewer a user likely would want."
7095 (if (and spice-waveform-viewer
7096 (assoc spice-waveform-viewer spice-waveform-viewer-alist))
7097 spice-waveform-viewer ;; is specified by user, take his choice
7098 (if (spice-standard-p 'eldo) "Xelga" ;; eldo's viewer is xelga
7099 (if (spice-standard-p 'hspice) "Awaves" ;; Hspice's viewer is awaves
7100 "Nutmeg")))) ;; fallback Spice3's viewer nutmeg ...
7103 (defun spice-waveform-viewer-derive-filename (arg)
7104 "Derive from the buffer file name the name of a derived file.
7106 If ARG is a string, it is a suffix to replace the buffer's
7107 suffix, if ARG is a list , , if ARG is a function, the function
7108 is called without arguments and it should return the derived
7109 filename, if ARG is nil, nil is returned, if ARG is t, the
7110 filename itself is returned unmodified."
7111 (cond ((stringp arg)
7112 (concat (file-name-sans-extension buffer-file-name) arg))
7113 ((listp arg)
7114 (let ((alist arg)
7115 filename)
7116 ;(message alist)
7117 (while alist
7118 (message (concat (file-name-sans-extension buffer-file-name) (car alist)))
7119 (setq
7120 filename
7121 (concat (file-name-sans-extension buffer-file-name) (car alist)))
7122 (setq alist (cdr alist)))
7123 filename))
7124 ((functionp arg)
7125 (funcall arg))
7126 (nil
7127 nil) ;; nil if nil ...
7129 buffer-file-name) ;; fallback if t ...
7133 (defvar spice-waveform-viewer-command ""
7134 "Variable containing buffer local waveform viewer command.")
7136 (defvar spice-waveform-viewer-filename nil
7137 "Variable filename field of waveform viewer structure.")
7139 (defvar spice-waveform-viewer-alist-entry nil
7140 "Variable holding selected entry of waveform viewer.")
7142 (defvar spice-waveform-viewer-read-command t
7143 "Variable containing boolean indicating reading of buffer local waveform viewer command.")
7145 (defvar spice-after-start-process-function nil
7146 "Variable containing after start process function.")
7148 (defun spice-set-waveform-viewer-command ()
7149 "Set waveform viewer command for spice."
7150 (interactive)
7151 (setq spice-waveform-viewer-alist-entry nil)
7152 (let ((commands-alist spice-waveform-viewer-alist))
7153 (while commands-alist
7154 (when (equal (spice-get-waveform-viewer)
7155 (nth 0 (car commands-alist)))
7156 (setq spice-waveform-viewer-alist-entry (car commands-alist))
7158 (setq commands-alist (cdr commands-alist)))))
7161 (defun spice-waveform-viewer-init ()
7162 "Initialize for waveform viewer."
7164 ;;------------------------------------------------------------
7165 (make-local-variable 'spice-waveform-viewer-command)
7166 (make-local-variable 'spice-waveform-viewer-read-command)
7167 (make-local-variable 'spice-waveform-viewer-filename)
7168 (make-local-variable 'spice-waveform-viewer-alist-entry)
7169 (make-local-variable 'spice-after-start-process-function)
7171 (setq spice-waveform-viewer-read-command 't)
7173 (spice-set-waveform-viewer-command))
7176 (defun spice-run-waveform-viewer ()
7177 "Run the waveform viewer if it is not yet running."
7178 (interactive)
7179 (if (not buffer-file-name)
7180 (message "Can not run waveform viewer on unsaved file-less buffers.")
7181 (let (name command file)
7182 (setq name (nth 0 spice-waveform-viewer-alist-entry)
7183 command (concat (nth 1 spice-waveform-viewer-alist-entry)
7185 (nth 2 spice-waveform-viewer-alist-entry)
7187 (spice-waveform-viewer-derive-filename
7188 (nth 4 spice-waveform-viewer-alist-entry)))
7189 file (buffer-name))
7190 (spice-process-check file)
7191 (message "Starting waveform viewer %s" name)
7192 (funcall (nth 3 spice-waveform-viewer-alist-entry) name command file))
7193 ) ; if (else part)
7197 (defun spice-master-directory ()
7198 "Directory of master file."
7199 (abbreviate-file-name
7200 (expand-file-name
7201 (file-name-directory (buffer-file-name)))))
7204 (defun spice-run-silent (name command file)
7205 "Start process NAME with (optional) second argument COMMAND and FILE."
7206 (let ((dir (spice-master-directory)))
7207 (with-current-buffer (get-buffer-create "*spice silent*")
7208 (erase-buffer)
7209 (if dir (cd dir))
7210 ; (message "cd to %s" dir)
7211 (let ((process (start-process (concat name " silent")
7212 (current-buffer) ; can be nil
7213 spice-shell
7214 spice-shell-command-option
7215 command)))
7216 (message "started %s" command)
7217 (if spice-after-start-process-function
7218 (funcall spice-after-start-process-function process))
7219 (set-process-query-on-exit-flag process)))))
7221 (defun spice-run-interactive (name command file)
7222 "Run waveform viewer interactively with process (NAME COMMAND FILE).
7223 Run command in a buffer (in comint-shell-mode) so that it accepts user
7224 interaction."
7225 (require 'comint)
7226 (let (; (default spice-command-default)
7227 (buffer (spice-waveform-buffer-name-function file))
7228 (process nil)
7229 (dir (spice-master-directory)))
7230 (spice-process-check file) ; Check that no process is running
7231 ; (setq spice-command-buffer (current-buffer))
7232 (with-output-to-temp-buffer buffer)
7233 (set-buffer buffer)
7234 (setq buffer-read-only nil)
7235 (if dir (cd dir))
7236 (insert "Running `" name "' on `" file "' with ``" command "''\n")
7237 (comint-exec buffer name spice-shell nil
7238 (list spice-shell-command-option command))
7239 (comint-mode)
7240 (setq mode-name name)
7241 ; (setq spice-command-default default)
7242 (setq process (get-buffer-process buffer))
7243 (if spice-after-start-process-function
7244 (funcall spice-after-start-process-function process))
7245 ; (spice-command-mode-line process) ; mode line setting
7246 ; (set-process-sentinel process 'spice-command-sentinel)
7247 (set-marker (process-mark process) (point-max))
7248 ;;; (setq compilation-in-progress (cons process compilation-in-progress))
7249 ; (spice-parse-reset)
7250 ; (setq spice-parse-function 'spice-parse-spice)
7251 ; (setq spice-sentinel-function 'spice-LaTeX-sentinel)
7254 (defun spice-command-mode-line (process)
7255 "Format the mode line for a buffer containing output from PROCESS."
7256 (setq mode-line-process (concat ": " (symbol-name (process-status process))))
7257 (set-buffer-modified-p (buffer-modified-p)))
7259 (defun spice-process-check (name)
7260 "Check if a process for the spice deck NAME already exist.
7261 If so, give the user the choice of aborting the process or the current
7262 command."
7263 (let ((process (get-buffer-process
7264 (spice-waveform-buffer-name-function name))))
7265 ; (message "checking %s for running process" (spice-waveform-buffer-name-function name))
7266 (cond ((null process))
7267 ((not (eq (process-status process) 'run)))
7268 ((yes-or-no-p (concat "Process `"
7269 (process-name process)
7270 "' for deck `"
7271 name
7272 "' running, kill it? "))
7273 (delete-process process))
7275 (error "Cannot have two processes for the spice deck")))))
7278 ;; ---- setting commands ?
7280 (defun spice-set-command ()
7281 "Set both simulator an waveform viewer commands for current buffer."
7282 (interactive)
7283 (spice-set-simulator-command)
7284 (spice-set-waveform-viewer-command)
7288 ;;------------------------------------------------------------
7289 ;; File initialization support, code taken from eldo-mode and
7290 ;; modified/extended
7291 ;;------------------------------------------------------------
7293 ;; initialize empty file:
7294 (defun spice-initialize-empty-file ()
7295 "Create a standard template for a new/empty file.
7297 This is the default initialization function. If the user has specified
7298 an initialization function, by setting
7299 `spice-initialize-file-function', the user-specified function is
7300 called instead. This function first checks for the template file
7301 specified in `spice-initialization-file' which is inserted and a default
7302 changelog entry is added. If this file isn't readable, a default
7303 template is inserted depending on the submode (eldo, hspice or layla)
7304 that has been selected."
7305 (interactive "*") ; read-only check
7306 (if (file-readable-p spice-initialize-template-file) ;; template file
7307 (insert-file-contents spice-initialize-template-file)
7308 ;; this has been taken from eldo-mode and thus only applies if
7309 ;; eldo is selected
7310 (if (spice-standard-p 'eldo)
7311 (progn
7312 (insert
7313 (concat "# " (buffer-name) " "
7314 "\n.notrc\n.nocom"
7315 "\n\n"
7316 spice-default-header
7317 "\n\n"))
7318 (spice-add-section "LIBRARIES")
7319 (insert "\n\n\n")
7320 (spice-add-section "SIMULATION OPTIONS")
7321 (insert
7322 (concat "\n\n"
7323 ".options STAT=1 SIMUDIV=10 !Status reports\n"
7324 ".options noascii nomod \n"
7325 ".options eps=1e-7 itol=1e-6 gmin=1e-16 analog \n"
7326 ".options nobound_phase"
7327 ".width out=80 \n"
7328 ".temp=27 \n"
7329 "\n\n\n"))
7330 (spice-add-section "SUPPLIES/REFERENCES")
7331 (insert "\n\n.END\n\n\n\n")
7332 (spice-add-section "Changelog")
7333 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7335 (if (spice-standard-p 'hspice) ;; hspice specific options
7336 (progn
7337 (insert
7338 (concat "* " (buffer-name) " "
7339 "\n\n"
7340 spice-default-header
7341 "\n\n"))
7342 (spice-add-section "LIBRARIES")
7343 (insert "\n\n\n")
7344 (spice-add-section "SIMULATION OPTIONS")
7345 (insert
7346 (concat "\n\n"
7347 ".options nomod nopage opts \n"
7348 ".options itl1=5000 itl2=2500 itl3=20 itl4=20 itl5=0 \n"
7349 ".options numdgt=10 $ print 10 digits in output \n"
7350 ".width out=80 \n"
7351 ".temp=27 \n"
7352 "\n\n\n"))
7353 (spice-add-section "SUPPLIES/REFERENCES")
7354 (insert "\n\n.end\n\n\n\n")
7355 (spice-add-section "Changelog")
7356 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7358 (if (spice-standard-p 'layla) ;; layla specific options
7359 (progn
7360 (insert
7361 (concat "* " (buffer-name) " "
7362 "\n"
7363 spice-default-header
7364 "\n\n"))
7365 (spice-add-section "MAIN CIRCUIT")
7366 (insert "\n\n\n")
7367 (spice-add-section "PORTS")
7368 (insert "\n\n.end\n\n\n\n")
7369 (spice-add-section "Changelog")
7370 (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
7376 (spice-add-changelog-entry "File created") ; in any case
7379 ;; ======================================================================
7380 ;; Support for .subckt search !?
7381 ;; ======================================================================
7383 ;; What about searching from an included file, how to find the
7384 ;; top-level then ? think I've cracked it: .end identifies top-level
7385 ;; spice files so remember the last one to start search from if the
7386 ;; search fails
7388 ;; BUG: doesn't handle nested .subckt defs ! Reports first found match...
7390 (defun spice-search-included-files (subckt)
7391 (save-excursion
7392 (let ((mrk nil))
7393 (goto-char (point-min))
7394 (while (and
7395 (search-forward-regexp spice-library-regexp-start
7396 (point-max) t)
7397 (not mrk))
7398 (beginning-of-line)
7399 (if (looking-at (concat spice-library-regexp-start
7400 spice-library-regexp-end))
7401 (if (file-readable-p (substitute-in-file-name (match-string 3)))
7402 (setq mrk
7403 (spice-search-file-for-subckt
7404 (substitute-in-file-name (match-string 3)) subckt))
7405 (message "File '%s' isn't readable" (match-string 3))) ; if
7406 ) ; if
7407 (end-of-line)) ; while
7408 mrk) ; let
7409 ) ; save-
7413 (defvar spice-subckt-search-master-filename nil
7414 "Latest top level (identified by .end in file) .cir file used in subcircuit searches.")
7416 (defun spice-search-file-for-subckt (filename subckt)
7417 "Searche a FILENAME for a SUBCKT definition.
7418 Remembers `spice-subckt-search-master-filename' for future subckt searches."
7419 (with-current-buffer (find-file-noselect filename)
7420 (condition-case nil
7421 (let ((index-alist (imenu--make-index-alist t))
7422 (mrk nil))
7423 (if (assoc spice-imenu-end-submenu-name index-alist)
7424 (setq spice-subckt-search-master-filename buffer-file-name))
7425 (setq mrk (assoc-string subckt index-alist))
7426 (if mrk mrk (spice-search-included-files subckt)))
7427 (error nil))))
7430 ;; History of subckt searches.
7431 (defvar spice-subckt-search-history nil
7432 "History of subcircuit searches.")
7434 (defun spice-guess-subckt-name ()
7435 "Guess name of subckt from context, multiple lines."
7436 (let ((subckt "")) ; (current-word)
7437 (save-excursion
7438 (beginning-of-line)
7439 (while (and (looking-at "^+")
7440 (not (forward-line -1))))
7441 (if (looking-at spice-xinstance-regexp)
7442 (progn
7443 ;; (message "Could it be '%s' ?" (match-string 3))
7444 (setq subckt (match-string 5))
7445 (remove-text-properties 0 (length subckt) '(face nil) subckt)
7446 ))) ; save-
7447 subckt))
7450 (defun spice-visit-subckt-def (mark)
7451 "Helper function visiting buffer and MARK specified."
7452 (when (and (eq (marker-buffer (cdr mark))
7453 (current-buffer))
7454 (not (and transient-mark-mode mark-active)))
7455 (push-mark))
7456 (pop-to-buffer (marker-buffer (cdr mark)) t)
7457 (widen)
7458 (goto-char (cdr mark)))
7461 (defun spice-search-subckt (subckt-args)
7462 "Searches for the .subckt definition with name under cursor, or any other name specified by user.
7464 Be CAREFUL using this command. Depending on the structure of your
7465 spice decks this might find wrong definitions. To AVOID any such
7466 problems always start searching from the TOP-LEVEL spice
7467 deck (ie. the file that is supplied to the simulator). If you
7468 start searching from an included file, potentially the definition
7469 is not found or it is found starting from ANOTHER top level
7470 file (which could result in a completely wrong search result).
7472 This search command places the mark if search result is in the
7473 same file, return to the search start position by using C-u
7474 C-<SPC> or C-u C-@."
7475 (interactive
7476 (list (let* ((default-subckt (spice-guess-subckt-name))
7477 (input (read-from-minibuffer
7478 "Subcircuit name: "
7479 default-subckt nil nil
7480 spice-subckt-search-history)))
7481 (if (string= input "")
7482 (if (string= default-subckt "")
7483 (error "No subckt args given")
7484 default-subckt)
7485 input))))
7486 ;(message (format "name of subckt is %s" subckt-args))
7487 (let (mrk)
7488 (setq mrk (spice-search-file-for-subckt buffer-file-name subckt-args))
7489 ; (message (format "mark is %s" (cdr mrk)))
7490 (if (and (cdr mrk) (markerp (cdr mrk)))
7491 (spice-visit-subckt-def mrk)
7492 (progn
7493 (message "Couldn't find subcircuit '%s', retrying search in top-level file"
7494 subckt-args))) ; if
7495 (if (and (not mrk)
7496 spice-subckt-search-master-filename)
7497 (progn
7498 (setq mrk (spice-search-file-for-subckt
7499 spice-subckt-search-master-filename subckt-args))
7500 (if (and (cdr mrk) (markerp (cdr mrk)))
7501 (progn
7502 (spice-visit-subckt-def mrk)
7503 (message "Used top-level file '%s' to find '%s'"
7504 spice-subckt-search-master-filename subckt-args)
7506 (progn
7507 (message
7508 (format "Couldn't find subcircuit '%s', retry search in top-level file"
7509 subckt-args))
7510 ))))))
7513 ;; ======================================================================
7514 ;; loading of include files of current deck.
7516 (defun spice-load-include-files (&optional non-recursive)
7517 "Loads all files that are included in this deck.
7519 Makes it more easy to load a project. This loading occurs
7520 recursively. Files already loaded are not reloaded or scanned for
7521 .includes. This function is only guaranteed to work when all
7522 included files are not already loaded."
7523 (interactive)
7524 (let ((index-alist (imenu--make-index-alist t))
7525 l filename)
7526 (if (setq l (cdr (assoc spice-imenu-libraries-submenu-name index-alist))) ;; file contains include files/libraries
7527 (while l
7528 (setq filename (expand-file-name
7529 (substitute-in-file-name (car (car l)))))
7530 ;;(message "Trying to load %s" filename)
7531 (if (and (file-readable-p filename)
7532 (not
7533 (assoc filename ;; already loaded
7534 (mapcar
7535 (lambda (buffer)
7536 (cons (buffer-file-name buffer) buffer))
7537 (buffer-list)))))
7538 (with-current-buffer (find-file-noselect filename)
7539 ;; (message "filename is %s" filename)
7540 ;; (spice-mode) ? ref. discussion Manu
7541 (unless (or non-recursive
7542 (not (eq major-mode 'spice-mode)))
7543 (spice-load-include-files))))
7544 (setq l (cdr l))))))
7547 ;; ======================================================================
7548 ;; unloading of spice files except current deck.
7550 (defun spice-unload-other-decks ()
7551 "Kills all other spice files except current one.
7553 Makes it easy to unload a lot of spice files without restarting Emacs."
7554 (interactive)
7555 (save-excursion
7556 (let ((current (current-buffer)))
7557 (mapcar
7558 (lambda (buffer)
7559 (set-buffer buffer)
7560 (if (and (eq major-mode 'spice-mode)
7561 (not (eq current buffer)))
7562 (progn
7563 (message "Killing %s" buffer)
7564 (kill-buffer buffer))))
7565 (buffer-list)))))
7568 ;; ======================================================================
7569 ;; folding for commented out regions ...
7570 ;;; taken from and adapted:
7571 ;;; Filename: foldingo.el
7572 ;;; Author: Christian Queinnec <Christian.Queinnec@lip6.fr>
7573 ;; This is work in progress; (user) interface might change
7575 (defvar spice-some-comment-regions-are-hidden nil
7576 "Keeps track if some comment regions are hidden.")
7577 (make-variable-buffer-local 'spice-some-comment-regions-are-hidden)
7579 (defvar spice-last-hide-comment-regions-tick nil
7580 "Keeps track when last time comment hiding was called.")
7581 (make-variable-buffer-local 'spice-last-hide-comment-regions-tick)
7583 (defun spice-hide-init ()
7584 "Initialize buffer local variables to make hiding of spice regions
7585 effective"
7586 ;; trick to make a comment-start/padding dependent regexp:
7587 (custom-initialize-reset 'spice-hide-line-prefix
7588 (car (get 'spice-hide-line-prefix
7589 'standard-value)))
7590 ;; make sure we have invisibility property working, local for a buffer
7591 (if (fboundp 'add-to-invisibility-spec)
7592 (add-to-invisibility-spec 'spice-mode))
7593 ;; (remove-from-invisibility-spec '(spice-mode . t))
7594 ;; local for buffers:
7595 (set (make-local-variable 'line-move-ignore-invisible) t)
7596 (if spice-auto-hide-comments
7597 (spice-hide-all-comments))
7600 (defun spice-hide (from to)
7601 "Not supported, don't use this."
7602 (interactive "*r")
7603 (spice-hide-region from to t))
7605 (defun spice-unhide (from to)
7606 "Not supported, don't use this."
7607 (interactive "*r")
7608 (spice-hide-region from to nil))
7610 (defun spice-hide-all-comments-p ()
7611 "Checks if there are comments that can be hidden...; assumes that if
7612 the user edited the file, new comments might have been created and
7613 thus hide all comments must be activated. This is not the best
7614 criterion, but it is safe."
7615 ;; (interactive)
7616 ;; (message "buffer tick is %s, last hide comment is %s"
7617 ;; (buffer-modified-tick) spice-last-hide-comment-regions-tick)
7618 (if (and
7619 spice-last-hide-comment-regions-tick ; can be nil
7620 (= spice-last-hide-comment-regions-tick (buffer-modified-tick)))
7621 nil t))
7623 (defun spice-hide-all-comments ()
7624 "Hides all commented out regions in the current spice deck. Allows
7625 to get a better overview of the deck if many lines are commented out.
7626 It relies on having all regions being commented out using the
7627 \"Comment Region\" menu entry that uses `comment-region'. The regexp
7628 used to match comment lines, `spice-hide-line-prefix', might identify
7629 standard spice comment lines used for documentation. To avoid
7630 problems, make sure documentation is not part of comments. For
7631 instance by using the doc starters available in the spice languages,
7632 or by making sure they are different from the comment lines generated
7633 with the menu entry, by placing two *'s when the default comment is
7634 only one *. If you want to unhide all the hidden comment lines, use
7635 `spice-unhide-all-comments'."
7636 (interactive)
7637 (spice-unhide-all-comments)
7638 (setq spice-last-hide-comment-regions-tick (buffer-modified-tick))
7639 (save-excursion
7640 (goto-char (point-min))
7641 ;; (message "beginning of buffer reached %s" (point))
7642 (forward-line)
7643 (while (search-forward-regexp (concat "^" spice-hide-line-prefix)
7644 (point-max) t)
7645 (beginning-of-line)
7646 ;; (message "reached %s" (point))
7647 (let ((beg (point))
7649 lines)
7650 ;; (message "found start of regexp %s" (point))
7651 (setq lines (forward-line))
7652 ;; (message "%s left" lines)
7653 ;; the empty lines following commented lines are also hidden
7654 (while (and (looking-at (concat "^\\(" spice-hide-line-prefix "\\|[ ]*$\\)"))
7655 (= (setq lines (forward-line)) 0))
7656 ;; (message "%s left" lines)
7658 (setq end (point))
7659 (spice-hide-region beg end t))))
7660 (spice-set-spice-name)
7663 (defun spice-unhide-all-comments ()
7664 "Unhides all hidden comment regions."
7665 (interactive)
7666 (setq spice-some-comment-regions-are-hidden nil)
7667 (setq spice-last-hide-comment-regions-tick nil)
7668 (spice-hide-region (point-min) (point-max) nil)
7669 (spice-set-spice-name)) ;; update mode-line
7671 (defun spice-hide-region (from to flag)
7672 "Hides or shows lines from FROM to TO, according to FLAG. If FLAG
7673 is nil then the text is shown, while if FLAG is t the text is hidden."
7674 (let ((inhibit-read-only t))
7675 (save-excursion
7676 (goto-char from)
7677 ; (foldingo-discard-overlays (point) to 'invisible 'spice-comment)
7678 (spice-discard-overlays from to 'spice-comment)
7679 (if flag
7680 (let ((overlay (make-overlay (point) to)))
7681 (spice-make-overlay-hidden overlay))))))
7683 (defun spice-make-overlay-hidden (overlay)
7684 ;; Make overlay hidden and intangible.
7685 ;; (overlay-put overlay 'intangible t)
7686 (overlay-put overlay 'invisible 'spice-mode)
7687 (overlay-put overlay 'spice-comment t)
7688 (setq spice-some-comment-regions-are-hidden t)
7689 ;; (overlay-put overlay 'intangible t)
7692 (defun spice-discard-overlays (from to prop)
7693 "discards overlays in region FROM to TO that have property PROP set."
7694 (let ((inhibit-read-only t))
7695 (save-excursion
7696 (goto-char from)
7697 (while (< (point) to)
7698 (let ((overlays (overlays-at (point))))
7699 (while overlays
7700 (let ((o (car overlays)))
7701 (if (overlay-get o prop)
7702 (delete-overlay o)))
7703 (setq overlays (cdr overlays))))
7704 (goto-char (next-overlay-change (point)))))))
7707 ;; ======================================================================
7708 ;; utility spice-mode-output functions
7710 (defun spice-check-output-mode ()
7711 "Check if current buffer is output file and return symbol or NIL."
7712 (save-excursion
7713 (goto-char (point-min))
7714 (if (looking-at "1\\*\\*\\*\\*\\*\\*\\*") ; eldo
7715 'eldo
7716 (if (or (looking-at "Using: ")
7717 (looking-at " \\*\\*\\*\\*\\*\\* Star-HSPICE")) ; hspice
7718 'hspice
7719 nil))))
7721 (defun spice-output-p ()
7722 "Check if current buffer is output file."
7723 (interactive)
7724 (if spice-output-local t nil))
7726 (defconst spice-output-sections-regexp
7727 (concat
7729 "\\(0\\*\\*\\*\\*\\| \\*\\*\\*\\*\\*\\*\\) *"
7730 "\\( [a-z0-9]\\w*\\(\\s-+\\w+\\)* \\)\\s-+\\(t[a-z]*\\) ?=.*$")
7731 "Regexp identifying spice output headers (both hspice and eldo).")
7733 (defvar spice-output-font-lock-keywords
7734 (list
7735 (list spice-output-sections-regexp
7736 '(1 font-lock-comment-face)
7737 '(2 spice-title-face)
7738 (list 4 spice-constant-face))
7739 (list "^[0-1] ?\\*.*$" 0 font-lock-comment-face)
7740 (list "^ \\(\\*\\*\\*\\*\\*?\\) \\(.*\\)$"
7741 '(1 font-lock-comment-face)
7742 '(2 font-lock-type-face))
7743 (list "^\\(FATAL \\)?ERROR.+$" 0 'font-lock-warning-face) ; eldo errors
7744 (list "^\\s-*\\(..?error..?[: ]\\).+$" 0 'font-lock-warning-face) ; hspice errors
7746 "List of regexps for font-lock in output mode."
7749 (defun spice-mode-output ()
7750 "Spice major mode start up function for spice output files. Experimental ;)"
7752 (setq buffer-read-only t) ; don't want to edit output files, do we
7753 ; common mistake in hspice output files!
7755 ;; use local keymap (for keys and menu)
7756 (use-local-map spice-output-mode-map)
7758 ;; set menu for local buffer
7759 (easy-menu-define spice-output-menu spice-output-mode-map
7760 "Menu keymap for Spice Output Mode." spice-output-menu-list)
7762 ;; font-lock local start-up
7763 (set (make-local-variable 'font-lock-defaults)
7764 (list 'spice-output-font-lock-keywords
7765 nil t (list (cons ?\" "w")))) ; nil, t (do multiline
7766 ; comments)
7768 ;; imenu buffer local init
7769 (set (make-local-variable 'imenu-case-fold-search) t)
7770 (set (make-local-variable 'imenu-generic-expression)
7771 (list (list "*Errors*"
7772 "^\\s-*\\(\\(..?error..?[: ]\\|\\(FATAL \\)?ERROR\\).+$\\)"
7774 (list nil ;; "*Sections*"
7775 spice-output-sections-regexp
7776 2)))
7780 (defun spice-output-filename ()
7781 "Determines output filename of current spice deck."
7782 (interactive)
7783 (let ((filename nil)
7784 (l spice-output-filename-alist))
7785 (while l
7786 (if (spice-standard-p (car (car l)))
7787 (progn
7788 (setq filename (eval (car (cdr (car l)))))
7789 ;; (message "Checking filename %s" filename)
7790 (if (file-readable-p filename)
7791 (setq l nil)
7792 (setq filename nil))))
7793 (setq l (cdr l)))
7794 filename))
7796 (defun spice-output-file-p ()
7797 "Checks if an output file is available for current spice deck."
7798 (interactive)
7799 (and (not spice-output-local)
7800 (buffer-file-name)
7801 (spice-output-filename)))
7803 (defun spice-load-output-file-internal (filename)
7804 "Loads output file into emacs and sets major mode"
7805 (interactive)
7806 (if (and
7807 (stringp filename)
7808 (file-readable-p filename))
7809 (progn
7810 (find-file-other-window filename)
7811 (spice-mode))))
7813 (defun spice-load-output-file ()
7814 "Loads output file into spice, calls `spice-load-output-file-internal'
7815 to do the actual work, this is called from the menu or key binding"
7816 (interactive)
7817 (let (filename)
7818 (setq filename (spice-output-filename))
7819 (spice-load-output-file-internal filename)))
7822 ;; ======================================================================
7823 ;; .guess statement auxiliary functions (eldo !)
7825 (defvar spice-guess-nodeset-statements nil
7826 "holds temp .guess/nodeset statements")
7828 (defun spice-derive-guess-nodeset-statements (from to)
7829 "Derives .guess/nodeset statements from DC operating point
7830 lines. This implements the hspice functionality of .ic0 files for
7831 eldo..."
7832 (save-excursion
7833 (let ( ;; (count 0)
7835 (goto-char (max from to))
7836 (setq m1 (make-marker))
7837 (set-marker m1 (point))
7838 (goto-char (min from to))
7839 (while (re-search-forward "^\\s-*\\(\\S-+\\)\\s-+\\([-0-9\.E+]+\\)"
7840 m1 t)
7841 (progn
7842 ;;(message "Inserting .guess...(%s)" (make-string (incf count) ?.))
7843 ;;(beginning-of-line)
7844 ;;(insert ".guess V(" (match-string 1) ") = " (match-string 2) "\n*")
7845 (setq spice-guess-nodeset-statements
7846 (append spice-guess-nodeset-statements
7847 (list (concat " V("
7848 (match-string-no-properties 1)
7849 ") = "
7850 (match-string-no-properties 2)))
7853 )))))
7855 (defun spice-create-guess-nodeset-file (str)
7856 "Creates a <buffer-file-name>_guess/nodeset.cir file from node
7857 voltage pairs in the current output file."
7858 (interactive)
7859 (setq spice-guess-nodeset-statements nil)
7860 (let (from to outbuf stats filename)
7861 (setq filename (file-name-nondirectory buffer-file-name))
7862 (save-excursion
7863 (goto-char (point-min))
7864 (setq from (re-search-forward "^\\s-+NODE\\s-+VOLTAGE\\s-*$" (point-max) t))
7865 (if from
7866 (setq to (re-search-forward "^$" (point-max) t)))
7867 (if (and from to)
7868 (spice-derive-guess-nodeset-statements from to)))
7869 (if (not spice-guess-nodeset-statements)
7870 (message "Didn't find 'node -- voltage' pairs in output file...")
7871 (setq outbuf
7872 (find-file-noselect (concat
7873 (file-name-sans-extension buffer-file-name)
7874 "_" str ".cir")))
7875 (switch-to-buffer-other-window outbuf)
7876 (erase-buffer)
7877 (insert "* ." str " statements derived from " filename " ["
7878 (format-time-string "%b %d %Y") " " (format-time-string "%T")
7879 "]\n\n")
7880 (setq stats spice-guess-nodeset-statements)
7881 (while stats
7882 (insert ".")
7883 (insert str)
7884 (insert " ")
7885 (insert (car stats))
7886 (insert "\n")
7887 (setq stats (cdr stats)))
7888 (insert "\n\n* ." str " statements derived "
7889 (format-time-string "%b %d %Y") " "
7890 (format-time-string "%T") "\n\n")
7891 (save-buffer)
7892 (goto-char (point-min))
7893 ) ; when
7894 ) ; let
7898 (defun spice-replace-with-guess-statements (from to)
7899 "replace with .guess statements."
7900 (interactive "*r")
7901 (spice-replace-with-guess-nodeset-statements "guess" from to))
7904 (defun spice-replace-with-nodeset-statements (from to)
7905 "replace with .nodeset statements."
7906 (interactive "*r")
7907 (spice-replace-with-guess-nodeset-statements "nodeset" from to))
7910 (defun spice-replace-with-guess-nodeset-statements (str from to)
7911 "Replaces selected region with .guess/nodeset statements."
7912 (interactive)
7913 (setq spice-guess-nodeset-statements nil)
7914 (if (and from to)
7915 (spice-derive-guess-nodeset-statements from to))
7916 (if (not spice-guess-nodeset-statements)
7917 (message "Didn't find any 'node -- voltage' pairs in region...")
7918 (let (stats)
7919 (kill-region from to)
7920 (setq stats spice-guess-nodeset-statements)
7921 (while stats
7922 (insert ".")
7923 (insert str)
7924 (insert " ")
7925 (insert (car stats))
7926 (insert "\n")
7927 (setq stats (cdr stats))))
7931 ;; ======================================================================
7932 ;; fill-prefix related functions
7934 (defvar spice-save-comment-line-break-function nil
7935 "*Mode specific variable to save previous line break function in.")
7937 (defun spice-comment-indent-new-line (&optional soft)
7938 "Spice mode comment-indent-new-line function, used by `auto-fill'. Sets
7939 `fill-prefix' depending on context: comment prefix if in comment with special
7940 layla handling (!); \"!\" doc prefix if in hspice mode; \"$\" doc prefix
7941 in eldo mode, otherwise uses \"+ \" prefix."
7942 (interactive)
7943 (let ((fpx fill-prefix) ; remember prefix
7944 (end (point))) ; don't look beyond point for doc starters
7945 (if (save-excursion
7946 (beginning-of-line)
7948 (looking-at (concat "\\([" comment-start
7949 (when (spice-standard-p 'layla)
7950 spice-continuation-prefix)
7951 (when (spice-standard-p 'hspice)
7952 "$")
7953 (when (spice-standard-p 'eldo)
7954 "!")
7955 "]+\\)"))
7956 (and
7957 (spice-standard-p 'hspice)
7958 (re-search-forward "\\s-\\([$]\\)" end t))
7959 (and
7960 (spice-standard-p 'eldo)
7961 (re-search-forward "\\s-\\([!]\\)" end t))))
7962 (setq fill-prefix (concat (match-string-no-properties 1) " "))
7963 (setq fill-prefix (concat spice-continuation-prefix " ")))
7964 ;(comment-indent-new-line) ;;call standard comment-indent-new-line function
7965 (when spice-save-comment-line-break-function
7966 (funcall spice-save-comment-line-break-function))
7967 (setq fill-prefix fpx)))
7970 (defun spice-fill-context-prefix () ; ???
7971 "Calculates prefix from current position (move-to-left-margin), and
7972 returns it. Non-comment paragraphs can also be filled correctly."
7973 ;; (message "deriving fill prefix")
7974 (let ((result
7975 (if (or (looking-at (concat "\\([" comment-start
7976 (when (spice-standard-p 'layla)
7977 spice-continuation-prefix)
7978 "]+\\)"))
7979 (looking-at "\\([$!]+\\)"))
7980 (concat (match-string-no-properties 1) " ")
7981 (concat spice-continuation-prefix " "))))
7982 ;; (message (format "result is '%s'" result))
7983 result))
7985 (defun spice-delete-indentation (&optional arg)
7986 "Wrapper for `delete-indentation', sets `fill-prefix' to adequate value."
7987 (interactive "*P")
7988 (let ((fillpfx fill-prefix))
7989 (beginning-of-line)
7990 (if arg (forward-line 1))
7991 (if (looking-at "\\([+$!*]+\\)") ;; don't check submodes here ?
7992 (setq fill-prefix (match-string-no-properties 1)))
7993 (delete-indentation)
7994 (setq fill-prefix fillpfx)))
7997 ;; ======================================================================
7998 ;; msb fix (from cperl-mode.el)
7999 (defvar spice-msb-fixed nil) ;; global variable keeping track of addition
8001 (defun spice-msb-fix ()
8002 "Adds \"Spice Decks\" entry in msb menu, assumes that msb is already loaded"
8003 (setq spice-msb-fixed t)
8004 (let* ((l (length msb-menu-cond))
8005 (last (nth (1- l) msb-menu-cond))
8006 (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
8007 (handle (1- (nth 1 last))))
8008 (setcdr precdr (list
8009 (list
8010 '(eq major-mode 'spice-mode)
8011 handle
8012 "Spice Decks (%d)")
8013 last))))
8016 ;; ======================================================================
8017 ;; utility spice-mode functions
8019 (defun spice-about ()
8020 (interactive)
8021 (sit-for 0)
8022 (message "spice-mode version %s, © %s" spice-version spice-developer))
8024 (defun spice-set-spice-name ()
8025 "Set mode line name of spice mode"
8026 (setq mode-name "Spice"))
8028 ;; (defun spice-set-spice-name ()
8029 ;; "Set mode line name of spice mode"
8030 ;; (setq mode-name
8031 ;; (concat
8032 ;; (when (not spice-output-local)
8033 ;; (concat
8034 ;; (when (spice-standard-p 'layla) "Layla")
8035 ;; (when (spice-standard-p 'mondriaan) "-Mdrn")
8036 ;; (when (spice-standard-p 'hspice)
8037 ;; (when (spice-standard-p 'layla) "/"))
8038 ;; (when (spice-standard-p 'hspice) "Hspice")
8039 ;; (when (spice-standard-p 'eldo)
8040 ;; (when (or (spice-standard-p 'hspice)
8041 ;; (spice-standard-p 'layla)) "/"))
8042 ;; (when (spice-standard-p 'eldo) "Eldo")
8043 ;; (when (spice-standard-p 'eldorf) "-RF")
8044 ;; (when (spice-standard-p 'eldovloga) "-VlA")
8045 ;; (when (spice-standard-p 'fasthenry)
8046 ;; (when (or (spice-standard-p 'eldo)
8047 ;; (spice-standard-p 'hspice)
8048 ;; (spice-standard-p 'layla)) "/"))
8049 ;; (when (spice-standard-p 'fasthenry) "FastHenry")
8050 ;; (when (spice-standard-p 'draccdl)
8051 ;; (when (or (spice-standard-p 'eldo)
8052 ;; (spice-standard-p 'hspice)
8053 ;; (spice-standard-p 'layla)
8054 ;; (spice-standard-p 'fasthenry)) "/"))
8055 ;; (when (spice-standard-p 'draccdl) "DracCDL")
8056 ;; (when (spice-standard-p 'spectre)
8057 ;; (when (or (spice-standard-p 'eldo)
8058 ;; (spice-standard-p 'hspice)
8059 ;; (spice-standard-p 'layla)
8060 ;; (spice-standard-p 'fasthenry)
8061 ;; (spice-standard-p 'draccdl)) "/"))
8062 ;; (when (spice-standard-p 'spectre) "Spectre")
8063 ;; (when (or (spice-standard-p 'fasthenry)
8064 ;; (spice-standard-p 'eldo)
8065 ;; (spice-standard-p 'hspice)
8066 ;; (spice-standard-p 'layla)
8067 ;; (spice-standard-p 'draccdl)
8068 ;; (spice-standard-p 'spectre)) "|")))
8069 ;; "Spice"
8070 ;; (when spice-output-local "-output")
8071 ;; (when spice-some-comment-regions-are-hidden " H+"))))
8074 (defun spice-check-spice-standard ()
8075 "checks if spice-standard is set to a correct value."
8076 ;; if mondriaan then also layla
8077 (when (spice-standard-p 'mondriaan)
8078 (unless (spice-standard-p 'layla)
8079 (error "Error: turn on Layla when you want to use Mondriaan")))
8080 ;; if eldoRf then also eldo
8081 (when (spice-standard-p 'eldorf)
8082 (unless (spice-standard-p 'eldo)
8083 (error "Error: turn on Eldo when you want to use Eldo RF")))
8084 ;; if eldo verilog-A then also eldo
8085 (when (spice-standard-p 'eldovloga)
8086 (unless (spice-standard-p 'eldo)
8087 (error "Error: turn on Eldo when you want to use Eldo Verilog-A")))
8090 (defun spice-update-existing-buffers ()
8091 "updates all spice-mode buffers with new customization"
8092 (save-excursion
8093 (let ((current (current-buffer)))
8094 (mapcar
8095 (lambda (buffer)
8096 (set-buffer buffer)
8097 (if (and (eq major-mode 'spice-mode)
8098 (not (eq current buffer)))
8099 (progn
8100 (message "Activating customizations in %s" buffer)
8101 (spice-activate-customizations-local))))
8102 (buffer-list))))
8106 (defun spice-activate-customizations-local ()
8107 "Activates customization (of global variables) in current buffer."
8108 (if (spice-output-p)
8109 (use-local-map spice-output-mode-map)
8110 (use-local-map spice-mode-map))
8111 (spice-set-spice-name)
8112 (spice-update-mode-menu)
8113 (set-syntax-table spice-mode-syntax-table)
8114 (if (not (spice-output-p))
8115 (setq imenu-generic-expression spice-imenu-generic-expression))
8116 (when spice-imenu-add-to-menubar
8117 (imenu-add-to-menubar "Index"))
8118 ;; rebuild menu:
8119 (setq imenu--index-alist nil)
8120 (imenu--make-index-alist t)
8121 (spice-compile-init)
8122 (spice-waveform-viewer-init)
8123 (if (fboundp 'font-lock-unset-defaults)
8124 (font-lock-unset-defaults))
8125 (font-lock-set-defaults)
8126 (font-lock-flush)
8130 (defun spice-activate-customizations-obsolete ()
8131 "Activate all customizations on local variables.
8133 Run this if you set the spice-standard variable to modify
8134 spice-mode's behaviour in the local buffer. It sets up the buffer
8135 local variables using the modified global variables of the
8136 customization buffer."
8137 (interactive)
8138 (if (spice-output-p)
8139 (use-local-map spice-output-mode-map)
8140 (use-local-map spice-mode-map))
8141 ;; (setq spice-standard-local spice-standard)
8142 (spice-set-spice-name)
8143 (spice-menu-init)
8144 (spice-update-mode-menu)
8145 (spice-mode-syntax-table-init)
8146 (set-syntax-table spice-mode-syntax-table)
8147 (spice-keywords-init)
8148 (spice-font-lock-init)
8149 (spice-imenu-init)
8150 (if (not (spice-output-p))
8151 (setq imenu-generic-expression spice-imenu-generic-expression))
8152 ;; add imenu to menubar ?
8153 (when spice-imenu-add-to-menubar
8154 (imenu-add-to-menubar "Index"))
8155 (spice-compile-variables-init)
8156 (spice-compile-init)
8157 (spice-waveform-viewer-init)
8158 (if (fboundp 'font-lock-unset-defaults)
8159 (font-lock-unset-defaults))
8160 ;; (setq font-lock-defaults
8161 ;; (list 'spice-font-lock-keywords nil t (list (cons ?\" "w"))))
8162 (font-lock-set-defaults)
8163 (font-lock-flush))
8166 ;; ======================================================================
8167 ;; spice-mode main entry point
8168 ;; ======================================================================
8169 ;;;###autoload
8170 (defun spice-mode ()
8171 "Major mode for editing spice decks in (X)Emacs.
8173 Entry to Spice mode calls the value of the variable `spice-mode-hook'
8174 with no args, if that value is non-nil after initialization is finished.
8176 Usage & Features:
8177 -----------------
8179 - Comprehensive menu
8181 - Highlighting of (extended) SPICE syntax, with (limited) ERROR notification
8182 Please setup spice-mode to recognize the correct syntax through
8183 customization of the `spice-standard' variable. You can use the menu
8184 entry Spice->Customize->Spice Standard to do this interactively.
8186 - Template insertion (abbrev/electrification) for many spice constructs,
8187 two alternatives are available: Abbrev minor mode and `tempo-complete-tag'
8188 + Abbrevs can be turned on and off via the Settings submenu.
8189 To see the available abbrevs, use `M-x list-abbrevs' or use the menu
8190 after enabling abbrev minor mode. To find out what key sequence
8191 triggers an expand do 'C-h w expand-abbrev'.
8192 + `tempo-complete-tag' is bound to <tab> - for example, type 'M<tab>'
8193 at the beginning of a line and you will be prompted with a complete
8194 Mosfet template. Most tags are pretty straightforward i.e 'C' for a
8195 capacitor, 'L' for an inductance etc...
8196 You can type `C-h v tempo-tags'for a complete list of tags and
8197 associated templates. Note: to insert a real <TAB>, use <C-q TAB> or
8198 <shift TAB>.
8200 - Comment & documentation string handling
8201 + the '*' symbol is used to comment out a whole line - that symbol has
8202 to be at the beginning of a line
8203 + the '!' and '$' symbols are used to document your netlist in eldo
8204 and hspice/layla mode respectively
8205 + menu entry to comment out region/uncomment region
8206 + key bindings for commenting/uncommenting a region as in `auctex-mode'.
8208 - Comment hiding support
8209 + Can hide all commented out regions in a buffer to improve readability
8210 + prefix string is customizable: `spice-hide-line-prefix'.
8211 + custom variable can be set to automatically hide all commented regions
8212 at load time (`spice-auto-hide-comments')
8213 + requires use of doc strings, otherwise also documentation might be
8214 hidden
8215 + When parts of the deck are hidden the string \"H+\" appears in the
8216 modeline.
8218 - Imenu (Index menu and/or shift right click in emacs if configured)
8219 + shows subcircuit definitions
8220 + shows .end statements in submenu
8221 + shows device models in submenus
8222 + shows libraries (.lib/.inc) in submenu
8223 + shows analyses in submenu
8224 + shows sections in submenu
8225 + shows output file sections in menu
8226 + shows LAYLA objects in submenus if layla submode has been enabled
8227 + can be added to the menubar by setting `spice-imenu-add-to-menubar'
8228 (uses `imenu-add-to-menubar' to add an Imenu entry to the menubar).
8230 - File browser using Speedbar (`speedbar') and/or index/sources menu
8232 - .inc/.include/.lib/.libfas access
8233 + through mouse-2 click (`ffap-at-mouse' or `spice-load-file-at-mouse')
8234 + using \\r (ie. <return>), (`ffap')
8235 + through menu entry all include/lib files of a deck can be loaded at
8236 once (`spice-load-include-files'), recursively.
8238 - Searching for .subckt defs: `spice-search-subckt' or `C-c C-s'
8239 + extracts subcircuit name from context
8240 + search history
8241 + mark is set where search has been started if the definition is found
8242 in the same file. Return to mark with `C-u C-<SPC>' (or `C-u C-@')
8243 as with interactive searches (fi `isearch-forward')
8244 + be careful when starting the search from an included file,
8245 correctness can not be guaranteed. Starting a search from
8246 a top-level .cir file gives correct results. The latest used
8247 top-level file is stored (a top-level file contains a .end
8248 statement !), and also searched if the subckt def is not found in
8249 a first pass (for instance when starting from an included file).
8251 - Postscript printing with fontification (through `ps-print' package).
8253 - Addition of Spice Deck submenu in msb mode, see `msb', `spice-msb-fix'.
8255 - Section support (as in eldo-mode):
8256 + add section headers, goto section through menu entries or interactive
8257 + customizable through `spice-section-alist', you can add your
8258 own section headers, alter the list of predefined sections, ...
8259 + Changelog addition through `spice-add-changelog-entry', or
8260 use `C-c a c'.
8262 - Simulator support
8263 + use `spice-simulator' and `spice-simulator-switches' to
8264 select your simulator from `spice-simulator-alist'.
8265 + Support for error parsing of spice3 (batch-mode, -b),
8266 hspice, eldo and spectre. Add your own in spice-mode or through
8267 customization in `.emacs'.
8268 + use local file variables to customize per file as follows:
8269 <<< test.cir >>>
8271 .end
8273 * Local Variables:
8274 * mode: spice
8275 * spice-simulator: \"Hspice\"
8276 * spice-simulator-switches: \"\"
8277 * eval: (spice-set-command)
8278 * End:
8279 <<< test.cir ends here >>>
8281 - Waveform viewer support (beta)
8282 + use `spice-waveform-viewer' and `spice-waveform-viewer-switches' to
8283 select your waveform from `spice-waveform-viewer-alist'.
8284 + Support for interactive (command-line) waveform viewer such as
8285 nutmeg, or batch (GUI) type waveform viewer such as xelga or gsi.
8287 - Output file support
8288 + can load output file from menu (checks if file exists and is readable)
8289 + imenu in output files shows output file sections
8290 + for eldo .chi files: can create <file>_guess.cir files automatically
8291 for inclusion in <file>.cir file through
8292 `spice-create-guess-nodeset-file'
8293 or `spice-replace-with-guess-nodeset-statements'; this speeds up DC
8294 convergence for AC analyses.
8296 - (Fully) customizable
8297 + can select spice compatibility mode:
8298 * spice2g6/3 (default)
8299 * hspice (default)
8300 * eldo (default), RF and verilog-A extensions
8301 * fasthenry (default)
8302 * Dracula CDL
8303 * LAYLA, Mondriaan extensions
8304 * any combination of the above (there are conflicts however, so not
8305 all keyword fontification is correct in the latter case)
8306 + spice-mode font-lock faces
8307 + spice-mode default initialization of empty/new files determined by
8308 `spice-initialize-empty-file', `spice-initialize-template-file',
8309 `spice-default-header' and `spice-initialize-file-function'.
8310 + see the customization examples in the `spice-mode.el' file header
8311 + You can adapt `spice-simulator-alist' for your local site in
8312 `spice-mode.el' or in `.emacs' through customization.
8313 + You can adapt `spice-waveform-viewer-alist' for your local site in
8314 `spice-mode.el' or in `.emacs' through customization.
8315 + You can adapt `spice-section-alist' for your local site in
8316 `spice-mode.el' or in `.emacs' through customization.
8318 - Auto fill minor mode support
8319 + can be turned on from the Settings menu
8320 + auto fill works both for element where the continuation character
8321 is a '+', as well as in comment/doc mode where the continuation
8322 character is a '*', '$' or a '!'.
8323 + uses `fill-column' to determine where to wrap the line
8324 + doesn't use `fill-prefix'. A context dependent prefix is calculated
8325 through the `spice-comment-indent-new-line' function. This function
8326 is used as `comment-line-break-function' instead of the default line
8327 break function (in emacs: `comment-indent-new-line').
8329 - Paragraph support: [a-z] starts dev lines, '+' continues dev lines,
8330 [*!$] start paragraphs.
8332 - Works under GNU Emacs20.6/21.[123].
8335 Do not use a -*- Mode -*- line in a spice deck as the first card in
8336 the deck is defined to be the title card. Rather, autoload spice-mode
8337 through your .emacs file:
8339 (autoload 'spice-mode \"spice-mode\" \"Spice/Layla Editing Mode\" t)
8340 (setq auto-mode-alist (append (list (cons \"\\\\.sp$\" 'spice-mode)
8341 (cons \"\\\\.cir$\" 'spice-mode)
8342 (cons \"\\\\.cdl$\" 'spice-mode)
8343 (cons \"\\\\.chi$\" 'spice-mode) ; output
8344 (cons \"\\\\.mod$\" 'spice-mode)); models
8345 auto-mode-alist))
8347 Alternative methods are provided in the spice-mode.el file header.
8349 Key bindings in highlighted include file lines:
8350 -----------------------------------------------
8352 \\{spice-mode-mouse-map}
8354 Key bindings for other parts in the file:
8355 -----------------------------------------
8357 \\{spice-mode-map}
8359 ;;Key bindings for output files:
8360 ;;------------------------------
8362 ;;\\{spice-output-mode-map}
8365 (interactive)
8366 (kill-all-local-variables) ; important !
8368 (setq major-mode 'spice-mode)
8369 (setq mode-name "Spice")
8371 ;; remember if this file is an output type
8372 (set (make-local-variable 'spice-output-local) (spice-check-output-mode))
8374 ;; set mode name
8375 (spice-set-spice-name)
8377 ;; build global syntax table
8378 (unless spice-mode-syntax-table
8379 (spice-mode-syntax-table-init))
8380 ;; set it for local buffer
8381 (set-syntax-table spice-mode-syntax-table)
8383 ;; initialize global spice keywords, required for output mode !
8384 (unless spice-keywords
8385 (spice-keywords-init))
8387 ;; global font-lock start-up
8388 (unless spice-font-lock-keywords
8389 (spice-font-lock-init))
8391 ;; create global Spice mode menu's: mode-menu and output-mode-menu
8392 (unless (and spice-menu-list spice-output-menu-list)
8393 (spice-menu-init))
8395 ;; global spice-imenu init (not output mode !)
8396 (unless spice-imenu-generic-expression
8397 (spice-imenu-init))
8399 ;; global vars for compile init
8400 (unless spice-compilation-error-regexp-alist
8401 (spice-compile-variables-init))
8403 (set (make-local-variable 'parse-sexp-ignore-comments) nil)
8405 (set (make-local-variable 'tempo-interactive) t)
8406 (set (make-local-variable 'require-final-newline) t) ; hspice empty deck errors
8408 (set (make-local-variable 'comment-start) "*")
8409 (set (make-local-variable 'comment-end) "")
8410 (set (make-local-variable 'comment-start-skip) "\*")
8411 (set (make-local-variable 'comment-multi-line) nil)
8413 ;;------------------------------------------------------------
8414 ;; initialize hiding functions, mix of global and buffer local settings
8415 (spice-hide-init)
8417 (if (spice-output-p)
8418 (spice-mode-output)
8420 ;; use local keymap (for keys and menu)
8421 (use-local-map spice-mode-map)
8423 ;; set menu for local buffer
8424 (easy-menu-define spice-menu spice-mode-map
8425 "Menu keymap for Spice Mode." spice-menu-list)
8427 ;; abbreviations table: buffer local
8428 (setq local-abbrev-table spice-mode-abbrev-table)
8430 ;; buffer local init
8431 (set (make-local-variable 'fill-prefix) nil) ; automatically derived
8432 ;; remove auto-fill-inhibit and added spice-comment-indent... function
8433 ;; (set (make-local-variable 'auto-fill-inhibit-regexp) "^\*[^\.\+].*")
8435 ;; buffer local init for indentation of comment
8436 (set (make-local-variable 'spice-save-comment-line-break-function)
8437 comment-line-break-function)
8438 (set (make-local-variable 'comment-line-break-function)
8439 'spice-comment-indent-new-line)
8440 (set (make-local-variable 'fill-column) 78) ;; was 80
8442 ;; support for paragraphs (is it useful?) ; this is really arbitrary
8443 ;; all buffer local
8444 ;; (set (make-local-variable 'paragraph-start) "^[!$*]-.*$")
8445 ;; (set (make-local-variable 'paragraph-separate) "^[!$*]-.*$")
8446 (set (make-local-variable 'paragraph-start)
8447 "\\([a-z\\.].*\\([\n][+].*\\)*\\|[$]...+\\|[!]...+\\|[ \t\f]*$\\|\\*...+\\|.*\\s-[$!].*$\\)")
8448 ;; (set (make-local-variable 'paragraph-separate) "[a-z$!*]")
8449 (set (make-local-variable 'paragraph-separate) "\\([ \t\f]*\\|.*\\s-[$!].*\\)$")
8450 (set (make-local-variable 'adaptive-fill-regexp) nil)
8451 (set (make-local-variable 'adaptive-fill-function) 'spice-fill-context-prefix)
8452 (set (make-local-variable 'adaptive-fill-first-line-regexp) "[*$!+]\\s-+")
8454 ;; Tempo tags - using 'tempo-local-tags' doesn't work (why??)
8455 (set (make-local-variable 'tempo-tags)
8456 (append spice-tempo-tags tempo-tags))
8458 ;; buffer local font lock
8459 (set (make-local-variable 'font-lock-defaults)
8460 (list 'spice-font-lock-keywords nil t (list (cons ?\" "w")))) ;; nil, t (do multiline comments)
8461 (set (make-local-variable 'font-lock-multiline) t)
8462 (font-lock-set-defaults)
8464 ;; imenu init:
8465 (set (make-local-variable 'imenu-case-fold-search) t)
8466 ;; buffer local imenu init
8467 (set (make-local-variable 'imenu-generic-expression)
8468 spice-imenu-generic-expression)
8470 ;; add speedbar (global, can be moved ?)
8471 (spice-speedbar-init)
8473 ;;------------------------------------------------------------
8474 ;; now hook in 'spice-colorize-libraries (eldo-mode.el)
8475 ;; all buffer local:
8476 (add-hook 'font-lock-after-fontify-buffer-hook
8477 'spice-colorize-libraries-buffer t t) ; not in emacs 20
8478 (add-hook 'after-change-functions 'spice-colorize-libraries t t)
8479 (spice-colorize-libraries-buffer)
8481 ;;------------------------------------------------------------
8482 ;; compile buffer local init
8483 (spice-compile-init)
8485 ;;------------------------------------------------------------
8486 ;; buffer local init
8487 (spice-waveform-viewer-init)
8489 ;; if new file add a default template
8490 (if (and (= (buffer-size) 0)
8491 (not buffer-read-only)
8492 spice-initialize-empty-file
8493 (functionp spice-initialize-file-function))
8494 (funcall spice-initialize-file-function))
8496 ) ;; matches big if (normal spice or spice output mode)
8498 ;; build imenu, buffer local
8499 (imenu--make-index-alist t)
8501 ;; add imenu to menubar, buffer local
8502 (when spice-imenu-add-to-menubar
8503 (imenu-add-to-menubar "Index"))
8505 ;; msb fix, run only once
8506 (and (featurep 'msb) ;; have we got this feature ?
8507 msb-mode ;; is it on ?
8508 (boundp 'msb-menu-cond) ;; still using msb-menu-cond ?
8509 (not spice-msb-fixed) ;; haven't yet added spice decks category ?
8510 (spice-msb-fix)) ;; add category
8512 ;; open describe window, hope this doesn't annoy people too much...
8513 (if spice-show-describe-mode
8514 (save-excursion
8515 (describe-mode) ;; aha...
8516 (setq spice-show-describe-mode nil)) ;; but only once in a session !!
8518 (if spice-echo-intro
8519 (message "Spice mode %s. Type C-h m for documentation." ;; always
8520 spice-version))
8522 ;; run spice-mode hooks
8523 (run-hooks 'spice-mode-hook)
8527 ;; this is sometimes useful
8528 (provide 'spice-mode)
8530 ;;; spice-mode.el ends here
8532 ;;; Local Variables:
8533 ;;; mode:Emacs-lisp
8534 ;;; End: