/spice-mode/spice-mode.el

#
Emacs Lisp | 8679 lines | 7223 code | 774 blank | 682 comment | 271 complexity | 89b5512e5c5904e034ebe8a4bff124e0 MD5 | raw file
  1. ;;; spice-mode.el --- major mode providing a spice mode hook for fontification
  2. ;;; $Id: spice-mode.el,v 1.100 2007/01/03 16:46:46 vdplasg Exp $
  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: ngspice, gnucap, spice, spice2g6, spice3, eldo, hspice, layla, mondriaan, fasthenry, CDL, spectre compatibility, netlist editing
  8. ;; Filename: spice-mode.el
  9. ;; Version: 1.2.25
  10. ;; Maintainer: Geert A. M. Van der Plas <geert_vanderplas@email.com>
  11. ;; Last-Updated: 01 November 2004
  12. ;; Description: spice file editing
  13. ;; URL: http://spice-mode.4t.com/
  14. ;; old-URL: http://www.esat.kuleuven.ac.be/~vdplas/emacs/
  15. ;; Compatibility: Emacs2[01], (partly tested)XEmacs21
  16. ;; Please send suggestions and bug reports to
  17. ;; mailto:Geert_VanderPlas@email.com
  18. ;; Copyright (C) 1994, MIT Artificial Intelligence Lab
  19. ;; Copyright (C) 1997- Emmanuel Rouat
  20. ;; Copyright (C) 1999- Geert A. M. Van der Plas
  21. ;; This file is free software; you can redistribute it and/or modify
  22. ;; it under the terms of the GNU General Public License as published by
  23. ;; the Free Software Foundation; either version 2, or (at your option)
  24. ;; any later version.
  25. ;; This file is distributed in the hope that it will be useful,
  26. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. ;; GNU General Public License for more details.
  29. ;; You should have received a copy of the GNU General Public License
  30. ;; along with GNU Emacs; see the file COPYING. If not, write to
  31. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  32. ;; INSTALL:
  33. ;; ========
  34. ;; byte compile spice-mode.el to spice-mode.elc (see `byte-compile-file')
  35. ;; put these two files in an arbitrary, but accesible directory
  36. ;; for example: $HOME/emacs, /usr/lib/emacs/site-lisp/ or
  37. ;; /usr/local/lib/emacs/site-lisp/
  38. ;; If you chose a non-standard place to put the files add the following
  39. ;; line to your Emacs start-up file (`.emacs') or custom `site-start.el'
  40. ;; file (replace <directory-name> by the directory where you placed
  41. ;; spice-mode.el and spice-mode.elc):
  42. ;; (setq load-path (cons (expand-file-name "<directory-name>") load-path))
  43. ;; To use spice-mode, add either the following to your `.emacs' file. This
  44. ;; assumes that you will use the .sp, .cir, .ckt, .mod, ... extensions for
  45. ;; your spice source decks and output files:
  46. ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
  47. ;; (setq auto-mode-alist (append (list (cons "\\.sp$" 'spice-mode)
  48. ;; (cons "\\.cir$" 'spice-mode)
  49. ;; (cons "\\.ckt$" 'spice-mode)
  50. ;; (cons "\\.spc$" 'spice-mode) ; xcircuit output
  51. ;; (cons "\\.spice$" 'spice-mode) ; magic output
  52. ;; (cons "\\.mod$" 'spice-mode)
  53. ;; (cons "\\.cdl$" 'spice-mode)
  54. ;; (cons "\\.chi$" 'spice-mode) ;eldo outpt
  55. ;; (cons "\\.inp$" 'spice-mode))
  56. ;; auto-mode-alist))
  57. ;; Other way to load spice mode (by Andrew Scott):
  58. ;; ;;; Testing for spice-mode (Another spice mode, also works on Spice,
  59. ;; ;;; Eldo, Layla; this one works on GNU Emacs-20.6 issues).
  60. ;; (autoload 'spice-mode "spice-mode" "Spice/Layla Editing Mode" t)
  61. ;; (add-to-list 'auto-mode-alist '("\\.cir$" . spice-mode))
  62. ;; (add-to-list 'auto-mode-alist '("\\.ckt$" . spice-mode))
  63. ;; (add-to-list 'auto-mode-alist '("\\.inp$" . spice-mode))
  64. ;; (add-to-list 'auto-mode-alist '("\\.spout$" . spice-mode));hspice out
  65. ;; (add-to-list 'auto-mode-alist '("\\.pdir$" . spice-mode))
  66. ;; ;;; Intel formats
  67. ;; (add-to-list 'auto-mode-alist '("\\.[sS][pP]$" . spice-mode))
  68. ;; (add-to-list 'auto-mode-alist '("\\.[sm]?t0$" . spice-mode))
  69. ;; (add-to-list 'auto-mode-alist '("\\.[h]?spice$" . spice-mode))
  70. ;; CUSTOMIZATION:
  71. ;; ==============
  72. ;; use customization to modify the behaviour of spice-mode; add
  73. ;; custom-set-variables to your `.emacs' file, for example:
  74. ;; (custom-set-variables
  75. ;; ; '(spice-initialize-file-function (quote geert-spice-file-header)) ;; use geert-spice-file-header function (not included in this file !)
  76. ;; '(spice-initialize-empty-file t) ;; initialize empty/new spice file
  77. ;; ; '(spice-standard '(spice2g6 (hspice eldo eldorf eldovloga layla))) ;; all 4 modes
  78. ;; '(spice-standard (quote (spice2g6 (hspice eldo)))) ;; hspice and eldo
  79. ;; '(spice-standard (quote (spice2g6 ()))) ;; spice2g6/3 only
  80. ;; '(spice-simulator "Spice3") ;; default simulator
  81. ;; '(spice-waveform-viewer "ngnutmeg") ;; default waveform
  82. ;; '(spice-highlight-keywords nil) ;; less highlighting
  83. ;; '(spice-section-alist ;; add own sections
  84. ;; ;; this is ugly, I know ;)
  85. ;; (append (nth 1 (nth 0 (get 'spice-section-alist 'standard-value)))
  86. ;; (list
  87. ;; (list "My Header" "MY HEADER" nil)
  88. ;; )))
  89. ;; '(spice-use-func-menu t) ;; use func-menu (XEmacs)
  90. ;; '(spice-show-describe-mode nil) ;; don't describe mode at startup
  91. ;; )
  92. ;; This can also be achieved interactively through customizations !
  93. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  94. ;;; Commentary:
  95. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  96. ;; The original spice-mode.el created by C. Vieri has been modified
  97. ;; extensively. These changes have been heavily influenced by the eldo-mode.el
  98. ;; of Emmanuel Rouat (the tempo-templates for one) and the vhdl-mode.el of
  99. ;; Reto Zimmermann and Rodney J. Whitby (the font-locking, the
  100. ;; customization, the menus, ...) Help in understanding 'advanced' lisp
  101. ;; was provided by G. Debyser <geert.debyser@advalvas.be>, our (common) lisp
  102. ;; expert. Since version 0.97 a lot of input/ideas have been provided by
  103. ;; Emmanuel Rouat. Just take a look and search for eldo-mode ;)
  104. ;; This package provides an Emacs major mode for editing SPICE decks.
  105. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  106. ;;; TODO:
  107. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  108. ;; - customization group spice- needs to be improved
  109. ;; activate customizations needs to be looked at (potentially removed)
  110. ;; - fix problem imenu sometimes truncating filenames of include files
  111. ;; by replacing the functionality with own function
  112. ;; - improve Y instance handling. use builtin macromodels, and own development;; models
  113. ;; - ...
  114. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  115. ;;; BUGS:
  116. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  117. ;; - searching for .subckt could be buggy because of user's file structure
  118. ;; - xinstance highlighting is buggy, and probably always will ?
  119. ;; - font-lock expressions are incredibly complicated, and multiple spice
  120. ;; formats are not handled correctly at the same time...
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;; If you have any questions about this mode, feel free to contact me
  123. ;; at the following address: geert_vanderplas@email.com. If I find the
  124. ;; time, I can take a look at the problem
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. ;; free variables
  127. (defvar fume-function-name-regexp-alist)
  128. (defvar fume-function-name-regexp)
  129. (defvar compilation-file-regexp-alist)
  130. (defvar fume-find-function-name-method-alist)
  131. (defvar fume-menubar-menu-name)
  132. (defvar fume-buffer-menu)
  133. (defvar fume-buffer-name)
  134. (defvar fume-index-method)
  135. (defvar msb-menu-cond)
  136. (defconst spice-version "1.2.26 (12 Dec 2009)"
  137. "Current version of spice mode (spice2g6/spice3/hspice/eldo(rf&verilog-a)/fasthenry/layla/mondriaan/draccdl/spectre).")
  138. (defconst spice-developer
  139. "Geert Van der Plas & Emmanuel Rouat (<geert_vanderplas@email.com>, <emmanuel.rouat@wanadoo.fr>)"
  140. "Current developers/maintainers of spice-mode.")
  141. (defvar spice-running-xemacs (string-match "XEmacs" emacs-version)
  142. "A variable that tells us whether we're in Xemacs or not")
  143. (defvar spice-tempo-tags nil
  144. "List of templates used in spice mode.")
  145. ;; help function
  146. (defun spice-custom-set (variable value &rest functions)
  147. "Set variables as in `custom-set-default' and call FUNCTIONS (if
  148. bound) afterwards."
  149. (if (fboundp 'custom-set-default)
  150. (custom-set-default variable value)
  151. (set-default variable value))
  152. (while functions
  153. (when (fboundp (car functions)) (funcall (car functions)))
  154. (setq functions (cdr functions))))
  155. (defgroup spice nil
  156. "Customizations for Spice mode."
  157. :prefix "spice-"
  158. :link '(url-link "http://spice-mode.4t.com/")
  159. :group 'languages
  160. )
  161. ;;;###autoload
  162. (defcustom spice-mode-hook nil
  163. "*List of hook functions run by `spice-mode' (see `run-hooks')."
  164. :type 'hook
  165. :group 'spice)
  166. ;;;###autoload
  167. (defcustom spice-standard '(spice2g6 (hspice eldo eldorf eldovloga fasthenry)) ; "layla" has been removed
  168. "*Spice standards used.
  169. Basic standard:
  170. Spice2g6 : Original Berkeley Spice (leave this always on!)
  171. Additional standards:
  172. Gnucap : The Gnu Circuit Analysis Package
  173. Hspice (TM) : Commercial Spice, formerly Meta Software, now owned by Synopsys
  174. Eldo (TM) : Commercial Spice, formerly Anacad, now owned by Mentor Graphics
  175. EldoRf (TM) : RF Steady State analyses of Eldo (also turn on Eldo!)
  176. EldoVlogA : Verilog-A extensions to Eldo netlist language (also turn on Eldo!)
  177. FastHenry : Multipole-accelerated inductance analysis program from MIT
  178. Layla : KULeuven LAYLA (layout synthesis) extensions to Spice format
  179. Mondriaan : KULeuven MONDRIAAN (layout synthesis) extensions (also turn on Layla!)
  180. DracCDL (TM): Dracula CDL extensions (Cadence LOGLVS netlists)
  181. Spectre (TM): Spice compatibility of Spectre language (simulator language=spice decks)
  182. "
  183. :type '(list (choice :tag "Basic standard"
  184. (const :tag "Spice2g6" spice2g6))
  185. (set :tag "Additional standards" :indent 2
  186. (const :tag "Hspice" hspice)
  187. (const :tag "Eldo" eldo)
  188. (const :tag "Eldo RF" eldorf)
  189. (const :tag "Eldo Verilog-A" eldovloga)
  190. (const :tag "FastHenry" fasthenry)
  191. (const :tag "Layla" layla)
  192. (const :tag "Mondriaan" mondriaan)
  193. (const :tag "DracCDL" draccdl)
  194. (const :tag "Spectre Spice Compatibility" spectre)))
  195. :set (lambda (variable value)
  196. (spice-custom-set variable value
  197. 'spice-check-spice-standard
  198. 'spice-mode-syntax-table-init
  199. 'spice-keywords-init
  200. 'spice-font-lock-init
  201. 'spice-imenu-init
  202. 'spice-update-existing-buffers))
  203. :group 'spice)
  204. ;;;###autoload
  205. (defcustom spice-imenu-add-to-menubar t
  206. "*Spice mode adds imenu (Index) item to menubar"
  207. :group 'spice
  208. :set (lambda (variable value)
  209. (spice-custom-set variable value
  210. 'spice-update-existing-buffers))
  211. :type 'boolean)
  212. ;;;###autoload
  213. (defcustom spice-use-func-menu nil
  214. "*Spice func menu setting (untested), comparable to imenu"
  215. :group 'spice
  216. :set (lambda (variable value)
  217. (spice-custom-set variable value
  218. 'spice-update-existing-buffers))
  219. :type 'boolean)
  220. ;;;###autoload
  221. (defcustom spice-show-describe-mode nil ; was t
  222. "*Spice mode runs `describe-mode' once at start of spice-mode"
  223. :group 'spice
  224. :type 'boolean)
  225. ;;;###autoload
  226. (defcustom spice-echo-intro t
  227. "*Spice mode echos introductory message on entry to spice-mode"
  228. :group 'spice
  229. :type 'boolean)
  230. (defgroup spice-initialize-file nil
  231. "Customizations for initialization of empty/new spice files."
  232. :group 'spice)
  233. ;;;###autoload
  234. (defcustom spice-initialize-empty-file nil
  235. "*Spice initialize empty/new file setting"
  236. :group 'spice-initialize-file
  237. :type 'boolean)
  238. ;;;###autoload
  239. (defcustom spice-initialize-template-file "~/.spice-default"
  240. "*File containing the default header that is inserted when opening
  241. an empty file (ie. a new file), see also `spice-initialize-empty-file'"
  242. :group 'spice-initialize-file
  243. :type 'file)
  244. ;;;###autoload
  245. (defcustom spice-default-header nil
  246. "*Default header for new Spice netlists, see also `spice-initialize-empty-file'"
  247. :group 'spice-initialize-file
  248. :type 'string)
  249. ;;;###autoload
  250. (defcustom spice-initialize-file-function 'spice-initialize-empty-file
  251. "*Optional initialize function for empty/new files, see also
  252. `spice-initialize-empty-file'. If a different function is specified it
  253. should insert a default header/template in the current buffer. This
  254. function should check which submode is in use with `spice-standard-p'
  255. and adapt its output accordingly. It may also use the `spice-default-header'
  256. variable and insert its contents into the buffer."
  257. :group 'spice-initialize-file
  258. :type 'function)
  259. (defgroup spice-simulate nil
  260. "Customizations for simulation."
  261. :group 'spice)
  262. (defcustom spice-simulator-alist
  263. '(
  264. ;; Spice3; spice3 -b <file.cir>
  265. ;;
  266. ("Gnucap" "gnucap -b" ""
  267. ("\\s-*Error[\t ]+on[ \t]+line[\t ]+\\([0-9]+\\) +:.+"
  268. 0 1 nil (buffer-file-name))
  269. ("Circuit: \\(.*\\)$" 1)) ; spice3 hack, is not the filename, but that's no prob
  270. ;; Hspice; hspice <file.cir>
  271. ;; **error**: only 1 connection at node 0:2
  272. ("Hspice" "hspice" ""
  273. ("\\s-*\\(..?error..?[: ]\\).+" 0 spice-linenum 1 (buffer-file-name))
  274. ("[* ]* [iI]nput [fF]ile: +\\([^ \t]+\\).*$" 1))
  275. ;; Eldo; eldo -i <file.cir>
  276. ;; ERROR 503: MODEL "NMOS": Undeclared model reference.
  277. ("Eldo" "eldo -i" ""
  278. ("\\s-*\\(E[rR][rR][oO][rR] +[0-9]+:\\).*"
  279. 0 spice-linenum 1 (buffer-file-name))
  280. ("Running \\(eldo\\).*$" 1)) ; eldo hack, true filename can not be found
  281. ;; Spectre; spectre <file.cir>
  282. ;; "viblok2.cir" 7: Unknown dot word `.param'.
  283. ("Spectre" "spectre" ""
  284. ("\\s-*\"\\([^ \t\n]+\\)\" +\\([0-9]+\\):.*"
  285. 1 2)
  286. ("" 0)) ; filename is in regexp of error
  287. ;;; Add your local simulators here:
  288. ;;
  289. )
  290. "*List of available Spice simulators and their properties.
  291. Each list entry specifies the following items for a simulator:
  292. Simulator:
  293. Simulator Name : name used in variable `spice-simulator' to choose
  294. simulator
  295. Simulate Command : command including options used for simulation program
  296. Extra switches : extra switches for simulator, after filename
  297. Error Message:
  298. Regexp : regular expression to match error messages
  299. File Subexp Index: index of subexpression that matches the file name
  300. Line Subexp Index: index of subexpression that matches the line number.
  301. use function `spice-linenum' when the line number
  302. is not available
  303. Col Subexp Index : index of subexpression that matches the column number
  304. if not available but `spice-linenum' has been
  305. supplied in the previous field, use 1
  306. File Message:
  307. Regexp : regular expression to match a file name message
  308. File Subexp Index: index of subexpression that matches the file name
  309. See also variable `spice-simulator-switches' to add options to the
  310. simulate command.
  311. Most simulators do not include the file name in the error message, but print
  312. out a file name message in advance. In this case, set \"File Subexp Index\"
  313. to 0 and fill out the \"File Message\" entries.
  314. "
  315. :type '(repeat (list :tag "Simulator" :indent 2
  316. (string :tag "Simulator Name ")
  317. (string :tag "Simulate Command ")
  318. ;(string :tag "From Directory " "./")
  319. (string :tag "Extra Switches ")
  320. (list :tag "Error Message" :indent 4
  321. (regexp :tag "Regexp ")
  322. (integer :tag "File Subexp Index")
  323. (integer :tag "Line Subexp Index"))
  324. (list :tag "File Message" :indent 4
  325. (regexp :tag "Regexp ")
  326. (integer :tag "File Subexp Index"))))
  327. :set (lambda (variable value)
  328. (spice-custom-set variable value
  329. 'spice-menu-init
  330. 'spice-compile-variables-init
  331. 'spice-update-existing-buffers))
  332. :group 'spice-simulate)
  333. ;;;###autoload
  334. (defcustom spice-simulator nil ; example: "Hspice"
  335. "*Spice command, used when compiling buffer with `compile-mode',
  336. see also `spice-simulator-switches'."
  337. :group 'spice-simulate
  338. :type 'string)
  339. ;;;###autoload
  340. (defcustom spice-simulator-switches "" ; example "-noconf"
  341. "*Spice command switches, used when compiling buffer with `compile-mode',
  342. see also `spice-simulator'."
  343. :group 'spice-simulate
  344. :type 'string)
  345. (defcustom spice-waveform-viewer-alist
  346. '(
  347. ;; Nutmeg; nutmeg <waveformdata.dat>
  348. ;;
  349. ("Gwave" "gwave" "" spice-run-silent
  350. (".raw" ".braw" ".ac0" ".tr0" ".sw0" ".W" ".N" ".acs")) ; gwave viewer
  351. ("ngnutmeg" "ngnutmeg" "" spice-run-interactive (".dat" ".ac0" ".tr0")) ; spice3 nutmeg viewer
  352. ("Xelga" "xelga" "" spice-run-silent ".cou") ; xelga eldo viewer
  353. ("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...
  354. ;; ("Awaves2" "echo_awaves" "" spice-run-silent nil) ; awaves hspice viewer
  355. ;;; Add your local waveform viewers here:
  356. ;;
  357. )
  358. "*List of available Waveform viewers and their properties.
  359. Each list entry specifies the following items for a waveform viewer:
  360. Waveform Viewer:
  361. Wave Viewer Name : name used in variable `spice-waveform-viewer' to choose
  362. a waveform viewer
  363. Wave Viewer Command : command including options used for waveform viewer
  364. Extra switches : extra switches for waveform viewer, after filename
  365. See also variable `spice-waveform-viewer-switches' to add options to the
  366. waveform viewer command.
  367. "
  368. :type '(repeat (list :tag "Waveform Viewer" :indent 2
  369. (string :tag "Waveform Viewer Name ")
  370. (string :tag "Waveform Viewing Command ")
  371. (string :tag "Extra Switches ")
  372. (choice :tag "How"
  373. :value spice-run-silent
  374. (function-item spice-run-silent)
  375. (function-item spice-run-interactive)
  376. (function :tag "Other"))
  377. (choice (string :tag "Filename Suffix ")
  378. (function :tag "Function Deriving Filename")
  379. (repeat (list :tag "List of Filename Suffixes")))))
  380. :set (lambda (variable value)
  381. (spice-custom-set variable value
  382. 'spice-menu-init
  383. 'spice-update-existing-buffers))
  384. :group 'spice-simulate)
  385. ;;;###autoload
  386. (defcustom spice-waveform-viewer nil ; example: "ngnutmeg"
  387. "*Spice command, used when starting waveform viewer,
  388. see also `spice-waveform-viewer-switches'."
  389. :group 'spice-simulate
  390. :type 'string)
  391. ;;;###autoload
  392. (defcustom spice-waveform-viewer-switches "" ; example "-b"
  393. "*Spice waveform viewer command switches,
  394. see also `spice-waveform-viewer'."
  395. :group 'spice-simulate
  396. :type 'string)
  397. (defgroup spice-commands nil
  398. "Customizations for commands."
  399. :group 'spice)
  400. ;;;###autoload
  401. (defcustom spice-shell
  402. (if (memq system-type '(ms-dos emx windows-nt))
  403. shell-file-name
  404. "/bin/sh")
  405. "*Name of shell used to parse spice commands."
  406. :group 'spice-commands
  407. :type 'file)
  408. ;;;###autoload
  409. (defcustom spice-shell-command-option
  410. (cond ((memq system-type '(ms-dos emx windows-nt) )
  411. (cond ((boundp 'shell-command-option)
  412. shell-command-option)
  413. ((boundp 'shell-command-switch)
  414. shell-command-switch)
  415. (t
  416. "/c")))
  417. (t ;Unix & EMX (Emacs 19 port to OS/2)
  418. "-c"))
  419. "*Shell argument indicating that next argument is the command."
  420. :group 'spice-commands
  421. :type 'string)
  422. (defgroup spice-hide nil
  423. "Customizations for hiding of comments."
  424. :group 'spice)
  425. ;;;###autoload
  426. (custom-declare-variable 'spice-hide-line-prefix
  427. '(concat
  428. (regexp-quote
  429. (concat comment-start
  430. (if (boundp 'comment-padding)
  431. (if (integerp comment-padding)
  432. (make-string comment-padding ? )
  433. comment-padding)
  434. " ")))
  435. "[a-z\\*!$0-9+\\.]")
  436. "*Regexp string describing lines that are commented out and will be
  437. hidden. The regexp is matched to the beginning of a line, the ^ is
  438. added automatically. The initialization of this variable is handled
  439. in `spice-hide-init', which is after the setting of `comment-start'
  440. and `comment-padding' variables."
  441. :initialize (lambda (variable value)
  442. (message "Deferring initialization of %s with %s to spice-hide-init" variable value)) ; avoid init now, comment-start and padding aren't set yet.
  443. :group 'spice-hide
  444. :type 'string)
  445. ;;;###autoload
  446. (defcustom spice-auto-hide-comments nil
  447. "*Boolean indicating automatic hiding of all commented regions at load time."
  448. :group 'spice-hide
  449. :type 'boolean)
  450. (defgroup spice-section nil
  451. "Customizations for sections."
  452. :group 'spice)
  453. ;; sections (entirely different implementation but sections idea has
  454. ;; been taken from eldo-mode.el)
  455. ;;;###autoload
  456. (defcustom spice-section-alist
  457. '(
  458. ;; Libraries
  459. ("Libraries" "LIBRARIES" nil) ;
  460. ;; Netlist
  461. ("Netlist" "NETLIST" nil) ;
  462. ;; Main Circuit
  463. ("Main Circuit" "MAIN CIRCUIT" nil) ;
  464. ;; Options
  465. ("Options" "SIMULATION OPTIONS" nil) ;
  466. ;; Supplies
  467. ("Supplies" "SUPPLIES/REFERENCES" nil) ;
  468. ;; Input Signals
  469. ("Input Signals" "INPUT SIGNALS" nil) ;
  470. ;; DC Analysis
  471. ("DC Analysis" "DC ANALYSIS" nil) ;
  472. ;; AC Analysis
  473. ("AC Analysis" "AC ANALYSIS" nil) ;
  474. ;; Transient Analysis
  475. ("Transient Analysis" "TRANSIENT ANALYSIS" nil) ;
  476. ;;; Add your site-local spice sections here:
  477. ;;
  478. )
  479. "*List of valid sections in a Spice file and their options.
  480. Each list entry specifies the following items for a section:
  481. Section:
  482. Section Name : name used in to select/create find section, make this
  483. name short and descriptive.
  484. Section String : string used in file to start section (usually all
  485. uppercase variant of name).
  486. Extra switches : extra switches for a section, unspecified for now."
  487. :type '(repeat (list :tag "Section" :indent 2
  488. (string :tag "Section Name ")
  489. (string :tag "Section String ")
  490. (sexp :tag "Extra Switches (nil)")))
  491. :set (lambda (variable value)
  492. (spice-custom-set variable value
  493. 'spice-keywords-init
  494. 'spice-font-lock-init
  495. 'spice-menu-init
  496. 'spice-imenu-init
  497. 'spice-update-existing-buffers))
  498. :group 'spice-section)
  499. (defgroup spice-faces nil
  500. "Customizations for highlighting."
  501. :group 'spice)
  502. ;;;###autoload
  503. (defcustom spice-highlight-keywords t
  504. "*Non-nil means highlight SPICE keywords and other standardized words.
  505. The following faces are used:
  506. `spice-title-face' : title (first line in a spice file)
  507. `spice-doc-face' : doc strings
  508. `spice-analysis-face' : analyses
  509. `spice-instance-name-face' : instance/element names
  510. `spice-model-name-face' : subckt model names
  511. `spice-layla-function-name-face': layla function names
  512. `spice-include-file-face' : include files and libraries
  513. `font-lock-keyword-face' : keywords
  514. `font-lock-warning-face' : warnings
  515. `font-lock-comment-face' : comment
  516. `font-lock-function-name-face': subcircuit references / names of objects
  517. `font-lock-type-face' : types
  518. `font-lock-string-face' : strings & include files
  519. `font-lock-constant-face' : simulator's options
  520. `font-lock-variable-name-face': names of .param's & variables
  521. NOTE: Activate the new setting in a spice buffer by re-fontifying it (menu
  522. entry \"Fontify Buffer\"). XEmacs: turn off and on font locking."
  523. :type 'boolean
  524. :group 'spice-faces)
  525. ;; We try to use usual/standard font-lock faces, plus a few specific ones:
  526. (custom-add-to-group
  527. 'spice-faces 'font-lock-comment-face 'custom-face)
  528. (custom-add-to-group
  529. 'spice-faces 'font-lock-keyword-face 'custom-face)
  530. (custom-add-to-group
  531. 'spice-faces 'font-lock-type-face 'custom-face)
  532. (custom-add-to-group
  533. 'spice-faces 'font-lock-function-name-face 'custom-face)
  534. (custom-add-to-group
  535. 'spice-faces 'font-lock-variable-name-face 'custom-face)
  536. (custom-add-to-group
  537. 'spice-faces 'font-lock-warning-face 'custom-face)
  538. (custom-add-to-group
  539. 'spice-faces 'font-lock-string-face 'custom-face)
  540. (defgroup spice-output nil
  541. "Customizations for spice output file handling."
  542. :group 'spice)
  543. ;;;###autoload
  544. (defcustom spice-output-filename-alist
  545. '(
  546. ;; Libraries
  547. (eldo (concat (file-name-sans-extension (buffer-file-name)) ".chi")) ;
  548. (hspice (concat (file-name-sans-extension (buffer-file-name)) ".lis")) ;
  549. (hspice (concat (file-name-sans-extension (buffer-file-name)) ".spout")) ;
  550. (hspice (concat (file-name-sans-extension (buffer-file-name)) ".hspout")) ;
  551. (spice2g6 (concat (file-name-sans-extension (buffer-file-name)) ".out")) ;
  552. )
  553. "*List of valid output names depending on selected spice standard:
  554. Spice Standard : one of spice2g6, hspice, eldo or layla
  555. Expression : expression calculating the output filename
  556. "
  557. :type '(repeat (list :tag "Output Filenames" :indent 2
  558. (symbol :tag "Spice Standard ")
  559. (sexp :tag "Expression ")))
  560. :group 'spice-output)
  561. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  562. ;; buffer local vars for spice-mode
  563. ;;(defvar spice-standard-local nil
  564. ;; "buffer local version of spice-standard.")
  565. (defvar spice-output-local nil
  566. "buffer local version of spice-output.")
  567. (defun spice-standard-p (standard)
  568. "Check if STANDARD is specified as used standard on local variable."
  569. (or (eq standard (car spice-standard))
  570. (memq standard (cadr spice-standard))))
  571. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  572. ;; regexps for spice mode
  573. (defconst spice-continuation-prefix "+"
  574. "Continuation prefix for normal spice line")
  575. (defconst spice-line-break "\\(\n\\s-*\\+\\s-*\\)*"
  576. "Regexp that matches a (possible) line break (\n+)")
  577. (defconst spice-model-name "\\([a-z][^ \t\n=]*\\)" ; "\\([a-z]\\sw*[^ \t\n=]*\\)"
  578. "Regexp that describes a syntactically correct model or subckt name")
  579. (defconst spice-library-regexp-start
  580. "^\\.\\(inc\\|include\\|verilog\\|use_veriloga\\|lib\\(\\s-+key=\\w+\\)?\\|libfas\\|subckt\\s-+lib\\|model\\s-+lib\\)\\s-+[\"']?"
  581. "Regexp that matches the beginning of library or include filename")
  582. (defconst spice-library-regexp-end
  583. "\\([^ \t\n\"']*\\)"
  584. "Regexp that matches the end of library or include filename") ; doesn't catch end of buffer
  585. (defconst spice-section-regexp-start "\\(^[*!$]\\s-*\\)"
  586. "spice mode section header start regexp.")
  587. (defconst spice-spice2g6-keywords
  588. '(
  589. "subckt"
  590. "print" "plot"
  591. "opt" ; opt is actually a spice3 keyword, not 2g6
  592. "nodeset"
  593. "model" "macro" "include" ; include is actually a spice3 keyword, not 2g6
  594. "ends" "end"
  595. )
  596. "List of Spice2g6 keywords")
  597. (defconst spice-spice2g6-analyses
  598. '(
  599. "tran" "op" "noise" "four" "disto" "dc" "ac"
  600. )
  601. "List of Spice2g6 analysis keywords")
  602. (defconst spice-spice2g6-analysis-modifiers
  603. '(
  604. "dec" "lin" "oct" ;; the ubiquitous spice2g6 ac modifiers
  605. "pol" "zer" "pz" "cur" "vol" ;; pz analysis spice3
  606. "ac" ;; .sens analysis spice3
  607. )
  608. "List of Spice2g6 analysis modifier keywords")
  609. (defconst spice-eldo-keywords
  610. '(
  611. "width" "use" "unprotect" "tvinclude" "topcell"
  612. "table" "subdup" "solve" "sinus" "sigbus"
  613. "setsoa" "setbus" "save" "restart" "ramp"
  614. "protect" "probe" "plotbus"
  615. "param" "overwrite_input" "optwind" "optpwl" "optnoise" "options"
  616. "option" "optfour"
  617. "notrc" "nocom" "modlogic"
  618. "moddup" "meas" "mcmod" "lotgroup" "loop" "load"
  619. "libfas" "lib" "init" "include" "ic" "hier" "guess" "global"
  620. "extract" "endl" "enddata" "dspf_include" "distrib" "del"
  621. "defwave" "defplotdig" "defmac" "data" "d2a" "comchar" "conso" "connect"
  622. "chrsim" "chrent" "chrand" "checksoa" "checkbus" "alter" "addlib" "a2d"
  623. )
  624. "List of Eldo keywords")
  625. (defconst spice-eldo-colon-keywords
  626. '(
  627. "param" "pin" "model"
  628. )
  629. "List of Eldo colon keywords")
  630. (defconst spice-eldo-macromodel-keywords
  631. '(
  632. "opamp0" "opamp0d" "opamp1" "opamp1d" "opamp2" "opamp2d"
  633. "satr" "satv" "vswitch" "cswitch"
  634. "tri2sin" "stairgen" "sawgen" "trigen"
  635. "amm" "pam"
  636. "sa_ho" "tr_ho"
  637. "pwm" "vco"
  638. "peak_d" "lev_d"
  639. "logamp" "expamp"
  640. "diff" "integ"
  641. "add" "sub" "mult" "div"
  642. "sc_ideal" "sc_i" "sc_n" "sc_p" "sc_s1" "sc_s2"
  643. "sc_sp1" "sc_sp2" "sc_b" "sc_u"
  644. )
  645. "List of Eldo macromodels")
  646. (defconst spice-eldo-analyses
  647. '(
  648. "wcase" "tf" "temp"
  649. "step" "snf" "sens" "pz"
  650. "noisetran" "mc"
  651. )
  652. "List of Eldo analysis keywords")
  653. (defconst spice-eldo-analysis-modifiers
  654. '(
  655. )
  656. "List of Eldo analysis modifier keywords")
  657. (defconst spice-eldorf-keywords
  658. '(
  659. "sst"
  660. )
  661. "List of Eldo RF keywords")
  662. (defconst spice-eldovloga-keywords
  663. '(
  664. "verilog" "use_veriloga"
  665. )
  666. "List of Eldo Verilog-A keywords")
  667. (defconst spice-eldovloga-colon-keywords
  668. '(
  669. "port" "generic"
  670. )
  671. "List of Eldo Verilog-A colon keywords")
  672. (defconst spice-eldorf-analyses
  673. '(
  674. "sstac" "sstxf" "sstnoise"
  675. )
  676. "List of Eldo RF keywords")
  677. (defconst spice-hspice-keywords
  678. '(
  679. "width" "unprot" "unprotect" "uic"
  680. "title" "sys" "system" "save"
  681. "sample" "prot" "protect"
  682. "probe" "pc" "parameter"
  683. "param" "options" "option"
  684. "nomod"
  685. "measure" "meas" "macro"
  686. "load" "lib" "include" "inc" "ic" "graph" "global"
  687. "eom" "enddata" "dellib" "delete"
  688. "del" "dcvolt" "data" "control" "comment"
  689. "alter"
  690. "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
  691. )
  692. "List of Hspice keywords")
  693. (defconst spice-hspice-analyses
  694. '(
  695. "disto"
  696. "fft"
  697. "tf" "temp"
  698. "net" ;; S, Z, Y and H parameters
  699. "sample"
  700. "sens"
  701. "pz"
  702. "noise"
  703. )
  704. "List of Hspice analysis keywords")
  705. (defconst spice-hspice-analysis-modifiers
  706. '(
  707. "sweep" "poi"
  708. )
  709. "List of Hspice analysis modifier keywords")
  710. (defconst spice-fasthenry-keywords
  711. '(
  712. "units" "default" "external" "equiv"
  713. )
  714. "List of FastHenry keywords")
  715. (defconst spice-fasthenry-analyses
  716. '(
  717. "freq"
  718. )
  719. "List of FastHenry analysis keywords")
  720. (defconst spice-fasthenry-analysis-modifiers
  721. '(
  722. )
  723. "List of FastHenry analysis modifier keywords")
  724. (defconst spice-layla-keywords
  725. '(
  726. "stop" "start"
  727. "port" "performance" "parameter"
  728. "param" "options" "option"
  729. "net"
  730. "model" "matching"
  731. "include" "inc"
  732. "bus"
  733. )
  734. "List of Layla keywords")
  735. (defconst spice-mondriaan-keywords
  736. '(
  737. "master" "routingarea" "routingchannel" "ports" "portgrid" "net"
  738. )
  739. "List of Mondriaan keywords")
  740. (defconst spice-draccdl-keywords
  741. '(
  742. "bipolar" "busdelimiter" "capa" "caparea" "capval" "default" "dioarea"
  743. "dioperi" "diode" "edifdelimiter" "busdelimiter" "equation" "equiv"
  744. "gnonswap" "ldd" "mega" "nonswap" "nopin" "nosub" "pin" "pininfo"
  745. "resi" "ressize" "resval" "reverse" "scale" "spice" "unspec"
  746. "eom" "global" "param" "macro" "swap"
  747. )
  748. "List of Dracula CDL keywords")
  749. (defconst spice-spice2g6-types
  750. '(
  751. "ac" "dc" "exp" "pulse" "pwl" "sffm" "sin"
  752. )
  753. "List of types in spice2g6")
  754. (defconst spice-hspice-types
  755. '(
  756. "metal" "dielectric" "pec" "rectangle" "circle" "strip" "polygon" ;; ""
  757. )
  758. "List of types in hspice")
  759. (defconst spice-eldo-types
  760. '(
  761. "pattern"
  762. )
  763. "List of source types in eldo")
  764. (defconst spice-eldorf-types
  765. '(
  766. "fpulse" "four" "probe"
  767. )
  768. "List of source types in eldorf")
  769. (defconst spice-fasthenry-types
  770. '(
  771. "point" "rect" "circle"
  772. "user1" "user2" "user3" "user4" "user5" "user6" "user7"
  773. )
  774. "List of source types in fasthenry")
  775. (defconst spice-special-model-type-names
  776. '(
  777. "d" "npn" "pnp" "nmos" "pmos"
  778. )
  779. "List of model type names which are excluded for imenu")
  780. (defconst spice-spice2g6-model-type-names
  781. '(
  782. "r" "c" "urc" "ltra"
  783. "njf" "pjf"
  784. "nmf" "pmf"
  785. "sw" "csw"
  786. )
  787. "List of model type names in spice2g6")
  788. (defconst spice-eldo-model-type-names
  789. '(
  790. "res" "cap" "ind"
  791. "rn" "rp" "lpnp"
  792. )
  793. "List of model type names extra in eldo")
  794. (defconst spice-eldo-vloga-model-type-names
  795. '(
  796. "macro"
  797. )
  798. "List of model type names extra in Eldo Verilog-A")
  799. (defconst spice-hspice-model-type-names
  800. '(
  801. "l" "core" "w" "plot"
  802. )
  803. "List of model type names extra in hspice")
  804. (defconst spice-spice2g6-output-keywords
  805. '("print" "plot")
  806. "List of output keywords in spice2g6")
  807. (defconst spice-spice2g6-output-types
  808. '("ac" "dc" "tran")
  809. "List of output types in spice2g6")
  810. (defconst spice-eldo-output-keywords
  811. '("extract" "meas")
  812. "List of output keywords in eldo")
  813. (defconst spice-eldo-output-types
  814. '("dcac" "dcsweep" "dctran" "noise" "four" "sweep")
  815. "List of output types in eldo")
  816. (defconst spice-eldorf-output-types
  817. '("fsst" "tsst" "sstac" "sstxf" "ssnoise" )
  818. "List of output types in eldo")
  819. (defconst spice-hspice-output-keywords
  820. '("probe" "graph" "measure")
  821. "List of output keywords in hspice")
  822. (defconst spice-hspice-output-types
  823. '("noise" "disto")
  824. "List of output types in hspice")
  825. (defconst spice-spice2g6-options-keywords
  826. '("trytocompact")
  827. "List of spice2g6/3 options keywords.")
  828. (defconst spice-eldo-options-keywords
  829. '("wsf" "wsfascii" "sda"
  830. "precise" "spi3asc" "spi3bin" "spicedc" "spiout" "libfas" "nolib"
  831. "ammeter" "msgbias" "nowarn" "ulogic" "aspec" "mod4pins" "modwl" "wl"
  832. "captab" "coustep" "input" "lcapop" "list" "noascii" "ascii"
  833. "autostop" "nobound_phase" "nocou" "node" "nomod" "nopage" "nosizechk"
  834. "notrc" "trap" "smooth" "be" "gear" "newton" "iem" "analog" "digital"
  835. "osr" "mixed" "pstran" "dptran" "itl6" "itl7" "itl8" "nmaxsize"
  836. "noconvassist" "nolat" "pivrel" "pivtol" "qtrunc" "noconvassist"
  837. "nolat" "pivrel" "pivtol" "qtrunc" "relvar" "splitc" "noswitch"
  838. "unbound" "randmc" "usedefap" "engnot" "nodcpart" "probeop"
  839. "noprobeop" "histlim" "wbulk" "noinit" "nonoise" "tempcouk" "nofnsiem"
  840. "icdc" "icdev" "carlo_gauss" "cteprec" "d2dmvl9bit" "defconvmsg"
  841. "maxnodeord" "notrclib" "motorola" "aex")
  842. "List of eldo options keywords.")
  843. (defconst spice-eldorf-options-keywords
  844. '("sst_freqdiv")
  845. "List of Eldo RF options keywords.")
  846. (defconst spice-hspice-options-keywords
  847. '("acct" "converge"
  848. "absh" "acout" "cds" "scale" "cshdc" "alt999" "alt9999" "csdf"
  849. "accurate" "dvdt" "measout" "acout" "brief" "cshunt" "gshunt" "probe"
  850. "kcltest" "dctran" "di" "itl5" "list" "sda" "gshunt" "cshunt" "post"
  851. "node" "noelck" "gshunt" "maxamp" "nomod" "aspec" "icsweep" "relh"
  852. "nopage" "newtol" "reli" "notop" "parhier" "off" "spice" "wl"
  853. "dvtr" "nxx" "seed" "risetime" "imax" "nopiv" "imin" "opts" "cscal"
  854. "vntol" "absv" "pathnum" "badchr" "fmax" "plim" "diagnostic" "pivref"
  855. "fscal" "autostop" "nowarn" "gscal" "search" "lscal" "bypass" "verify"
  856. "sparse" "pivot" "pzabs" "cpu" "pztol" "fast" "interp" "h9007" "expli"
  857. "ritol" "itlpz" "itrprt" "unwrap" "captab" "newtol" "dccap")
  858. "List of hspice options keywords.")
  859. (defconst spice-spice2g6-options-parameters
  860. '("gmin" "reltol" "abstol" "vntol" "trtol" "chgtol" "pivtol" "pivrel"
  861. "tnom" "temp" "lvlcod" "itl1" "itl2" "itl3" "itl4" "itl5" "defl"
  862. "defw" "defad" "defas" "method")
  863. "List of spice2g6/3 options parameters.")
  864. (defconst spice-eldo-options-parameters
  865. '("cptime" "msgnode" "zoomtime" "bsim3ver" "defnrd" "defnrs" "defpd" "defps"
  866. "gramp" "scale" "scalebsim" "scalm" "soiback" "flicker_noise"
  867. "thermal_noise" "cousmp" "limprobe" "ascii" "savetime" "simudiv"
  868. "stat" "timediv" "maxord" "bloc" "epsdig" "absvar" "capanw" "chgtol"
  869. "dvdt" "eps" "fluxtol" "freqsmp" "ft" "hmin" "hmax" "itol" "lvltim"
  870. "maxnodes" "maxtran" "maxv" "netsize" "ngtol" "ratprint" "reltrunc"
  871. "sample" "startsmp" "step" "trtol" "tuning" "vmin" "vntol" "xa"
  872. "numdgt" "dcpart" "couresol" "defa2d" "defd2a" "vbcsat" "dclog" "epso"
  873. "optype")
  874. "List of eldo options parameters.")
  875. (defconst spice-eldorf-options-parameters
  876. '("sst_start" "sst_stop" "sst_nper"
  877. "sst_npt" "sst_ovrsmp" "sst_spectrum" "sst_uic"
  878. "sst_max_liniter" "sst_verbose")
  879. "List of Eldo RF options parameters.")
  880. (defconst spice-hspice-options-parameters
  881. '("artist" "dcap" "absh" "absvar" "absi" "absv" "delmax" "absmos"
  882. "dcfor" "dchold" "fs" "mentor" "absvdc" "dcon" "ft" "co" "reltol" ; "post"
  883. "cvtol" "di" "dcstep" "imin" "ingold" "imax" "lennam" "psf" "maxamp"
  884. "dv" "defl" "relh" "gmax" "relvar" "measdgt" "zuken" "defnrd" "reli"
  885. "gmindc" "rmax" "defnrs" "relmos" "gramp" "rmin" "defpd" "relv"
  886. "slopetol" "defps" "relvdc" "timeres" "limpts" "scalm" "relq" "numdgt"
  887. "resmin" "optlst" "trtol" "genk" "pivot" "sparse" "lvltim" "klim"
  888. "maxord" "post_version" "bkpsiz" "mu" "xmu" "warnlimit" "expli"
  889. "bytol" "cptime" "epsmin" "mbypass" "expmax" "limtim" "vfloor")
  890. "List of hspice options parameters.")
  891. (defconst spice-layla-options-parameters
  892. '("begin_temp_iterations" "begin_acc_prob" "min_temp_scale_factor"
  893. "max_temp_scale_factor" "max_inner_loop_delta" "max_cost_delta"
  894. "min_range_scale_factor" "nr_temp_steps"
  895. "min_stable_inner_loops" "min_local_iterations" "max_local_iterations"
  896. "max_iterations" "bank_min_ar" "bank_max_ar" "bank_orientations"
  897. "bank_routing_space" "bus_sides" "bus_layer" "bus_port_width"
  898. "bus_port_height" "bus_port_distance" "bus_routing_space" "cap_min_ar"
  899. "cap_max_ar" "cap_orientations" "cap_routing_space" "cap_ar_step"
  900. "coil_orientations" "coil_routing_space" "alfa_area"
  901. "alfa_performance" "alfa_aspect_ratio" "alfa_overlap" "alfa_overlap_min"
  902. "alfa_overlap_max" "kappa_overlap" "device_min_ar" "device_max_ar"
  903. "device_orientations" "device_routing_space" "device_current"
  904. "diode_min_ar" "diode_max_ar" "diode_orientations"
  905. "diode_routing_space" "diode_current" "matching_compute_method"
  906. "dummy_min_ar" "dummy_max_ar" "dummy_orientations"
  907. "dummy_routing_space" "dummy_ar_step"
  908. "mos_min_ar" "mos_max_ar" "mos_orientations" "mos_routing_space"
  909. "mos_current" "prob_reshape" "prob_reorientation"
  910. "prob_symmetric_translation" "prob_symmetric_swap"
  911. "prob_symmetric_flip" "prob_symmetric_flip" "prob_symmetric_shift"
  912. "prob_independent_translation" "prob_independent_swap"
  913. "prob_independent_flip" "min_move_range" "net_compute_method"
  914. "write_init" "write_int" "int_write_interval" "write_fin" "write_final"
  915. "mentor_write_ipc" "gds2_write_ipc" "construct_net_performance"
  916. "construct_matching_performance" "aspect_ratio" "field_grow_factor"
  917. "field_aspect_ratio" "disable_symmetry" "disable_matching"
  918. "do_kul_routing" "kul_router_program" "kul_router_directives_file"
  919. "number_of_randomize_loops" "port_inherit_terminals" "bus_priority"
  920. "port_sides" "port_layer" "port_width" "port_height" "port_distance"
  921. "port_abutment" "port_routing_space" "port_no_routing" "port_current"
  922. "res_ar_step" "res_min_ar" "res_max_ar" "res_orientations"
  923. "res_routing_space" "res_width" "res_current" "disable_couple_flipping"
  924. "symmetry_max_offset_factor" "print_cost" "placement_name"
  925. "write_final_ample" "write_final_skill" "write_final_gds2_bin"
  926. "write_final_gds2_cells" "write_final_tud"
  927. "write_final_ample_generators" "write_final_ample_cells"
  928. "write_final_cif" "write_final_rose" "write_final_kul"
  929. "write_final_text"
  930. "write_int_ample" "write_int_skill" "write_int_gds2_bin"
  931. "write_int_gds2_cells" "write_int_tud" "write_int_ample_generators"
  932. "write_int_ample_cells" "write_int_cif" "write_int_rose"
  933. "write_int_kul" "write_int_text"
  934. "write_init_ample" "write_init_skill" "write_init_gds2_bin"
  935. "write_init_gds2_cells" "write_init_tud" "write_init_ample_generators"
  936. "write_init_ample_cells" "write_init_cif" "write_init_rose"
  937. "write_init_kul" "write_init_text" "time_out"
  938. "random_seed" "anneal_rs" )
  939. "List of LAYLA options parameters.")
  940. (defconst spice-layla-functions
  941. '(
  942. "bus_double_param" "bus_integer_param" "bus_string_param"
  943. "device_double_param" "device_integer_param" "device_string_param"
  944. "net_double_param" "net_integer_param" "net_string_param"
  945. "placement_double_param" "placement_integer_param" "placement_string_param"
  946. "port_double_param" "port_integer_param" "port_string_param"
  947. "symmetry_double_param" "symmetry_integer_param" "symmetry_string_param"
  948. )
  949. "List of functions in Layla mode")
  950. (defconst spice-draccdl-device-keywords
  951. '("nonswap" )
  952. "List of Dracula CDL device keywords.")
  953. (defconst spice-draccdl-device-parameters
  954. '("w" "l" "sub" "ea" ;; CDL parameters
  955. "x" "y") ;; added X&Y, dracula extracts them (not CDL!)
  956. "List of Dracula & CDL device parameters.")
  957. (defconst spice-spice2g6-entity-start-keywords
  958. '(
  959. "ends" "macro" "subckt"
  960. )
  961. "List of spice2g6 entity start keywords")
  962. (defconst spice-eldo-entity-start-keywords
  963. '(
  964. "endl"
  965. )
  966. "List of eldo entity start keywords")
  967. (defconst spice-hspice-entity-start-keywords
  968. '(
  969. "endl" "eom"
  970. "fsoptions" "layerstack" "material" "shape" ; FEM solver for W elements
  971. )
  972. "List of hspice entity start keywords")
  973. (defconst spice-layla-entity-start-keywords
  974. '(
  975. "bus" "net" "symmetry" "performance" "port"
  976. )
  977. "List of layla entity start keywords")
  978. (defconst spice-mondriaan-entity-start-keywords
  979. '(
  980. "routingarea" "routingchannel" ;; "net" ; already in layla
  981. )
  982. "List of mondriaan entity start keywords")
  983. (defconst spice-draccdl-entity-start-keywords
  984. '(
  985. "eom"
  986. )
  987. "List of DracCDL entity start keywords")
  988. (defvar spice-keywords nil
  989. "List of spice mode keywords.")
  990. (defvar spice-colon-keywords nil
  991. "List of spice mode colon keywords.")
  992. (defvar spice-analyses nil
  993. "List of spice mode analyses.")
  994. (defvar spice-analysis-modifiers nil
  995. "List of spice mode analysis modifiers.")
  996. (defvar spice-types nil
  997. "List of spice mode standardized types.")
  998. (defvar spice-functions nil
  999. "List of spice mode functions.")
  1000. (defvar spice-section-headings nil
  1001. "List of spice mode section headings.")
  1002. (defvar spice-misc-model-type-names nil
  1003. "List of miscellaneous model type name.")
  1004. (defvar spice-model-type-names nil
  1005. "List of all model type name.")
  1006. (defvar spice-output-keywords nil
  1007. "List of all output keywords.")
  1008. (defvar spice-output-types nil
  1009. "List of all output types.")
  1010. (defvar spice-options-keywords nil
  1011. "List of all output options keywords.")
  1012. (defvar spice-options-parameters nil
  1013. "List of all output options parameters.")
  1014. (defvar spice-entity-start-keywords nil
  1015. "List of entity definition keywords.")
  1016. (defvar spice-keywords-regexp nil
  1017. "Regexp for keywords.")
  1018. (defvar spice-colon-keywords-regexp nil
  1019. "Regexp for colon keywords.")
  1020. (defvar spice-analyses-regexp nil
  1021. "Regexp for analyses.")
  1022. (defvar spice-analysis-modifiers-regexp nil
  1023. "Regexp for analysis modifiers.")
  1024. (defvar spice-layla-keywords-regexp nil
  1025. "Regexp for layla keywords.")
  1026. (defvar spice-mondriaan-keywords-regexp nil
  1027. "Regexp for mondriaan keywords.")
  1028. (defvar spice-draccdl-keywords-regexp nil
  1029. "Regexp for dracula CDL keywords.")
  1030. (defvar spice-types-regexp nil
  1031. "Regexp for spice mode types.")
  1032. (defvar spice-functions-regexp nil
  1033. "Regexp for spice mode functions (Layla).")
  1034. (defvar spice-section-headings-regexp nil
  1035. "Regexp for spice mode section headings.")
  1036. (defvar spice-xinstance-regexp nil
  1037. "Regexp for x instances.")
  1038. (defvar spice-model-name-regexp nil
  1039. "Regexp model names of elements.")
  1040. (defvar spice-entity-start-regexp nil
  1041. "Regexp for start of entity definition.")
  1042. (require 'font-lock)
  1043. (defvar spice-instance-name-face 'spice-instance-name-face
  1044. "Face name to use spice instances.")
  1045. (defface spice-instance-name-face
  1046. '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
  1047. (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
  1048. (((class color) (background light)) (:foreground "ForestGreen" :bold t))
  1049. (((class color) (background dark)) (:foreground "Yellow" :bold t))
  1050. (t (:bold t)))
  1051. "Spice mode face used to highlight instances."
  1052. :group 'spice-faces)
  1053. (defvar spice-model-name-face 'spice-model-name-face
  1054. "Face name to use spice instances.")
  1055. (defface spice-model-name-face
  1056. '((((class grayscale) (background light)) (:foreground "LightGray"))
  1057. (((class grayscale) (background dark)) (:foreground "DimGray"))
  1058. (((class color) (background light)) (:foreground "Red3"))
  1059. (((class color) (background dark)) (:foreground "LightSteelBlue"))
  1060. (t (:bold t)))
  1061. "Spice mode face used to highlight models."
  1062. :group 'spice-faces)
  1063. (defvar spice-title-face 'spice-title-face
  1064. "Face name for title string.")
  1065. (defface spice-title-face
  1066. '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
  1067. (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
  1068. (((class color) (background light))
  1069. (:foreground "Yellow" :background "black" :bold t))
  1070. (((class color) (background dark))
  1071. (:foreground "green3":background "lightyellow" :bold t))
  1072. (t (:bold t)))
  1073. "Spice mode face used for title string."
  1074. :group 'spice-faces)
  1075. (defvar spice-layla-function-name-face 'spice-layla-function-name-face
  1076. "Face name to use for layla function names.")
  1077. (defface spice-layla-function-name-face
  1078. '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
  1079. (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
  1080. (((class color) (background light))
  1081. (:foreground "Darkgreen"))
  1082. (((class color) (background dark)) (:foreground "green"))
  1083. (t (:bold t)))
  1084. "Spice mode face used to higlight layla functions."
  1085. :group 'spice-faces)
  1086. (defvar spice-analysis-face 'spice-analysis-face
  1087. "Face name to highlight spice mode analysis commands.")
  1088. (defface spice-analysis-face
  1089. '((((class color) (background light)) (:foreground "Magenta" :bold t :underline t))
  1090. (((class color) (background dark)) (:foreground "Lightgreen" :bold t :underline t))
  1091. (t (:bold t)))
  1092. "Spice mode face used to highlight analysis commands."
  1093. :group 'spice-faces)
  1094. (defvar spice-doc-face (if spice-running-xemacs
  1095. 'font-lock-doc-string-face
  1096. 'font-lock-string-face)
  1097. "Face name to use for doc strings.")
  1098. (custom-add-to-group
  1099. 'spice-faces (if spice-running-xemacs
  1100. 'font-lock-doc-string-face
  1101. 'font-lock-string-face)
  1102. 'custom-face)
  1103. (defvar spice-constant-face (if spice-running-xemacs
  1104. 'font-lock-reference-face
  1105. (if (facep 'font-lock-constant-face)
  1106. 'font-lock-constant-face
  1107. 'font-lock-reference-face)) ; old emacs20.1
  1108. "Face name to use for constants.")
  1109. (custom-add-to-group
  1110. 'spice-faces (if spice-running-xemacs
  1111. 'font-lock-reference-face
  1112. (if (facep 'font-lock-constant-face)
  1113. 'font-lock-constant-face
  1114. 'font-lock-reference-face))
  1115. 'custom-face)
  1116. (defvar spice-include-file-face (if spice-running-xemacs
  1117. 'font-lock-preprocessor-face
  1118. 'font-lock-string-face)
  1119. "Face name to use for include files and libraries.")
  1120. (custom-add-to-group
  1121. 'spice-faces (if spice-running-xemacs
  1122. 'font-lock-preprocessor-face
  1123. 'font-lock-string-face)
  1124. 'custom-face)
  1125. (if (not spice-running-xemacs)
  1126. (custom-add-to-group
  1127. 'spice-faces 'font-lock-builtin-face 'custom-face)
  1128. (defface spice-builtin-face
  1129. '((((class grayscale) (background light)) (:foreground "LightGray"))
  1130. (((class grayscale) (background dark)) (:foreground "DimGray"))
  1131. (((class color) (background light)) (:foreground "Orchid" :bold t))
  1132. (((class color) (background dark)) (:foreground "LightBlue" :bold t))
  1133. (t (:bold t)))
  1134. "Spice mode face used for builtin types."
  1135. :group 'spice-faces))
  1136. (defvar spice-builtin-face (if spice-running-xemacs
  1137. 'spice-builtin-face
  1138. 'font-lock-builtin-face)
  1139. "Face name for builtin types.")
  1140. (defun spice-keywords-init ()
  1141. "Initialize reserved words."
  1142. (setq spice-keywords
  1143. (append spice-spice2g6-keywords
  1144. (when (spice-standard-p 'hspice)
  1145. spice-hspice-keywords)
  1146. (when (spice-standard-p 'eldo)
  1147. spice-eldo-keywords)
  1148. (when (spice-standard-p 'eldorf)
  1149. spice-eldorf-keywords)
  1150. (when (spice-standard-p 'fasthenry)
  1151. spice-fasthenry-keywords)))
  1152. (setq spice-colon-keywords
  1153. (append (when (spice-standard-p 'eldo)
  1154. spice-eldo-colon-keywords)
  1155. (when (spice-standard-p 'eldovloga)
  1156. spice-eldovloga-colon-keywords)))
  1157. (setq spice-analyses
  1158. (append spice-spice2g6-analyses
  1159. (when (spice-standard-p 'hspice)
  1160. spice-hspice-analyses)
  1161. (when (spice-standard-p 'eldo)
  1162. spice-eldo-analyses)
  1163. (when (spice-standard-p 'eldorf)
  1164. spice-eldorf-analyses)
  1165. (when (spice-standard-p 'fasthenry)
  1166. spice-fasthenry-analyses)))
  1167. (setq spice-analysis-modifiers
  1168. (append spice-spice2g6-analysis-modifiers
  1169. (when (spice-standard-p 'hspice)
  1170. spice-hspice-analysis-modifiers)
  1171. (when (spice-standard-p 'eldo)
  1172. spice-eldo-analysis-modifiers)
  1173. (when (spice-standard-p 'fasthenry)
  1174. spice-fasthenry-analysis-modifiers)))
  1175. (setq spice-misc-model-type-names
  1176. (append spice-spice2g6-model-type-names
  1177. (when (spice-standard-p 'hspice)
  1178. spice-hspice-model-type-names)
  1179. (when (spice-standard-p 'eldovloga)
  1180. spice-eldo-vloga-model-type-names)
  1181. (when (spice-standard-p 'eldo)
  1182. spice-eldo-model-type-names)))
  1183. (setq spice-output-keywords
  1184. (append spice-spice2g6-output-keywords
  1185. (when (spice-standard-p 'hspice)
  1186. spice-hspice-output-keywords)
  1187. (when (spice-standard-p 'eldo)
  1188. spice-eldo-output-keywords)))
  1189. (setq spice-output-types
  1190. (append spice-spice2g6-output-types
  1191. (when (spice-standard-p 'hspice)
  1192. spice-hspice-output-types)
  1193. (when (spice-standard-p 'eldo)
  1194. spice-eldo-output-types)
  1195. (when (spice-standard-p 'eldorf)
  1196. spice-eldorf-output-types)))
  1197. (setq spice-model-type-names
  1198. (append spice-misc-model-type-names
  1199. spice-special-model-type-names))
  1200. (setq spice-types
  1201. (append spice-spice2g6-types
  1202. (when (spice-standard-p 'hspice)
  1203. spice-hspice-types)
  1204. (when (spice-standard-p 'eldo)
  1205. spice-eldo-types)
  1206. (when (spice-standard-p 'eldorf)
  1207. spice-eldorf-types)
  1208. (when (spice-standard-p 'fasthenry)
  1209. spice-fasthenry-types)))
  1210. (setq spice-options-keywords
  1211. (append spice-spice2g6-options-keywords
  1212. (when (spice-standard-p 'hspice)
  1213. spice-hspice-options-keywords)
  1214. (when (spice-standard-p 'eldo)
  1215. spice-eldo-options-keywords)
  1216. (when (spice-standard-p 'eldorf)
  1217. spice-eldorf-options-keywords)))
  1218. (setq spice-options-parameters
  1219. (append spice-spice2g6-options-parameters
  1220. (when (spice-standard-p 'hspice)
  1221. spice-hspice-options-parameters)
  1222. (when (spice-standard-p 'layla)
  1223. spice-layla-options-parameters)
  1224. (when (spice-standard-p 'eldo)
  1225. spice-eldo-options-parameters)
  1226. (when (spice-standard-p 'eldorf)
  1227. spice-eldorf-options-parameters)))
  1228. (setq spice-functions spice-layla-functions)
  1229. (setq spice-section-headings (list "Changelog")) ; Changelog is special case
  1230. (let ((section-alist spice-section-alist) heading)
  1231. (while section-alist
  1232. (setq heading (downcase (car (cdr (car section-alist)))))
  1233. (setq spice-section-headings (append spice-section-headings
  1234. (list heading)))
  1235. (setq section-alist (cdr section-alist))))
  1236. (setq spice-entity-start-keywords
  1237. (append spice-spice2g6-entity-start-keywords
  1238. (when (spice-standard-p 'hspice)
  1239. spice-hspice-entity-start-keywords)
  1240. (when (spice-standard-p 'layla)
  1241. spice-layla-entity-start-keywords)
  1242. (when (spice-standard-p 'mondriaan)
  1243. spice-mondriaan-entity-start-keywords)
  1244. (when (spice-standard-p 'draccdl)
  1245. spice-draccdl-entity-start-keywords)
  1246. (when (spice-standard-p 'eldo)
  1247. spice-eldo-entity-start-keywords)))
  1248. (setq spice-section-headings-regexp
  1249. (concat spice-section-regexp-start "\\("
  1250. (regexp-opt spice-section-headings) "\\)\\(.*\\)$"
  1251. ; "\\s-*$" ; ??
  1252. ))
  1253. (setq spice-keywords-regexp
  1254. (concat "^\\.\\("
  1255. (regexp-opt spice-keywords)
  1256. "\\)\\>"))
  1257. (setq spice-colon-keywords-regexp
  1258. (concat "\\<\\("
  1259. (regexp-opt spice-colon-keywords)
  1260. "\\)\\(:\\)"))
  1261. (setq spice-analyses-regexp
  1262. (concat "^\\s-*"
  1263. "\\(\\.\\)\\("
  1264. (regexp-opt spice-analyses)
  1265. "\\)\\>"))
  1266. (setq spice-analysis-modifiers-regexp
  1267. (concat "\\<\\(" (regexp-opt spice-analysis-modifiers) "\\)\\>"))
  1268. (setq spice-layla-keywords-regexp
  1269. (concat "^\\s-*\\*?"
  1270. "\\.\\("
  1271. (regexp-opt spice-layla-keywords)
  1272. "\\)\\>"))
  1273. (setq spice-mondriaan-keywords-regexp
  1274. (concat "^\\s-*\\*?"
  1275. "\\.\\("
  1276. (regexp-opt spice-mondriaan-keywords)
  1277. "\\)\\>"))
  1278. (setq spice-draccdl-keywords-regexp
  1279. (concat "^\\s-*"
  1280. "\\.\\("
  1281. (regexp-opt spice-draccdl-keywords)
  1282. "\\)\\>"))
  1283. (setq spice-types-regexp
  1284. (concat "\\<\\(" ;"\\(\\s-+\\|\n\\+\\s-*\\)\\<\\("
  1285. (regexp-opt spice-types)
  1286. "\\)\\>"))
  1287. (setq spice-functions-regexp
  1288. (concat "^\\s-*\\(\\*?\\.\\("
  1289. (regexp-opt spice-functions)
  1290. "\\)\\)\\>(\\([^,]+\\),\\([^,]+\\),[^,]+)"))
  1291. ; old xinstance regexp
  1292. ; "\\([ \t]+[^ $!(=\t\n][^ (=\t\n]*\\|\n[+]\\)*" ; $! are hspice & eldo's doc string starters
  1293. (setq spice-xinstance-regexp
  1294. (concat "^\\(x\\S-*\\)"
  1295. "\\(\\([ \t]+[^ *"
  1296. ;; "\\(\\([ \t]*[^ *" ;; should solve problem when no space between + and name, but fails horribly due to CPU hungry recursion in matcher....
  1297. (when (spice-standard-p 'hspice) "$")
  1298. (when (spice-standard-p 'eldo) "!")
  1299. ":(=\t\n][^ :(=\t\n]*\\|[ \t]*\\(\n?[*"
  1300. (when (spice-standard-p 'hspice) "$")
  1301. (when (spice-standard-p 'eldo) "!")
  1302. "].*\\)?\n[+]\\)*\\s-*\\)" ;; \\([a-z]\\w*\\)
  1303. "\\<" spice-model-name "\\>"
  1304. "\\(\\s-*\n\\|\\s-+[^=\n]\\)"
  1305. ))
  1306. (setq spice-model-name-regexp
  1307. (concat "^\\([qmd]\\S-*\\)" ;; only bips, mos and diodes
  1308. "\\([ \t]+[^ *" ;; first '*' was '+' ! but fails see spice-xinstance-regexp...
  1309. (when (spice-standard-p 'hspice) "$")
  1310. (when (spice-standard-p 'eldo) "!")
  1311. "(=\t\n][^ (=\t\n]*\\|[ \t]*\\([*"
  1312. (when (spice-standard-p 'hspice) "$")
  1313. (when (spice-standard-p 'eldo) "!")
  1314. "].*\\)?\n[+]\\)*\\s-*" ;; \\([a-z]\\w*\\)
  1315. "\\<" spice-model-name "\\>"
  1316. "\\(\\s-*\n\\|\\s-+[^=]\\)"
  1317. ))
  1318. (setq spice-entity-start-regexp
  1319. (concat "^\\*?\\.\\("
  1320. (regexp-opt spice-entity-start-keywords)
  1321. "\\)")))
  1322. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1323. ;; Font lock initialization
  1324. (defvar spice-font-lock-keywords-0 nil
  1325. ;; set in `spice-font-lock-init' because dependent on custom variables
  1326. "For consideration as a value of `spice-font-lock-keywords'.
  1327. This does highlighting of keywords and standard identifiers.")
  1328. (defvar spice-font-lock-keywords-1 nil
  1329. ;; set in `spice-font-lock-init' because dependent on custom variables
  1330. "For consideration as a value of `spice-font-lock-keywords'.
  1331. This does highlighting of keywords and standard identifiers.")
  1332. (defvar spice-font-lock-keywords-2 nil
  1333. ;; set in `spice-font-lock-init' because dependent on custom variables
  1334. "For consideration as a value of `spice-font-lock-keywords'.
  1335. This does highlighting of keywords and standard identifiers.")
  1336. (defvar spice-font-lock-keywords-3 nil
  1337. ;; set in `spice-font-lock-init' because dependent on custom variables
  1338. "For consideration as a value of `spice-font-lock-keywords'.
  1339. This does highlighting of keywords and standard identifiers.")
  1340. (defvar spice-font-lock-keywords-4 nil
  1341. ;; set in `spice-font-lock-init' because dependent on custom variables
  1342. "For consideration as a value of `spice-font-lock-keywords'.
  1343. This does highlighting of keywords and standard identifiers.")
  1344. (defvar spice-font-lock-keywords-5 nil
  1345. ;; set in `spice-font-lock-init' because dependent on custom variables
  1346. "For consideration as a value of `spice-font-lock-keywords'.
  1347. This does highlighting of keywords and standard identifiers.")
  1348. (defvar spice-font-lock-keywords-6 nil
  1349. ;; set in `spice-font-lock-init' because dependent on custom variables
  1350. "For consideration as a value of `spice-font-lock-keywords'.
  1351. This does highlighting of keywords and standard identifiers.")
  1352. (defvar spice-font-lock-keywords-7 nil
  1353. ;; set in `spice-font-lock-init' because dependent on custom variables
  1354. "For consideration as a value of `spice-font-lock-keywords'.
  1355. This does highlighting of keywords and standard identifiers.")
  1356. (defvar spice-font-lock-keywords-8 nil
  1357. ;; set in `spice-font-lock-init' because dependent on custom variables
  1358. "For consideration as a value of `spice-font-lock-keywords'.
  1359. This does highlighting of keywords and standard identifiers.")
  1360. (defvar spice-font-lock-keywords-9 nil
  1361. ;; set in `spice-font-lock-init' because dependent on custom variables
  1362. "For consideration as a value of `spice-font-lock-keywords'.
  1363. This does highlighting of keywords and standard identifiers.")
  1364. (defvar spice-font-lock-keywords-10 nil
  1365. ;; set in `spice-font-lock-init' because dependent on custom variables
  1366. "For consideration as a value of `spice-font-lock-keywords'.
  1367. This does highlighting of keywords and standard identifiers.")
  1368. (defvar spice-font-lock-keywords-11 nil
  1369. ;; set in `spice-font-lock-init' because dependent on custom variables
  1370. "For consideration as a value of `spice-font-lock-keywords'.
  1371. This does highlighting of keywords and standard identifiers.")
  1372. (defvar spice-font-lock-keywords-12 nil
  1373. ;; set in `spice-font-lock-init' because dependent on custom variables
  1374. "For consideration as a value of `spice-font-lock-keywords'.
  1375. This does highlighting of keywords and standard identifiers.")
  1376. (defvar spice-font-lock-keywords-13 nil
  1377. ;; set in `spice-font-lock-init' because dependent on custom variables
  1378. "For consideration as a value of `spice-font-lock-keywords'.
  1379. This does highlighting of keywords and standard identifiers.")
  1380. ;; fast variable name matcher in parameter=value constructs
  1381. (defun spice-match-variable-name (limit)
  1382. "match variable names"
  1383. (let (pos found (start (point)))
  1384. (setq found nil)
  1385. (setq pos (search-forward "=" limit 'end)) ;
  1386. (while (and pos
  1387. (not found))
  1388. (forward-word -1)
  1389. (if (< (point) start) (goto-char pos))
  1390. (if (looking-at "\\([a-z]\\w*\\)\\s-*\\(=\\)")
  1391. (progn
  1392. (goto-char pos)
  1393. ;; (message (match-string 1))
  1394. (setq found t))
  1395. (progn
  1396. (goto-char pos)
  1397. (setq pos (search-forward "=" limit 'end)))))
  1398. found))
  1399. ;; font-lock aux functions
  1400. (defun spice-match-eldo-colon-keywords (limit)
  1401. "match ((param|pin|model|port|generic):)" ;; latter two are eldo verilog-A
  1402. (let (pos found (start (point)))
  1403. (setq found nil)
  1404. (setq pos (search-forward ":" limit 'end)) ;
  1405. (while pos
  1406. (forward-word -1)
  1407. (if (< (point) start) (goto-char pos))
  1408. ;; (message "pos is %d" pos)
  1409. (if (looking-at ;; "\\(\\(param\\|pin\\|model\\|port\\|generic\\):\\)")
  1410. spice-colon-keywords-regexp)
  1411. (progn
  1412. (goto-char pos)
  1413. (setq pos nil)
  1414. (setq found t))
  1415. (progn
  1416. (goto-char pos)
  1417. (setq pos (search-forward ":" limit 'end)))))
  1418. found))
  1419. ;; these are try outs to solve the font-locking of problematic xinstances:
  1420. (defun spice-match-xinstances-dummy (limit)
  1421. "match xinstances"
  1422. (let (min max pt)
  1423. (setq pt (point))
  1424. (goto-char (point-min))
  1425. (setq min (point))
  1426. (goto-char (point-max))
  1427. (setq max (point))
  1428. (save-excursion
  1429. (set-buffer (get-buffer-create "*Matcher*"))
  1430. (goto-char (point-max))
  1431. (insert (format "Point min is %s\n" min))
  1432. (insert (format "Current point is %s\n" pt))
  1433. (insert (format "Limit is %s\n" limit))
  1434. (insert (format "Point max is %s\n" max))
  1435. )
  1436. )
  1437. nil
  1438. )
  1439. (defun spice-idle-font-lock (beg end)
  1440. "runs font-lock on a region"
  1441. (message "rerunning font-lock on %s:%s=%s" beg end (buffer-substring beg end))
  1442. (save-excursion (font-lock-fontify-region beg end)))
  1443. (defvar spice-previous-xinstance-match-result nil)
  1444. (make-variable-buffer-local 'spice-previous-xinstance-match-result)
  1445. (defun spice-match-in-xinstance (limit)
  1446. "checks if in xinstance"
  1447. (let ((pt (point)))
  1448. (if (or (looking-at "^\\s-*[xX]")
  1449. (re-search-backward "^[xX]" (point-min) t))
  1450. (if (and (looking-at spice-xinstance-regexp)
  1451. (or (> (match-end 5) pt)
  1452. (not spice-previous-xinstance-match-result))
  1453. )
  1454. (progn
  1455. (message ".")
  1456. (goto-char (match-end 5))
  1457. (if (or (> pt (match-beginning 1))
  1458. (< limit (match-end 5)))
  1459. (progn
  1460. (message "*")
  1461. ;;(spice-idle-font-lock (match-beginning 1) (match-end 5))
  1462. (run-with-idle-timer 1 nil 'spice-idle-font-lock
  1463. (match-beginning 1) (match-end 5))
  1464. ))
  1465. ;; (if (> (match-end 5) limit)
  1466. ;; (run-with-idle-timer 1 nil 'spice-idle-font-lock
  1467. ;; (match-beginning 1) (match-end 5)))
  1468. t)
  1469. (goto-char pt)
  1470. nil)
  1471. nil)
  1472. ))
  1473. (defun spice-match-next-xinstance (limit)
  1474. "checks if there is a next xinstance partly within limit"
  1475. (if (re-search-forward "^[xX]" limit 'end)
  1476. (progn
  1477. (backward-char 1)
  1478. (if (looking-at spice-xinstance-regexp)
  1479. (progn
  1480. (message "+")
  1481. (goto-char (match-end 5))
  1482. t)
  1483. (message "-")
  1484. (forward-char 1)
  1485. (spice-match-next-xinstance limit))
  1486. )
  1487. nil))
  1488. (defun spice-match-xinstance (limit)
  1489. "match xinstances"
  1490. (if (spice-match-in-xinstance limit)
  1491. t
  1492. (spice-match-next-xinstance limit)))
  1493. (defun spice-match-xinstances-old (limit)
  1494. "match an xinstance"
  1495. (setq spice-previous-xinstance-match-result (spice-match-xinstance limit))
  1496. spice-previous-xinstance-match-result)
  1497. ;; this xinstances matcher is a complete parser !
  1498. (defun spice-match-xinstances (limit)
  1499. "match xinstance subckt name, this one parses the lines, should work for
  1500. all cases, infinite number of comment lines, continuation lines. Could fail
  1501. when modifying an xinstance line though, hard to tell."
  1502. (interactive)
  1503. (let ((result nil) match-start)
  1504. (while
  1505. (and (not result)
  1506. (re-search-forward "^\\(x\\S-*\\)" limit 'end)) ;; should be checked ?
  1507. (setq match-start (match-data))
  1508. ;;(message "match-start is %s" match-start)
  1509. (while
  1510. (or
  1511. (and (looking-at "\\([ \t]+\\|\\s-*\n[+]\\s-*\\)\\(\\([a-z][^ :(=\t\n]*\\)\\|\\([^ *$!:(=\t\n][^ :(=\t\n]*\\)\\)\\(\\s-*\n\\|\\s-+[^=\n]\\)")
  1512. (progn
  1513. (goto-char (match-end 2))
  1514. (setq result t)))
  1515. (save-match-data
  1516. (and
  1517. (looking-at "\\(\\([ \t]+\\|\\s-*\n\\s-*\\)[$!*].*\\)")
  1518. (progn
  1519. (goto-char (match-end 1))
  1520. t))))
  1521. nil))
  1522. (when result (set-match-data
  1523. (append (list (car match-start) (car (cdr (match-data))))
  1524. (cdr (cdr match-start)) (cdr (cdr (match-data))))))
  1525. ;;(when result (message "Matched %s[%d]" (match-string 3) (match-end 3)))
  1526. (when result (when (< limit (match-end 3)) (setq result nil)))
  1527. result))
  1528. (defvar spice-font-lock-keywords nil
  1529. "Regular expressions to highlight in spice mode.")
  1530. (defun spice-font-lock-init ()
  1531. "Initialize fontification." ; makes spice-font-lock-keywords valid
  1532. ;; highlight title & titles after .alter & .title (hspice only)
  1533. (setq spice-font-lock-keywords-0
  1534. (append (list ;; first line of spice deck
  1535. (list "\\`.+$" 0 spice-title-face)
  1536. (list spice-section-headings-regexp
  1537. '(1 font-lock-comment-face)
  1538. '(2 spice-title-face)
  1539. (list (regexp-opt-depth spice-section-headings-regexp)
  1540. spice-doc-face 'keep t)))
  1541. ;; hspice title in .alter or .title line
  1542. (when (spice-standard-p 'hspice)
  1543. (list
  1544. (list "^\\.\\(alter\\|title\\)\\s-+\\(.+\\)$"
  1545. 2 spice-title-face)))))
  1546. ;; highlight layla functions: .xx_yy_param(name,prop,val);
  1547. (setq spice-font-lock-keywords-1
  1548. (list
  1549. (list spice-functions-regexp
  1550. '(1 spice-layla-function-name-face)
  1551. (list (- (regexp-opt-depth spice-functions-regexp) 1)
  1552. font-lock-function-name-face)
  1553. (list (regexp-opt-depth spice-functions-regexp)
  1554. font-lock-variable-name-face)
  1555. )))
  1556. ;; highlight spice keywords (mainly .<keyword> & .<analysis>)
  1557. (setq spice-font-lock-keywords-2
  1558. (list ;; .opt, .nodeset, ...
  1559. (list spice-keywords-regexp 0 font-lock-keyword-face)
  1560. ;; '+' of continuation lines ? maybe over the top ...
  1561. ;; (list (concat "^"
  1562. ;; (when (spice-standard-p 'layla) "\\*?")
  1563. ;; "\\+") 0 font-lock-keyword-face)
  1564. ;; .op, .ac, .dc, .tran, ...
  1565. (list spice-analyses-regexp
  1566. '(1 font-lock-keyword-face)
  1567. '(2 spice-analysis-face)
  1568. (list spice-analysis-modifiers-regexp
  1569. nil nil '(0 font-lock-type-face)))))
  1570. (setq spice-font-lock-keywords-12
  1571. ;; do dracula CDL stuff
  1572. (list
  1573. ;; add $ docs when they are followed by a space...
  1574. (list (concat "\\<\\([$]\\)\\s-+\\(.*\\)$")
  1575. (list 1 font-lock-comment-face)
  1576. (list 2 spice-doc-face 'keep))
  1577. ;; special models on element line
  1578. (list (concat "\\([$]\\(?:ldd\\)?\\[\\)" spice-model-name "\\(\\]\\)")
  1579. '(1 font-lock-keyword-face)
  1580. '(2 spice-model-name-face)
  1581. '(3 font-lock-keyword-face))
  1582. ;; normal .model on element line
  1583. (list (concat "\\([$]\\.model\\)\\s-*=\\s-*" spice-model-name)
  1584. '(1 font-lock-keyword-face)
  1585. '(2 spice-model-name-face))
  1586. ;; element options behind $ syntax
  1587. (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-keywords) "\\)")
  1588. '(1 font-lock-keyword-face)
  1589. '(2 font-lock-keyword-face))
  1590. ;; element parameters behind $ syntax
  1591. (list (concat "\\([$]\\)\\(" (regexp-opt spice-draccdl-device-parameters) "\\)\\s-*=")
  1592. '(1 font-lock-keyword-face)
  1593. '(2 font-lock-variable-name-face))
  1594. ;; general '.' keywords
  1595. (list spice-draccdl-keywords-regexp 0 font-lock-keyword-face)))
  1596. ;; highlight layla specific keywords, also if *. syntax is used
  1597. (setq spice-font-lock-keywords-3
  1598. (append (list
  1599. (list spice-layla-keywords-regexp 0 font-lock-keyword-face)
  1600. (list "^\\(\\*\\)\\+" 1 font-lock-keyword-face))
  1601. (when (spice-standard-p 'mondriaan)
  1602. (list
  1603. (list spice-mondriaan-keywords-regexp 0 font-lock-keyword-face)))))
  1604. (setq spice-font-lock-keywords-13
  1605. ;; do spectre stuff
  1606. (list
  1607. ;; * spectre: + syntax
  1608. (list "^\\(\\*\\)\\s-+spectre:\\s-+" 1 font-lock-keyword-face)
  1609. ;; // comments
  1610. (list "//.*$" 0 font-lock-comment-face)
  1611. ;; add simulator language=spice
  1612. (list "^\\s-*\\(simulator\\)\\>"
  1613. '(1 font-lock-keyword-face))))
  1614. ;; varia: .end, spice instances and '*' comment lines and output lines
  1615. (setq spice-font-lock-keywords-4
  1616. (list
  1617. ;; elements
  1618. ;;'("^[a-z]\\S-*" . spice-instance-name-face)
  1619. '("^[a-z][^ \t\n]+" . spice-instance-name-face)
  1620. ;(list (concat "^\\*\\([^"
  1621. ; (when (spice-standard-p 'layla) "+")
  1622. ; "\n].*\\|\n\\)") 0 font-lock-comment-face)
  1623. (list (concat "^\\*[^\n"
  1624. (when (or (spice-standard-p 'hspice)
  1625. (spice-standard-p 'draccdl)
  1626. (spice-standard-p 'layla)) "$")
  1627. (when (spice-standard-p 'eldo) "!")
  1628. "]*") 0 font-lock-comment-face)
  1629. (list (concat "^\\.\\(" (regexp-opt spice-output-keywords)
  1630. "\\)\\s-*" spice-line-break "\\s-+\\("
  1631. (regexp-opt spice-output-types) "\\)\\>")
  1632. '(0 font-lock-type-face keep)) ;
  1633. ))
  1634. ;; highlight additional . unknowns (to detect stupid typing errors)
  1635. (setq spice-font-lock-keywords-5
  1636. (list '("^\\s-*\\.[^ \t\n]*" 0 font-lock-warning-face)))
  1637. ;; highlight additional $ and ! comments, only eldo, hspice, draccdl and layla
  1638. (setq spice-font-lock-keywords-6
  1639. (list
  1640. (list (concat "\\<\\(["
  1641. (when (or (spice-standard-p 'hspice)
  1642. (spice-standard-p 'draccdl)
  1643. (spice-standard-p 'layla)) "$")
  1644. (when (spice-standard-p 'eldo) "!")
  1645. "]\\)\\(.*\\)$")
  1646. (list 1 font-lock-comment-face)
  1647. (list 2 spice-doc-face 'append) ;; needs at least 'append or 'keep
  1648. )
  1649. (list (concat "\\<\\([*"
  1650. (when (or (spice-standard-p 'hspice)
  1651. (spice-standard-p 'draccdl)
  1652. (spice-standard-p 'layla)) "$")
  1653. (when (spice-standard-p 'eldo) "!")
  1654. "]\\)")
  1655. ;; elisp mode like quotes, for extra clarity
  1656. (list "['\"]\\([^'\"]+\\)['\"]" nil nil
  1657. (list 1 spice-constant-face 'prepend)))))
  1658. ;; subcircuit instance names of x instances and model names of mos,bip&diode
  1659. (setq spice-font-lock-keywords-7
  1660. (list
  1661. (list spice-xinstance-regexp 5 spice-model-name-face)
  1662. ;; test xinstance function matcher
  1663. ;;(list 'spice-match-xinstances
  1664. ;; '(4 spice-model-name-face keep t)
  1665. ;; '(5 font-lock-warning-face keep t))
  1666. (list spice-model-name-regexp 4 spice-model-name-face)
  1667. ))
  1668. ;; highlight poly's of inductors and caps
  1669. (setq spice-font-lock-keywords-8
  1670. (list
  1671. '("^[cl]\\w*\\s-+\\w[^ \t\n]*\\s-+\\w[^ \t\n]*\\s-+\\(poly\\)"
  1672. 1 font-lock-type-face)))
  1673. ;; types, included files, libs and names of subcircuits, ports, libs, models
  1674. (setq spice-font-lock-keywords-9
  1675. (append
  1676. ;; names and types of models/subckt, lib concept of eldo...
  1677. (when (spice-standard-p 'eldo)
  1678. (list
  1679. (list (concat "^\\s-*\\.\\(model\\|subckt\\|macro\\)\\s-+"
  1680. "\\(\\(lib\\)\\s-+[^ \t\n]+\\s-+\\)"
  1681. spice-model-name)
  1682. '(3 font-lock-keyword-face)
  1683. '(4 font-lock-function-name-face))))
  1684. (list
  1685. ;; types
  1686. (list "^[+vi.]" '(0 'default) ;; find v & i's and continuation and . lines
  1687. (list spice-types-regexp nil nil '(1 font-lock-type-face)))
  1688. ;; libs, inc's, ...
  1689. (list (concat spice-library-regexp-start
  1690. spice-library-regexp-end) 3 spice-include-file-face)
  1691. ;; names of (defined) entities
  1692. (list
  1693. (concat spice-entity-start-regexp
  1694. "\\(\\s-+\\([a-z]\\w*\\)\\s-*"
  1695. "\\|\\s-*[\n][+]\\s-*\\([a-z]\\w*\\)\\s-*\\)")
  1696. (1+ (regexp-opt-depth spice-entity-start-regexp))
  1697. font-lock-function-name-face)
  1698. ;; names and types of models
  1699. (list (concat "^\\s-*\\.model\\s-+"
  1700. spice-model-name
  1701. spice-line-break "\\s-+\\("
  1702. (regexp-opt spice-model-type-names) "\\)\\>")
  1703. '(1 font-lock-function-name-face)
  1704. '(3 font-lock-type-face))
  1705. ))
  1706. )
  1707. ;; highlight additional eldo reserved words
  1708. (setq spice-font-lock-keywords-10
  1709. (list
  1710. ;; eldo's labels
  1711. (list "\\<\\(label\\)\\s-*=\\s-*\\([^\"]\\w*\\)\\>"
  1712. '(1 font-lock-type-face)
  1713. '(2 font-lock-variable-name-face))
  1714. ;; eldo's labels(2)
  1715. (list "\\<\\(label\\)\\s-*=\\s-*\"\\([^\"]+\\)\""
  1716. '(1 font-lock-type-face)
  1717. '(2 font-lock-variable-name-face))
  1718. ;; eldo's param,model&pin:
  1719. ;;'("\\<\\(\\(param\\|pin\\|model\\):\\)" 0 font-lock-keyword-face)
  1720. (list 'spice-match-eldo-colon-keywords
  1721. (list 1 font-lock-keyword-face)
  1722. '(2 'default))
  1723. ;; eldo's builtin macro models
  1724. (list (concat "^y\\w+\\s-+\\<\\("
  1725. (regexp-opt spice-eldo-macromodel-keywords) "\\)\\>")
  1726. '(1 spice-builtin-face))
  1727. ;; eldo's y instances, type is second word on line
  1728. (list (concat "^y\\w+\\s-+\\<" spice-model-name "\\>")
  1729. 1 spice-model-name-face)))
  1730. ;; highlight property names property=value & strings (way at the end)
  1731. (setq spice-font-lock-keywords-11
  1732. (list
  1733. ;; this is 1 second faster when loading 28 files, appx 10000 lines
  1734. ;; .options keywords & parameters
  1735. (list (concat "^\\s-*" ;; was "^"
  1736. (when (spice-standard-p 'layla) "\\*?")
  1737. "\\.opt\\(ion"
  1738. (when (or (spice-standard-p 'hspice)
  1739. (spice-standard-p 'layla))
  1740. "\\(s\\)?")
  1741. "\\)?\\s-+")
  1742. '(0 font-lock-keyword-face) ;; not used, already colored
  1743. (list (concat "\\<\\(\\("
  1744. (regexp-opt spice-options-keywords)
  1745. "\\)\\>\\|\\("
  1746. (regexp-opt spice-options-parameters)
  1747. "\\)\\s-*=\\)") nil nil
  1748. (list 1 spice-constant-face)))
  1749. ;; param=value
  1750. ;; '("\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
  1751. ;; this function matcher is much faster, it searches for '=' and then
  1752. ;; returns the word in front of the '=', doesn't work in xemacs though
  1753. ;;(if (string-match "XEmacs" emacs-version)
  1754. ;; (list "\\<\\([a-z]\\w*\\)\\s-*=" 1 font-lock-variable-name-face)
  1755. (list 'spice-match-variable-name
  1756. (list 1 font-lock-variable-name-face 'append)
  1757. ;;(list 1 font-lock-variable-name-face)
  1758. '(2 'default 'append)) ;; default is required for XEmacs
  1759. ;; 'append is required for Xemacs 21.4.11 on Windows. Otherwise
  1760. ;; the matcher overrules the previous highlighting (for instance when
  1761. ;; this 'var=value' is after a doc starter...
  1762. ;; )
  1763. ;; changelog entries
  1764. (list
  1765. (concat
  1766. "^[*"
  1767. (when (or (spice-standard-p 'hspice)
  1768. (spice-standard-p 'layla)) "$")
  1769. (when (spice-standard-p 'eldo) "!")
  1770. "]+\\s-+\\([A-Z].*[0-9]\\)\\s-+\\([a-zA-Z].*\\)<\\(.*@.*\\)>$")
  1771. '(1 font-lock-string-face t)
  1772. '(2 font-lock-type-face t)
  1773. '(3 font-lock-variable-name-face t))
  1774. ;; strings
  1775. '("\"[^\"]*\"" 0 font-lock-string-face)
  1776. ;; scale factors and powers or is this overkill ?
  1777. (list (concat
  1778. "\\<[-+]?[0-9.]+\\(\\("
  1779. (regexp-opt '("T" "G" "Meg" "K" "mil" "m" "u" "M" "n" "p" "f"))
  1780. "\\)[a-zA-Z]*\\)\\>")
  1781. (list 2 spice-constant-face 'append))
  1782. (list (concat
  1783. "[0-9.]\\(e\\)[-+]?[0-9]+\\>")
  1784. (list 1 spice-constant-face 'append))
  1785. ))
  1786. ;; set font-lock-keywords, all of 'em
  1787. (setq spice-font-lock-keywords
  1788. (append spice-font-lock-keywords-0 ;; title first
  1789. (when (spice-standard-p 'layla)
  1790. spice-font-lock-keywords-1)
  1791. (when spice-highlight-keywords
  1792. spice-font-lock-keywords-2)
  1793. (when (and
  1794. spice-highlight-keywords
  1795. (spice-standard-p 'layla))
  1796. spice-font-lock-keywords-3)
  1797. (when (spice-standard-p 'spectre)
  1798. spice-font-lock-keywords-13)
  1799. (when (spice-standard-p 'draccdl)
  1800. spice-font-lock-keywords-12)
  1801. spice-font-lock-keywords-4
  1802. (when spice-highlight-keywords
  1803. spice-font-lock-keywords-5)
  1804. (when (or (spice-standard-p 'layla)
  1805. (spice-standard-p 'hspice)
  1806. (spice-standard-p 'draccdl)
  1807. (spice-standard-p 'eldo))
  1808. spice-font-lock-keywords-6)
  1809. spice-font-lock-keywords-7
  1810. (when spice-highlight-keywords
  1811. spice-font-lock-keywords-8)
  1812. spice-font-lock-keywords-9
  1813. (when (spice-standard-p 'eldo)
  1814. spice-font-lock-keywords-10)
  1815. (when spice-highlight-keywords
  1816. spice-font-lock-keywords-11)
  1817. )))
  1818. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1819. ;;; Comments (taken from eldo-mode.el)
  1820. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1821. ;; uncomment function, should work for any case now:
  1822. (defun spice-uncomment-region (beg end)
  1823. "Uncomment selected region - comment symbol is '*'
  1824. Doc comments (starting with '!') are unaffected."
  1825. (interactive "*r")
  1826. (comment-region beg end '(2))) ; 2 is arbitrary, can be any value
  1827. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1828. ;;; spice mode map
  1829. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1830. ;; (require 'tempo) ; ? is this necessary
  1831. (defvar spice-mode-map ()
  1832. "Keymap used in spice-mode.")
  1833. (if spice-mode-map
  1834. ()
  1835. (let ((map (make-sparse-keymap)))
  1836. ;; key binding for template completion
  1837. (define-key map "\t" 'tempo-complete-tag)
  1838. ;; (define-key map "\S-\t" 'indent-for-tab-command)
  1839. (define-key map [(shift tab)] 'indent-for-tab-command)
  1840. (define-key map [(shift iso-lefttab)] 'indent-for-tab-command)
  1841. ;; key bindings for compile
  1842. (define-key map "\C-c\C-r" 'spice-compile) ;; r for run
  1843. (define-key map "\C-c\C-k" 'kill-compilation)
  1844. ;; replace global binding
  1845. (define-key map "\C-x`" 'spice-next-error)
  1846. ;; key bindings for waveform viewer
  1847. (define-key map "\C-c\C-v" 'spice-run-waveform-viewer)
  1848. ;; key bindings for output file loading
  1849. (define-key map "\C-c\C-o" 'spice-load-output-file)
  1850. ;; key bindings for include file loading
  1851. (define-key map "\C-c\C-l" 'spice-load-include-files)
  1852. ;; comment region, use auctex-mode bindings...
  1853. (define-key map "\C-c\C-c" 'comment-region)
  1854. ;;(define-key map "\C-c:" 'spice-uncomment-region) ;; \C-u\C-c\C-c
  1855. ;; .subckt search
  1856. (define-key map "\C-c\C-s" 'spice-search-subckt)
  1857. ;; join lines
  1858. (define-key map "\M-^" 'spice-delete-indentation)
  1859. ;; key bindings for hiding/unhidding comments
  1860. (define-key map "\C-c;" 'spice-hide-all-comments)
  1861. (define-key map "\C-c:" 'spice-unhide-all-comments)
  1862. ;; changelog addition
  1863. (define-key map "\C-c\C-ac" 'spice-add-changelog-entry)
  1864. ;; fontification
  1865. (when spice-running-xemacs
  1866. (define-key map "\C-c\C-f" 'font-lock-fontify-buffer))
  1867. (setq spice-mode-map map)))
  1868. (defvar spice-output-mode-map ()
  1869. "Keymap used in Spice-output mode.")
  1870. (if spice-output-mode-map
  1871. ()
  1872. (let ((map (make-sparse-keymap)))
  1873. ;; nothing for now ...
  1874. (setq spice-output-mode-map map)))
  1875. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1876. ;;; libraries & include files (taken & adapted from eldo-mode.el, E. Rouat)
  1877. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1878. (if spice-running-xemacs
  1879. (require 'overlay)
  1880. (require 'lucid)) ;; what else can we do ??
  1881. ;;------------------------------------------------------------
  1882. ;; Mouse bindings (only used by 'spice-load-file-at-mouse')
  1883. ;; I separate this from spice-mode-map so that this particular
  1884. ;; mouse binding doesn't interfere with other bindings
  1885. (defvar spice-mode-mouse-map nil
  1886. "Map containing mouse bindings for spice-mode.")
  1887. (if spice-mode-mouse-map
  1888. ()
  1889. (let ((map (make-sparse-keymap)))
  1890. (set-keymap-parent map spice-mode-map)
  1891. ;; mouse button bindings
  1892. ;;(define-key map "\r" 'ffap)
  1893. (define-key map "\r" 'spice-load-file-at-point)
  1894. (if spice-running-xemacs
  1895. (define-key map 'button2 'spice-load-file-at-mouse) ;; ffap-at-mouse ?
  1896. (define-key map [mouse-2] 'spice-load-file-at-mouse))
  1897. (if spice-running-xemacs
  1898. (define-key map 'Sh-button2 'mouse-yank)
  1899. (define-key map [S-mouse-2] 'mouse-yank-at-click))
  1900. (setq spice-mode-mouse-map map)))
  1901. ;; overlays and extents are a mess. Depending on emacs/xemacs versions the
  1902. ;; following code might actually work. What is known now is that this
  1903. ;; works in: emacs 20.7, 21.1 and 21.2 (Linux versions have been tested),
  1904. ;; xemacs 21.1 (Windows) and xemacs 21.5 (Linux). You need
  1905. ;; fsf-compat package for xemacs 21.4.5 (Linux). Anyone still following this ?
  1906. ;; create set-extent-keymap procedure when it does not exist
  1907. (eval-and-compile
  1908. (unless (fboundp 'set-extent-keymap)
  1909. (defun set-extent-keymap (extent keymap)
  1910. "fallback version of set-extent-keymap (for emacs 2[01])"
  1911. (set-extent-property extent 'local-map keymap))))
  1912. (defun spice-colorize-libraries (beg end old-len)
  1913. "This function colorises libraries and included files when the mouse
  1914. passes over them. Clicking on the middle-mouse button loads them in a buffer.
  1915. BEWARE, this feature was hard to implement, and contains (non-fatal) bugs,
  1916. primarily because emacs 20 does not have the same support for this as xemacs
  1917. has."
  1918. (save-excursion
  1919. (save-match-data
  1920. (let (end-point)
  1921. (goto-char end)
  1922. (end-of-line)
  1923. (setq end-point (point))
  1924. (goto-char beg)
  1925. (beginning-of-line) ; scan entire line !
  1926. ;; delete overlays existing on this line
  1927. (let ((overlays (overlays-in (point) end-point)))
  1928. (while overlays
  1929. (if (and (overlay-get (car overlays) 'detachable)
  1930. (overlay-get (car overlays) 'spice-library))
  1931. (delete-overlay (car overlays))
  1932. )
  1933. (setq overlays (cdr overlays)))) ; let
  1934. ; make new ones, could reuse deleted one ?
  1935. (while (search-forward-regexp spice-library-regexp-start end-point t)
  1936. (let (start-lib extent)
  1937. (setq start-lib (point))
  1938. (search-forward-regexp spice-library-regexp-end end-point)
  1939. ; (let ((end-lib (point)))
  1940. (or (extent-at (point) (buffer-name) 'mouse-face) ;; not yet extended
  1941. (progn
  1942. (setq extent (make-extent start-lib (point)))
  1943. (set-extent-property extent 'start-closed 't)
  1944. (set-extent-property extent 'end-closed 't)
  1945. (set-extent-property extent 'detachable 't)
  1946. (set-extent-property extent 'spice-library 't)
  1947. (set-extent-property extent 'mouse-face 'highlight)
  1948. (set-extent-keymap extent spice-mode-mouse-map)))))))))
  1949. (defun spice-colorize-libraries-buffer ()
  1950. (interactive)
  1951. ;; (message "running colorize libraries buffer")
  1952. ;; delete overlays
  1953. (let ((overlays (overlays-in (point-min) (point-max))))
  1954. (while overlays
  1955. (if (and
  1956. (overlay-get (car overlays) 'detachable)
  1957. (overlay-get (car overlays) 'spice-library))
  1958. (delete-overlay (car overlays)))
  1959. (setq overlays (cdr overlays)))) ; let
  1960. ;; remake overlays
  1961. (spice-colorize-libraries (point-min) (point-max) nil))
  1962. ;; ffap needs wrapper to detect end of buffer condition
  1963. (defun spice-load-file-at-point ()
  1964. "wrapper for ffap. But if at end of buffer inserts a newline instead"
  1965. (interactive)
  1966. (if (looking-at "\\'")
  1967. (newline) ;; assumes \r is bound to load file...
  1968. (ffap)))
  1969. ;; ffap-at-mouse isn't available in xemacs < 21
  1970. ;; so define this function to do more or less the same (primarily
  1971. ;; wraps ffap-at-mouse, except for xemacs 20)...
  1972. (defun spice-load-file-at-mouse (event)
  1973. "loads file under button 2 click. Checks if file is readable."
  1974. (interactive "@e")
  1975. (if (fboundp 'ffap-at-mouse)
  1976. (ffap-at-mouse event) ;; use ffap-at-mouse if available
  1977. (save-excursion ;; implement a spice specific ffap-at-mouse
  1978. (mouse-set-point event)
  1979. (beginning-of-line)
  1980. (if (looking-at (concat spice-library-regexp-start
  1981. spice-library-regexp-end))
  1982. (if (file-readable-p (substitute-in-file-name (match-string 3)))
  1983. (find-file (substitute-in-file-name (match-string 3)))
  1984. (progn
  1985. (message "File '%s' isn't readable, use shift-mouse2 to paste in this field" (match-string 3))))
  1986. ))))
  1987. ;;------------------------------------------------------------
  1988. ;; Changelog and sections support (taken from eldo-mode, trying
  1989. ;; to be compatible :)
  1990. ;;------------------------------------------------------------
  1991. (defun spice-doc-char ()
  1992. "Return doc char that's valid in the selected spice submode"
  1993. (cond
  1994. ((and (spice-standard-p 'eldo)
  1995. (spice-standard-p 'hspice))
  1996. "*") ; if both eldo and hspice is turned on
  1997. ((spice-standard-p 'eldo)
  1998. "!") ; only eldo
  1999. ((spice-standard-p 'hspice)
  2000. "$") ; only hspice
  2001. (t
  2002. "*"))) ; everything else
  2003. (defun spice-find-changelog-point ()
  2004. "Find adequate position to place Changelog entries: just before .end
  2005. or if not found at end of buffer."
  2006. (save-excursion
  2007. (goto-char (point-min))
  2008. (let ((pos (re-search-forward
  2009. "^\\.end\\b" nil t)))
  2010. (if pos (progn (forward-line 1)
  2011. (point))
  2012. (point-max)))))
  2013. (defun spice-add-changelog-entry (changelog-entry)
  2014. "Find changelog section (create it if not found) and add an entry for today."
  2015. (interactive "sChangelog entry: ")
  2016. (goto-char (point-min))
  2017. (if (not (re-search-forward
  2018. (concat spice-section-regexp-start "Changelog") nil t))
  2019. (spice-add-section "Changelog" (spice-find-changelog-point)))
  2020. (spice-goto-section "Changelog")
  2021. ; (forward-line 2)
  2022. (let ((string (concat (spice-doc-char)
  2023. (if (equal (spice-doc-char) "*") "* " " ")
  2024. (substring (current-time-string) 0 11)
  2025. (substring (current-time-string) -4) " "
  2026. (user-full-name) " <" user-mail-address ">")))
  2027. (if (not (search-forward string nil t))
  2028. (insert "\n" string "\n\n")
  2029. (forward-line 2))
  2030. (insert (spice-doc-char)
  2031. (if (equal (spice-doc-char) "*") "*" "")
  2032. " - " changelog-entry "\n")))
  2033. (defun spice-goto-section (section)
  2034. "Move point to the beginning of the specified section; If the
  2035. section is not found, leave point at previous location."
  2036. (interactive "ssection: ")
  2037. (let ((pos (point)))
  2038. (goto-char (point-min))
  2039. (if (not (re-search-forward
  2040. (concat spice-section-regexp-start section "\\b") nil t))
  2041. (progn (message "Couldn't find section %s" section)
  2042. (goto-char pos))
  2043. (progn
  2044. (forward-line 2)
  2045. (recenter))))) ;; added recenter
  2046. (defun spice-comment-bar (&optional aligned)
  2047. "Insert solid comment bar from column zero to end of line. If optional
  2048. argument is provided, bar will be added from current column."
  2049. (interactive)
  2050. (if (not aligned) (beginning-of-line) )
  2051. (insert "*")
  2052. (insert-char ?- (- (1- fill-column) (current-column)))
  2053. (insert "\n"))
  2054. (defun spice-add-section (section &optional arg)
  2055. "Add a section in buffer at (optional) point arg"
  2056. (interactive "ssection: ")
  2057. (if arg
  2058. (goto-char arg))
  2059. (spice-comment-bar)
  2060. (insert
  2061. (concat (spice-doc-char) "\t" section " \n"))
  2062. (spice-comment-bar)
  2063. ;; (unless (assoc section spice-section-alist)
  2064. ;; ;; new entry
  2065. ;; (custom-set-variables
  2066. ;; (quote (spice-section-alist
  2067. ;; (append spice-section-alist
  2068. ;; (list (list section (upcase section) nil))))))
  2069. ;; )
  2070. )
  2071. (defvar spice-cache-section-alist nil)
  2072. (defun spice-cache-section-p (section)
  2073. "checks for all sections in file and remembers if they were present or not"
  2074. (save-excursion
  2075. (setq spice-cache-section-alist nil)
  2076. (goto-char (point-min))
  2077. (while (re-search-forward spice-section-headings-regexp nil t)
  2078. (setq spice-cache-section-alist
  2079. (cons (cons (downcase (spice-match-string-no-properties 2)) t)
  2080. spice-cache-section-alist)))
  2081. (spice-section-p section)))
  2082. (defun spice-section-p (section)
  2083. "checks if named section is in file, returns t if found, nil otherwise,
  2084. uses cache generated with the `spice-cache-section-p' function."
  2085. (assoc section spice-cache-section-alist))
  2086. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2087. ;;; Templates (extensive, long code...)
  2088. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2089. (require 'tempo)
  2090. ;;; element templates
  2091. ;; resistors
  2092. (tempo-define-template
  2093. "spice-spice2g6-resistor"
  2094. '("R"
  2095. (p "[name]: ") '(just-one-space)
  2096. (p "[pos node]: ") '(just-one-space)
  2097. (p "[neg node]: ") '(just-one-space)
  2098. (p "[val]: "))
  2099. ;; "spice2g6 resistor"
  2100. "R"
  2101. "tempo template for spice2g6 resistor"
  2102. 'spice-tempo-tags)
  2103. (tempo-define-template
  2104. "spice-spice3-semiconductor-resistor"
  2105. '("R"
  2106. (p "[name]: ") '(just-one-space)
  2107. (p "[pos node]: ") '(just-one-space)
  2108. (p "[neg node]: ") '(just-one-space)
  2109. (p "<value>: " value) '(just-one-space)
  2110. (p "<mname>: " mname) '(just-one-space)
  2111. (p "<length>: " l 'noinsert)
  2112. (if (string-equal (tempo-lookup-named 'l) "")
  2113. () (list 'l "L=" '(s l)))
  2114. '(just-one-space)
  2115. (p "<width>: " w 'noinsert)
  2116. (if (string-equal (tempo-lookup-named 'w) "")
  2117. () (list 'l "W=" '(s w)))
  2118. '(just-one-space)
  2119. (p "<temp>: " temp 'noinsert)
  2120. (if (string-equal (tempo-lookup-named 'temp) "")
  2121. () (list 'l "TEMP=" '(s temp)))
  2122. '(just-one-space)
  2123. )
  2124. ;; "spice3 semiconductor resistor"
  2125. "RSS"
  2126. "tempo template for spice3 semiconductor resistor"
  2127. 'spice-tempo-tags)
  2128. (tempo-define-template
  2129. "spice-eldo-resistor"
  2130. '("R"
  2131. (p "[name]: ") '(just-one-space)
  2132. (p "[pos node]: ") '(just-one-space)
  2133. (p "[neg node]: ") '(just-one-space)
  2134. (p "<mname>: " mname) '(just-one-space)
  2135. (if (string-equal (tempo-lookup-named 'mname) "")
  2136. (list 'l "r=" '(p "[val]: "))
  2137. (list 'l '(p "[val]: "))) '(just-one-space)
  2138. (p "<temp coef 1>: " tc1 'noinsert)
  2139. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2140. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2141. '(just-one-space)
  2142. (if (and (tempo-lookup-named 'tc2)
  2143. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2144. (list 'l "TC2=" '(s tc2)))
  2145. '(just-one-space)
  2146. (p "<ac resistance>: " ac 'noinsert)
  2147. (if (string-equal (tempo-lookup-named 'ac) "")
  2148. () (list 'l "AC=" '(s ac)))
  2149. '(just-one-space)
  2150. (p "<temp>: " temp 'noinsert)
  2151. (if (string-equal (tempo-lookup-named 'temp) "")
  2152. () (list 'l "T=" '(s temp)))
  2153. '(just-one-space)
  2154. (p "<m>: " m 'noinsert)
  2155. (if (string-equal (tempo-lookup-named 'm) "")
  2156. () (list 'l "M=" '(s m)))
  2157. '(just-one-space)
  2158. (p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)
  2159. (if (string-equal (tempo-lookup-named 'nonoise) "y")
  2160. (list 'l "NONOISE"))
  2161. '(just-one-space)
  2162. (p "<kf>: " kf 'noinsert)
  2163. (if (string-equal (tempo-lookup-named 'kf) "")
  2164. () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
  2165. '(just-one-space)
  2166. (if (and (tempo-lookup-named 'af)
  2167. (not (string-equal (tempo-lookup-named 'af) "")))
  2168. (list 'l '(s af)))
  2169. '(just-one-space)
  2170. )
  2171. ;; "eldo resistor"
  2172. "RE"
  2173. "tempo template for eldo resistor"
  2174. 'spice-tempo-tags)
  2175. (tempo-define-template
  2176. "spice-eldo-expression-resistor"
  2177. '("R"
  2178. (p "[name]: ") '(just-one-space)
  2179. (p "[pos node]: ") '(just-one-space)
  2180. (p "[neg node]: ") '(just-one-space)
  2181. (p "[VALUE | TABLE]: " type 'noinsert) '(just-one-space)
  2182. (if (string-equal (tempo-lookup-named 'type) "VALUE")
  2183. (list 'l "VALUE={" '(p "[val, enter expression without {}]: ") "}")
  2184. (list 'l "TABLE={" '(p "[table of values, enter table without {}]: ") "}"))
  2185. '(just-one-space)
  2186. (if (string-equal (tempo-lookup-named 'type) "VALUE")
  2187. (list 'l '(p "<nonoise in transient [y/n]?>: " nonoise 'noinsert)))
  2188. (if (and (tempo-lookup-named 'nonoise)
  2189. (string-equal (tempo-lookup-named 'nonoise) "y"))
  2190. (list 'l "NONOISE"))
  2191. '(just-one-space)
  2192. (p "<kf>: " kf 'noinsert)
  2193. (if (string-equal (tempo-lookup-named 'kf) "")
  2194. () (list 'l '(s kf) '(p "<af>: " af 'noinsert)))
  2195. '(just-one-space)
  2196. (if (and (tempo-lookup-named 'af)
  2197. (not (string-equal (tempo-lookup-named 'af) "")))
  2198. (list 'l '(s af)))
  2199. )
  2200. ;; "eldo expression resistor"
  2201. "REE"
  2202. "tempo template for eldo expression resistor"
  2203. 'spice-tempo-tags)
  2204. (tempo-define-template
  2205. "spice-eldo-semiconductor-resistor"
  2206. '("P"
  2207. (p "[name]: ") '(just-one-space)
  2208. (p "[pos node]: ") '(just-one-space)
  2209. (p "[neg node]: ") '(just-one-space)
  2210. (p "[mname]: " mname) '(just-one-space)
  2211. (p "<res>: " r 'noinsert)
  2212. (if (string-equal (tempo-lookup-named 'r) "")
  2213. () (list 'l "R=" '(s r)))
  2214. '(just-one-space)
  2215. (p "<length>: " l 'noinsert)
  2216. (if (string-equal (tempo-lookup-named 'l) "")
  2217. () (list 'l "L=" '(s l)))
  2218. '(just-one-space)
  2219. (p "<contact offset length>: " cl 'noinsert)
  2220. (if (string-equal (tempo-lookup-named 'cl) "")
  2221. () (list 'l "CL=" '(s cl)))
  2222. '(just-one-space)
  2223. (p "<width>: " w 'noinsert)
  2224. (if (string-equal (tempo-lookup-named 'w) "")
  2225. () (list 'l "W=" '(s w)))
  2226. '(just-one-space)
  2227. (p "<contact offset width>: " cw 'noinsert)
  2228. (if (string-equal (tempo-lookup-named 'cw) "")
  2229. () (list 'l "CW=" '(s cw)))
  2230. '(just-one-space)
  2231. (p "<area>: " area 'noinsert)
  2232. (if (string-equal (tempo-lookup-named 'area) "")
  2233. () (list 'l "AREA=" '(s area)))
  2234. '(just-one-space)
  2235. (p "<init cond (voltage, voltage)>: " ic 'noinsert)
  2236. (if (string-equal (tempo-lookup-named 'ic) "")
  2237. () (list 'l "IC=" '(s ic)))
  2238. '(just-one-space)
  2239. )
  2240. ;; "eldo semiconductor resistor"
  2241. "RES"
  2242. "tempo template for eldo semiconductor resistor"
  2243. 'spice-tempo-tags)
  2244. (tempo-define-template
  2245. "spice-hspice-resistor"
  2246. '("R"
  2247. (p "[name]: ") '(just-one-space)
  2248. (p "[pos node]: ") '(just-one-space)
  2249. (p "[neg node]: ") '(just-one-space)
  2250. (p "<mname>: " mname) '(just-one-space)
  2251. (if (string-equal (tempo-lookup-named 'mname) "")
  2252. (list 'l "R=" '(p "[val]: "))
  2253. (list 'l '(p "<val>: " val 'noinsert)
  2254. '(if (not (string-equal (tempo-lookup-named 'val) ""))
  2255. (list 'l "R=" '(s val))))) '(just-one-space)
  2256. (p "<temp coef 1>: " tc1 'noinsert)
  2257. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2258. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2259. '(just-one-space)
  2260. (if (and (tempo-lookup-named 'tc2)
  2261. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2262. (list 'l "TC2=" '(s tc2)))
  2263. '(just-one-space)
  2264. (p "<scale>: " scale 'noinsert)
  2265. (if (string-equal (tempo-lookup-named 'scale) "")
  2266. () (list 'l "SCALE=" '(s scale)))
  2267. '(just-one-space)
  2268. (p "<m>: " m 'noinsert)
  2269. (if (string-equal (tempo-lookup-named 'm) "")
  2270. () (list 'l "M=" '(s m)))
  2271. '(just-one-space)
  2272. (p "<ac resistance>: " ac 'noinsert)
  2273. (if (string-equal (tempo-lookup-named 'ac) "")
  2274. () (list 'l "AC=" '(s ac)))
  2275. '(just-one-space)
  2276. (p "<diff temp>: " dtemp 'noinsert)
  2277. (if (string-equal (tempo-lookup-named 'dtemp) "")
  2278. () (list 'l "DTEMP=" '(s dtemp)))
  2279. '(just-one-space)
  2280. (p "<length>: " l 'noinsert)
  2281. (if (string-equal (tempo-lookup-named 'l) "")
  2282. () (list 'l "L=" '(s l)))
  2283. '(just-one-space)
  2284. (p "<width>: " w 'noinsert)
  2285. (if (string-equal (tempo-lookup-named 'w) "")
  2286. () (list 'l "W=" '(s w)))
  2287. '(just-one-space)
  2288. (p "<cap>: " c 'noinsert)
  2289. (if (string-equal (tempo-lookup-named 'c) "")
  2290. () (list 'l "C=" '(s c)))
  2291. '(just-one-space)
  2292. )
  2293. ;; "hspice resistor"
  2294. "RH"
  2295. "template for hspice resistor tempo templates"
  2296. 'spice-tempo-tags)
  2297. (tempo-define-template
  2298. "spice-layla-resistor"
  2299. '("R"
  2300. (p "[name]: ") '(just-one-space)
  2301. (p "[pos node]: ") '(just-one-space)
  2302. (p "[neg node]: ") '(just-one-space)
  2303. ; (p "<mname>: ") '(just-one-space)
  2304. (p "[value]: ") '(just-one-space)
  2305. (p "<width>: " w 'noinsert)
  2306. (if (string-equal (tempo-lookup-named 'w) "")
  2307. () (list 'l "width=" '(s w)))
  2308. '(just-one-space)
  2309. "\n+ type=\""
  2310. (p "[type (no quotes)]: ") "\""
  2311. '(just-one-space)
  2312. (p "<symmetry (no quotes)>: " symmetry 'noinsert)
  2313. (if (string-equal (tempo-lookup-named 'symmetry) "")
  2314. () (list 'l "symmetry=\"" '(s symmetry) "\""))
  2315. '(just-one-space)
  2316. (p "<matching (no quotes)>: " matching 'noinsert)
  2317. (if (string-equal (tempo-lookup-named 'matching) "")
  2318. () (list 'l "matching=\"" '(s matching) "\""))
  2319. '(just-one-space)
  2320. (p "<couple>: " couple 'noinsert)
  2321. (if (string-equal (tempo-lookup-named 'couple) "")
  2322. () (list 'l "couple=" '(s couple)))
  2323. '(just-one-space)
  2324. (p "<array (no quotes)>: " array 'noinsert)
  2325. (if (string-equal (tempo-lookup-named 'array) "")
  2326. () (list 'l "array=\"" '(s array) "\""))
  2327. '(just-one-space)
  2328. (p "<orientations (no quotes)>: " orientations 'noinsert)
  2329. (if (string-equal (tempo-lookup-named 'orientations) "")
  2330. () (list 'l "orientations=\"" '(s orientations) "\""))
  2331. '(just-one-space)
  2332. (p "<unit_value>: " unit_value 'noinsert)
  2333. (if (string-equal (tempo-lookup-named 'unit_value) "")
  2334. () (list 'l "unit_value=" '(s unit_value)))
  2335. '(just-one-space)
  2336. (p "<current>: " current 'noinsert)
  2337. (if (string-equal (tempo-lookup-named 'current) "")
  2338. () (list 'l "current=" '(s current)))
  2339. '(just-one-space)
  2340. (p "<power>: " power 'noinsert)
  2341. (if (string-equal (tempo-lookup-named 'power) "")
  2342. () (list 'l "power=" '(s power)))
  2343. '(just-one-space)
  2344. (p "<min_ar>: " min_ar 'noinsert)
  2345. (if (string-equal (tempo-lookup-named 'min_ar) "")
  2346. () (list 'l "min_ar=" '(s min_ar)))
  2347. '(just-one-space)
  2348. (p "<max_ar>: " max_ar 'noinsert)
  2349. (if (string-equal (tempo-lookup-named 'max_ar) "")
  2350. () (list 'l "max_ar=" '(s max_ar)))
  2351. '(just-one-space)
  2352. (p "<routing_space>: " routing_space 'noinsert)
  2353. (if (string-equal (tempo-lookup-named 'routing_space) "")
  2354. () (list 'l "routing_space=" '(s routing_space)))
  2355. '(just-one-space)
  2356. )
  2357. ;; "layla resistor"
  2358. "RL"
  2359. "tempo template for layla resistor"
  2360. 'spice-tempo-tags)
  2361. ;; capacitors
  2362. (tempo-define-template
  2363. "spice-spice2g6-capacitor"
  2364. '("C"
  2365. (p "[name]: ") '(just-one-space)
  2366. (p "[pos node]: ") '(just-one-space)
  2367. (p "[neg node]: ") '(just-one-space)
  2368. (p "[val]: ") '(just-one-space)
  2369. (p "<initial cond (voltage)>: " ic 'noinsert)
  2370. (if (string-equal (tempo-lookup-named 'ic) "")
  2371. () (list 'l "ic=" '(s ic)))
  2372. )
  2373. ;; "spice2g6 capacitor"
  2374. "C"
  2375. "tempo template for spice2g6 capacitor"
  2376. 'spice-tempo-tags)
  2377. (tempo-define-template
  2378. "spice-spice3-semiconductor-capacitor"
  2379. '("C"
  2380. (p "[name]: ") '(just-one-space)
  2381. (p "[pos node]: ") '(just-one-space)
  2382. (p "[neg node]: ") '(just-one-space)
  2383. (p "<value>: " value) '(just-one-space)
  2384. (p "<mname>: " mname) '(just-one-space)
  2385. (p "<length>: " l 'noinsert)
  2386. (if (string-equal (tempo-lookup-named 'l) "")
  2387. () (list 'l "L=" '(s l)))
  2388. '(just-one-space)
  2389. (p "<width>: " w 'noinsert)
  2390. (if (string-equal (tempo-lookup-named 'w) "")
  2391. () (list 'l "W=" '(s w)))
  2392. '(just-one-space)
  2393. (p "<initial conditions (Voltage)>: " ic 'noinsert)
  2394. (if (string-equal (tempo-lookup-named 'ic) "")
  2395. () (list 'l "IC=" '(s ic)))
  2396. '(just-one-space)
  2397. )
  2398. ;; "spice3 semiconductor capacitor"
  2399. "CSS"
  2400. "tempo template for spice3 semiconductor capacitor"
  2401. 'spice-tempo-tags)
  2402. (tempo-define-template
  2403. "spice-eldo-capacitor"
  2404. '("C"
  2405. (p "[name]: ") '(just-one-space)
  2406. (p "[pos node]: ") '(just-one-space)
  2407. (p "[neg node]: ") '(just-one-space)
  2408. (p "<mname | POLY>: " mname) '(just-one-space)
  2409. (if (string-equal (tempo-lookup-named 'mname) "POLY")
  2410. (list 'l '(p "[val and poly coefficients]: "))
  2411. (list 'l '(p "[val]: ")))
  2412. '(just-one-space)
  2413. (p "<m>: " m 'noinsert)
  2414. (if (string-equal (tempo-lookup-named 'm) "")
  2415. () (list 'l "M=" '(s m)))
  2416. '(just-one-space)
  2417. (p "<length>: " l 'noinsert)
  2418. (if (string-equal (tempo-lookup-named 'l) "")
  2419. () (list 'l "L=" '(s l)))
  2420. '(just-one-space)
  2421. (p "<width>: " w 'noinsert)
  2422. (if (string-equal (tempo-lookup-named 'w) "")
  2423. () (list 'l "W=" '(s w)))
  2424. '(just-one-space)
  2425. (p "<diff temp>: " dtemp 'noinsert)
  2426. (if (string-equal (tempo-lookup-named 'dtemp) "")
  2427. () (list 'l "DTEMP=" '(s dtemp)))
  2428. '(just-one-space)
  2429. (p "<temp coef 1>: " tc1 'noinsert)
  2430. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2431. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2432. '(just-one-space)
  2433. (if (and (tempo-lookup-named 'tc2)
  2434. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2435. (list 'l "TC2=" '(s tc2)))
  2436. '(just-one-space)
  2437. (p "<initial cond (voltage)>: " ic 'noinsert)
  2438. (if (string-equal (tempo-lookup-named 'ic) "")
  2439. () (list 'l "IC=" '(s ic)))
  2440. )
  2441. ;; "eldo capacitor"
  2442. "CE"
  2443. "tempo template for eldo capacitor"
  2444. 'spice-tempo-tags)
  2445. (tempo-define-template
  2446. "spice-eldo-expression-capacitor"
  2447. '("C"
  2448. (p "[name]: ") '(just-one-space)
  2449. (p "[pos node]: ") '(just-one-space)
  2450. (p "[neg node]: ") '(just-one-space)
  2451. (p "<temp coef 1>: " tc1 'noinsert)
  2452. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2453. (list 'l "TC1=" '(s tc1)))
  2454. '(just-one-space)
  2455. (p "<temp coef 2>: " tc2 'noinsert)
  2456. (if (string-equal (tempo-lookup-named 'tc2) "") ()
  2457. (list 'l "TC2=" '(s tc2)))
  2458. '(just-one-space)
  2459. (p "<temp coef 3>: " tc3 'noinsert)
  2460. (if (string-equal (tempo-lookup-named 'tc3) "") ()
  2461. (list 'l "TC3=" '(s tc3)))
  2462. '(just-one-space)
  2463. "VALUE={"
  2464. (p "[val enter expression without {}]: ")
  2465. "}"
  2466. )
  2467. ;; "eldo expression capacitor"
  2468. "CEE"
  2469. "tempo template for eldo expression capacitor"
  2470. 'spice-tempo-tags)
  2471. (tempo-define-template
  2472. "spice-hspice-capacitor"
  2473. '("C"
  2474. (p "[name]: ") '(just-one-space)
  2475. (p "[pos node]: ") '(just-one-space)
  2476. (p "[neg node]: ") '(just-one-space)
  2477. (p "<mname | POLY>: " mname) '(just-one-space)
  2478. (if (string-equal (tempo-lookup-named 'mname) "POLY")
  2479. (list 'l '(p "[val and poly coefficients]: " val))
  2480. (if (string-equal (tempo-lookup-named 'mname) "")
  2481. (list 'l "C=" '(p "[val or expression]: " val))
  2482. (list 'l "C=" '(p "[val]: " val))))
  2483. '(just-one-space)
  2484. (if (and (not (string-equal (tempo-lookup-named 'mname) "POLY"))
  2485. (char-equal (string-to-char (tempo-lookup-named 'val))
  2486. (string-to-char "'")))
  2487. (list 'l '(p "<ctype>: " ctype 'noinsert)))
  2488. (if (and (tempo-lookup-named 'ctype)
  2489. (not (string-equal (tempo-lookup-named 'ctype) "")))
  2490. (list 'l "CTYPE=" '(s ctype)))
  2491. '(just-one-space)
  2492. (p "<temp coef 1>: " tc1 'noinsert)
  2493. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2494. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2495. '(just-one-space)
  2496. (if (and (tempo-lookup-named 'tc2)
  2497. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2498. (list 'l "TC2=" '(s tc2)))
  2499. '(just-one-space)
  2500. (p "<scale>: " scale 'noinsert)
  2501. (if (string-equal (tempo-lookup-named 'scale) "")
  2502. () (list 'l "SCALE=" '(s scale)))
  2503. '(just-one-space)
  2504. (p "<initial cond (voltage)>: " ic 'noinsert)
  2505. (if (string-equal (tempo-lookup-named 'ic) "")
  2506. () (list 'l "IC=" '(s ic)))
  2507. '(just-one-space)
  2508. (p "<m>: " m 'noinsert)
  2509. (if (string-equal (tempo-lookup-named 'm) "")
  2510. () (list 'l "M=" '(s m)))
  2511. '(just-one-space)
  2512. (p "<width>: " w 'noinsert)
  2513. (if (string-equal (tempo-lookup-named 'w) "")
  2514. () (list 'l "W=" '(s w)))
  2515. '(just-one-space)
  2516. (p "<length>: " l 'noinsert)
  2517. (if (string-equal (tempo-lookup-named 'l) "")
  2518. () (list 'l "L=" '(s l)))
  2519. '(just-one-space)
  2520. (p "<diff temp>: " dtemp 'noinsert)
  2521. (if (string-equal (tempo-lookup-named 'dtemp) "")
  2522. () (list 'l "DTEMP=" '(s dtemp)))
  2523. '(just-one-space)
  2524. )
  2525. ;; "hspice capacitor"
  2526. "CH"
  2527. "tempo template for hspice capacitor"
  2528. 'spice-tempo-tags)
  2529. (tempo-define-template
  2530. "spice-layla-capacitor"
  2531. '("C"
  2532. (p "[name]: ") '(just-one-space)
  2533. (p "[pos node]: ") '(just-one-space)
  2534. (p "[neg node]: ") '(just-one-space)
  2535. (p "[value]: ") '(just-one-space)
  2536. (p "<units_ver>: " units_ver 'noinsert)
  2537. (if (string-equal (tempo-lookup-named 'units_ver) "")
  2538. () (list 'l "units_ver=" '(s units_ver)))
  2539. '(just-one-space)
  2540. (p "<units_hor>: " units_hor 'noinsert)
  2541. (if (string-equal (tempo-lookup-named 'units_hor) "")
  2542. () (list 'l "units_hor=" '(s units_hor)))
  2543. '(just-one-space)
  2544. "\n+ type=\""
  2545. (p "[type (no quotes)]: ") "\""
  2546. '(just-one-space)
  2547. (p "<symmetry (no quotes)>: " symmetry 'noinsert)
  2548. (if (string-equal (tempo-lookup-named 'symmetry) "")
  2549. () (list 'l "symmetry=\"" '(s symmetry) "\""))
  2550. '(just-one-space)
  2551. (p "<matching (no quotes)>: " matching 'noinsert)
  2552. (if (string-equal (tempo-lookup-named 'matching) "")
  2553. () (list 'l "matching=\"" '(s matching) "\""))
  2554. '(just-one-space)
  2555. (p "<couple>: " couple 'noinsert)
  2556. (if (string-equal (tempo-lookup-named 'couple) "")
  2557. () (list 'l "couple=" '(s couple)))
  2558. '(just-one-space)
  2559. (p "<array (no quotes)>: " array 'noinsert)
  2560. (if (string-equal (tempo-lookup-named 'array) "")
  2561. () (list 'l "array=\"" '(s array) "\""))
  2562. '(just-one-space)
  2563. (p "<orientations (no quotes)>: " orientations 'noinsert)
  2564. (if (string-equal (tempo-lookup-named 'orientations) "")
  2565. () (list 'l "orientations=\"" '(s orientations) "\""))
  2566. '(just-one-space)
  2567. (p "<unit_value>: " unit_value 'noinsert)
  2568. (if (string-equal (tempo-lookup-named 'unit_value) "")
  2569. () (list 'l "unit_value=" '(s unit_value)))
  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)
  2587. )
  2588. ;; "layla capacitor"
  2589. "CL"
  2590. "tempo template for layla capacitor"
  2591. 'spice-tempo-tags)
  2592. ;; inductors
  2593. (tempo-define-template
  2594. "spice-spice2g6-inductor"
  2595. '("L"
  2596. (p "[name]: ") '(just-one-space)
  2597. (p "[pos node]: ") '(just-one-space)
  2598. (p "[neg node]: ") '(just-one-space)
  2599. (p "[val]: ") '(just-one-space)
  2600. (p "<initial cond (current)>: " ic 'noinsert)
  2601. (if (string-equal (tempo-lookup-named 'ic) "")
  2602. () (list 'l "ic=" '(s ic)))
  2603. )
  2604. ;; "spice2g6 inductor"
  2605. "L"
  2606. "tempo template for spice2g6 inductor"
  2607. 'spice-tempo-tags)
  2608. (tempo-define-template
  2609. "spice-eldo-inductor"
  2610. '("L"
  2611. (p "[name]: ") '(just-one-space)
  2612. (p "[pos node]: ") '(just-one-space)
  2613. (p "[neg node]: ") '(just-one-space)
  2614. (p "<mname | POLY>: " mname) '(just-one-space)
  2615. (if (string-equal (tempo-lookup-named 'mname) "POLY")
  2616. (list 'l '(p "[val and poly coefficients]: "))
  2617. (list 'l '(p "[val]: ")))
  2618. '(just-one-space)
  2619. (p "<initial cond (current)>: " ic 'noinsert)
  2620. (if (string-equal (tempo-lookup-named 'ic) "")
  2621. () (list 'l "ic=" '(s ic)))
  2622. )
  2623. ;; "eldo inductor"
  2624. "LE"
  2625. "tempo template for eldo inductor"
  2626. 'spice-tempo-tags)
  2627. (tempo-define-template
  2628. "spice-eldo-expression-inductor"
  2629. '("L"
  2630. (p "[name]: ") '(just-one-space)
  2631. (p "[pos node]: ") '(just-one-space)
  2632. (p "[neg node]: ") '(just-one-space)
  2633. "VALUE={"
  2634. (p "[val enter expression without {}]: ")
  2635. "}"
  2636. )
  2637. ;; "eldo expression inductor"
  2638. "LEE"
  2639. "tempo template for eldo expression inductor"
  2640. 'spice-tempo-tags)
  2641. (tempo-define-template
  2642. "spice-hspice-inductor"
  2643. '("L"
  2644. (p "[name]: ") '(just-one-space)
  2645. (p "[pos node]: ") '(just-one-space)
  2646. (p "[neg node]: ") '(just-one-space)
  2647. (p "<POLY | NT>: " poly 'noinsert) '(just-one-space)
  2648. (cond ((string-equal (tempo-lookup-named 'poly) "POLY")
  2649. (list 'l "POLY " '(p "[value and coefficients]: ")))
  2650. ((string-equal (tempo-lookup-named 'poly) "NT")
  2651. (list 'l "NT=" '(p "[number of turns]: " nt)))
  2652. (t
  2653. (list 'l "L=" '(p "[value or expression]: " val)))
  2654. )
  2655. '(just-one-space)
  2656. (if (and (tempo-lookup-named 'val)
  2657. (char-equal (string-to-char (tempo-lookup-named 'val))
  2658. (string-to-char "'")))
  2659. (list 'l '(p "<ltype>: " ltype 'noinsert)))
  2660. (if (and (tempo-lookup-named 'ltype)
  2661. (not (string-equal (tempo-lookup-named 'ltype) "")))
  2662. (list 'l "LTYPE=" '(s ltype)))
  2663. '(just-one-space)
  2664. (p "<temp coef 1>: " tc1 'noinsert)
  2665. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2666. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2667. '(just-one-space)
  2668. (if (and (tempo-lookup-named 'tc2)
  2669. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2670. (list 'l "TC2=" '(s tc2)))
  2671. '(just-one-space)
  2672. (p "<scale>: " scale 'noinsert)
  2673. (if (string-equal (tempo-lookup-named 'scale) "")
  2674. () (list 'l "SCALE=" '(s scale)))
  2675. '(just-one-space)
  2676. (p "<initial cond (current)>: " ic 'noinsert)
  2677. (if (string-equal (tempo-lookup-named 'ic) "")
  2678. () (list 'l "IC=" '(s ic)))
  2679. '(just-one-space)
  2680. (p "<m>: " m 'noinsert)
  2681. (if (string-equal (tempo-lookup-named 'm) "")
  2682. () (list 'l "M=" '(s m)))
  2683. '(just-one-space)
  2684. (p "<diff temp>: " dtemp 'noinsert)
  2685. (if (string-equal (tempo-lookup-named 'dtemp) "")
  2686. () (list 'l "DTEMP=" '(s dtemp)))
  2687. '(just-one-space)
  2688. (p "<res>: " r 'noinsert)
  2689. (if (string-equal (tempo-lookup-named 'r) "")
  2690. () (list 'l "R=" '(s r)))
  2691. '(just-one-space)
  2692. )
  2693. ;; "hspice inductor"
  2694. "LH"
  2695. "tempo template for hspice inductor"
  2696. 'spice-tempo-tags)
  2697. (tempo-define-template
  2698. "spice-layla-inductor"
  2699. '("L"
  2700. (p "[name]: ") '(just-one-space)
  2701. (p "[pos node]: ") '(just-one-space)
  2702. (p "[neg node]: ") '(just-one-space)
  2703. (p "<value>: ") '(just-one-space)
  2704. (p "<outer radius>: " radius 'noinsert)
  2705. (if (string-equal (tempo-lookup-named 'radius) "")
  2706. () (list 'l "radius=" '(s radius)))
  2707. '(just-one-space)
  2708. (p "<width>: " w 'noinsert)
  2709. (if (string-equal (tempo-lookup-named 'w) "")
  2710. () (list 'l "w=" '(s w)))
  2711. '(just-one-space)
  2712. (p "<number of turns>: " n 'noinsert)
  2713. (if (string-equal (tempo-lookup-named 'n) "")
  2714. () (list 'l "n=" '(s n)))
  2715. '(just-one-space)
  2716. (p "<space>: " space 'noinsert)
  2717. (if (string-equal (tempo-lookup-named 'space) "")
  2718. () (list 'l "space=" '(s space)))
  2719. '(just-one-space)
  2720. (p "<end_fraction [0-1]>: " end_fraction 'noinsert)
  2721. (if (string-equal (tempo-lookup-named 'end_fraction) "")
  2722. () (list 'l "end_fraction=" '(s end_fraction)))
  2723. '(just-one-space)
  2724. "\n+ type=\""
  2725. (p "[type (no quotes)]: ") "\""
  2726. '(just-one-space)
  2727. (p "<symmetry (no quotes)>: " symmetry 'noinsert)
  2728. (if (string-equal (tempo-lookup-named 'symmetry) "")
  2729. () (list 'l "symmetry=\"" '(s symmetry) "\""))
  2730. '(just-one-space)
  2731. (p "<matching (no quotes)>: " matching 'noinsert)
  2732. (if (string-equal (tempo-lookup-named 'matching) "")
  2733. () (list 'l "matching=\"" '(s matching) "\""))
  2734. '(just-one-space)
  2735. (p "<couple>: " couple 'noinsert)
  2736. (if (string-equal (tempo-lookup-named 'couple) "")
  2737. () (list 'l "couple=" '(s couple)))
  2738. '(just-one-space)
  2739. (p "<array (no quotes)>: " array 'noinsert)
  2740. (if (string-equal (tempo-lookup-named 'array) "")
  2741. () (list 'l "array=\"" '(s array) "\""))
  2742. '(just-one-space)
  2743. (p "<orientations (no quotes)>: " orientations 'noinsert)
  2744. (if (string-equal (tempo-lookup-named 'orientations) "")
  2745. () (list 'l "orientations=\"" '(s orientations) "\""))
  2746. '(just-one-space)
  2747. (p "<power>: " power 'noinsert)
  2748. (if (string-equal (tempo-lookup-named 'power) "")
  2749. () (list 'l "power=" '(s power)))
  2750. '(just-one-space)
  2751. (p "<min_ar>: " min_ar 'noinsert)
  2752. (if (string-equal (tempo-lookup-named 'min_ar) "")
  2753. () (list 'l "min_ar=" '(s min_ar)))
  2754. '(just-one-space)
  2755. (p "<max_ar>: " max_ar 'noinsert)
  2756. (if (string-equal (tempo-lookup-named 'max_ar) "")
  2757. () (list 'l "max_ar=" '(s max_ar)))
  2758. '(just-one-space)
  2759. (p "<routing_space>: " routing_space 'noinsert)
  2760. (if (string-equal (tempo-lookup-named 'routing_space) "")
  2761. () (list 'l "routing_space=" '(s routing_space)))
  2762. '(just-one-space)
  2763. )
  2764. ;; "layla inductor"
  2765. "LL"
  2766. "tempo template for layla inductor"
  2767. 'spice-tempo-tags)
  2768. ;; coupled inductors
  2769. (tempo-define-template
  2770. "spice-spice2g6-coupled-inductors"
  2771. '("K"
  2772. (p "[name]: ") '(just-one-space)
  2773. (p "[first inductor]: ") '(just-one-space)
  2774. (p "[second inductor]: ") '(just-one-space)
  2775. (p "[coupling coefficient]: ")
  2776. )
  2777. ;; "spice2g6 inductor coupling"
  2778. "K"
  2779. "tempo template for spice2g6 coupled inductors"
  2780. 'spice-tempo-tags)
  2781. ;; lossless transmission lines
  2782. (tempo-define-template
  2783. "spice-spice2g6-lossless-transmission"
  2784. '("T"
  2785. (p "[name]: ") '(just-one-space)
  2786. (p "[out port1]: ") '(just-one-space)
  2787. (p "[ref port1]: ") '(just-one-space)
  2788. (p "[out port2]: ") '(just-one-space)
  2789. (p "[ref port2]: ") '(just-one-space)
  2790. "Z0=" (p "[char impedance]: ") '(just-one-space)
  2791. (p "<time delay in seconds>: " td 'noinsert)
  2792. (if (string-equal (tempo-lookup-named 'td) "")
  2793. (list 'l '(p "<freq>: " freq 'noinsert)) (list 'l "td=" '(s td)))
  2794. '(just-one-space)
  2795. (if (and (tempo-lookup-named 'freq)
  2796. (not (string-equal (tempo-lookup-named 'freq) "")))
  2797. (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
  2798. '(just-one-space)
  2799. (if (and (tempo-lookup-named 'nrmlen)
  2800. (not (string-equal (tempo-lookup-named 'nrmlen) "")))
  2801. (list 'l "nl=" '(s nrmlen)))
  2802. '(just-one-space)
  2803. (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
  2804. (if (string-equal (tempo-lookup-named 'ic) "")
  2805. () (list 'l "ic=" '(s ic)))
  2806. )
  2807. ;;"spice2g6 lossless transmission line"
  2808. "T"
  2809. "tempo template for spice2g6 lossless transmission line"
  2810. 'spice-tempo-tags)
  2811. (tempo-define-template
  2812. "spice-hspice-lossless-transmission"
  2813. '("T"
  2814. (p "[name]: ") '(just-one-space)
  2815. (p "[out port1]: ") '(just-one-space)
  2816. (p "[ref port1]: ") '(just-one-space)
  2817. (p "[out port2]: ") '(just-one-space)
  2818. (p "[ref port2]: ") '(just-one-space)
  2819. "Z0=" (p "[char impedance]: ") '(just-one-space)
  2820. (p "<time delay in seconds per meter>: " td 'noinsert)
  2821. (if (string-equal (tempo-lookup-named 'td) "")
  2822. (list 'l '(p "<freq>: " freq 'noinsert))
  2823. (list 'l "td=" '(s td) '(p "<length [1m]>: " l 'noinsert)))
  2824. '(just-one-space)
  2825. (if (and (tempo-lookup-named 'l)
  2826. (not (string-equal (tempo-lookup-named 'l) "")))
  2827. (list 'l "l=" '(s l)))
  2828. '(just-one-space)
  2829. (if (and (tempo-lookup-named 'freq)
  2830. (not (string-equal (tempo-lookup-named 'freq) "")))
  2831. (list 'l "f=" '(s freq) '(p "<normalized length [0.25]>: " nrmlen 'noinsert)))
  2832. '(just-one-space)
  2833. (if (and (tempo-lookup-named 'nrmlen)
  2834. (not (string-equal (tempo-lookup-named 'nrmlen) "")))
  2835. (list 'l "nl=" '(s nrmlen)))
  2836. '(just-one-space)
  2837. (p "<initial cond (voltage port1, current port1, voltage port2, current port2)>: " ic 'noinsert)
  2838. (if (string-equal (tempo-lookup-named 'ic) "")
  2839. () (list 'l "ic=" '(s ic)))
  2840. )
  2841. ;;"hspice lossless transmission line"
  2842. "TH"
  2843. "tempo template for hspice lossless transmission line"
  2844. 'spice-tempo-tags)
  2845. ;; lossy transmission lines
  2846. (tempo-define-template
  2847. "spice-spice2g6-lossy-transmission"
  2848. '("O"
  2849. (p "[name]: ") '(just-one-space)
  2850. (p "[out port1]: ") '(just-one-space)
  2851. (p "[ref port1]: ") '(just-one-space)
  2852. (p "[out port2]: ") '(just-one-space)
  2853. (p "[ref port2]: ") '(just-one-space)
  2854. (p "[mname]: ") '(just-one-space)
  2855. )
  2856. ;;"spice2g6 lossy transmission line"
  2857. "O"
  2858. "tempo template for spice2g6 lossy transmission line"
  2859. 'spice-tempo-tags)
  2860. (tempo-define-template
  2861. "spice-spice3-rcline"
  2862. '("U"
  2863. (p "[name]: ") '(just-one-space)
  2864. (p "[in port]: ") '(just-one-space)
  2865. (p "[out port]: ") '(just-one-space)
  2866. (p "[ref port]: ") '(just-one-space)
  2867. (p "[mname]: ") '(just-one-space)
  2868. "L="
  2869. (p "[length (m)]: ") '(just-one-space)
  2870. (p "<lumps>: " lumps 'noinsert)
  2871. (if (string-equal (tempo-lookup-named 'lumps) "")
  2872. () (list 'l "N=" '(s lumps)))
  2873. '(just-one-space)
  2874. )
  2875. ;;"spice3 lossy transmission line"
  2876. "RCLS"
  2877. "tempo template for spice2g6 lossy transmission line"
  2878. 'spice-tempo-tags)
  2879. (tempo-define-template
  2880. "spice-eldo-rcline"
  2881. '("R"
  2882. (p "[name]: ") '(just-one-space)
  2883. (p "[pos node]: ") '(just-one-space)
  2884. (p "[neg node]: ") '(just-one-space)
  2885. (p "[mname]: " mname) '(just-one-space)
  2886. (p "<res>: " r 'noinsert)
  2887. (if (string-equal (tempo-lookup-named 'r) "")
  2888. () (list 'l "R=" '(s r)))
  2889. '(just-one-space)
  2890. (p "<temp coef 1>: " tc1 'noinsert)
  2891. (if (string-equal (tempo-lookup-named 'tc1) "") ()
  2892. (list 'l "TC1=" '(s tc1) '(p "<temp coef 2>: " tc2 'noinsert)))
  2893. '(just-one-space)
  2894. (if (and (tempo-lookup-named 'tc2)
  2895. (not (string-equal (tempo-lookup-named 'tc2) "")))
  2896. (list 'l "TC2=" '(s tc2)))
  2897. '(just-one-space)
  2898. (p "<cap>: " c 'noinsert)
  2899. (if (string-equal (tempo-lookup-named 'c) "")
  2900. () (list 'l "C=" '(s c)))
  2901. '(just-one-space)
  2902. (p "<length>: " l 'noinsert)
  2903. (if (string-equal (tempo-lookup-named 'l) "")
  2904. () (list 'l "L=" '(s l)))
  2905. '(just-one-space)
  2906. (p "<width>: " w 'noinsert)
  2907. (if (string-equal (tempo-lookup-named 'w) "")
  2908. () (list 'l "W=" '(s w)))
  2909. '(just-one-space)
  2910. (p "<m>: " m 'noinsert)
  2911. (if (string-equal (tempo-lookup-named 'm) "")
  2912. () (list 'l "M=" '(s m)))
  2913. '(just-one-space)
  2914. (p "<diff temp>: " dtemp 'noinsert)
  2915. (if (string-equal (tempo-lookup-named 'dtemp) "")
  2916. () (list 'l "DTEMP=" '(s dtemp)))
  2917. '(just-one-space)
  2918. (p "<scale>: " scale 'noinsert)
  2919. (if (string-equal (tempo-lookup-named 'scale) "")
  2920. () (list 'l "SCALE=" '(s scale)))
  2921. '(just-one-space)
  2922. )
  2923. ;;"eldo rcline"
  2924. "RCLE"
  2925. "tempo template for eldo rcline"
  2926. 'spice-tempo-tags)
  2927. ;; active elements
  2928. ;; diodes
  2929. (tempo-define-template
  2930. "spice-spice2g6-diode"
  2931. '("D"
  2932. (p "[name]: ") '(just-one-space)
  2933. (p "[positive node]: ") '(just-one-space)
  2934. (p "[negative node]: ") '(just-one-space)
  2935. (p "[mname]: ") '(just-one-space)
  2936. (p "<area>: ") '(just-one-space)
  2937. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  2938. (if (and (tempo-lookup-named 'off)
  2939. (string-equal (tempo-lookup-named 'off) "y"))
  2940. (list 'l "OFF"))
  2941. '(just-one-space)
  2942. (p "<initial cond (diode voltage)>: " ic 'noinsert)
  2943. (if (string-equal (tempo-lookup-named 'ic) "")
  2944. () (list 'l "IC=" '(s ic)))
  2945. '(just-one-space)
  2946. (p "<temp>: " temp 'noinsert)
  2947. (if (string-equal (tempo-lookup-named 'temp) "")
  2948. () (list 'l "TEMP=" '(s temp)))
  2949. '(just-one-space)
  2950. )
  2951. ;;"spice2g6 diode"
  2952. "D"
  2953. "tempo template for spice2g6 diode"
  2954. 'spice-tempo-tags)
  2955. (tempo-define-template
  2956. "spice-eldo-diode"
  2957. '("D"
  2958. (p "[name]: ") '(just-one-space)
  2959. (p "[positive node]: ") '(just-one-space)
  2960. (p "[negative node]: ") '(just-one-space)
  2961. (p "[mname]: ") '(just-one-space)
  2962. (p "<area>: " area 'noinsert) '(just-one-space)
  2963. (if (string-equal (tempo-lookup-named 'area) "")
  2964. () (list 'l "AREA=" '(s area)))
  2965. '(just-one-space)
  2966. (p "<perimeter>: " peri 'noinsert)
  2967. (if (string-equal (tempo-lookup-named 'peri) "")
  2968. () (list 'l "PERI=" '(s peri)))
  2969. '(just-one-space)
  2970. (p "<temp>: " temp 'noinsert)
  2971. (if (string-equal (tempo-lookup-named 'temp) "")
  2972. () (list 'l "TEMP=" '(s temp)))
  2973. '(just-one-space)
  2974. (p "<off [y/n]>: " off 'noinsert)
  2975. (if (and (tempo-lookup-named 'off)
  2976. (string-equal (tempo-lookup-named 'off) "y"))
  2977. (list 'l "OFF"))
  2978. '(just-one-space)
  2979. (p "<nonoise [y/n]>: " nonoise 'noinsert)
  2980. (if (and (tempo-lookup-named 'nonoise)
  2981. (string-equal (tempo-lookup-named 'nonoise) "y"))
  2982. (list 'l "NONOISE"))
  2983. '(just-one-space)
  2984. )
  2985. ;;"eldo diode"
  2986. "DE"
  2987. "tempo template for eldo diode"
  2988. 'spice-tempo-tags)
  2989. (tempo-define-template
  2990. "spice-hspice-diode"
  2991. '("D"
  2992. (p "[name]: ") '(just-one-space)
  2993. (p "[positive node]: ") '(just-one-space)
  2994. (p "[negative node]: ") '(just-one-space)
  2995. (p "[mname]: ") '(just-one-space)
  2996. (p "<area>: " area 'noinsert) '(just-one-space)
  2997. (if (string-equal (tempo-lookup-named 'area) "")
  2998. (list 'l '(p "<width>: " w 'noinsert))
  2999. (list 'l "AREA=" '(s area) '(p "<perimeter>: " peri 'noinsert)))
  3000. '(just-one-space)
  3001. (if (and (tempo-lookup-named 'peri)
  3002. (not (string-equal (tempo-lookup-named 'peri) "")))
  3003. (list 'l "PJ=" '(s peri)))
  3004. '(just-one-space)
  3005. (if (string-equal (tempo-lookup-named 'area) "")
  3006. (list 'l '(p "<length>: " l 'noinsert)))
  3007. '(just-one-space)
  3008. (if (and (tempo-lookup-named 'l)
  3009. (not (string-equal (tempo-lookup-named 'l) "")))
  3010. () (list 'l "L=" '(s l)))
  3011. '(just-one-space)
  3012. (p "<width poly cap>: " wp 'noinsert)
  3013. (if (string-equal (tempo-lookup-named 'wp) "")
  3014. () (list 'l "WP=" '(s wp)))
  3015. '(just-one-space)
  3016. (p "<length poly cap>: " lp 'noinsert)
  3017. (if (string-equal (tempo-lookup-named 'lp) "")
  3018. () (list 'l "LP=" '(s lp)))
  3019. '(just-one-space)
  3020. (p "<width metal cap>: " wm 'noinsert)
  3021. (if (string-equal (tempo-lookup-named 'wm) "")
  3022. () (list 'l "WM=" '(s wm)))
  3023. '(just-one-space)
  3024. (p "<length metal cap>: " lm 'noinsert)
  3025. (if (string-equal (tempo-lookup-named 'lm) "")
  3026. () (list 'l "LM=" '(s lm)))
  3027. '(just-one-space)
  3028. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3029. (if (and (tempo-lookup-named 'off)
  3030. (string-equal (tempo-lookup-named 'off) "y"))
  3031. (list 'l "OFF"))
  3032. '(just-one-space)
  3033. (p "<initial cond (voltage)>: " ic 'noinsert)
  3034. (if (string-equal (tempo-lookup-named 'ic) "")
  3035. () (list 'l "IC=" '(s ic)))
  3036. '(just-one-space)
  3037. (p "<m>: " m 'noinsert)
  3038. (if (string-equal (tempo-lookup-named 'm) "")
  3039. () (list 'l "M=" '(s m)))
  3040. '(just-one-space)
  3041. (p "<diff temp>: " dtemp 'noinsert)
  3042. (if (string-equal (tempo-lookup-named 'dtemp) "")
  3043. () (list 'l "DTEMP=" '(s dtemp)))
  3044. '(just-one-space)
  3045. )
  3046. ;;"hspice diode"
  3047. "DH"
  3048. "tempo template for hspice diode"
  3049. 'spice-tempo-tags)
  3050. (tempo-define-template
  3051. "spice-layla-diode"
  3052. '("D"
  3053. (p "[name]: ") '(just-one-space)
  3054. (p "[positive node]: ") '(just-one-space)
  3055. (p "[negative node]: ") '(just-one-space)
  3056. ; (p "<mname>: ") '(just-one-space)
  3057. (p "[area]: ") '(just-one-space)
  3058. (p "<units_ver>: " units_ver 'noinsert)
  3059. (if (string-equal (tempo-lookup-named 'units_ver) "")
  3060. () (list 'l "units_ver=" '(s units_ver)))
  3061. '(just-one-space)
  3062. (p "<units_hor>: " units_hor 'noinsert)
  3063. (if (string-equal (tempo-lookup-named 'units_hor) "")
  3064. () (list 'l "units_hor=" '(s units_hor)))
  3065. '(just-one-space)
  3066. "\n+ type=\""
  3067. (p "[type (no quotes)]: ") "\""
  3068. '(just-one-space)
  3069. (p "<symmetry (no quotes)>: " symmetry 'noinsert)
  3070. (if (string-equal (tempo-lookup-named 'symmetry) "")
  3071. () (list 'l "symmetry=\"" '(s symmetry) "\""))
  3072. '(just-one-space)
  3073. (p "<matching (no quotes)>: " matching 'noinsert)
  3074. (if (string-equal (tempo-lookup-named 'matching) "")
  3075. () (list 'l "matching=\"" '(s matching) "\""))
  3076. '(just-one-space)
  3077. (p "<couple>: " couple 'noinsert)
  3078. (if (string-equal (tempo-lookup-named 'couple) "")
  3079. () (list 'l "couple=" '(s couple)))
  3080. '(just-one-space)
  3081. (p "<array (no quotes)>: " array 'noinsert)
  3082. (if (string-equal (tempo-lookup-named 'array) "")
  3083. () (list 'l "array=\"" '(s array) "\""))
  3084. '(just-one-space)
  3085. (p "<orientations (no quotes)>: " orientations 'noinsert)
  3086. (if (string-equal (tempo-lookup-named 'orientations) "")
  3087. () (list 'l "orientations=\"" '(s orientations) "\""))
  3088. '(just-one-space)
  3089. (p "<unit_value>: " unit_value 'noinsert)
  3090. (if (string-equal (tempo-lookup-named 'unit_value) "")
  3091. () (list 'l "unit_value=" '(s unit_value)))
  3092. '(just-one-space)
  3093. (p "<current>: " current 'noinsert)
  3094. (if (string-equal (tempo-lookup-named 'current) "")
  3095. () (list 'l "current=" '(s current)))
  3096. '(just-one-space)
  3097. (p "<power>: " power 'noinsert)
  3098. (if (string-equal (tempo-lookup-named 'power) "")
  3099. () (list 'l "power=" '(s power)))
  3100. '(just-one-space)
  3101. (p "<min_ar>: " min_ar 'noinsert)
  3102. (if (string-equal (tempo-lookup-named 'min_ar) "")
  3103. () (list 'l "min_ar=" '(s min_ar)))
  3104. '(just-one-space)
  3105. (p "<max_ar>: " max_ar 'noinsert)
  3106. (if (string-equal (tempo-lookup-named 'max_ar) "")
  3107. () (list 'l "max_ar=" '(s max_ar)))
  3108. '(just-one-space)
  3109. (p "<routing_space>: " routing_space 'noinsert)
  3110. (if (string-equal (tempo-lookup-named 'routing_space) "")
  3111. () (list 'l "routing_space=" '(s routing_space)))
  3112. '(just-one-space)
  3113. )
  3114. ;;"layla diode"
  3115. "DL"
  3116. "tempo template for layla diode"
  3117. 'spice-tempo-tags)
  3118. ;; bipolars
  3119. (tempo-define-template
  3120. "spice-spice2g6-bipolar"
  3121. '("Q"
  3122. (p "[name]: ") '(just-one-space)
  3123. (p "[collector node]: ") '(just-one-space)
  3124. (p "[base node]: ") '(just-one-space)
  3125. (p "[emitter node]: ") '(just-one-space)
  3126. (p "<substrate node>: ") '(just-one-space)
  3127. (p "[mname]: ") '(just-one-space)
  3128. (p "<area>: ") '(just-one-space)
  3129. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3130. (if (and (tempo-lookup-named 'off)
  3131. (string-equal (tempo-lookup-named 'off) "y"))
  3132. (list 'l "OFF"))
  3133. '(just-one-space)
  3134. (p "<initial cond (vbe, vce)>: " ic 'noinsert)
  3135. (if (string-equal (tempo-lookup-named 'ic) "")
  3136. () (list 'l "IC=" '(s ic)))
  3137. '(just-one-space)
  3138. (p "<temp>: " temp 'noinsert)
  3139. (if (string-equal (tempo-lookup-named 'temp) "")
  3140. () (list 'l "TEMP=" '(s temp)))
  3141. '(just-one-space)
  3142. )
  3143. ;;"spice2g6 bipolar"
  3144. "Q"
  3145. "tempo template for spice2g6 bipolar"
  3146. 'spice-tempo-tags)
  3147. (tempo-define-template
  3148. "spice-eldo-bipolar"
  3149. '("Q"
  3150. (p "[name]: ") '(just-one-space)
  3151. (p "[collector node]: ") '(just-one-space)
  3152. (p "[base node]: ") '(just-one-space)
  3153. (p "[emitter node]: ") '(just-one-space)
  3154. (p "<substrate node>: ") '(just-one-space)
  3155. (p "[mname]: ") '(just-one-space)
  3156. (p "<area>: " area 'noinsert) '(just-one-space)
  3157. (if (string-equal (tempo-lookup-named 'area) "")
  3158. () (list 'l "AREA=" '(s area)))
  3159. '(just-one-space)
  3160. (p "<rel base area>: " areab 'noinsert)
  3161. (if (string-equal (tempo-lookup-named 'areab) "")
  3162. () (list 'l "AREAB=" '(s areab)))
  3163. '(just-one-space)
  3164. (p "<rel collector area>: " areac 'noinsert)
  3165. (if (string-equal (tempo-lookup-named 'areac) "")
  3166. () (list 'l "AREAC=" '(s areac)))
  3167. '(just-one-space)
  3168. (p "<temp>: " temp 'noinsert)
  3169. (if (string-equal (tempo-lookup-named 'temp) "")
  3170. () (list 'l "T=" '(s temp)))
  3171. '(just-one-space)
  3172. (p "<m>: " m 'noinsert)
  3173. (if (string-equal (tempo-lookup-named 'm) "")
  3174. () (list 'l "M=" '(s m)))
  3175. '(just-one-space)
  3176. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3177. (if (and (tempo-lookup-named 'off)
  3178. (string-equal (tempo-lookup-named 'off) "y"))
  3179. (list 'l "OFF"))
  3180. '(just-one-space)
  3181. (p "<nonoise [y/n]>: " nonoise 'noinsert)
  3182. (if (and (tempo-lookup-named 'nonoise)
  3183. (string-equal (tempo-lookup-named 'nonoise) "y"))
  3184. (list 'l "NONOISE"))
  3185. '(just-one-space)
  3186. )
  3187. ;;"eldo bipolar"
  3188. "QE"
  3189. "tempo template for eldo bipolar"
  3190. 'spice-tempo-tags)
  3191. (tempo-define-template
  3192. "spice-hspice-bipolar"
  3193. '("Q"
  3194. (p "[name]: ") '(just-one-space)
  3195. (p "[collector node]: ") '(just-one-space)
  3196. (p "[base node]: ") '(just-one-space)
  3197. (p "[emitter node]: ") '(just-one-space)
  3198. (p "<substrate node>: ") '(just-one-space)
  3199. (p "[mname]: ") '(just-one-space)
  3200. (p "<area>: " area 'noinsert) '(just-one-space)
  3201. (if (string-equal (tempo-lookup-named 'area) "")
  3202. () (list 'l "AREA=" '(s area)))
  3203. '(just-one-space)
  3204. (p "<rel base area>: " areab 'noinsert)
  3205. (if (string-equal (tempo-lookup-named 'areab) "")
  3206. () (list 'l "AREAB=" '(s areab)))
  3207. '(just-one-space)
  3208. (p "<rel collector area>: " areac 'noinsert)
  3209. (if (string-equal (tempo-lookup-named 'areac) "")
  3210. () (list 'l "AREAC=" '(s areac)))
  3211. '(just-one-space)
  3212. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3213. (if (and (tempo-lookup-named 'off)
  3214. (string-equal (tempo-lookup-named 'off) "y"))
  3215. (list 'l "OFF"))
  3216. '(just-one-space)
  3217. (p "<init vbe>: " vbe 'noinsert)
  3218. (if (string-equal (tempo-lookup-named 'vbe) "")
  3219. () (list 'l "VBE=" '(s vbe)))
  3220. '(just-one-space)
  3221. (p "<init vce>: " vce 'noinsert)
  3222. (if (string-equal (tempo-lookup-named 'vce) "")
  3223. () (list 'l "VCE=" '(s vce)))
  3224. '(just-one-space)
  3225. (p "<m>: " m 'noinsert)
  3226. (if (string-equal (tempo-lookup-named 'm) "")
  3227. () (list 'l "M=" '(s m)))
  3228. '(just-one-space)
  3229. (p "<diff temp>: " dtemp 'noinsert)
  3230. (if (string-equal (tempo-lookup-named 'dtemp) "")
  3231. () (list 'l "DTEMP=" '(s dtemp)))
  3232. '(just-one-space)
  3233. )
  3234. ;;"hspice bipolar"
  3235. "QH"
  3236. "tempo template for hspice bipolar"
  3237. 'spice-tempo-tags)
  3238. ;; jfets
  3239. (tempo-define-template
  3240. "spice-spice2g6-jfet"
  3241. '("J"
  3242. (p "[name]: ") '(just-one-space)
  3243. (p "[drain node]: ") '(just-one-space)
  3244. (p "[gate node]: ") '(just-one-space)
  3245. (p "[source node]: ") '(just-one-space)
  3246. (p "[mname]: ") '(just-one-space)
  3247. (p "<area>: ") '(just-one-space)
  3248. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3249. (if (and (tempo-lookup-named 'off)
  3250. (string-equal (tempo-lookup-named 'off) "y"))
  3251. (list 'l "OFF"))
  3252. '(just-one-space)
  3253. (p "<initial cond (vds, vgs)>: " ic 'noinsert)
  3254. (if (string-equal (tempo-lookup-named 'ic) "")
  3255. () (list 'l "IC=" '(s ic)))
  3256. '(just-one-space)
  3257. (p "<temp>: " temp 'noinsert)
  3258. (if (string-equal (tempo-lookup-named 'temp) "")
  3259. () (list 'l "TEMP=" '(s temp)))
  3260. '(just-one-space)
  3261. )
  3262. ;;"spice2g6 jfet"
  3263. "J"
  3264. "tempo template for spice2g6 jfet"
  3265. 'spice-tempo-tags)
  3266. (tempo-define-template
  3267. "spice-eldo-jfet"
  3268. '("J"
  3269. (p "[name]: ") '(just-one-space)
  3270. (p "[drain node]: ") '(just-one-space)
  3271. (p "[gate node]: ") '(just-one-space)
  3272. (p "[source node]: ") '(just-one-space)
  3273. (p "[mname]: ") '(just-one-space)
  3274. (p "<area>: " area 'noinsert) '(just-one-space)
  3275. (if (string-equal (tempo-lookup-named 'area) "")
  3276. () (list 'l "AREA=" '(s area)))
  3277. '(just-one-space)
  3278. (p "<length>: " l 'noinsert)
  3279. (if (string-equal (tempo-lookup-named 'l) "")
  3280. () (list 'l "L=" '(s l)))
  3281. '(just-one-space)
  3282. (p "<width>: " w 'noinsert)
  3283. (if (string-equal (tempo-lookup-named 'w) "")
  3284. () (list 'l "W=" '(s w)))
  3285. '(just-one-space)
  3286. (p "<temp>: " temp 'noinsert)
  3287. (if (string-equal (tempo-lookup-named 'temp) "")
  3288. () (list 'l "T=" '(s temp)))
  3289. '(just-one-space)
  3290. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3291. (if (and (tempo-lookup-named 'off)
  3292. (string-equal (tempo-lookup-named 'off) "y"))
  3293. (list 'l "OFF"))
  3294. '(just-one-space)
  3295. (p "<nonoise [y/n]>: " nonoise 'noinsert)
  3296. (if (and (tempo-lookup-named 'nonoise)
  3297. (string-equal (tempo-lookup-named 'nonoise) "y"))
  3298. (list 'l "NONOISE"))
  3299. '(just-one-space)
  3300. )
  3301. ;;"eldo jfet"
  3302. "JE"
  3303. "tempo template for eldo jfet"
  3304. 'spice-tempo-tags)
  3305. (tempo-define-template
  3306. "spice-hspice-jfet"
  3307. '("J"
  3308. (p "[name]: ") '(just-one-space)
  3309. (p "[drain node]: ") '(just-one-space)
  3310. (p "[gate node]: ") '(just-one-space)
  3311. (p "[source node]: ") '(just-one-space)
  3312. (p "[mname]: ") '(just-one-space)
  3313. (p "<area>: " area 'noinsert)
  3314. (if (string-equal (tempo-lookup-named 'area) "")
  3315. (list 'l '(p "<length>: " l 'noinsert) '(p "<width>: " w 'noinsert))
  3316. (list 'l "AREA=" '(s area)))
  3317. '(just-one-space)
  3318. (if (and (tempo-lookup-named 'l)
  3319. (not (string-equal (tempo-lookup-named 'l) "")))
  3320. (list 'l "L=" '(s l)))
  3321. '(just-one-space)
  3322. (if (and (tempo-lookup-named 'w)
  3323. (not (string-equal (tempo-lookup-named 'w) "")))
  3324. (list 'l "W=" '(s w)))
  3325. '(just-one-space)
  3326. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3327. (if (and (tempo-lookup-named 'off)
  3328. (string-equal (tempo-lookup-named 'off) "y"))
  3329. (list 'l "OFF"))
  3330. '(just-one-space)
  3331. (p "<initial cond (vds,vgs)>: " ic 'noinsert)
  3332. (if (string-equal (tempo-lookup-named 'ic) "")
  3333. () (list 'l "IC=" '(s ic)))
  3334. '(just-one-space)
  3335. (p "<m>: " m 'noinsert)
  3336. (if (string-equal (tempo-lookup-named 'm) "")
  3337. () (list 'l "M=" '(s m)))
  3338. '(just-one-space)
  3339. (p "<diff temp>: " dtemp 'noinsert)
  3340. (if (string-equal (tempo-lookup-named 'dtemp) "")
  3341. () (list 'l "DTEMP=" '(s dtemp)))
  3342. '(just-one-space)
  3343. )
  3344. ;;"hspice jfet"
  3345. "JH"
  3346. "tempo template for hspice jfet"
  3347. 'spice-tempo-tags)
  3348. ;; mosfets
  3349. (tempo-define-template
  3350. "spice-spice2g6-mosfet"
  3351. '("M"
  3352. (p "[name]: ") '(just-one-space)
  3353. (p "[drain node]: ") '(just-one-space)
  3354. (p "[gate node]: ") '(just-one-space)
  3355. (p "[source node]: ") '(just-one-space)
  3356. (p "[bulk node]: ") '(just-one-space)
  3357. (p "[mname]: ") '(just-one-space)
  3358. (p "<length>: " l 'noinsert)
  3359. (if (string-equal (tempo-lookup-named 'l) "")
  3360. () (list 'l "L=" '(s l)))
  3361. '(just-one-space)
  3362. (p "<width>: " w 'noinsert)
  3363. (if (string-equal (tempo-lookup-named 'w) "")
  3364. () (list 'l "W=" '(s w)))
  3365. '(just-one-space)
  3366. (p "<area drain>: " ad 'noinsert)
  3367. (if (string-equal (tempo-lookup-named 'ad) "")
  3368. () (list 'l "AD=" '(s ad)))
  3369. '(just-one-space)
  3370. (p "<area source>: " as 'noinsert)
  3371. (if (string-equal (tempo-lookup-named 'as) "")
  3372. () (list 'l "AS=" '(s as)))
  3373. '(just-one-space)
  3374. (p "<perimeter drain>: " pd 'noinsert)
  3375. (if (string-equal (tempo-lookup-named 'pd) "")
  3376. () (list 'l "PD=" '(s pd)))
  3377. '(just-one-space)
  3378. (p "<perimeter source>: " ps 'noinsert)
  3379. (if (string-equal (tempo-lookup-named 'ps) "")
  3380. () (list 'l "PS=" '(s ps)))
  3381. '(just-one-space)
  3382. (p "<number of drain contacts>: " nrd 'noinsert)
  3383. (if (string-equal (tempo-lookup-named 'nrd) "")
  3384. () (list 'l "NRD=" '(s nrd)))
  3385. '(just-one-space)
  3386. (p "<number of source contacts>: " nrs 'noinsert)
  3387. (if (string-equal (tempo-lookup-named 'nrs) "")
  3388. () (list 'l "NRS=" '(s nrs)))
  3389. '(just-one-space)
  3390. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3391. (if (and (tempo-lookup-named 'off)
  3392. (string-equal (tempo-lookup-named 'off) "y"))
  3393. (list 'l "OFF"))
  3394. '(just-one-space)
  3395. (p "<initial cond (vds, vgs, vgs)>: " ic 'noinsert)
  3396. (if (string-equal (tempo-lookup-named 'ic) "")
  3397. () (list 'l "IC=" '(s ic)))
  3398. '(just-one-space)
  3399. )
  3400. ;;"spice2g6 mosfet"
  3401. "M"
  3402. "tempo template for spice2g6 mosfet"
  3403. 'spice-tempo-tags)
  3404. (tempo-define-template
  3405. "spice-eldo-mosfet"
  3406. '("M"
  3407. (p "[name]: ") '(just-one-space)
  3408. (p "[drain node]: ") '(just-one-space)
  3409. (p "[gate node]: ") '(just-one-space)
  3410. (p "[source node]: ") '(just-one-space)
  3411. (p "[bulk node]: ") '(just-one-space)
  3412. (p "<optional nodes>: ") '(just-one-space)
  3413. "MOD="
  3414. (p "[mname]: ") '(just-one-space)
  3415. (p "<length>: " l 'noinsert)
  3416. (if (string-equal (tempo-lookup-named 'l) "")
  3417. () (list 'l "L=" '(s l)))
  3418. '(just-one-space)
  3419. (p "<width>: " w 'noinsert)
  3420. (if (string-equal (tempo-lookup-named 'w) "")
  3421. () (list 'l "W=" '(s w)))
  3422. '(just-one-space)
  3423. (p "<area drain>: " ad 'noinsert)
  3424. (if (string-equal (tempo-lookup-named 'ad) "")
  3425. () (list 'l "AD=" '(s ad)))
  3426. '(just-one-space)
  3427. (p "<area source>: " as 'noinsert)
  3428. (if (string-equal (tempo-lookup-named 'as) "")
  3429. () (list 'l "AS=" '(s as)))
  3430. '(just-one-space)
  3431. (p "<perimeter drain>: " pd 'noinsert)
  3432. (if (string-equal (tempo-lookup-named 'pd) "")
  3433. () (list 'l "PD=" '(s pd)))
  3434. '(just-one-space)
  3435. (p "<perimeter source>: " ps 'noinsert)
  3436. (if (string-equal (tempo-lookup-named 'ps) "")
  3437. () (list 'l "PS=" '(s ps)))
  3438. '(just-one-space)
  3439. (p "<geometry model>: " geo 'noinsert)
  3440. (if (string-equal (tempo-lookup-named 'geo) "")
  3441. () (list 'l "GEO=" '(s geo)))
  3442. '(just-one-space)
  3443. (p "<number of drain contacts>: " nrd 'noinsert)
  3444. (if (string-equal (tempo-lookup-named 'nrd) "")
  3445. () (list 'l "NRD=" '(s nrd)))
  3446. '(just-one-space)
  3447. (p "<number of source contacts>: " nrs 'noinsert)
  3448. (if (string-equal (tempo-lookup-named 'nrs) "")
  3449. () (list 'l "NRS=" '(s nrs)))
  3450. '(just-one-space)
  3451. (p "<m>: " m 'noinsert)
  3452. (if (string-equal (tempo-lookup-named 'm) "")
  3453. () (list 'l "M=" '(s m)))
  3454. '(just-one-space)
  3455. (p "<extra drain contact resistance>: " rdc 'noinsert)
  3456. (if (string-equal (tempo-lookup-named 'rdc) "")
  3457. () (list 'l "RDC=" '(s rdc)))
  3458. '(just-one-space)
  3459. (p "<extra source contact resistance>: " rsc 'noinsert)
  3460. (if (string-equal (tempo-lookup-named 'rsc) "")
  3461. () (list 'l "RSC=" '(s rsc)))
  3462. '(just-one-space)
  3463. (p "<temp>: " temp 'noinsert)
  3464. (if (string-equal (tempo-lookup-named 'temp) "")
  3465. () (list 'l "T=" '(s temp)))
  3466. '(just-one-space)
  3467. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3468. (if (and (tempo-lookup-named 'off)
  3469. (string-equal (tempo-lookup-named 'off) "y"))
  3470. (list 'l "OFF"))
  3471. '(just-one-space)
  3472. (p "<nonoise [y/n]>: " nonoise 'noinsert)
  3473. (if (and (tempo-lookup-named 'nonoise)
  3474. (string-equal (tempo-lookup-named 'nonoise) "y"))
  3475. (list 'l "NONOISE"))
  3476. '(just-one-space)
  3477. )
  3478. ;;"eldo mosfet"
  3479. "ME"
  3480. "tempo template for eldo mosfet"
  3481. 'spice-tempo-tags)
  3482. (tempo-define-template
  3483. "spice-hspice-mosfet"
  3484. '("M"
  3485. (p "[name]: ") '(just-one-space)
  3486. (p "[drain node]: ") '(just-one-space)
  3487. (p "[gate node]: ") '(just-one-space)
  3488. (p "[source node]: ") '(just-one-space)
  3489. (p "[bulk node]: ") '(just-one-space)
  3490. (p "[mname]: ") '(just-one-space)
  3491. (p "<length>: " l 'noinsert)
  3492. (if (string-equal (tempo-lookup-named 'l) "")
  3493. () (list 'l "L=" '(s l)))
  3494. '(just-one-space)
  3495. (p "<width>: " w 'noinsert)
  3496. (if (string-equal (tempo-lookup-named 'w) "")
  3497. () (list 'l "W=" '(s w)))
  3498. '(just-one-space)
  3499. (p "<area drain>: " ad 'noinsert)
  3500. (if (string-equal (tempo-lookup-named 'ad) "")
  3501. () (list 'l "AD=" '(s ad)))
  3502. '(just-one-space)
  3503. (p "<area source>: " as 'noinsert)
  3504. (if (string-equal (tempo-lookup-named 'as) "")
  3505. () (list 'l "AS=" '(s as)))
  3506. '(just-one-space)
  3507. (p "<perimeter drain>: " pd 'noinsert)
  3508. (if (string-equal (tempo-lookup-named 'pd) "")
  3509. () (list 'l "PD=" '(s pd)))
  3510. '(just-one-space)
  3511. (p "<perimeter source>: " ps 'noinsert)
  3512. (if (string-equal (tempo-lookup-named 'ps) "")
  3513. () (list 'l "PS=" '(s ps)))
  3514. '(just-one-space)
  3515. (p "<number of drain contacts>: " nrd 'noinsert)
  3516. (if (string-equal (tempo-lookup-named 'nrd) "")
  3517. () (list 'l "NRD=" '(s nrd)))
  3518. '(just-one-space)
  3519. (p "<number of source contacts>: " nrs 'noinsert)
  3520. (if (string-equal (tempo-lookup-named 'nrs) "")
  3521. () (list 'l "NRS=" '(s nrs)))
  3522. '(just-one-space)
  3523. (p "<extra drain contact resistance>: " rdc 'noinsert)
  3524. (if (string-equal (tempo-lookup-named 'rdc) "")
  3525. () (list 'l "RDC=" '(s rdc)))
  3526. '(just-one-space)
  3527. (p "<extra source contact resistance>: " rsc 'noinsert)
  3528. (if (string-equal (tempo-lookup-named 'rsc) "")
  3529. () (list 'l "RSC=" '(s rsc)))
  3530. '(just-one-space)
  3531. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3532. (if (and (tempo-lookup-named 'off)
  3533. (string-equal (tempo-lookup-named 'off) "y"))
  3534. (list 'l "OFF"))
  3535. '(just-one-space)
  3536. (p "<init cond (vds,vgs,vbs)>: " ic 'noinsert)
  3537. (if (string-equal (tempo-lookup-named 'ic) "")
  3538. () (list 'l "IC=" '(s ic)))
  3539. '(just-one-space)
  3540. (p "<diff temp>: " dtemp 'noinsert)
  3541. (if (string-equal (tempo-lookup-named 'dtemp) "")
  3542. () (list 'l "DTEMP=" '(s dtemp)))
  3543. '(just-one-space)
  3544. (p "<geometry model>: " geo 'noinsert)
  3545. (if (string-equal (tempo-lookup-named 'geo) "")
  3546. () (list 'l "GEO=" '(s geo)))
  3547. '(just-one-space)
  3548. (p "<m>: " m 'noinsert)
  3549. (if (string-equal (tempo-lookup-named 'm) "")
  3550. () (list 'l "M=" '(s m)))
  3551. '(just-one-space)
  3552. (p "<delvto>: " delvto 'noinsert)
  3553. (if (string-equal (tempo-lookup-named 'delvto) "")
  3554. () (list 'l "DELVTO=" '(s delvto)))
  3555. '(just-one-space)
  3556. )
  3557. ;;"hspice mosfet"
  3558. "MH"
  3559. "tempo template for hspice mosfet"
  3560. 'spice-tempo-tags)
  3561. (tempo-define-template
  3562. "spice-layla-mosfet"
  3563. '("M"
  3564. (p "[name]: ") '(just-one-space)
  3565. (p "[drain node]: ") '(just-one-space)
  3566. (p "[gate node]: ") '(just-one-space)
  3567. (p "[source node]: ") '(just-one-space)
  3568. (p "[bulk node]: ") '(just-one-space)
  3569. (p "[mname]: ") '(just-one-space)
  3570. (p "<length>: " l 'noinsert)
  3571. (if (string-equal (tempo-lookup-named 'l) "")
  3572. () (list 'l "L=" '(s l)))
  3573. '(just-one-space)
  3574. (p "<width>: " w 'noinsert)
  3575. (if (string-equal (tempo-lookup-named 'w) "")
  3576. () (list 'l "W=" '(s w)))
  3577. '(just-one-space)
  3578. "\n+ type=\""
  3579. (p "[type (no quotes)]: ") "\""
  3580. '(just-one-space)
  3581. (p "<symmetry (no quotes)>: " symmetry 'noinsert)
  3582. (if (string-equal (tempo-lookup-named 'symmetry) "")
  3583. () (list 'l "symmetry=\"" '(s symmetry) "\""))
  3584. '(just-one-space)
  3585. (p "<matching (no quotes)>: " matching 'noinsert)
  3586. (if (string-equal (tempo-lookup-named 'matching) "")
  3587. () (list 'l "matching=\"" '(s matching) "\""))
  3588. '(just-one-space)
  3589. (p "<couple>: " couple 'noinsert)
  3590. (if (string-equal (tempo-lookup-named 'couple) "")
  3591. () (list 'l "couple=" '(s couple)))
  3592. '(just-one-space)
  3593. (p "<array (no quotes)>: " array 'noinsert)
  3594. (if (string-equal (tempo-lookup-named 'array) "")
  3595. () (list 'l "array=\"" '(s array) "\""))
  3596. '(just-one-space)
  3597. (p "<orientations (no quotes)>: " orientations 'noinsert)
  3598. (if (string-equal (tempo-lookup-named 'orientations) "")
  3599. () (list 'l "orientations=\"" '(s orientations) "\""))
  3600. '(just-one-space)
  3601. (p "<unit_value>: " unit_value 'noinsert)
  3602. (if (string-equal (tempo-lookup-named 'unit_value) "")
  3603. () (list 'l "unit_value=" '(s unit_value)))
  3604. '(just-one-space)
  3605. (p "<current>: " current 'noinsert)
  3606. (if (string-equal (tempo-lookup-named 'current) "")
  3607. () (list 'l "current=" '(s current)))
  3608. '(just-one-space)
  3609. (p "<power>: " power 'noinsert)
  3610. (if (string-equal (tempo-lookup-named 'power) "")
  3611. () (list 'l "power=" '(s power)))
  3612. '(just-one-space)
  3613. (p "<min_ar>: " min_ar 'noinsert)
  3614. (if (string-equal (tempo-lookup-named 'min_ar) "")
  3615. () (list 'l "min_ar=" '(s min_ar)))
  3616. '(just-one-space)
  3617. (p "<max_ar>: " max_ar 'noinsert)
  3618. (if (string-equal (tempo-lookup-named 'max_ar) "")
  3619. () (list 'l "max_ar=" '(s max_ar)))
  3620. '(just-one-space)
  3621. (p "<routing_space>: " routing_space 'noinsert)
  3622. (if (string-equal (tempo-lookup-named 'routing_space) "")
  3623. () (list 'l "routing_space=" '(s routing_space)))
  3624. '(just-one-space)
  3625. )
  3626. ;;"layla mosfet"
  3627. "ML"
  3628. "tempo template for layla mosfet"
  3629. 'spice-tempo-tags)
  3630. ;; mesfets
  3631. (tempo-define-template
  3632. "spice-spice2g6-mesfet"
  3633. '("Z"
  3634. (p "[name]: ") '(just-one-space)
  3635. (p "[drain node]: ") '(just-one-space)
  3636. (p "[gate node]: ") '(just-one-space)
  3637. (p "[source node]: ") '(just-one-space)
  3638. (p "[mname]: ") '(just-one-space)
  3639. (p "<area>: ") '(just-one-space)
  3640. (p "<off [y/n]>: " off 'noinsert) '(just-one-space)
  3641. (if (and (tempo-lookup-named 'off)
  3642. (string-equal (tempo-lookup-named 'off) "y"))
  3643. (list 'l "OFF"))
  3644. '(just-one-space)
  3645. (p "<initial cond (vds, vgs)>: " ic 'noinsert)
  3646. (if (string-equal (tempo-lookup-named 'ic) "")
  3647. () (list 'l "IC=" '(s ic)))
  3648. '(just-one-space)
  3649. )
  3650. ;;"spice2g6 mesfet"
  3651. "Z"
  3652. "tempo template for spice2g6 mesfet"
  3653. 'spice-tempo-tags)
  3654. ;; subcircuit defs
  3655. (tempo-define-template
  3656. "spice-spice2g6-subckt"
  3657. '(".subckt "
  3658. (p "[subckt name]: " lname) 'r 'n 'n
  3659. ".ends " (s lname) '>)
  3660. "SUB"
  3661. "template for inserting a subckt definition"
  3662. 'spice-tempo-tags)
  3663. ;; Controlled sources
  3664. ;; Voltage sources
  3665. (tempo-define-template
  3666. "spice-spice2g6-vcvs"
  3667. '("E"
  3668. (p "[name]: ") '(just-one-space)
  3669. (p "[positive node]: ") '(just-one-space)
  3670. (p "[negative node]: ") '(just-one-space)
  3671. (p "[positive controling node]: ") '(just-one-space)
  3672. (p "[negative controling node]: ") '(just-one-space)
  3673. (p "[gain]: ") '(just-one-space)
  3674. )
  3675. "VCVS"
  3676. "template for inserting a voltage controled voltage source"
  3677. 'spice-tempo-tags)
  3678. (tempo-define-template
  3679. "spice-spice2g6-ccvs"
  3680. '("H"
  3681. (p "[name]: ") '(just-one-space)
  3682. (p "[positive node]: ") '(just-one-space)
  3683. (p "[negative node]: ") '(just-one-space)
  3684. (p "[voltage source]: ") '(just-one-space)
  3685. (p "[gain]: ") '(just-one-space)
  3686. )
  3687. "CCVS"
  3688. "template for inserting a current controled voltage source"
  3689. 'spice-tempo-tags)
  3690. ;; Current sources
  3691. (tempo-define-template
  3692. "spice-spice2g6-vccs"
  3693. '("G"
  3694. (p "[name]: ") '(just-one-space)
  3695. (p "[positive node]: ") '(just-one-space)
  3696. (p "[negative node]: ") '(just-one-space)
  3697. (p "[positive controling node]: ") '(just-one-space)
  3698. (p "[negative controling node]: ") '(just-one-space)
  3699. (p "[transadmitance]: ") '(just-one-space)
  3700. )
  3701. "VCCS"
  3702. "template for inserting a voltage controled current source"
  3703. 'spice-tempo-tags)
  3704. (tempo-define-template
  3705. "spice-spice2g6-cccs"
  3706. '("F"
  3707. (p "[name]: ") '(just-one-space)
  3708. (p "[positive node]: ") '(just-one-space)
  3709. (p "[negative node]: ") '(just-one-space)
  3710. (p "[voltage source]: ") '(just-one-space)
  3711. (p "[gain]: ") '(just-one-space)
  3712. )
  3713. "CCCS"
  3714. "template for inserting a current controled current source"
  3715. 'spice-tempo-tags)
  3716. ;; Waveforms
  3717. (tempo-define-template
  3718. "spice-pulse"
  3719. '("pulse("
  3720. (p "[start value]: ") " "
  3721. (p "[pulsed value]: ") " "
  3722. (p "[delay]: ") " "
  3723. (p "[rise time]: ") " "
  3724. (p "[fall time]: ") " "
  3725. (p "[pulse duration]: ") " "
  3726. (p "[period]: ")
  3727. ")"'n)
  3728. "PU"
  3729. "template for inserting an Pulse waveform"
  3730. 'spice-tempo-tags)
  3731. (tempo-define-template
  3732. "spice-sine"
  3733. '("sin("
  3734. (p "[Offset]: ") " "
  3735. (p "[Amplitude]: ") " "
  3736. (p "[Frequency]: ") " "
  3737. (p "[Delay]: ") " "
  3738. (p "[Damping factor]: ")
  3739. (p "[Phase delay]: ") '(just-one-space)
  3740. ")"'n)
  3741. "sin"
  3742. "template for inserting a Sine function"
  3743. 'spice-tempo-tags)
  3744. (tempo-define-template
  3745. "spice-exp"
  3746. '("exp("
  3747. (p "[start value]: ") " "
  3748. (p "[target value]: ") " "
  3749. (p "[rise delay]: ") " "
  3750. (p "[tau1]: ") " "
  3751. (p "[fall delay]: ") " "
  3752. (p "[tau2]: ")
  3753. ")"'n)
  3754. "exp"
  3755. "template for inserting an EXP waveform"
  3756. 'spice-tempo-tags)
  3757. ;;(tempo-define-template
  3758. ;; "spice-pwl"
  3759. ;; '("pwl("
  3760. ;; (p "[start time]: ") " "
  3761. ;; (p "[start value]: ") " "
  3762. ;; ")"'n)
  3763. ;; "pwl"
  3764. ;; "template for inserting an PWL waveform")
  3765. (load "skeleton")
  3766. (define-skeleton spice-pwl
  3767. "Skeleton for Piece Wise Linear waveform"
  3768. "Time/value doublet: "
  3769. "pwl(" str
  3770. ( "Next doublet: (%s) "
  3771. " "str )
  3772. resume:
  3773. ")"
  3774. 'spice-tempo-tags)
  3775. (tempo-define-template
  3776. "hspice-sffm"
  3777. '("sffm("
  3778. (p "[offset value]: ") " "
  3779. (p "[amplitude value]: ") " "
  3780. (p "[carrier frequency]: ") " "
  3781. (p "[modulation index]: ") " "
  3782. (p "[signal frequency]: ")
  3783. ")"'n)
  3784. "sffm"
  3785. "template for inserting an HSPICE SFFM waveform"
  3786. 'spice-tempo-tags)
  3787. (tempo-define-template
  3788. "hspice-am"
  3789. '("am("
  3790. (p "[signal amplitude]: ") " "
  3791. (p "[offset constant]: ") " "
  3792. (p "[modulation frequency]: ") " "
  3793. (p "[carrier frequency]: ") " "
  3794. (p "[delay time]: ")
  3795. ")"'n)
  3796. "am"
  3797. "template for inserting an HSPICE AM waveform"
  3798. 'spice-tempo-tags)
  3799. (tempo-define-template
  3800. "spice-ac"
  3801. '("ac("
  3802. (p "[magnitude]: ") " "
  3803. (p "[phase]: ")
  3804. ")"'n)
  3805. "ac"
  3806. "template for inserting an AC waveform"
  3807. 'spice-tempo-tags)
  3808. (tempo-define-template
  3809. "spice-eldo-pattern"
  3810. '("pattern "
  3811. (p "[Vhi]: ") " "
  3812. (p "[Vlo]: ") " "
  3813. (p "[delay]: ") " "
  3814. (p "[rise time]: ") " "
  3815. (p "[fall time]: ") " "
  3816. (p "[Bit duration]: ") " "
  3817. (p "[Bits]: ")
  3818. 'n)
  3819. "eldo-pattern"
  3820. "template for inserting an ELDO Pattern function"
  3821. 'spice-tempo-tags)
  3822. (tempo-define-template
  3823. "spice-eldo-noise"
  3824. '("noise("
  3825. (p "[White noise level]: ") " "
  3826. (p "[Flicker noise level]: ") " "
  3827. (p "[Alpha]: ") " "
  3828. (p "[Cut-off freq]: ") " "
  3829. (p "[Filter order]: ")
  3830. ")"'n)
  3831. "noise"
  3832. "template for inserting an ELDO NOISE waveform"
  3833. 'spice-tempo-tags)
  3834. (tempo-define-template
  3835. "spice-eldorf-fpulse"
  3836. '("fpulse("
  3837. (p "[initial value]: ") " "
  3838. (p "[pulse value]: ") " "
  3839. (p "[delay time]: ") " "
  3840. (p "[rise time]: ") " "
  3841. (p "[fall time]: ") " "
  3842. (p "[pulse duration]: ") " "
  3843. (p "[FUND1|FUND2|FUND3 (of .sst)]: ")
  3844. ")"'n)
  3845. "eldorf-fpulse"
  3846. "template for inserting an Eldo-RF fpulse waveform"
  3847. 'spice-tempo-tags)
  3848. (tempo-define-template
  3849. "spice-eldorf-four"
  3850. '("four" '(just-one-space)
  3851. (p "[FUND1]: ")
  3852. (p "<FUND2>: " fund2 'noinsert)
  3853. (if (string-equal (tempo-lookup-named 'fund2) "")
  3854. ()
  3855. (list 'l " " '(s fund2) '(p "<FUND3>: " fund3 'noinsert)))
  3856. (if (string-equal (tempo-lookup-named 'fund3) "")
  3857. ()
  3858. (list 'l " " '(s fund3)))
  3859. '(just-one-space)
  3860. (p "[MA|RI|DB|PMA|PDB|PDBM]: ") '(just-one-space)
  3861. "("
  3862. (p "[int_val1]: ")
  3863. (p "<int_val2>: " int_val2 'noinsert)
  3864. (if (string-equal (tempo-lookup-named 'int_val2) "")
  3865. ()
  3866. (list 'l "," '(s int_val2) '(p "<int_val3>: " int_val3 'noinsert)))
  3867. (if (string-equal (tempo-lookup-named 'int_val3) "")
  3868. ()
  3869. (list 'l "," '(s int_val3)))
  3870. ")" '(just-one-space)
  3871. (p "[real_val1]: ") '(just-one-space)
  3872. (p "[real_val2]: ") '(just-one-space)
  3873. 'n)
  3874. "eldorf-four"
  3875. "template for inserting an Eldo-RF Fpulse waveform"
  3876. 'spice-tempo-tags)
  3877. ;; Eldo Extracts
  3878. (tempo-define-template
  3879. "spice-eldo-phmag"
  3880. '(".EXTRACT AC label=\"Phase margin\" xycond(vp("
  3881. (p "[Node]: " lname)
  3882. "),vdb(" (s lname) ")<0.0)+180 "
  3883. 'n)
  3884. "phmag"
  3885. "template for extracting the phase margin"
  3886. 'spice-tempo-tags)
  3887. (tempo-define-template
  3888. "spice-eldo-gmag"
  3889. '(".EXTRACT AC label=\"Gain margin\" -xycond(vdb("
  3890. (p "[Node]: " lname)
  3891. "),vp(" (s lname) ")<-180) "
  3892. 'n)
  3893. "gmag"
  3894. "template for extracting the gain margin"
  3895. 'spice-tempo-tags)
  3896. (tempo-define-template
  3897. "spice-eldo-fc"
  3898. '(".EXTRACT AC label=\"Cut freq\" xdown(vdb("
  3899. (p "[Node]: " lname)
  3900. "),yval(vdb(" (s lname) "),1)-3) "
  3901. 'n)
  3902. "fc"
  3903. "template for extracting the cut frequency"
  3904. 'spice-tempo-tags)
  3905. (tempo-define-template
  3906. "spice-eldo-ugfc"
  3907. '(".EXTRACT AC label=\"Unity gain freq\" xdown(vdb("
  3908. (p "[Node]: " lname)
  3909. "),0) "
  3910. 'n)
  3911. "ugfc"
  3912. "template for extracting the unity gain frequency"
  3913. 'spice-tempo-tags)
  3914. (tempo-define-template
  3915. "spice-eldo-period"
  3916. '(".EXTRACT TRAN xdown(v("
  3917. (p "[Node]: " lname)
  3918. "),"
  3919. (p "[threshold]: " vth)
  3920. ","
  3921. (p "[estimation time]: " t)
  3922. ",end)"
  3923. "-xdown(v(" (s lname) "),"(s vth) ","(s t) ",start) !period"
  3924. 'n)
  3925. "period"
  3926. "template for extracting the period of a signal"
  3927. 'spice-tempo-tags)
  3928. (tempo-define-template
  3929. "spice-eldo-period-macro"
  3930. '(".DEFMAC period(a,th,time)=xdown(a,th,time,end)"
  3931. "-xdown(a,th,time,start)"
  3932. 'n)
  3933. "period"
  3934. "macro for extracting the period of signal a"
  3935. 'spice-tempo-tags)
  3936. (tempo-define-template
  3937. "spice-eldo-duty-macro"
  3938. '(".DEFMAC duty_cycle(a,th,time)=(xdown(a,th,time,end)"
  3939. "-xup(a,th,time,end))/(xdown(a,th,time,end)-xdown(a,th,time,start))*100"
  3940. 'n)
  3941. "duty"
  3942. "macro for extracting the duty cycle of signal a"
  3943. 'spice-tempo-tags)
  3944. (tempo-define-template
  3945. "spice-eldo-settling-macro"
  3946. '(".DEFMAC settling(xaxis,a,ratio,Tstart,Tfinal)=xycond(xaxis,(a>(yval(a,Tfinal)*(1+ratio)))"
  3947. " || (a<(yval(a,Tfinal)*(1-ratio))),Tfinal,Tstart) - Tstart"
  3948. 'n)
  3949. "settling"
  3950. "macro for extracting the settling cycle of signal A, within ?ratio of value of A at time Tfinal"
  3951. 'spice-tempo-tags)
  3952. ;; Eldo Macromodels
  3953. (tempo-define-template
  3954. "spice-eldo-comp"
  3955. '("COMP"
  3956. (p "[Instance name]: ") " "
  3957. (p "[Positive input]: ") " "
  3958. (p "[Negative input]: ") " "
  3959. (p "[Output]: ") " "
  3960. (p "[Model name]: ") " "
  3961. (p "<Vhigh>: " vhi 'noinsert)
  3962. (if (string-equal (tempo-lookup-named 'vhi) "")
  3963. (list 'l "VHI=5.0") ;; default value
  3964. (list 'l "VHI=" '(s vhi)))
  3965. '(just-one-space)
  3966. (p "<Vlow>: " vlo 'noinsert)
  3967. (if (string-equal (tempo-lookup-named 'vlo) "")
  3968. (list 'l "VLO=0.0") ;; default value
  3969. (list 'l "VLO=" '(s vlo)))
  3970. '(just-one-space)
  3971. (p "<Input offset>: " voff 'noinsert)
  3972. (if (string-equal (tempo-lookup-named 'voff) "")
  3973. (list 'l "VOFF=0.0") ;; default value
  3974. (list 'l "VOFF=" '(s voff)))
  3975. '(just-one-space)
  3976. (p "<Hysteresis voltage>: " vdef 'noinsert)
  3977. (if (string-equal (tempo-lookup-named 'vdef) "")
  3978. (list 'l "VDEF=0.0") ;; default value
  3979. (list 'l "VDEF=" '(s vdef)))
  3980. '(just-one-space)
  3981. (p "<Commutation time>: " tcom 'noinsert)
  3982. (if (string-equal (tempo-lookup-named 'tcom) "")
  3983. (list 'l "TCOM=1ns") ;; default value
  3984. (list 'l "TCOM=" '(s tcom)))
  3985. '(just-one-space)
  3986. (p "<Transit time>: " tpd 'noinsert)
  3987. (if (string-equal (tempo-lookup-named 'tpd) "")
  3988. (list 'l "TPD=0.0") ;; default value
  3989. (list 'l "TPD=" '(s tpd)))
  3990. '(just-one-space)
  3991. 'n)
  3992. "comp"
  3993. "template for inserting an ELDO Single output comparator"
  3994. 'spice-tempo-tags)
  3995. (tempo-define-template
  3996. "spice-eldo-compd"
  3997. '("COMPD"
  3998. (p "[Instance name]: ") " "
  3999. (p "[Positive input]: ") " "
  4000. (p "[Negative input]: ") " "
  4001. (p "[Positive Output]: ") " "
  4002. (p "[Negative Output]: ") " "
  4003. (p "[Model name]: ") " "
  4004. (p "<Vhigh>: " vhi 'noinsert)
  4005. (if (string-equal (tempo-lookup-named 'vhi) "")
  4006. (list 'l "VHI=5.0") ;; default value
  4007. (list 'l "VHI=" '(s vhi)))
  4008. '(just-one-space)
  4009. (p "<Vlow>: " vlo 'noinsert)
  4010. (if (string-equal (tempo-lookup-named 'vlo) "")
  4011. (list 'l "VLO=0.0") ;; default value
  4012. (list 'l "VLO=" '(s vlo)))
  4013. '(just-one-space)
  4014. (p "<Input offset>: " voff 'noinsert)
  4015. (if (string-equal (tempo-lookup-named 'voff) "")
  4016. (list 'l "VOFF=0.0") ;; default value
  4017. (list 'l "VOFF=" '(s voff)))
  4018. '(just-one-space)
  4019. (p "<Hysteresis voltage>: " vdef 'noinsert)
  4020. (if (string-equal (tempo-lookup-named 'vdef) "")
  4021. (list 'l "VDEF=0.0") ;; default value
  4022. (list 'l "VDEF=" '(s vdef)))
  4023. '(just-one-space)
  4024. (p "<Commutation time>: " tcom 'noinsert)
  4025. (if (string-equal (tempo-lookup-named 'tcom) "")
  4026. (list 'l "TCOM=1ns") ;; default value
  4027. (list 'l "TCOM=" '(s tcom)))
  4028. '(just-one-space)
  4029. (p "<Transit time>: " tpd 'noinsert)
  4030. (if (string-equal (tempo-lookup-named 'tpd) "")
  4031. (list 'l "TPD=0.0") ;; default value
  4032. (list 'l "TPD=" '(s tpd)))
  4033. '(just-one-space)
  4034. 'n)
  4035. "compd"
  4036. "template for inserting an ELDO Differential output comparator"
  4037. 'spice-tempo-tags)
  4038. (tempo-define-template
  4039. "spice-eldo-linear-opa0"
  4040. '("Y"
  4041. (p "[Instance name]: ") " OPAMP0 "
  4042. (p "[Positive input]: ") " "
  4043. (p "[Negative input]: ") " "
  4044. (p "[Output]: ") " "
  4045. (p "[Ground]: ") " param: "
  4046. (p "<Gain>: " gain 'noinsert)
  4047. (if (string-equal (tempo-lookup-named 'gain) "")
  4048. (list 'l "GAIN=1e5") ;; default value
  4049. (list 'l "GAIN=" '(s gain)))
  4050. '(just-one-space)
  4051. (p "<Input impedance>: " rin 'noinsert)
  4052. (if (string-equal (tempo-lookup-named 'rin) "")
  4053. (list 'l "RIN=1e7") ;; default value
  4054. (list 'l "RIN=" '(s rin)))
  4055. '(just-one-space)
  4056. 'n)
  4057. "opa0"
  4058. "template for inserting an ELDO single output linear opamp"
  4059. 'spice-tempo-tags)
  4060. (tempo-define-template
  4061. "spice-eldo-linear-opa0d"
  4062. '("Y"
  4063. (p "[Instance name]: ") " OPAMP0D "
  4064. (p "[Positive input]: ") " "
  4065. (p "[Negative input]: ") " "
  4066. (p "[Positive Output]: ") " "
  4067. (p "[Negative Output]: ") " "
  4068. (p "[Ground]: ") " param: "
  4069. (p "<Gain>: " gain 'noinsert)
  4070. (if (string-equal (tempo-lookup-named 'gain) "")
  4071. (list 'l "GAIN=1e5") ;; default value
  4072. (list 'l "GAIN=" '(s gain)))
  4073. '(just-one-space)
  4074. (p "<Input impedance>: " rin 'noinsert)
  4075. (if (string-equal (tempo-lookup-named 'rin) "")
  4076. (list 'l "RIN=1e7") ;; default value
  4077. (list 'l "RIN=" '(s rin)))
  4078. '(just-one-space)
  4079. 'n)
  4080. "opa0d"
  4081. "template for inserting an ELDO differential output linear opamp"
  4082. 'spice-tempo-tags)
  4083. (tempo-define-template
  4084. "spice-eldo-linear-opa1"
  4085. '("Y"
  4086. (p "[Instance name]: ") " OPAMP1 "
  4087. (p "[Positive input]: ") " "
  4088. (p "[Negative input]: ") " "
  4089. (p "[Output]: ") " "
  4090. (p "[Ground]: ") " param: "
  4091. (p "<Gain>: " gain 'noinsert)
  4092. (if (string-equal (tempo-lookup-named 'gain) "")
  4093. (list 'l "GAIN=1e5") ;; default value
  4094. (list 'l "GAIN=" '(s gain)))
  4095. '(just-one-space)
  4096. (p "<Input offset>: " voff 'noinsert)
  4097. (if (string-equal (tempo-lookup-named 'voff) "")
  4098. (list 'l "VOFF=0.0") ;; default value
  4099. (list 'l "VOFF=" '(s voff)))
  4100. '(just-one-space)
  4101. (p "<Dominant pole>: " p1 'noinsert)
  4102. (if (string-equal (tempo-lookup-named 'p1) "")
  4103. (list 'l "P1=100") ;; default value
  4104. (list 'l "P1=" '(s p1)))
  4105. '(just-one-space)
  4106. (p "<Input impedance>: " rin 'noinsert)
  4107. (if (string-equal (tempo-lookup-named 'rin) "")
  4108. (list 'l "RIN=1e7") ;; default value
  4109. (list 'l "RIN=" '(s rin)))
  4110. '(just-one-space)
  4111. 'n)
  4112. "opa1"
  4113. "template for inserting an ELDO single output 1-pole linear opamp"
  4114. 'spice-tempo-tags)
  4115. (tempo-define-template
  4116. "spice-eldo-linear-opa1d"
  4117. '("Y"
  4118. (p "[Instance name]: ") " OPAMP1D "
  4119. (p "[Positive input]: ") " "
  4120. (p "[Negative input]: ") " "
  4121. (p "[Positive Output]: ") " "
  4122. (p "[Negative Output]: ") " "
  4123. (p "[Ground]: ") " param: "
  4124. (p "<Gain>: " gain 'noinsert)
  4125. (if (string-equal (tempo-lookup-named 'gain) "")
  4126. (list 'l "GAIN=1e5") ;; default value
  4127. (list 'l "GAIN=" '(s gain)))
  4128. '(just-one-space)
  4129. (p "<Input offset>: " voff 'noinsert)
  4130. (if (string-equal (tempo-lookup-named 'voff) "")
  4131. (list 'l "VOFF=0.0") ;; default value
  4132. (list 'l "VOFF=" '(s voff)))
  4133. '(just-one-space)
  4134. (p "<Dominant pole>: " p1 'noinsert)
  4135. (if (string-equal (tempo-lookup-named 'p1) "")
  4136. (list 'l "P1=100") ;; default value
  4137. (list 'l "P1=" '(s p1)))
  4138. '(just-one-space)
  4139. (p "<Input impedance>: " rin 'noinsert)
  4140. (if (string-equal (tempo-lookup-named 'rin) "")
  4141. (list 'l "RIN=1e7") ;; default value
  4142. (list 'l "RIN=" '(s rin)))
  4143. '(just-one-space)
  4144. (p "<Common mode rejection ratio>: " cmrr 'noinsert)
  4145. (if (string-equal (tempo-lookup-named 'cmrr) "")
  4146. (list 'l "CMRR=0.0") ;; default value
  4147. (list 'l "CMRR=" '(s cmrr)))
  4148. '(just-one-space)
  4149. 'n)
  4150. "opa1d"
  4151. "template for inserting an ELDO differential output 1-pole linear opamp"
  4152. 'spice-tempo-tags)
  4153. (tempo-define-template
  4154. "spice-eldo-linear-opa2"
  4155. '("Y"
  4156. (p "[Instance name]: ") " OPAMP2 "
  4157. (p "[Positive input]: ") " "
  4158. (p "[Negative input]: ") " "
  4159. (p "[Output]: ") " "
  4160. (p "[Ground]: ") " param: "
  4161. (p "<Gain>: " gain 'noinsert)
  4162. (if (string-equal (tempo-lookup-named 'gain) "")
  4163. (list 'l "GAIN=1e5") ;; default value
  4164. (list 'l "GAIN=" '(s gain)))
  4165. '(just-one-space)
  4166. (p "<Input offset>: " voff 'noinsert)
  4167. (if (string-equal (tempo-lookup-named 'voff) "")
  4168. (list 'l "VOFF=0.0") ;; default value
  4169. (list 'l "VOFF=" '(s voff)))
  4170. '(just-one-space)
  4171. (p "<Dominant pole>: " p1 'noinsert)
  4172. (if (string-equal (tempo-lookup-named 'p1) "")
  4173. (list 'l "P1=100") ;; default value
  4174. (list 'l "P1=" '(s p1)))
  4175. '(just-one-space)
  4176. (p "<Non-dominant pole>: " p2 'noinsert)
  4177. (if (string-equal (tempo-lookup-named 'p2) "")
  4178. (list 'l "P2=1e6") ;; default value
  4179. (list 'l "P2=" '(s p2)))
  4180. '(just-one-space)
  4181. (p "<Input impedance>: " rin 'noinsert)
  4182. (if (string-equal (tempo-lookup-named 'rin) "")
  4183. (list 'l "RIN=1e7") ;; default value
  4184. (list 'l "RIN=" '(s rin)))
  4185. '(just-one-space)
  4186. 'n)
  4187. "opa2"
  4188. "template for inserting an ELDO single output 2-pole linear opamp"
  4189. 'spice-tempo-tags)
  4190. (tempo-define-template
  4191. "spice-eldo-linear-opa2d"
  4192. '("Y"
  4193. (p "[Instance name]: ") " OPAMP2D "
  4194. (p "[Positive input]: ") " "
  4195. (p "[Negative input]: ") " "
  4196. (p "[Positive Output]: ") " "
  4197. (p "[Negative Output]: ") " "
  4198. (p "[Ground]: ") " param: "
  4199. (p "<Gain>: " gain 'noinsert)
  4200. (if (string-equal (tempo-lookup-named 'gain) "")
  4201. (list 'l "GAIN=1e5") ;; default value
  4202. (list 'l "GAIN=" '(s gain)))
  4203. '(just-one-space)
  4204. (p "<Input offset>: " voff 'noinsert)
  4205. (if (string-equal (tempo-lookup-named 'voff) "")
  4206. (list 'l "VOFF=0.0") ;; default value
  4207. (list 'l "VOFF=" '(s voff)))
  4208. '(just-one-space)
  4209. (p "<Dominant pole>: " p1 'noinsert)
  4210. (if (string-equal (tempo-lookup-named 'p1) "")
  4211. (list 'l "P1=100") ;; default value
  4212. (list 'l "P1=" '(s p1)))
  4213. '(just-one-space)
  4214. (p "<Non-dominant pole>: " p2 'noinsert)
  4215. (if (string-equal (tempo-lookup-named 'p2) "")
  4216. (list 'l "P2=1e6") ;; default value
  4217. (list 'l "P2=" '(s p2)))
  4218. '(just-one-space)
  4219. (p "<Input impedance>: " rin 'noinsert)
  4220. (if (string-equal (tempo-lookup-named 'rin) "")
  4221. (list 'l "RIN=1e7") ;; default value
  4222. (list 'l "RIN=" '(s rin)))
  4223. '(just-one-space)
  4224. (p "<Common mode rejection ratio>: " cmrr 'noinsert)
  4225. (if (string-equal (tempo-lookup-named 'cmrr) "")
  4226. (list 'l "CMRR=0.0") ;; default value
  4227. (list 'l "CMRR=" '(s cmrr)))
  4228. '(just-one-space)
  4229. 'n)
  4230. "opa2d"
  4231. "template for inserting an ELDO differential output 2-pole linear opamp"
  4232. 'spice-tempo-tags)
  4233. (tempo-define-template
  4234. "spice-eldo-delay"
  4235. '("DEL"
  4236. (p "[Instance name]: ") " "
  4237. (p "[Input]: ") " "
  4238. (p "[Output]: ") " "
  4239. (p "[Delay value]: ") " "
  4240. 'n)
  4241. "del"
  4242. "template for inserting an ELDO delay"
  4243. 'spice-tempo-tags)
  4244. (tempo-define-template
  4245. "spice-eldo-satr"
  4246. '("Y"
  4247. (p "[Instance name]: ") " SATR "
  4248. (p "[Input]: ") " "
  4249. (p "[Output]: ") " param: "
  4250. (p "<Value of resistance>: " r 'noinsert)
  4251. (if (string-equal (tempo-lookup-named 'r) "")
  4252. (list 'l "R=1") ;; default value
  4253. (list 'l "R=" '(s r)))
  4254. '(just-one-space)
  4255. (p "<Max current>: " imax 'noinsert)
  4256. (if (string-equal (tempo-lookup-named 'imax) "")
  4257. (list 'l "IMAX=1") ;; default value
  4258. (list 'l "IMAX=" '(s imax)))
  4259. '(just-one-space)
  4260. (p "<Slew rate(V/?s)>: " sr 'noinsert)
  4261. (if (string-equal (tempo-lookup-named 'sr) "")
  4262. (list 'l "SR=0") ;; default value
  4263. (list 'l "SR=" '(s sr)))
  4264. '(just-one-space)
  4265. (p "<Dominant pole>: " p1 'noinsert)
  4266. (if (string-equal (tempo-lookup-named 'p1) "")
  4267. (list 'l "P1=1e6") ;; default value
  4268. (list 'l "P1=" '(s p1)))
  4269. '(just-one-space)
  4270. (p "<resistance of low-pass filter>: " r1 'noinsert)
  4271. (if (string-equal (tempo-lookup-named 'r1) "")
  4272. (list 'l "R1=30") ;; default value
  4273. (list 'l "R1=" '(s r1)))
  4274. 'n)
  4275. "satr"
  4276. "template for inserting an ELDO saturating resistor"
  4277. 'spice-tempo-tags)
  4278. (tempo-define-template
  4279. "spice-eldo-satv"
  4280. '("Y"
  4281. (p "[Instance name]: ") " SATV "
  4282. (p "[Positive input]: ") " "
  4283. (p "[Negative input]: ") " "
  4284. (p "[Positive Output]: ") " "
  4285. (p "[Negative Output]: ") " param: "
  4286. (p "<VMax>: " vmax 'noinsert)
  4287. (if (string-equal (tempo-lookup-named 'vmax) "")
  4288. (list 'l "VMAX=5.0") ;; default value
  4289. (list 'l "VMAX=" '(s vmax)))
  4290. '(just-one-space)
  4291. (p "<VMin>: " vmin 'noinsert)
  4292. (if (string-equal (tempo-lookup-named 'vmin) "")
  4293. (list 'l "VMIN=-5.0") ;; default value
  4294. (list 'l "VMIN=" '(s vmin)))
  4295. '(just-one-space)
  4296. (p "<Positive saturation voltage>: " vsatp 'noinsert)
  4297. (if (string-equal (tempo-lookup-named 'vsatp) "")
  4298. (list 'l "VSATP=4.75") ;; default value
  4299. (list 'l "VSATP=" '(s vsatp)))
  4300. '(just-one-space)
  4301. (p "<Negative saturation voltage>: " vsatn 'noinsert)
  4302. (if (string-equal (tempo-lookup-named 'vsatn) "")
  4303. (list 'l "VSATN=-4.75") ;; default value
  4304. (list 'l "VSATN=" '(s vsatn)))
  4305. '(just-one-space)
  4306. (p "<Slope at VSATP>: " pslope 'noinsert)
  4307. (if (string-equal (tempo-lookup-named 'pslope) "")
  4308. (list 'l "PSLOPE=0.25") ;; default value
  4309. (list 'l "PSLOPE=" '(s pslope)))
  4310. '(just-one-space)
  4311. (p "<Slope at VSATN>: " nslope 'noinsert)
  4312. (if (string-equal (tempo-lookup-named 'nslope) "")
  4313. (list 'l "NSLOPE=0.25") ;; default value
  4314. (list 'l "NSLOPE=" '(s nslope)))
  4315. 'n)
  4316. "satv"
  4317. "template for inserting an ELDO voltage limitor"
  4318. 'spice-tempo-tags)
  4319. (tempo-define-template
  4320. "spice-eldo-vswitch"
  4321. '("Y"
  4322. (p "[Instance name]: ") " VSWITCH "
  4323. (p "[Input]: ") " "
  4324. (p "[Output]: ") " "
  4325. (p "[Positive controlling node]: ") " "
  4326. (p "[Negative controlling node]: ") " param: "
  4327. (p "<Level (1/2)>: " level 'noinsert)
  4328. (if (string-equal (tempo-lookup-named 'level) "")
  4329. (list 'l "LEVEL=1") ;; default value
  4330. (list 'l "LEVEL=2" ))
  4331. '(just-one-space)
  4332. (p "<Voltage for 'ON' state>: " von 'noinsert)
  4333. (if (string-equal (tempo-lookup-named 'von) "")
  4334. (list 'l "VON=0.95") ;; default value
  4335. (list 'l "VON=" '(s von)))
  4336. '(just-one-space)
  4337. (p "<Voltage for 'OFF' state>: " voff 'noinsert)
  4338. (if (string-equal (tempo-lookup-named 'voff) "")
  4339. (list 'l "VOFF=0.05") ;; default value
  4340. (list 'l "VOFF=" '(s voff)))
  4341. '(just-one-space)
  4342. (p "<RON resistance>: " ron 'noinsert)
  4343. (if (string-equal (tempo-lookup-named 'ron) "")
  4344. (list 'l "RON=1e-2") ;; default value
  4345. (list 'l "RON=" '(s ron)))
  4346. '(just-one-space)
  4347. (p "<ROFF resistance>: " roff 'noinsert)
  4348. (if (string-equal (tempo-lookup-named 'roff) "")
  4349. (list 'l "ROFF=1e10") ;; default value
  4350. (list 'l "ROFF=" '(s roff)))
  4351. 'n)
  4352. "vswitch"
  4353. "template for inserting an ELDO voltage controled switch"
  4354. 'spice-tempo-tags)
  4355. (tempo-define-template
  4356. "spice-eldo-cswitch"
  4357. '("Y"
  4358. (p "[Instance name]: ") " CSWITCH "
  4359. (p "[Input]: ") " "
  4360. (p "[Output]: ") " IC: "
  4361. (p "[Controlling current]: ") " param: "
  4362. (p "<Level (1/2)>: " level 'noinsert)
  4363. (if (string-equal (tempo-lookup-named 'level) "")
  4364. (list 'l "LEVEL=1") ;; default value
  4365. (list 'l "LEVEL=2" ))
  4366. '(just-one-space)
  4367. (p "<Current for 'ON' state>: " ion 'noinsert)
  4368. (if (string-equal (tempo-lookup-named 'ion) "")
  4369. (list 'l "ION=0.95") ;; default value
  4370. (list 'l "ION=" '(s ion)))
  4371. '(just-one-space)
  4372. (p "<Current for 'OFF' state>: " ioff 'noinsert)
  4373. (if (string-equal (tempo-lookup-named 'ioff) "")
  4374. (list 'l "IOFF=0.05") ;; default value
  4375. (list 'l "IOFF=" '(s ioff)))
  4376. '(just-one-space)
  4377. (p "<RON resistance>: " ron 'noinsert)
  4378. (if (string-equal (tempo-lookup-named 'ron) "")
  4379. (list 'l "RON=1e-2") ;; default value
  4380. (list 'l "RON=" '(s ron)))
  4381. '(just-one-space)
  4382. (p "<ROFF resistance>: " roff 'noinsert)
  4383. (if (string-equal (tempo-lookup-named 'roff) "")
  4384. (list 'l "ROFF=1e10") ;; default value
  4385. (list 'l "ROFF=" '(s roff)))
  4386. 'n)
  4387. "cswitch"
  4388. "template for inserting an ELDO current controled switch"
  4389. 'spice-tempo-tags)
  4390. (tempo-define-template
  4391. "spice-eldo-tri2sin"
  4392. '("Y"
  4393. (p "[Instance name]: ") " TRI2SIN "
  4394. (p "[Positive input]: ") " "
  4395. (p "[Negative input]: ") " "
  4396. (p "[Positive output]: ") " "
  4397. (p "[Negative output]: ") " param: "
  4398. (p "<Level (1/2)>: " level 'noinsert)
  4399. (if (string-equal (tempo-lookup-named 'level) "")
  4400. (list 'l "LEVEL=1") ;; default value
  4401. (list 'l "LEVEL=" '(s level)))
  4402. '(just-one-space)
  4403. (p "<Gain>: " gain 'noinsert)
  4404. (if (string-equal (tempo-lookup-named 'gain) "")
  4405. (list 'l "GAIN=1e5") ;; default value
  4406. (list 'l "GAIN=" '(s gain)))
  4407. '(just-one-space)
  4408. (p "<Input offset>: " voff 'noinsert)
  4409. (if (string-equal (tempo-lookup-named 'voff) "")
  4410. (list 'l "VOFF=0.0") ;; default value
  4411. (list 'l "VOFF=" '(s voff)))
  4412. '(just-one-space)
  4413. (p "<Upper input voltage limit >: " vu 'noinsert)
  4414. (if (string-equal (tempo-lookup-named 'vu) "")
  4415. (list 'l "VU=1") ;; default value
  4416. (list 'l "VU=" '(s vu)))
  4417. '(just-one-space)
  4418. (p "<Lower input voltage limit >: " vl 'noinsert)
  4419. (if (string-equal (tempo-lookup-named 'vl) "")
  4420. (list 'l "VL=1") ;; default value
  4421. (list 'l "VL=" '(s vl)))
  4422. 'n)
  4423. "tri2sin"
  4424. "template for inserting an ELDO triangular to sine wave converter"
  4425. 'spice-tempo-tags)
  4426. (tempo-define-template
  4427. "spice-eldo-stairgen"
  4428. '("Y"
  4429. (p "[Instance name]: ") " STAIRGEN "
  4430. (p "[Positive input]: ") " "
  4431. (p "[Negative input]: ") " param: "
  4432. (p "<Start voltage>: " vstart 'noinsert)
  4433. (if (string-equal (tempo-lookup-named 'vstart) "")
  4434. (list 'l "VSTART=0.0") ;; default value
  4435. (list 'l "VSTART=" '(s vstart)))
  4436. '(just-one-space)
  4437. (p "<Step voltage>: " vdelta 'noinsert)
  4438. (if (string-equal (tempo-lookup-named 'vdelta) "")
  4439. (list 'l "VDELTA=0.1") ;; default value
  4440. (list 'l "VDELTA=" '(s vdelta)))
  4441. '(just-one-space)
  4442. (p "<Number of steps>: " nstep 'noinsert)
  4443. (if (string-equal (tempo-lookup-named 'nstep) "")
  4444. (list 'l "NSTEP=10") ;; default value
  4445. (list 'l "NSTEP=" '(s nstep)))
  4446. '(just-one-space)
  4447. (p "<Period>: " tdu 'noinsert)
  4448. (if (string-equal (tempo-lookup-named 'tdu) "")
  4449. (list 'l "TDU=1e-4") ;; default value
  4450. (list 'l "TDU=" '(s tdu)))
  4451. '(just-one-space)
  4452. (p "<Slew rate (V/?s)>: " slr 'noinsert)
  4453. (if (string-equal (tempo-lookup-named 'slr) "")
  4454. (list 'l "SLR=1") ;; default value
  4455. (list 'l "SLR=" '(s slr)))
  4456. 'n)
  4457. "stairgen"
  4458. "template for inserting an ELDO staircase waveform generator"
  4459. 'spice-tempo-tags)
  4460. (tempo-define-template
  4461. "spice-eldo-sawgen"
  4462. '("Y"
  4463. (p "[Instance name]: ") " SAWGEN "
  4464. (p "[Positive input]: ") " "
  4465. (p "[Negative input]: ") " param: "
  4466. (p "<Start voltage>: " v0 'noinsert)
  4467. (if (string-equal (tempo-lookup-named 'v0) "")
  4468. (list 'l "V0=0.0") ;; default value
  4469. (list 'l "V0=" '(s v0)))
  4470. '(just-one-space)
  4471. (p "<Voltage magnitude>: " v1 'noinsert)
  4472. (if (string-equal (tempo-lookup-named 'v1) "")
  4473. (list 'l "V1=5.0") ;; default value
  4474. (list 'l "V1=" '(s v1)))
  4475. '(just-one-space)
  4476. (p "<Period>: " tdu 'noinsert)
  4477. (if (string-equal (tempo-lookup-named 'tdu) "")
  4478. (list 'l "TDU=1e-4") ;; default value
  4479. (list 'l "TDU=" '(s tdu)))
  4480. '(just-one-space)
  4481. (p "<Delay>: " tdel 'noinsert)
  4482. (if (string-equal (tempo-lookup-named 'tdel) "")
  4483. (list 'l "TDEL=0.0") ;; default value
  4484. (list 'l "TDEL=" '(s tdel)))
  4485. 'n)
  4486. "sawgen"
  4487. "template for inserting an ELDO sawtooth waveform generator"
  4488. 'spice-tempo-tags)
  4489. (tempo-define-template
  4490. "spice-eldo-trigen"
  4491. '("Y"
  4492. (p "[Instance name]: ") " TRIGEN "
  4493. (p "[Positive input]: ") " "
  4494. (p "[Negative input]: ") " param: "
  4495. (p "<Start voltage>: " v0 'noinsert)
  4496. (if (string-equal (tempo-lookup-named 'v0) "")
  4497. (list 'l "V0=0.0") ;; default value
  4498. (list 'l "V0=" '(s v0)))
  4499. '(just-one-space)
  4500. (p "<Voltage magnitude>: " v1 'noinsert)
  4501. (if (string-equal (tempo-lookup-named 'v1) "")
  4502. (list 'l "V1=5.0") ;; default value
  4503. (list 'l "V1=" '(s v1)))
  4504. '(just-one-space)
  4505. (p "<First edge duration>: " rdu 'noinsert)
  4506. (if (string-equal (tempo-lookup-named 'rdu) "")
  4507. (list 'l "RDU=1e-4") ;; default value
  4508. (list 'l "RDU=" '(s rdu)))
  4509. '(just-one-space)
  4510. (p "<Second edge duration>: " fdu 'noinsert)
  4511. (if (string-equal (tempo-lookup-named 'fdu) "")
  4512. (list 'l "FDU=1e-4") ;; default value
  4513. (list 'l "FDU=" '(s fdu)))
  4514. '(just-one-space)
  4515. (p "<Delay>: " tdel 'noinsert)
  4516. (if (string-equal (tempo-lookup-named 'tdel) "")
  4517. (list 'l "TDEL=0.0") ;; default value
  4518. (list 'l "TDEL=" '(s tdel)))
  4519. 'n)
  4520. "trigen"
  4521. "template for inserting an ELDO triangular waveform generator"
  4522. 'spice-tempo-tags)
  4523. (tempo-define-template
  4524. "spice-eldo-amm"
  4525. '("Y"
  4526. (p "[Instance name]: ") " AMM "
  4527. (p "[Positive input]: ") " "
  4528. (p "[Negative input]: ") " "
  4529. (p "[Positive Output]: ") " "
  4530. (p "[Negative Output]: ") " param: "
  4531. (p "<Level (1/2)>: " level 'noinsert)
  4532. (if (string-equal (tempo-lookup-named 'level) "")
  4533. (list 'l "LEVEL=1") ;; default value
  4534. (list 'l "LEVEL=" '(s level)))
  4535. '(just-one-space)
  4536. (p "<Slewrate (V/?s)>: " slr 'noinsert)
  4537. (if (string-equal (tempo-lookup-named 'slr) "")
  4538. (list 'l "SLR=10") ;; default value
  4539. (list 'l "SLR=" '(s slr)))
  4540. '(just-one-space)
  4541. (p "<Offset voltage>: " voff 'noinsert)
  4542. (if (string-equal (tempo-lookup-named 'voff) "")
  4543. (list 'l "VOFF=0.0") ;; default value
  4544. (list 'l "VOFF=" '(s voff)))
  4545. '(just-one-space)
  4546. (p "<Carrier frequency>: " fc 'noinsert)
  4547. (if (string-equal (tempo-lookup-named 'fc) "")
  4548. (list 'l "FC=1e6") ;; default value
  4549. (list 'l "FC=" '(s fc)))
  4550. '(just-one-space)
  4551. (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
  4552. (if (string-equal (tempo-lookup-named 'nsam) "")
  4553. (list 'l "NSAM=10") ;; default value
  4554. (list 'l "NSAM=" '(s nsam)))
  4555. 'n)
  4556. "amm"
  4557. "template for inserting an ELDO amplitude modulator"
  4558. 'spice-tempo-tags)
  4559. (tempo-define-template
  4560. "spice-eldo-pam"
  4561. '("Y"
  4562. (p "[Instance name]: ") " PAM "
  4563. (p "[Positive input]: ") " "
  4564. (p "[Negative input]: ") " "
  4565. (p "[Positive Output]: ") " "
  4566. (p "[Negative Output]: ") " param: "
  4567. (p "<Level (1/2)>: " level 'noinsert)
  4568. (if (string-equal (tempo-lookup-named 'level) "")
  4569. (list 'l "LEVEL=1") ;; default value
  4570. (list 'l "LEVEL=" '(s level)))
  4571. '(just-one-space)
  4572. (p "<Slewrate (V/?s)>: " slr 'noinsert)
  4573. (if (string-equal (tempo-lookup-named 'slr) "")
  4574. (list 'l "SLR=10") ;; default value
  4575. (list 'l "SLR=" '(s slr)))
  4576. '(just-one-space)
  4577. (p "<Offset voltage>: " voff 'noinsert)
  4578. (if (string-equal (tempo-lookup-named 'voff) "")
  4579. (list 'l "VOFF=0.0") ;; default value
  4580. (list 'l "VOFF=" '(s voff)))
  4581. '(just-one-space)
  4582. (p "<Carrier frequency>: " fc 'noinsert)
  4583. (if (string-equal (tempo-lookup-named 'fc) "")
  4584. (list 'l "FC=1e6") ;; default value
  4585. (list 'l "FC=" '(s fc)))
  4586. '(just-one-space)
  4587. (p "<Minimal number of sampling points per period>: " nsam 'noinsert)
  4588. (if (string-equal (tempo-lookup-named 'nsam) "")
  4589. (list 'l "NSAM=10") ;; default value
  4590. (list 'l "NSAM=" '(s nsam)))
  4591. 'n)
  4592. "pam"
  4593. "template for inserting an ELDO pulse amplitude modulator"
  4594. 'spice-tempo-tags)
  4595. (tempo-define-template
  4596. "spice-eldo-saho"
  4597. '("Y"
  4598. (p "[Instance name]: ") " SA_HO "
  4599. (p "[Positive input]: ") " "
  4600. (p "[Negative input]: ") " "
  4601. (p "[Positive Output]: ") " "
  4602. (p "[Negative Output]: ") " param: "
  4603. (p "<Sampling frequency>: " fs 'noinsert)
  4604. (if (string-equal (tempo-lookup-named 'fs) "")
  4605. (list 'l "FS=1e6") ;; default value
  4606. (list 'l "FS=" '(s fs)))
  4607. '(just-one-space)
  4608. (p "<Acquisition time>: " tacq 'noinsert)
  4609. (if (string-equal (tempo-lookup-named 'tacq) "")
  4610. (list 'l "TACQ=1e-9") ;; default value
  4611. (list 'l "TACQ=" '(s tacq)))
  4612. '(just-one-space)
  4613. (p "<Droop voltage>: " dv 'noinsert)
  4614. (if (string-equal (tempo-lookup-named 'dv) "")
  4615. (list 'l "DV=20mv") ;; default value
  4616. (list 'l "DV=" '(s dv)))
  4617. '(just-one-space)
  4618. 'n)
  4619. "saho"
  4620. "template for inserting an ELDO sample&hold"
  4621. 'spice-tempo-tags)
  4622. (tempo-define-template
  4623. "spice-eldo-trho"
  4624. '("Y"
  4625. (p "[Instance name]: ") " TR_HO "
  4626. (p "[Positive input]: ") " "
  4627. (p "[Negative input]: ") " "
  4628. (p "[Positive Output]: ") " "
  4629. (p "[Negative Output]: ") " "
  4630. (p "[Controlling node]: ") " param: "
  4631. (p "<Threshold voltage for CRT>: " vth 'noinsert)
  4632. (if (string-equal (tempo-lookup-named 'vth) "")
  4633. (list 'l "VTH=0.5") ;; default value
  4634. (list 'l "VTH=" '(s vth)))
  4635. '(just-one-space)
  4636. (p "<Acquisition time>: " tacq 'noinsert)
  4637. (if (string-equal (tempo-lookup-named 'tacq) "")
  4638. (list 'l "TACQ=1e-9") ;; default value
  4639. (list 'l "TACQ=" '(s tacq)))
  4640. 'n)
  4641. "trho"
  4642. "template for inserting an ELDO track&hold"
  4643. 'spice-tempo-tags)
  4644. (tempo-define-template
  4645. "spice-eldo-peakd"
  4646. '("Y"
  4647. (p "[Instance name]: ") " PEAK_D "
  4648. (p "[Positive input]: ") " "
  4649. (p "[Negative input]: ") " "
  4650. (p "[Positive Output]: ") " "
  4651. (p "[Negative Output]: ") " "
  4652. (p "[Controlling node]: ") " param: "
  4653. (p "<Level (1/2)>: " level 'noinsert)
  4654. (if (string-equal (tempo-lookup-named 'level) "")
  4655. (list 'l "LEVEL=1") ;; default value
  4656. (list 'l "LEVEL=2" ))
  4657. '(just-one-space)
  4658. (p "<Threshold voltage for CRT>: " vth 'noinsert)
  4659. (if (string-equal (tempo-lookup-named 'vth) "")
  4660. (list 'l "VTH=0.5") ;; default value
  4661. (list 'l "VTH=" '(s vth)))
  4662. '(just-one-space)
  4663. (p "<Threshold voltage for reset on output>: " res 'noinsert)
  4664. (if (string-equal (tempo-lookup-named 'res) "")
  4665. (list 'l "RES=0.5") ;; default value
  4666. (list 'l "RES=" '(s res)))
  4667. '(just-one-space)
  4668. (p "<Output slewrate (V/?s)>: " slr 'noinsert)
  4669. (if (string-equal (tempo-lookup-named 'slr) "")
  4670. (list 'l "SLR=1.0") ;; default value
  4671. (list 'l "SLR=" '(s slr)))
  4672. '(just-one-space)
  4673. (p "<Output slewrate on reset>: " rslr 'noinsert)
  4674. (if (string-equal (tempo-lookup-named 'rslr) "")
  4675. (list 'l "RSLR=1.0") ;; default value
  4676. (list 'l "RSLR=" '(s rslr)))
  4677. 'n)
  4678. "peakd"
  4679. "template for inserting an ELDO peak detector"
  4680. 'spice-tempo-tags)
  4681. (tempo-define-template
  4682. "spice-eldo-levdso"
  4683. '("Y"
  4684. (p "[Instance name]: ") " LEV_D "
  4685. (p "[Positive input]: ") " "
  4686. (p "[Negative input]: ") " "
  4687. (p "[Positive Output]: ") " "
  4688. (p "[Negative Output]: ") " param: "
  4689. (p "<Rise time (?s)>: " tr 'noinsert)
  4690. (if (string-equal (tempo-lookup-named 'tr) "")
  4691. (list 'l "TR=1.0") ;; default value
  4692. (list 'l "TR=" '(s tr)))
  4693. '(just-one-space)
  4694. (p "<Fall time (?s)>: " tf 'noinsert)
  4695. (if (string-equal (tempo-lookup-named 'tf) "")
  4696. (list 'l "TF=1.0") ;; default value
  4697. (list 'l "TF=" '(s tf)))
  4698. '(just-one-space)
  4699. (p "<Transit time (s)>: " tpd 'noinsert)
  4700. (if (string-equal (tempo-lookup-named 'tpd) "")
  4701. (list 'l "TPD=0.0") ;; default value
  4702. (list 'l "TPD=" '(s tpd)))
  4703. '(just-one-space)
  4704. (p "<Lower voltage level>: " v0 'noinsert)
  4705. (if (string-equal (tempo-lookup-named 'v0) "")
  4706. (list 'l "V0=0.0") ;; default value
  4707. (list 'l "V0=" '(s v0)))
  4708. '(just-one-space)
  4709. (p "<Higher voltage level>: " v1 'noinsert)
  4710. (if (string-equal (tempo-lookup-named 'v1) "")
  4711. (list 'l "V1=1.0") ;; default value
  4712. (list 'l "V1=" '(s v1)))
  4713. '(just-one-space)
  4714. (p "<Input offset voltage>: " voff 'noinsert)
  4715. (if (string-equal (tempo-lookup-named 'voff) "")
  4716. (list 'l "VOFF=0.0") ;; default value
  4717. (list 'l "VOFF=" '(s voff)))
  4718. '(just-one-space)
  4719. (p "<Lower reference voltage>: " vrl 'noinsert)
  4720. (if (string-equal (tempo-lookup-named 'vrl) "")
  4721. (list 'l "VRL=-0.1") ;; default value
  4722. (list 'l "VRL=" '(s vrl)))
  4723. '(just-one-space)
  4724. (p "<Higher reference voltage>: " vru 'noinsert)
  4725. (if (string-equal (tempo-lookup-named 'vru) "")
  4726. (list 'l "VRU=0.1") ;; default value
  4727. (list 'l "VRU=" '(s vru)))
  4728. 'n)
  4729. "levdso"
  4730. "template for inserting an ELDO single-output level detector"
  4731. 'spice-tempo-tags)
  4732. (tempo-define-template
  4733. "spice-eldo-levddo"
  4734. '("Y"
  4735. (p "[Instance name]: ") " LEV_D "
  4736. (p "[Positive input]: ") " "
  4737. (p "[Negative input]: ") " "
  4738. (p "[Positive Output]: ") " "
  4739. (p "[Negative Output]: ") " "
  4740. (p "[Reference node]: ") " param: "
  4741. (p "<Rise time (?s)>: " tr 'noinsert)
  4742. (if (string-equal (tempo-lookup-named 'tr) "")
  4743. (list 'l "TR=1.0") ;; default value
  4744. (list 'l "TR=" '(s tr)))
  4745. '(just-one-space)
  4746. (p "<Fall time (?s)>: " tf 'noinsert)
  4747. (if (string-equal (tempo-lookup-named 'tf) "")
  4748. (list 'l "TF=1.0") ;; default value
  4749. (list 'l "TF=" '(s tf)))
  4750. '(just-one-space)
  4751. (p "<Transit time (s)>: " tpd 'noinsert)
  4752. (if (string-equal (tempo-lookup-named 'tpd) "")
  4753. (list 'l "TPD=0.0") ;; default value
  4754. (list 'l "TPD=" '(s tpd)))
  4755. '(just-one-space)
  4756. (p "<Lower voltage level>: " v0 'noinsert)
  4757. (if (string-equal (tempo-lookup-named 'v0) "")
  4758. (list 'l "V0=0.0") ;; default value
  4759. (list 'l "V0=" '(s v0)))
  4760. '(just-one-space)
  4761. (p "<Higher voltage level>: " v1 'noinsert)
  4762. (if (string-equal (tempo-lookup-named 'v1) "")
  4763. (list 'l "V1=1.0") ;; default value
  4764. (list 'l "V1=" '(s v1)))
  4765. '(just-one-space)
  4766. (p "<Input offset voltage>: " voff 'noinsert)
  4767. (if (string-equal (tempo-lookup-named 'voff) "")
  4768. (list 'l "VOFF=0.0") ;; default value
  4769. (list 'l "VOFF=" '(s voff)))
  4770. '(just-one-space)
  4771. (p "<Lower reference voltage>: " vrl 'noinsert)
  4772. (if (string-equal (tempo-lookup-named 'vrl) "")
  4773. (list 'l "VRL=-0.1") ;; default value
  4774. (list 'l "VRL=" '(s vrl)))
  4775. '(just-one-space)
  4776. (p "<Higher reference voltage>: " vru 'noinsert)
  4777. (if (string-equal (tempo-lookup-named 'vru) "")
  4778. (list 'l "VRU=0.1") ;; default value
  4779. (list 'l "VRU=" '(s vru)))
  4780. 'n)
  4781. "levddo"
  4782. "template for inserting an ELDO differential-output level detector"
  4783. 'spice-tempo-tags)
  4784. (tempo-define-template
  4785. "spice-eldo-logamp"
  4786. '("Y"
  4787. (p "[Instance name]: ") " LOGAMP "
  4788. (p "[Input]: ") " "
  4789. (p "[Output]: ") " param: "
  4790. (p "<Gain>: " gain 'noinsert)
  4791. (if (string-equal (tempo-lookup-named 'gain) "")
  4792. (list 'l "K=1.0") ;; default value
  4793. (list 'l "K=" '(s gain)))
  4794. '(just-one-space)
  4795. (p "<Log function argument>: " e 'noinsert)
  4796. (if (string-equal (tempo-lookup-named 'e) "")
  4797. (list 'l "E=1") ;; default value
  4798. (list 'l "E=" '(s vmin)))
  4799. '(just-one-space)
  4800. (p "<Vmax>: " vmax 'noinsert)
  4801. (if (string-equal (tempo-lookup-named 'vmax) "")
  4802. (list 'l "VMAX=5.0") ;; default value
  4803. (list 'l "VMAX=" '(s vmax)))
  4804. '(just-one-space)
  4805. (p "<Vmin>: " vmin 'noinsert)
  4806. (if (string-equal (tempo-lookup-named 'vmin) "")
  4807. (list 'l "VMIN=-5.0") ;; default value
  4808. (list 'l "VMIN=" '(s vmin)))
  4809. '(just-one-space)
  4810. (p "<Positive saturation voltage>: " vsatp 'noinsert)
  4811. (if (string-equal (tempo-lookup-named 'vsatp) "")
  4812. (list 'l "VSATP=4.75") ;; default value
  4813. (list 'l "VSATP=" '(s vsatp)))
  4814. '(just-one-space)
  4815. (p "<Negative saturation voltage>: " vsatn 'noinsert)
  4816. (if (string-equal (tempo-lookup-named 'vsatn) "")
  4817. (list 'l "VSATN=-4.75") ;; default value
  4818. (list 'l "VSATN=" '(s vsatn)))
  4819. '(just-one-space)
  4820. (p "<Slope at VSATP>: " pslope 'noinsert)
  4821. (if (string-equal (tempo-lookup-named 'pslope) "")
  4822. (list 'l "PSLOPE=0.25") ;; default value
  4823. (list 'l "PSLOPE=" '(s pslope)))
  4824. '(just-one-space)
  4825. (p "<Slope at VSATN>: " nslope 'noinsert)
  4826. (if (string-equal (tempo-lookup-named 'nslope) "")
  4827. (list 'l "NSLOPE=0.25") ;; default value
  4828. (list 'l "NSLOPE=" '(s nslope)))
  4829. 'n)
  4830. "logamp"
  4831. "template for inserting an ELDO logarithmic amplifier"
  4832. 'spice-tempo-tags)
  4833. (tempo-define-template
  4834. "spice-eldo-antilog"
  4835. '("Y"
  4836. (p "[Instance name]: ") " EXPAMP "
  4837. (p "[Input]: ") " "
  4838. (p "[Output]: ") " param: "
  4839. (p "<Gain>: " k 'noinsert)
  4840. (if (string-equal (tempo-lookup-named 'k) "")
  4841. (list 'l "K=1.0") ;; default value
  4842. (list 'l "K=" '(s k)))
  4843. '(just-one-space)
  4844. (p "<Exp function argument>: " e 'noinsert)
  4845. (if (string-equal (tempo-lookup-named 'e) "")
  4846. (list 'l "E=1") ;; default value
  4847. (list 'l "E=" '(s vmin)))
  4848. '(just-one-space)
  4849. (p "<Base of power function>: " base 'noinsert)
  4850. (if (string-equal (tempo-lookup-named 'base) "")
  4851. (list 'l "BASE={EXP(1)}") ;; default value
  4852. (list 'l "BASE=" '(s base)))
  4853. '(just-one-space)
  4854. (p "<Vmax>: " vmax 'noinsert)
  4855. (if (string-equal (tempo-lookup-named 'vmax) "")
  4856. (list 'l "VMAX=5.0") ;; default value
  4857. (list 'l "VMAX=" '(s vmax)))
  4858. '(just-one-space)
  4859. (p "<Vmin>: " vmin 'noinsert)
  4860. (if (string-equal (tempo-lookup-named 'vmin) "")
  4861. (list 'l "VMIN=-5.0") ;; default value
  4862. (list 'l "VMIN=" '(s vmin)))
  4863. '(just-one-space)
  4864. (p "<Positive saturation voltage>: " vsatp 'noinsert)
  4865. (if (string-equal (tempo-lookup-named 'vsatp) "")
  4866. (list 'l "VSATP=4.75") ;; default value
  4867. (list 'l "VSATP=" '(s vsatp)))
  4868. '(just-one-space)
  4869. (p "<Negative saturation voltage>: " vsatn 'noinsert)
  4870. (if (string-equal (tempo-lookup-named 'vsatn) "")
  4871. (list 'l "VSATN=-4.75") ;; default value
  4872. (list 'l "VSATN=" '(s vsatn)))
  4873. '(just-one-space)
  4874. (p "<Slope at VSATP>: " pslope 'noinsert)
  4875. (if (string-equal (tempo-lookup-named 'pslope) "")
  4876. (list 'l "PSLOPE=0.25") ;; default value
  4877. (list 'l "PSLOPE=" '(s pslope)))
  4878. '(just-one-space)
  4879. (p "<Slope at VSATN>: " nslope 'noinsert)
  4880. (if (string-equal (tempo-lookup-named 'nslope) "")
  4881. (list 'l "NSLOPE=0.25") ;; default value
  4882. (list 'l "NSLOPE=" '(s nslope)))
  4883. 'n)
  4884. "expamp"
  4885. "template for inserting an ELDO anti-logarithmic amplifier"
  4886. 'spice-tempo-tags)
  4887. (tempo-define-template
  4888. "spice-eldo-diff"
  4889. '("Y"
  4890. (p "[Instance name]: ") " DIFF "
  4891. (p "[Input]: ") " "
  4892. (p "[Output]: ") " param: "
  4893. (p "<Time constant>: " k 'noinsert)
  4894. (if (string-equal (tempo-lookup-named 'k) "")
  4895. (list 'l "K=1") ;; default value
  4896. (list 'l "K=" '(s k)))
  4897. '(just-one-space)
  4898. (p "<DC value>: " c0 'noinsert)
  4899. (if (string-equal (tempo-lookup-named 'c0) "")
  4900. (list 'l "C0=1") ;; default value
  4901. (list 'l "C0=" '(s c0)))
  4902. '(just-one-space)
  4903. (p "<Slewrate (V/s)>: " slr 'noinsert)
  4904. (if (string-equal (tempo-lookup-named 'slr) "")
  4905. (list 'l "SLR=1e9") ;; default value
  4906. (list 'l "SLR=" '(s slr)))
  4907. 'n)
  4908. "diff"
  4909. "template for inserting an ELDO differentiator"
  4910. 'spice-tempo-tags)
  4911. (tempo-define-template
  4912. "spice-eldo-integ"
  4913. '("Y"
  4914. (p "[Instance name]: ") " INTEG "
  4915. (p "[Input]: ") " "
  4916. (p "[Output]: ") " param: "
  4917. (p "<Time constant>: " k 'noinsert)
  4918. (if (string-equal (tempo-lookup-named 'k) "")
  4919. (list 'l "K=1") ;; default value
  4920. (list 'l "K=" '(s k)))
  4921. '(just-one-space)
  4922. (p "<DC value>: " c0 'noinsert)
  4923. (if (string-equal (tempo-lookup-named 'c0) "")
  4924. (list 'l "C0=1") ;; default value
  4925. (list 'l "C0=" '(s c0)))
  4926. 'n)
  4927. "integ"
  4928. "template for inserting an ELDO integrator"
  4929. 'spice-tempo-tags)
  4930. (tempo-define-template
  4931. "spice-eldo-adder"
  4932. '("Y"
  4933. (p "[Instance name]: ") " "
  4934. (p "<ADD/SUB/MULT/DIV>: ") " "
  4935. (p "[Input 2]: ") " "
  4936. (p "[Output]: ") " param: "
  4937. (p "<Vmax>: " vmax 'noinsert)
  4938. (if (string-equal (tempo-lookup-named 'vmax) "")
  4939. (list 'l "VMAX=5.0") ;; default value
  4940. (list 'l "VMAX=" '(s vmax)))
  4941. '(just-one-space)
  4942. (p "<Vmin>: " vmin 'noinsert)
  4943. (if (string-equal (tempo-lookup-named 'vmin) "")
  4944. (list 'l "VMIN=-5.0") ;; default value
  4945. (list 'l "VMIN=" '(s vmin)))
  4946. '(just-one-space)
  4947. (p "<Positive saturation voltage>: " vsatp 'noinsert)
  4948. (if (string-equal (tempo-lookup-named 'vsatp) "")
  4949. (list 'l "VSATP=4.75") ;; default value
  4950. (list 'l "VSATP=" '(s vsatp)))
  4951. '(just-one-space)
  4952. (p "<Negative saturation voltage>: " vsatn 'noinsert)
  4953. (if (string-equal (tempo-lookup-named 'vsatn) "")
  4954. (list 'l "VSATN=-4.75") ;; default value
  4955. (list 'l "VSATN=" '(s vsatn)))
  4956. '(just-one-space)
  4957. (p "<Slope at VSATP>: " pslope 'noinsert)
  4958. (if (string-equal (tempo-lookup-named 'pslope) "")
  4959. (list 'l "PSLOPE=0.25") ;; default value
  4960. (list 'l "PSLOPE=" '(s pslope)))
  4961. '(just-one-space)
  4962. (p "<Slope at VSATN>: " nslope 'noinsert)
  4963. (if (string-equal (tempo-lookup-named 'nslope) "")
  4964. (list 'l "NSLOPE=0.25") ;; default value
  4965. (list 'l "NSLOPE=" '(s nslope)))
  4966. 'n)
  4967. "add"
  4968. "template for inserting an ELDO adder/subtrator/multiplier/divider"
  4969. 'spice-tempo-tags)
  4970. ;; -------------------
  4971. ;; Digital Macromodels
  4972. ;; -------------------
  4973. (tempo-define-template
  4974. "spice-eldo-inv"
  4975. '("INV"
  4976. (p "[Instance name]: ") " "
  4977. (p "[First input]: ") " "
  4978. (p "[Second input]: ") " "
  4979. (p "[Output]: ") " "
  4980. (p "[Model name]: ") " "
  4981. (p "<Vhigh>: " vhi 'noinsert)
  4982. (if (string-equal (tempo-lookup-named 'vhi) "")
  4983. (list 'l "VHI=5.0") ;; default value
  4984. (list 'l "VHI=" '(s vhi)))
  4985. '(just-one-space)
  4986. (p "<Vlow>: " vlo 'noinsert)
  4987. (if (string-equal (tempo-lookup-named 'vlo) "")
  4988. (list 'l "VLO=0.0") ;; default value
  4989. (list 'l "VLO=" '(s vlo)))
  4990. '(just-one-space)
  4991. (p "<Threshold input voltage>: " vth 'noinsert)
  4992. (if (string-equal (tempo-lookup-named 'vth) "")
  4993. (list 'l "VTH=2.5") ;; default value
  4994. (list 'l "VTH=" '(s vth)))
  4995. '(just-one-space)
  4996. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  4997. (if (string-equal (tempo-lookup-named 'vthi) "")
  4998. (list 'l "") ;; default value
  4999. (list 'l "VTHI=" '(s vthi)))
  5000. '(just-one-space)
  5001. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5002. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5003. (list 'l "") ;; default value
  5004. (list 'l "VTLO=" '(s vtlo)))
  5005. '(just-one-space)
  5006. (p "<Transit time>: " tpd 'noinsert)
  5007. (if (string-equal (tempo-lookup-named 'tpd) "")
  5008. (list 'l "TPD=1.0ns") ;; default value
  5009. (list 'l "TPD=" '(s tpd)))
  5010. '(just-one-space)
  5011. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5012. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5013. (list 'l "") ;; default value
  5014. (list 'l "TPDUP=" '(s tpdup)))
  5015. '(just-one-space)
  5016. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5017. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5018. (list 'l "") ;; default value
  5019. (list 'l "TPDOWN=" '(s tpdown)))
  5020. '(just-one-space)
  5021. (p "<Input capacitance>: " cin 'noinsert)
  5022. (if (string-equal (tempo-lookup-named 'cin) "")
  5023. (list 'l "CIN=0.0") ;; default value
  5024. (list 'l "CIN=" '(s cin)))
  5025. '(just-one-space)
  5026. 'n)
  5027. "inv"
  5028. "template for inserting an ELDO INVERTER gate macromodel"
  5029. 'spice-tempo-tags)
  5030. (tempo-define-template
  5031. "spice-eldo-xor"
  5032. '("XOR"
  5033. (p "[Instance name]: ") " "
  5034. (p "[First input]: ") " "
  5035. (p "[Second input]: ") " "
  5036. (p "[Output]: ") " "
  5037. (p "[Model name]: ") " "
  5038. (p "<Vhigh>: " vhi 'noinsert)
  5039. (if (string-equal (tempo-lookup-named 'vhi) "")
  5040. (list 'l "VHI=5.0") ;; default value
  5041. (list 'l "VHI=" '(s vhi)))
  5042. '(just-one-space)
  5043. (p "<Vlow>: " vlo 'noinsert)
  5044. (if (string-equal (tempo-lookup-named 'vlo) "")
  5045. (list 'l "VLO=0.0") ;; default value
  5046. (list 'l "VLO=" '(s vlo)))
  5047. '(just-one-space)
  5048. (p "<Threshold input voltage>: " vth 'noinsert)
  5049. (if (string-equal (tempo-lookup-named 'vth) "")
  5050. (list 'l "VTH=2.5") ;; default value
  5051. (list 'l "VTH=" '(s vth)))
  5052. '(just-one-space)
  5053. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5054. (if (string-equal (tempo-lookup-named 'vthi) "")
  5055. (list 'l "") ;; default value
  5056. (list 'l "VTHI=" '(s vthi)))
  5057. '(just-one-space)
  5058. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5059. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5060. (list 'l "") ;; default value
  5061. (list 'l "VTLO=" '(s vtlo)))
  5062. '(just-one-space)
  5063. (p "<Transit time>: " tpd 'noinsert)
  5064. (if (string-equal (tempo-lookup-named 'tpd) "")
  5065. (list 'l "TPD=1.0ns") ;; default value
  5066. (list 'l "TPD=" '(s tpd)))
  5067. '(just-one-space)
  5068. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5069. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5070. (list 'l "") ;; default value
  5071. (list 'l "TPDUP=" '(s tpdup)))
  5072. '(just-one-space)
  5073. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5074. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5075. (list 'l "") ;; default value
  5076. (list 'l "TPDOWN=" '(s tpdown)))
  5077. '(just-one-space)
  5078. (p "<Input capacitance>: " cin 'noinsert)
  5079. (if (string-equal (tempo-lookup-named 'cin) "")
  5080. (list 'l "CIN=0.0") ;; default value
  5081. (list 'l "CIN=" '(s cin)))
  5082. '(just-one-space)
  5083. 'n)
  5084. "xor"
  5085. "template for inserting an ELDO Exclusive-OR gate macromodel"
  5086. 'spice-tempo-tags)
  5087. (tempo-define-template
  5088. "spice-eldo-and2"
  5089. '("AND"
  5090. (p "[Instance name]: ") " "
  5091. (p "[First input]: ") " "
  5092. (p "[Second input]: ") " "
  5093. (p "[Output]: ") " "
  5094. (p "[Model name]: ") " "
  5095. (p "<Vhigh>: " vhi 'noinsert)
  5096. (if (string-equal (tempo-lookup-named 'vhi) "")
  5097. (list 'l "VHI=5.0") ;; default value
  5098. (list 'l "VHI=" '(s vhi)))
  5099. '(just-one-space)
  5100. (p "<Vlow>: " vlo 'noinsert)
  5101. (if (string-equal (tempo-lookup-named 'vlo) "")
  5102. (list 'l "VLO=0.0") ;; default value
  5103. (list 'l "VLO=" '(s vlo)))
  5104. '(just-one-space)
  5105. (p "<Threshold input voltage>: " vth 'noinsert)
  5106. (if (string-equal (tempo-lookup-named 'vth) "")
  5107. (list 'l "VTH=2.5") ;; default value
  5108. (list 'l "VTH=" '(s vth)))
  5109. '(just-one-space)
  5110. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5111. (if (string-equal (tempo-lookup-named 'vthi) "")
  5112. (list 'l "") ;; default value
  5113. (list 'l "VTHI=" '(s vthi)))
  5114. '(just-one-space)
  5115. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5116. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5117. (list 'l "") ;; default value
  5118. (list 'l "VTLO=" '(s vtlo)))
  5119. '(just-one-space)
  5120. (p "<Transit time>: " tpd 'noinsert)
  5121. (if (string-equal (tempo-lookup-named 'tpd) "")
  5122. (list 'l "TPD=1.0ns") ;; default value
  5123. (list 'l "TPD=" '(s tpd)))
  5124. '(just-one-space)
  5125. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5126. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5127. (list 'l "") ;; default value
  5128. (list 'l "TPDUP=" '(s tpdup)))
  5129. '(just-one-space)
  5130. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5131. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5132. (list 'l "") ;; default value
  5133. (list 'l "TPDOWN=" '(s tpdown)))
  5134. '(just-one-space)
  5135. (p "<Input capacitance>: " cin 'noinsert)
  5136. (if (string-equal (tempo-lookup-named 'cin) "")
  5137. (list 'l "CIN=0.0") ;; default value
  5138. (list 'l "CIN=" '(s cin)))
  5139. '(just-one-space)
  5140. 'n)
  5141. "and"
  5142. "template for inserting an ELDO 2 input AND gate macromodel"
  5143. 'spice-tempo-tags)
  5144. (tempo-define-template
  5145. "spice-eldo-nand2"
  5146. '("NAND"
  5147. (p "[Instance name]: ") " "
  5148. (p "[First input]: ") " "
  5149. (p "[Second input]: ") " "
  5150. (p "[Output]: ") " "
  5151. (p "[Model name]: ") " "
  5152. (p "<Vhigh>: " vhi 'noinsert)
  5153. (if (string-equal (tempo-lookup-named 'vhi) "")
  5154. (list 'l "VHI=5.0") ;; default value
  5155. (list 'l "VHI=" '(s vhi)))
  5156. '(just-one-space)
  5157. (p "<Vlow>: " vlo 'noinsert)
  5158. (if (string-equal (tempo-lookup-named 'vlo) "")
  5159. (list 'l "VLO=0.0") ;; default value
  5160. (list 'l "VLO=" '(s vlo)))
  5161. '(just-one-space)
  5162. (p "<Threshold input voltage>: " vth 'noinsert)
  5163. (if (string-equal (tempo-lookup-named 'vth) "")
  5164. (list 'l "VTH=2.5") ;; default value
  5165. (list 'l "VTH=" '(s vth)))
  5166. '(just-one-space)
  5167. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5168. (if (string-equal (tempo-lookup-named 'vthi) "")
  5169. (list 'l "") ;; default value
  5170. (list 'l "VTHI=" '(s vthi)))
  5171. '(just-one-space)
  5172. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5173. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5174. (list 'l "") ;; default value
  5175. (list 'l "VTLO=" '(s vtlo)))
  5176. '(just-one-space)
  5177. (p "<Transit time>: " tpd 'noinsert)
  5178. (if (string-equal (tempo-lookup-named 'tpd) "")
  5179. (list 'l "TPD=1.0ns") ;; default value
  5180. (list 'l "TPD=" '(s tpd)))
  5181. '(just-one-space)
  5182. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5183. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5184. (list 'l "") ;; default value
  5185. (list 'l "TPDUP=" '(s tpdup)))
  5186. '(just-one-space)
  5187. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5188. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5189. (list 'l "") ;; default value
  5190. (list 'l "TPDOWN=" '(s tpdown)))
  5191. '(just-one-space)
  5192. (p "<Input capacitance>: " cin 'noinsert)
  5193. (if (string-equal (tempo-lookup-named 'cin) "")
  5194. (list 'l "CIN=0.0") ;; default value
  5195. (list 'l "CIN=" '(s cin)))
  5196. '(just-one-space)
  5197. 'n)
  5198. "nand"
  5199. "template for inserting an ELDO 2 input NAND gate macromodel"
  5200. 'spice-tempo-tags)
  5201. (tempo-define-template
  5202. "spice-eldo-or2"
  5203. '("OR"
  5204. (p "[Instance name]: ") " "
  5205. (p "[First input]: ") " "
  5206. (p "[Second input]: ") " "
  5207. (p "[Output]: ") " "
  5208. (p "[Model name]: ") " "
  5209. (p "<Vhigh>: " vhi 'noinsert)
  5210. (if (string-equal (tempo-lookup-named 'vhi) "")
  5211. (list 'l "VHI=5.0") ;; default value
  5212. (list 'l "VHI=" '(s vhi)))
  5213. '(just-one-space)
  5214. (p "<Vlow>: " vlo 'noinsert)
  5215. (if (string-equal (tempo-lookup-named 'vlo) "")
  5216. (list 'l "VLO=0.0") ;; default value
  5217. (list 'l "VLO=" '(s vlo)))
  5218. '(just-one-space)
  5219. (p "<Threshold input voltage>: " vth 'noinsert)
  5220. (if (string-equal (tempo-lookup-named 'vth) "")
  5221. (list 'l "VTH=2.5") ;; default value
  5222. (list 'l "VTH=" '(s vth)))
  5223. '(just-one-space)
  5224. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5225. (if (string-equal (tempo-lookup-named 'vthi) "")
  5226. (list 'l "") ;; default value
  5227. (list 'l "VTHI=" '(s vthi)))
  5228. '(just-one-space)
  5229. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5230. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5231. (list 'l "") ;; default value
  5232. (list 'l "VTLO=" '(s vtlo)))
  5233. '(just-one-space)
  5234. (p "<Transit time>: " tpd 'noinsert)
  5235. (if (string-equal (tempo-lookup-named 'tpd) "")
  5236. (list 'l "TPD=1.0ns") ;; default value
  5237. (list 'l "TPD=" '(s tpd)))
  5238. '(just-one-space)
  5239. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5240. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5241. (list 'l "") ;; default value
  5242. (list 'l "TPDUP=" '(s tpdup)))
  5243. '(just-one-space)
  5244. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5245. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5246. (list 'l "") ;; default value
  5247. (list 'l "TPDOWN=" '(s tpdown)))
  5248. '(just-one-space)
  5249. (p "<Input capacitance>: " cin 'noinsert)
  5250. (if (string-equal (tempo-lookup-named 'cin) "")
  5251. (list 'l "CIN=0.0") ;; default value
  5252. (list 'l "CIN=" '(s cin)))
  5253. '(just-one-space)
  5254. 'n)
  5255. "or"
  5256. "template for inserting an ELDO 2 input OR gate macromodel"
  5257. 'spice-tempo-tags)
  5258. (tempo-define-template
  5259. "spice-eldo-nor2"
  5260. '("NOR"
  5261. (p "[Instance name]: ") " "
  5262. (p "[First input]: ") " "
  5263. (p "[Second input]: ") " "
  5264. (p "[Output]: ") " "
  5265. (p "[Model name]: ") " "
  5266. (p "<Vhigh>: " vhi 'noinsert)
  5267. (if (string-equal (tempo-lookup-named 'vhi) "")
  5268. (list 'l "VHI=5.0") ;; default value
  5269. (list 'l "VHI=" '(s vhi)))
  5270. '(just-one-space)
  5271. (p "<Vlow>: " vlo 'noinsert)
  5272. (if (string-equal (tempo-lookup-named 'vlo) "")
  5273. (list 'l "VLO=0.0") ;; default value
  5274. (list 'l "VLO=" '(s vlo)))
  5275. '(just-one-space)
  5276. (p "<Threshold input voltage>: " vth 'noinsert)
  5277. (if (string-equal (tempo-lookup-named 'vth) "")
  5278. (list 'l "VTH=2.5") ;; default value
  5279. (list 'l "VTH=" '(s vth)))
  5280. '(just-one-space)
  5281. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5282. (if (string-equal (tempo-lookup-named 'vthi) "")
  5283. (list 'l "") ;; default value
  5284. (list 'l "VTHI=" '(s vthi)))
  5285. '(just-one-space)
  5286. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5287. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5288. (list 'l "") ;; default value
  5289. (list 'l "VTLO=" '(s vtlo)))
  5290. '(just-one-space)
  5291. (p "<Transit time>: " tpd 'noinsert)
  5292. (if (string-equal (tempo-lookup-named 'tpd) "")
  5293. (list 'l "TPD=1.0ns") ;; default value
  5294. (list 'l "TPD=" '(s tpd)))
  5295. '(just-one-space)
  5296. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5297. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5298. (list 'l "") ;; default value
  5299. (list 'l "TPDUP=" '(s tpdup)))
  5300. '(just-one-space)
  5301. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5302. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5303. (list 'l "") ;; default value
  5304. (list 'l "TPDOWN=" '(s tpdown)))
  5305. '(just-one-space)
  5306. (p "<Input capacitance>: " cin 'noinsert)
  5307. (if (string-equal (tempo-lookup-named 'cin) "")
  5308. (list 'l "CIN=0.0") ;; default value
  5309. (list 'l "CIN=" '(s cin)))
  5310. '(just-one-space)
  5311. 'n)
  5312. "nor"
  5313. "template for inserting an ELDO 2 input NOR gate macromodel"
  5314. 'spice-tempo-tags)
  5315. (tempo-define-template
  5316. "spice-eldo-and3"
  5317. '("AND3"
  5318. (p "[Instance name]: ") " "
  5319. (p "[First input]: ") " "
  5320. (p "[Second input]: ") " "
  5321. (p "[Output]: ") " "
  5322. (p "[Model name]: ") " "
  5323. (p "<Vhigh>: " vhi 'noinsert)
  5324. (if (string-equal (tempo-lookup-named 'vhi) "")
  5325. (list 'l "VHI=5.0") ;; default value
  5326. (list 'l "VHI=" '(s vhi)))
  5327. '(just-one-space)
  5328. (p "<Vlow>: " vlo 'noinsert)
  5329. (if (string-equal (tempo-lookup-named 'vlo) "")
  5330. (list 'l "VLO=0.0") ;; default value
  5331. (list 'l "VLO=" '(s vlo)))
  5332. '(just-one-space)
  5333. (p "<Threshold input voltage>: " vth 'noinsert)
  5334. (if (string-equal (tempo-lookup-named 'vth) "")
  5335. (list 'l "VTH=2.5") ;; default value
  5336. (list 'l "VTH=" '(s vth)))
  5337. '(just-one-space)
  5338. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5339. (if (string-equal (tempo-lookup-named 'vthi) "")
  5340. (list 'l "") ;; default value
  5341. (list 'l "VTHI=" '(s vthi)))
  5342. '(just-one-space)
  5343. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5344. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5345. (list 'l "") ;; default value
  5346. (list 'l "VTLO=" '(s vtlo)))
  5347. '(just-one-space)
  5348. (p "<Transit time>: " tpd 'noinsert)
  5349. (if (string-equal (tempo-lookup-named 'tpd) "")
  5350. (list 'l "TPD=1.0ns") ;; default value
  5351. (list 'l "TPD=" '(s tpd)))
  5352. '(just-one-space)
  5353. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5354. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5355. (list 'l "") ;; default value
  5356. (list 'l "TPDUP=" '(s tpdup)))
  5357. '(just-one-space)
  5358. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5359. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5360. (list 'l "") ;; default value
  5361. (list 'l "TPDOWN=" '(s tpdown)))
  5362. '(just-one-space)
  5363. (p "<Input capacitance>: " cin 'noinsert)
  5364. (if (string-equal (tempo-lookup-named 'cin) "")
  5365. (list 'l "CIN=0.0") ;; default value
  5366. (list 'l "CIN=" '(s cin)))
  5367. '(just-one-space)
  5368. 'n)
  5369. "and3"
  5370. "template for inserting an ELDO 3 input AND gate macromodel"
  5371. 'spice-tempo-tags)
  5372. (tempo-define-template
  5373. "spice-eldo-nand3"
  5374. '("NAND3"
  5375. (p "[Instance name]: ") " "
  5376. (p "[First input]: ") " "
  5377. (p "[Second input]: ") " "
  5378. (p "[Output]: ") " "
  5379. (p "[Model name]: ") " "
  5380. (p "<Vhigh>: " vhi 'noinsert)
  5381. (if (string-equal (tempo-lookup-named 'vhi) "")
  5382. (list 'l "VHI=5.0") ;; default value
  5383. (list 'l "VHI=" '(s vhi)))
  5384. '(just-one-space)
  5385. (p "<Vlow>: " vlo 'noinsert)
  5386. (if (string-equal (tempo-lookup-named 'vlo) "")
  5387. (list 'l "VLO=0.0") ;; default value
  5388. (list 'l "VLO=" '(s vlo)))
  5389. '(just-one-space)
  5390. (p "<Threshold input voltage>: " vth 'noinsert)
  5391. (if (string-equal (tempo-lookup-named 'vth) "")
  5392. (list 'l "VTH=2.5") ;; default value
  5393. (list 'l "VTH=" '(s vth)))
  5394. '(just-one-space)
  5395. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5396. (if (string-equal (tempo-lookup-named 'vthi) "")
  5397. (list 'l "") ;; default value
  5398. (list 'l "VTHI=" '(s vthi)))
  5399. '(just-one-space)
  5400. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5401. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5402. (list 'l "") ;; default value
  5403. (list 'l "VTLO=" '(s vtlo)))
  5404. '(just-one-space)
  5405. (p "<Transit time>: " tpd 'noinsert)
  5406. (if (string-equal (tempo-lookup-named 'tpd) "")
  5407. (list 'l "TPD=1.0ns") ;; default value
  5408. (list 'l "TPD=" '(s tpd)))
  5409. '(just-one-space)
  5410. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5411. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5412. (list 'l "") ;; default value
  5413. (list 'l "TPDUP=" '(s tpdup)))
  5414. '(just-one-space)
  5415. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5416. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5417. (list 'l "") ;; default value
  5418. (list 'l "TPDOWN=" '(s tpdown)))
  5419. '(just-one-space)
  5420. (p "<Input capacitance>: " cin 'noinsert)
  5421. (if (string-equal (tempo-lookup-named 'cin) "")
  5422. (list 'l "CIN=0.0") ;; default value
  5423. (list 'l "CIN=" '(s cin)))
  5424. '(just-one-space)
  5425. 'n)
  5426. "nand3"
  5427. "template for inserting an ELDO 3 input NAND gate macromodel"
  5428. 'spice-tempo-tags)
  5429. (tempo-define-template
  5430. "spice-eldo-or3"
  5431. '("OR3"
  5432. (p "[Instance name]: ") " "
  5433. (p "[First input]: ") " "
  5434. (p "[Second input]: ") " "
  5435. (p "[Output]: ") " "
  5436. (p "[Model name]: ") " "
  5437. (p "<Vhigh>: " vhi 'noinsert)
  5438. (if (string-equal (tempo-lookup-named 'vhi) "")
  5439. (list 'l "VHI=5.0") ;; default value
  5440. (list 'l "VHI=" '(s vhi)))
  5441. '(just-one-space)
  5442. (p "<Vlow>: " vlo 'noinsert)
  5443. (if (string-equal (tempo-lookup-named 'vlo) "")
  5444. (list 'l "VLO=0.0") ;; default value
  5445. (list 'l "VLO=" '(s vlo)))
  5446. '(just-one-space)
  5447. (p "<Threshold input voltage>: " vth 'noinsert)
  5448. (if (string-equal (tempo-lookup-named 'vth) "")
  5449. (list 'l "VTH=2.5") ;; default value
  5450. (list 'l "VTH=" '(s vth)))
  5451. '(just-one-space)
  5452. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5453. (if (string-equal (tempo-lookup-named 'vthi) "")
  5454. (list 'l "") ;; default value
  5455. (list 'l "VTHI=" '(s vthi)))
  5456. '(just-one-space)
  5457. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5458. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5459. (list 'l "") ;; default value
  5460. (list 'l "VTLO=" '(s vtlo)))
  5461. '(just-one-space)
  5462. (p "<Transit time>: " tpd 'noinsert)
  5463. (if (string-equal (tempo-lookup-named 'tpd) "")
  5464. (list 'l "TPD=1.0ns") ;; default value
  5465. (list 'l "TPD=" '(s tpd)))
  5466. '(just-one-space)
  5467. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5468. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5469. (list 'l "") ;; default value
  5470. (list 'l "TPDUP=" '(s tpdup)))
  5471. '(just-one-space)
  5472. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5473. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5474. (list 'l "") ;; default value
  5475. (list 'l "TPDOWN=" '(s tpdown)))
  5476. '(just-one-space)
  5477. (p "<Input capacitance>: " cin 'noinsert)
  5478. (if (string-equal (tempo-lookup-named 'cin) "")
  5479. (list 'l "CIN=0.0") ;; default value
  5480. (list 'l "CIN=" '(s cin)))
  5481. '(just-one-space)
  5482. 'n)
  5483. "or3"
  5484. "template for inserting an ELDO 3 input OR gate macromodel"
  5485. 'spice-tempo-tags)
  5486. (tempo-define-template
  5487. "spice-eldo-nor3"
  5488. '("NOR3"
  5489. (p "[Instance name]: ") " "
  5490. (p "[First input]: ") " "
  5491. (p "[Second input]: ") " "
  5492. (p "[Output]: ") " "
  5493. (p "[Model name]: ") " "
  5494. (p "<Vhigh>: " vhi 'noinsert)
  5495. (if (string-equal (tempo-lookup-named 'vhi) "")
  5496. (list 'l "VHI=5.0") ;; default value
  5497. (list 'l "VHI=" '(s vhi)))
  5498. '(just-one-space)
  5499. (p "<Vlow>: " vlo 'noinsert)
  5500. (if (string-equal (tempo-lookup-named 'vlo) "")
  5501. (list 'l "VLO=0.0") ;; default value
  5502. (list 'l "VLO=" '(s vlo)))
  5503. '(just-one-space)
  5504. (p "<Threshold input voltage>: " vth 'noinsert)
  5505. (if (string-equal (tempo-lookup-named 'vth) "")
  5506. (list 'l "VTH=2.5") ;; default value
  5507. (list 'l "VTH=" '(s vth)))
  5508. '(just-one-space)
  5509. (p "<Threshold input voltage rising edge>: " vthi 'noinsert)
  5510. (if (string-equal (tempo-lookup-named 'vthi) "")
  5511. (list 'l "") ;; default value
  5512. (list 'l "VTHI=" '(s vthi)))
  5513. '(just-one-space)
  5514. (p "<Threshold input voltage falling edge>: " vtlo 'noinsert)
  5515. (if (string-equal (tempo-lookup-named 'vtlo) "")
  5516. (list 'l "") ;; default value
  5517. (list 'l "VTLO=" '(s vtlo)))
  5518. '(just-one-space)
  5519. (p "<Transit time>: " tpd 'noinsert)
  5520. (if (string-equal (tempo-lookup-named 'tpd) "")
  5521. (list 'l "TPD=1.0ns") ;; default value
  5522. (list 'l "TPD=" '(s tpd)))
  5523. '(just-one-space)
  5524. (p "<Transit time for output to reach VTHI>: " tpdup 'noinsert)
  5525. (if (string-equal (tempo-lookup-named 'tpdup) "")
  5526. (list 'l "") ;; default value
  5527. (list 'l "TPDUP=" '(s tpdup)))
  5528. '(just-one-space)
  5529. (p "<Transit time for output to reach VTLO>: " tpdown 'noinsert)
  5530. (if (string-equal (tempo-lookup-named 'tpdown) "")
  5531. (list 'l "") ;; default value
  5532. (list 'l "TPDOWN=" '(s tpdown)))
  5533. '(just-one-space)
  5534. (p "<Input capacitance>: " cin 'noinsert)
  5535. (if (string-equal (tempo-lookup-named 'cin) "")
  5536. (list 'l "CIN=0.0") ;; default value
  5537. (list 'l "CIN=" '(s cin)))
  5538. '(just-one-space)
  5539. 'n)
  5540. "nor3"
  5541. "template for inserting an ELDO 3 input NOR gate macromodel"
  5542. 'spice-tempo-tags)
  5543. ;; -------------------------
  5544. ;; Mixed signal Macromodels
  5545. ;; -------------------------
  5546. (tempo-define-template
  5547. "spice-eldo-adc"
  5548. '("ADC"
  5549. (p "[Instance name]: ") " "
  5550. (p "[Clock]: ") " "
  5551. (p "[Analog input]: ") " "
  5552. (p "[Digital Outputs from MSB to LSB]: ") " "
  5553. (p "<Edge (1/-1)>: " edge 'noinsert)
  5554. (if (string-equal (tempo-lookup-named 'edge) "")
  5555. (list 'l "EDGE=1") ;; default value
  5556. (list 'l "EDGE=-1"))
  5557. '(just-one-space)
  5558. (p "<Threshold clock voltage>: " vth 'noinsert)
  5559. (if (string-equal (tempo-lookup-named 'vth) "")
  5560. (list 'l "VTH=2.5") ;; default value
  5561. (list 'l "VTH=" '(s vth)))
  5562. '(just-one-space)
  5563. (p "<Vhigh>: " vhi 'noinsert)
  5564. (if (string-equal (tempo-lookup-named 'vhi) "")
  5565. (list 'l "VHI=5.0") ;; default value
  5566. (list 'l "VHI=" '(s vhi)))
  5567. '(just-one-space)
  5568. (p "<Vlow>: " vlo 'noinsert)
  5569. (if (string-equal (tempo-lookup-named 'vlo) "")
  5570. (list 'l "VLO=0.0") ;; default value
  5571. (list 'l "VLO=" '(s vlo)))
  5572. '(just-one-space)
  5573. (p "<Analog input lower voltage>: " vinf 'noinsert)
  5574. (if (string-equal (tempo-lookup-named 'vinf) "")
  5575. (list 'l "VINF=0.0") ;; default value
  5576. (list 'l "VTHI=" '(s vinf)))
  5577. '(just-one-space)
  5578. (p "<Analog input higher voltage>: " vsup 'noinsert)
  5579. (if (string-equal (tempo-lookup-named 'vsup) "")
  5580. (list 'l "VSUP=5.0") ;; default value
  5581. (list 'l "VSUP=" '(s vsup)))
  5582. '(just-one-space)
  5583. (p "<Output bits commutation time>: " tcom 'noinsert)
  5584. (if (string-equal (tempo-lookup-named 'tcom) "")
  5585. (list 'l "TCOM=1.0ns") ;; default value
  5586. (list 'l "TCOM=" '(s tcom)))
  5587. '(just-one-space)
  5588. (p "<Transit time>: " tpd 'noinsert)
  5589. (if (string-equal (tempo-lookup-named 'tpd) "")
  5590. (list 'l "TPD=10ns") ;; default value
  5591. (list 'l "TPD=" '(s tpd)))
  5592. '(just-one-space)
  5593. 'n)
  5594. "adc"
  5595. "template for inserting an ELDO Analog to Digital Converter macromodel"
  5596. 'spice-tempo-tags)
  5597. (tempo-define-template
  5598. "spice-eldo-dac"
  5599. '("DAC"
  5600. (p "[Instance name]: ") " "
  5601. (p "[Clock]: ") " "
  5602. (p "[Digital inputs from MSB to LSB]: ") " "
  5603. (p "[Analog output]: ") " "
  5604. (p "<Edge (1/-1)>: " edge 'noinsert)
  5605. (if (string-equal (tempo-lookup-named 'edge) "")
  5606. (list 'l "EDGE=1") ;; default value
  5607. (list 'l "EDGE=-1"))
  5608. '(just-one-space)
  5609. (p "<Threshold clock voltage>: " vth 'noinsert)
  5610. (if (string-equal (tempo-lookup-named 'vth) "")
  5611. (list 'l "VTH=2.5") ;; default value
  5612. (list 'l "VTH=" '(s vth)))
  5613. '(just-one-space)
  5614. (p "<Threshold input voltage>: " vtin 'noinsert)
  5615. (if (string-equal (tempo-lookup-named 'vtin) "")
  5616. (list 'l "VTIN=2.5") ;; default value
  5617. (list 'l "VTIN=" '(s vtin)))
  5618. '(just-one-space)
  5619. (p "<Analog Output Vhigh>: " vhi 'noinsert)
  5620. (if (string-equal (tempo-lookup-named 'vhi) "")
  5621. (list 'l "VHI=5.0") ;; default value
  5622. (list 'l "VHI=" '(s vhi)))
  5623. '(just-one-space)
  5624. (p "<Analog Output Vlow>: " vlo 'noinsert)
  5625. (if (string-equal (tempo-lookup-named 'vlo) "")
  5626. (list 'l "VLO=0.0") ;; default value
  5627. (list 'l "VLO=" '(s vlo)))
  5628. '(just-one-space)
  5629. (p "<Transit time>: " tpd 'noinsert)
  5630. (if (string-equal (tempo-lookup-named 'tpd) "")
  5631. (list 'l "TPD=10ns") ;; default value
  5632. (list 'l "TPD=" '(s tpd)))
  5633. '(just-one-space)
  5634. (p "<Output slope (V/s)>: " sl 'noinsert)
  5635. (if (string-equal (tempo-lookup-named 'sl) "")
  5636. (list 'l "SL=10e8") ;; default value
  5637. (list 'l "SL=" '(s tcom)))
  5638. '(just-one-space)
  5639. 'n)
  5640. "DAC"
  5641. "template for inserting an ELDO Digital to Analog Converter macromodel"
  5642. 'spice-tempo-tags)
  5643. ;; -------------------------
  5644. ;; Switched cap Macromodels
  5645. ;; -------------------------
  5646. (tempo-define-template
  5647. "spice-eldo-switchcap-opa"
  5648. '("OPA"
  5649. (p "[Instance name]: ") " "
  5650. (p "[Positive input]: ") " "
  5651. (p "[Negative input]: ") " "
  5652. (p "[Positive Output]: ") " "
  5653. (p "[Negative Output]: ") " "
  5654. (p "[Model name]: ") " "
  5655. (p "<Input offset>: " voff 'noinsert)
  5656. (if (string-equal (tempo-lookup-named 'voff) "")
  5657. (list 'l "VOFF=0.0") ;; default value
  5658. (list 'l "VOFF=" '(s voff)))
  5659. '(just-one-space)
  5660. (p "<Slew rate (V/s)>: " sl 'noinsert)
  5661. (if (string-equal (tempo-lookup-named 'sl) "")
  5662. (list 'l "SL=1e6") ;; default value
  5663. (list 'l "SL=" '(s voff)))
  5664. '(just-one-space)
  5665. (p "<Gain>: " gain 'noinsert)
  5666. (if (string-equal (tempo-lookup-named 'gain) "")
  5667. (list 'l "GAIN=1e5") ;; default value
  5668. (list 'l "GAIN=" '(s gain)))
  5669. '(just-one-space)
  5670. (p "<Input capacitance>: " cin 'noinsert)
  5671. (if (string-equal (tempo-lookup-named 'cin) "")
  5672. (list 'l "CIN=0") ;; default value
  5673. (list 'l "CIN=" '(s cin)))
  5674. '(just-one-space)
  5675. (p "<Output resistance>: " rs 'noinsert)
  5676. (if (string-equal (tempo-lookup-named 'rs) "")
  5677. (list 'l "RS=10e6") ;; default value
  5678. (list 'l "RS=" '(s rs)))
  5679. '(just-one-space)
  5680. (p "<Symmetrical saturation voltage>: " vsat 'noinsert)
  5681. (if (string-equal (tempo-lookup-named 'vsat) "")
  5682. (list 'l "VSAT=5.0") ;; default value
  5683. (list 'l "VSAT=" '(s vsat)))
  5684. '(just-one-space)
  5685. (p "<Asymmetrical saturation voltage>: " vsatm 'noinsert)
  5686. (if (string-equal (tempo-lookup-named 'vsatm) "")
  5687. (list 'l "VSATM=5.0") ;; default value
  5688. (list 'l "VSATM=" '(s vsatm)))
  5689. '(just-one-space)
  5690. (p "<Cutoff frequency (double stage only)>: " fc 'noinsert)
  5691. (if (string-equal (tempo-lookup-named 'fc) "")
  5692. (list 'l "FC=1k") ;; default value
  5693. (list 'l "FC=" '(s fc)))
  5694. '(just-one-space)
  5695. (p "<Non-dominant pole (single stage only)>: " fndp 'noinsert)
  5696. (if (string-equal (tempo-lookup-named 'fndp) "")
  5697. (list 'l "FNDP=1k") ;; default value
  5698. (list 'l "FNDP=" '(s fndp)))
  5699. '(just-one-space)
  5700. (p "<Max current>: " imax 'noinsert)
  5701. (if (string-equal (tempo-lookup-named 'imax) "")
  5702. (list 'l "IMAX=100mA") ;; default value
  5703. (list 'l "IMAX=" '(s imax)))
  5704. '(just-one-space)
  5705. (p "<Common mode rejection ratio>: " cmrr 'noinsert)
  5706. (if (string-equal (tempo-lookup-named 'cmrr) "")
  5707. (list 'l "CMRR=0.0") ;; default value
  5708. (list 'l "CMRR=" '(s cmrr)))
  5709. 'n)
  5710. "opa"
  5711. "template for inserting an ELDO differential single or double stage opamp"
  5712. 'spice-tempo-tags
  5713. )
  5714. (tempo-define-template
  5715. "spice-eldo-switch"
  5716. '("S"
  5717. (p "[Instance name]: ") " "
  5718. (p "[Controlling node]: ") " "
  5719. (p "[Node 1]: ") " "
  5720. (p "[Node 2]: ") " "
  5721. (p "[Model name]: ") " "
  5722. (p "<RON resistance>: " ron 'noinsert)
  5723. (if (string-equal (tempo-lookup-named 'ron) "")
  5724. (list 'l "RON=1k") ;; default value
  5725. (list 'l "RON=" '(s ron)))
  5726. '(just-one-space)
  5727. (p "<Overlap capacitance>: " crec 'noinsert)
  5728. (if (string-equal (tempo-lookup-named 'crec) "")
  5729. (list 'l "CREC=0") ;; default value
  5730. (list 'l "CREC=" '(s crec)))
  5731. 'n)
  5732. "switch"
  5733. "template for inserting an ELDO switch macromodel"
  5734. 'spice-tempo-tags
  5735. )
  5736. ;; Layla constructs
  5737. (tempo-define-template
  5738. "layla-port"
  5739. '(".port "
  5740. (p "[Name of port]: ") " "
  5741. (p "[Name of net]: ") " "
  5742. 'n)
  5743. "layla-port"
  5744. "template for inserting a Layla port"
  5745. 'spice-tempo-tags)
  5746. (tempo-define-template
  5747. "layla-performance"
  5748. '(".performance "
  5749. (p "[Name of performance]: ") " "
  5750. (p "[Nominal value]: ") " \n+"
  5751. (p "[Weight (alfa)]: ") " "
  5752. ; (p "[Weight (alfa)]: ") " "
  5753. 'n)
  5754. "layla-performance"
  5755. "template for inserting a Layla performance"
  5756. 'spice-tempo-tags)
  5757. (tempo-define-template
  5758. "layla-net"
  5759. '(".net "
  5760. (p "[Name of net]: ") " "
  5761. 'n)
  5762. "layla-net"
  5763. "template for inserting a Layla net"
  5764. 'spice-tempo-tags)
  5765. (tempo-define-template
  5766. "layla-bus"
  5767. '(".bus "
  5768. (p "[Name of bus]: ") " "
  5769. 'n)
  5770. "layla-bus"
  5771. "template for inserting a Layla bus"
  5772. 'spice-tempo-tags)
  5773. (defmacro spice-layla-function-template (name type)
  5774. "Create a layla tempo define for name and type"
  5775. `(let (p_prompt)
  5776. (setq p_prompt (concat "[Name of " ,name "]: "))
  5777. (tempo-define-template
  5778. (concat "layla-" ,name "-" ,type)
  5779. (list (concat "." ,name "_" ,type "_param(")
  5780. (list 'p p_prompt) ", "
  5781. '(p "[Name of parameter]: ") ", "
  5782. '(p "[Value of parameter]: ") ")"
  5783. 'n)
  5784. (concat "layla-" ,name "-" ,type)
  5785. (concat "template for inserting a " ,type " parameter for a Layla "
  5786. ,name)
  5787. 'spice-tempo-tags)))
  5788. (spice-layla-function-template "bus" "double")
  5789. (spice-layla-function-template "bus" "integer")
  5790. (spice-layla-function-template "bus" "string")
  5791. (spice-layla-function-template "device" "double")
  5792. (spice-layla-function-template "device" "integer")
  5793. (spice-layla-function-template "device" "string")
  5794. (spice-layla-function-template "net" "double")
  5795. (spice-layla-function-template "net" "integer")
  5796. (spice-layla-function-template "net" "string")
  5797. (spice-layla-function-template "placement" "double")
  5798. (spice-layla-function-template "placement" "integer")
  5799. (spice-layla-function-template "placement" "string")
  5800. (spice-layla-function-template "port" "double")
  5801. (spice-layla-function-template "port" "integer")
  5802. (spice-layla-function-template "port" "string")
  5803. (spice-layla-function-template "symmetry" "double")
  5804. (spice-layla-function-template "symmetry" "integer")
  5805. (spice-layla-function-template "symmetry" "string")
  5806. ;;------------------------------------------------------------
  5807. ;; Abbrev hook bindings (taken from eldo-mode)
  5808. (defvar spice-mode-abbrev-table nil
  5809. "Abbrev table to use in `spice-mode' buffers.")
  5810. ;; the table, global init inline here:
  5811. (if spice-mode-abbrev-table
  5812. ()
  5813. (let ((ac abbrevs-changed))
  5814. (define-abbrev-table 'spice-mode-abbrev-table ())
  5815. ;; passive elements:
  5816. ;; resistors
  5817. (define-abbrev spice-mode-abbrev-table "r" "" 'tempo-template-spice-spice2g6-resistor)
  5818. (define-abbrev spice-mode-abbrev-table "rss" "" 'tempo-template-spice-spice3-semiconductor-resistor)
  5819. (define-abbrev spice-mode-abbrev-table "re" "" 'tempo-template-spice-eldo-resistor)
  5820. (define-abbrev spice-mode-abbrev-table "ree" "" 'tempo-template-spice-eldo-expression-resistor)
  5821. (define-abbrev spice-mode-abbrev-table "res" "" 'tempo-template-spice-eldo-semiconductor-resistor)
  5822. (define-abbrev spice-mode-abbrev-table "rh" "" 'tempo-template-spice-hspice-resistor)
  5823. (define-abbrev spice-mode-abbrev-table "rl" "" 'tempo-template-spice-layla-resistor)
  5824. ;; capacitors
  5825. (define-abbrev spice-mode-abbrev-table "c" "" 'tempo-template-spice-spice2g6-capacitor)
  5826. (define-abbrev spice-mode-abbrev-table "css" "" 'tempo-template-spice-spice3-semiconductor-capacitor)
  5827. (define-abbrev spice-mode-abbrev-table "ce" "" 'tempo-template-spice-eldo-capacitor)
  5828. (define-abbrev spice-mode-abbrev-table "cee" "" 'tempo-template-spice-eldo-expression-capacitor)
  5829. (define-abbrev spice-mode-abbrev-table "ch" "" 'tempo-template-spice-hspice-capacitor)
  5830. (define-abbrev spice-mode-abbrev-table "cl" "" 'tempo-template-spice-layla-capacitor)
  5831. ;; inductors
  5832. (define-abbrev spice-mode-abbrev-table "l" "" 'tempo-template-spice-spice2g6-inductor)
  5833. (define-abbrev spice-mode-abbrev-table "le" "" 'tempo-template-spice-eldo-inductor)
  5834. (define-abbrev spice-mode-abbrev-table "lee" "" 'tempo-template-spice-eldo-expression-inductor)
  5835. (define-abbrev spice-mode-abbrev-table "lh" "" 'tempo-template-spice-hspice-inductor)
  5836. (define-abbrev spice-mode-abbrev-table "ll" "" 'tempo-template-spice-layla-inductor)
  5837. ;; coupled inductors
  5838. (define-abbrev spice-mode-abbrev-table "k" "" 'tempo-template-spice-spice2g6-coupled-inductors)
  5839. ;; lossless transmission lines
  5840. (define-abbrev spice-mode-abbrev-table "t" "" 'tempo-template-spice-spice2g6-lossless-transmission)
  5841. (define-abbrev spice-mode-abbrev-table "te" "" 'tempo-template-spice-spice2g6-lossless-transmission)
  5842. (define-abbrev spice-mode-abbrev-table "th" "" 'tempo-template-spice-hspice-lossless-transmission)
  5843. ;; lossy transmission lines
  5844. (define-abbrev spice-mode-abbrev-table "o" "" 'tempo-template-spice-spice2g6-lossy-transmission)
  5845. ; spice3 rcline
  5846. (define-abbrev spice-mode-abbrev-table "rcls" "" 'tempo-template-spice-spice3-rcline)
  5847. ; eldo rc-line
  5848. (define-abbrev spice-mode-abbrev-table "rcle" "" 'tempo-template-spice-eldo-rcline)
  5849. ; eldo lossy transmission line
  5850. ; not implemented
  5851. ;; active elements:
  5852. ;; diodes
  5853. (define-abbrev spice-mode-abbrev-table "d" "" 'tempo-template-spice-spice2g6-diode)
  5854. (define-abbrev spice-mode-abbrev-table "de" "" 'tempo-template-spice-eldo-diode)
  5855. (define-abbrev spice-mode-abbrev-table "dh" "" 'tempo-template-spice-hspice-diode)
  5856. (define-abbrev spice-mode-abbrev-table "dl" "" 'tempo-template-spice-layla-diode)
  5857. ;; bipolars
  5858. (define-abbrev spice-mode-abbrev-table "q" "" 'tempo-template-spice-spice2g6-bipolar)
  5859. (define-abbrev spice-mode-abbrev-table "qe" "" 'tempo-template-spice-eldo-bipolar)
  5860. (define-abbrev spice-mode-abbrev-table "qh" "" 'tempo-template-spice-hspice-bipolar)
  5861. ;; jfets
  5862. (define-abbrev spice-mode-abbrev-table "j" "" 'tempo-template-spice-spice2g6-jfet)
  5863. (define-abbrev spice-mode-abbrev-table "je" "" 'tempo-template-spice-eldo-jfet)
  5864. (define-abbrev spice-mode-abbrev-table "jh" "" 'tempo-template-spice-hspice-jfet)
  5865. ;; mosfets
  5866. (define-abbrev spice-mode-abbrev-table "m" "" 'tempo-template-spice-spice2g6-mosfet)
  5867. (define-abbrev spice-mode-abbrev-table "me" "" 'tempo-template-spice-eldo-mosfet)
  5868. (define-abbrev spice-mode-abbrev-table "mh" "" 'tempo-template-spice-hspice-mosfet)
  5869. (define-abbrev spice-mode-abbrev-table "ml" "" 'tempo-template-spice-layla-mosfet)
  5870. ;; mesfets
  5871. (define-abbrev spice-mode-abbrev-table "z" "" 'tempo-template-spice-spice2g6-mesfet)
  5872. ;; subcircuits
  5873. (define-abbrev spice-mode-abbrev-table "sub" "" 'tempo-template-spice-spice2g6-subckt)
  5874. ;; controlled sources
  5875. (define-abbrev spice-mode-abbrev-table "vcvs" "" 'tempo-template-spice-spice2g6-vcvs)
  5876. (define-abbrev spice-mode-abbrev-table "e" "" 'tempo-template-spice-spice2g6-vcvs)
  5877. (define-abbrev spice-mode-abbrev-table "ccvs" "" 'tempo-template-spice-spice2g6-ccvs)
  5878. (define-abbrev spice-mode-abbrev-table "h" "" 'tempo-template-spice-spice2g6-ccvs)
  5879. (define-abbrev spice-mode-abbrev-table "vccs" "" 'tempo-template-spice-spice2g6-vccs)
  5880. (define-abbrev spice-mode-abbrev-table "g" "" 'tempo-template-spice-spice2g6-vccs)
  5881. (define-abbrev spice-mode-abbrev-table "cccs" "" 'tempo-template-spice-spice2g6-cccs)
  5882. (define-abbrev spice-mode-abbrev-table "f" "" 'tempo-template-spice-spice2g6-cccs)
  5883. ;; transient signals
  5884. (define-abbrev spice-mode-abbrev-table "pwl" "" '(spice-pwl))
  5885. (define-abbrev spice-mode-abbrev-table "pu" "" 'tempo-template-spice-pulse)
  5886. ;(define-abbrev spice-mode-abbrev-table "'su" "" 'tempo-template-spice-subckt)
  5887. ;(define-abbrev spice-mode-abbrev-table "'ac" "" 'tempo-template-spice-ac)
  5888. (define-abbrev spice-mode-abbrev-table "sin" "" 'tempo-template-spice-sine)
  5889. ;(define-abbrev spice-mode-abbrev-table "'sffm" "" 'tempo-template-spice-hspice-sffm)
  5890. (define-abbrev spice-mode-abbrev-table "exp" "" 'tempo-template-spice-exp)
  5891. (define-abbrev spice-mode-abbrev-table "noi" "" 'tempo-template-spice-eldo-noise)
  5892. (define-abbrev spice-mode-abbrev-table "pat" "" 'tempo-template-spice-eldo-pattern)
  5893. ;; behavioral models
  5894. ;; eldo
  5895. (define-abbrev spice-mode-abbrev-table "comp" "" 'tempo-template-spice-eldo-comp)
  5896. (define-abbrev spice-mode-abbrev-table "compd" "" 'tempo-template-spice-eldo-compd)
  5897. (define-abbrev spice-mode-abbrev-table "opa0" "" 'tempo-template-spice-eldo-linear-opa0)
  5898. (define-abbrev spice-mode-abbrev-table "opa0d" "" 'tempo-template-spice-eldo-linear-opa0d)
  5899. (define-abbrev spice-mode-abbrev-table "opa1" "" 'tempo-template-spice-eldo-linear-opa0)
  5900. (define-abbrev spice-mode-abbrev-table "opa1d" "" 'tempo-template-spice-eldo-linear-opa0d)
  5901. (define-abbrev spice-mode-abbrev-table "opa2" "" 'tempo-template-spice-eldo-linear-opa0)
  5902. (define-abbrev spice-mode-abbrev-table "opa2d" "" 'tempo-template-spice-eldo-linear-opa0d)
  5903. ;; extracts
  5904. (define-abbrev spice-mode-abbrev-table "phmag" "" 'tempo-template-spice-eldo-phmag)
  5905. (define-abbrev spice-mode-abbrev-table "gmag" "" 'tempo-template-spice-eldo-gmag)
  5906. (define-abbrev spice-mode-abbrev-table "fc" "" 'tempo-template-spice-eldo-fc)
  5907. (define-abbrev spice-mode-abbrev-table "ugfc" "" 'tempo-template-spice-eldo-ugfc)
  5908. (define-abbrev spice-mode-abbrev-table "tf" "" 'tempo-template-spice-eldo-period)
  5909. (define-abbrev spice-mode-abbrev-table "tfm" "" 'tempo-template-spice-eldo-period-macro)
  5910. (define-abbrev spice-mode-abbrev-table "dc" "" 'tempo-template-spice-eldo-duty-macro)
  5911. (define-abbrev spice-mode-abbrev-table "he" "" 'tempo-template-spice-eldo-circuit-header)
  5912. (setq abbrevs-changed ac)))
  5913. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5914. ;;; Menus
  5915. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5916. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5917. ;; Spice menu (using `easy-menu.el')
  5918. (defun spice-create-mode-menu ()
  5919. "Create Spice Mode menu."
  5920. (append
  5921. (list
  5922. "Spice"
  5923. '("Edit"
  5924. ["Comment Region" comment-region (and (mark) (not buffer-read-only))]
  5925. ["Uncomment Region" spice-uncomment-region (and (mark) (not buffer-read-only))]
  5926. ["Comment bar" (spice-comment-bar 't) (not buffer-read-only)]
  5927. ["Fill Paragraph (Break Line)" fill-paragraph (not buffer-read-only)]
  5928. ["Join line" spice-delete-indentation (not buffer-read-only)]
  5929. "--"
  5930. ["Fontify..." font-lock-fontify-buffer t]
  5931. "--"
  5932. ["(Re)activate File links..." spice-colorize-libraries-buffer t]
  5933. ["Load include/lib files..." spice-load-include-files (assoc spice-imenu-libraries-submenu-name imenu--index-alist)]
  5934. ["Load output file" spice-load-output-file (spice-output-file-p)]
  5935. ["Unload all other spice files" spice-unload-other-decks t]
  5936. "--"
  5937. ["Replace with .guess stats" spice-replace-with-guess-statements (and (mark) (not buffer-read-only))]
  5938. ["Replace with .nodeset stats" spice-replace-with-nodeset-statements (and (mark) (not buffer-read-only))]
  5939. "--"
  5940. ["Hide Comment Regions" spice-hide-all-comments (spice-hide-all-comments-p)]
  5941. ["Unhide Comment Regions" spice-unhide-all-comments spice-some-comment-regions-are-hidden]
  5942. "--"
  5943. ["Search .subckt def" spice-search-subckt t]
  5944. "--"
  5945. ["Add Changelog Entry" spice-add-changelog-entry (not buffer-read-only)]
  5946. )
  5947. (list
  5948. "Simulate"
  5949. ;; ["Simulate" compile t]
  5950. ["Simulate" spice-compile (and buffer-file-name (not (spice-output-p)))]
  5951. ["Stop Simulation" kill-compilation (condition-case ()
  5952. (get-buffer-process
  5953. (compilation-find-buffer))
  5954. (error nil))]
  5955. "--"
  5956. ["Next Error..." spice-next-error t]
  5957. ["Previous Error..." spice-previous-error t]
  5958. "--"
  5959. (append
  5960. '("Simulator")
  5961. ;; example code taken literally from vhdl-mode.el !
  5962. ;; add menu entries for defined simulators
  5963. (let ((simu-alist spice-simulator-alist) menu-alist name)
  5964. (while simu-alist
  5965. (setq name (car (car simu-alist)))
  5966. (setq menu-alist (cons (vector name
  5967. (list 'spice-set-simulator name)
  5968. :style 'radio :selected
  5969. ; (list 'equal 'spice-simulator name)
  5970. (list 'equal '(spice-get-simulator) name)
  5971. )
  5972. menu-alist))
  5973. (setq simu-alist (cdr simu-alist)))
  5974. (setq menu-alist
  5975. (cons '["Add Simulator..."
  5976. (customize-variable 'spice-simulator-alist) t]
  5977. (cons "--" menu-alist)))
  5978. (nreverse menu-alist))))
  5979. (list
  5980. "Waveform viewer"
  5981. ["View" spice-run-waveform-viewer
  5982. (and spice-waveform-viewer-alist-entry
  5983. buffer-file-name)]
  5984. ["Kill Waveform Viewer" spice-kill-waveform-viewer
  5985. (condition-case ()
  5986. (get-buffer-process
  5987. (spice-waveform-buffer-name-function nil))
  5988. (error nil))]
  5989. "--"
  5990. (append
  5991. '("Waveform Viewer")
  5992. ;; example code taken literally from vhdl-mode.el !
  5993. ;; add menu entries for defined simulators
  5994. (let ((wave-alist spice-waveform-viewer-alist) menu-alist name)
  5995. (while wave-alist
  5996. (setq name (car (car wave-alist)))
  5997. (setq menu-alist (cons (vector name
  5998. (list 'spice-set-waveform-viewer name)
  5999. :style 'radio :selected
  6000. ;(list 'equal 'spice-simulator name)
  6001. (list 'equal
  6002. '(spice-get-waveform-viewer)
  6003. name))
  6004. menu-alist))
  6005. (setq wave-alist (cdr wave-alist)))
  6006. (setq menu-alist
  6007. (cons '["Add Waveform Viewer..."
  6008. (customize-variable 'spice-waveform-viewer-alist) t]
  6009. (cons "--" menu-alist)))
  6010. (nreverse menu-alist))))
  6011. "--"
  6012. '("Passive Elements"
  6013. ("Resistors"
  6014. ["Spice2g6 Resistor" tempo-template-spice-spice2g6-resistor t]
  6015. ["Spice3 Silicon Resistor" tempo-template-spice-spice3-semiconductor-resistor t]
  6016. ["Eldo Resistor" tempo-template-spice-eldo-resistor (spice-standard-p 'eldo)]
  6017. ["Eldo Expression Resistor" tempo-template-spice-eldo-expression-resistor (spice-standard-p 'eldo)]
  6018. ["Eldo Silicon Resistor" tempo-template-spice-eldo-semiconductor-resistor (spice-standard-p 'eldo)]
  6019. ["Hspice Resistor" tempo-template-spice-hspice-resistor (spice-standard-p 'hspice)]
  6020. ["Layla Resistor" tempo-template-spice-layla-resistor (spice-standard-p 'layla)]
  6021. )
  6022. ("Capacitors"
  6023. ["Spice2g6 Capacitor" tempo-template-spice-spice2g6-capacitor t]
  6024. ["Spice3 Silicon Capacitor" tempo-template-spice-spice3-semiconductor-capacitor t]
  6025. ["Eldo Capacitor" tempo-template-spice-eldo-capacitor (spice-standard-p 'eldo)]
  6026. ["Eldo Expression Capacitor" tempo-template-spice-eldo-expression-capacitor (spice-standard-p 'eldo)]
  6027. ["Hspice Capacitor" tempo-template-spice-hspice-capacitor (spice-standard-p 'hspice)]
  6028. ["Layla Capacitor" tempo-template-spice-layla-capacitor (spice-standard-p 'layla)]
  6029. )
  6030. ("Inductors"
  6031. ["Spice2g6 Inductor" tempo-template-spice-spice2g6-inductor t]
  6032. ["Spice2g6 Coupled Inductors" tempo-template-spice-spice2g6-coupled-inductors t]
  6033. ["Eldo Inductor" tempo-template-spice-eldo-inductor (spice-standard-p 'eldo)]
  6034. ["Eldo Expression Inductor" tempo-template-spice-eldo-expression-inductor (spice-standard-p 'eldo)]
  6035. ["Hspice Inductor" tempo-template-spice-hspice-inductor (spice-standard-p 'hspice)]
  6036. ["Layla Inductor" tempo-template-spice-layla-inductor (spice-standard-p 'layla)]
  6037. )
  6038. ("Transmission lines"
  6039. ["Spice2g6 Lossless" tempo-template-spice-spice2g6-lossless-transmission t]
  6040. ["Eldo Lossless" tempo-template-spice-eldo-lossless-transmission (spice-standard-p 'eldo)]
  6041. ["Hspice Lossless" tempo-template-spice-hspice-lossless-transmission (spice-standard-p 'hspice)]
  6042. ["Spice2g6 Lossy" tempo-template-spice-spice2g6-lossy-transmission t]
  6043. ["Spice3 RC line" tempo-template-spice-spice3-rcline t]
  6044. ["Eldo RC line" tempo-template-spice-eldo-rcline (spice-standard-p 'eldo)]
  6045. )
  6046. )
  6047. '("Active Elements"
  6048. ("Diodes"
  6049. ["Spice2g6 Diode" tempo-template-spice-spice2g6-diode t]
  6050. ["Eldo Diode" tempo-template-spice-eldo-diode (spice-standard-p 'eldo)]
  6051. ["Hspice Diode" tempo-template-spice-hspice-diode (spice-standard-p 'hspice)]
  6052. ["Layla Diode" tempo-template-spice-layla-diode (spice-standard-p 'layla)]
  6053. )
  6054. ("Bipolars"
  6055. ["Spice2g6 Bipolar" tempo-template-spice-spice2g6-bipolar t]
  6056. ["Eldo Bipolar" tempo-template-spice-eldo-bipolar (spice-standard-p 'eldo)]
  6057. ["Hspice Bipolar" tempo-template-spice-hspice-bipolar (spice-standard-p 'hspice)]
  6058. )
  6059. ("Jfets & Mesfets"
  6060. ["Spice2g6 Jfet" tempo-template-spice-spice2g6-jfet t]
  6061. ["Spice2g6 Mesfet" tempo-template-spice-spice2g6-mesfet t]
  6062. ["Eldo Jfet" tempo-template-spice-eldo-jfet (spice-standard-p 'eldo)]
  6063. ["Hspice Jfet" tempo-template-spice-hspice-jfet (spice-standard-p 'hspice)]
  6064. )
  6065. ("Mosfets"
  6066. ["Spice2g6 Mosfet" tempo-template-spice-spice2g6-mosfet t]
  6067. ["Eldo Mosfet" tempo-template-spice-eldo-mosfet (spice-standard-p 'eldo)]
  6068. ["Hspice Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'hspice)]
  6069. ["Layla Mosfet" tempo-template-spice-hspice-mosfet (spice-standard-p 'layla)]
  6070. )
  6071. )
  6072. '("Controlled Sources"
  6073. ["Spice2g6 VCVS" tempo-template-spice-spice2g6-vcvs t]
  6074. ["Spice2g6 CCVS" tempo-template-spice-spice2g6-ccvs t]
  6075. ["Spice2g6 VCCS" tempo-template-spice-spice2g6-vccs t]
  6076. ["Spice2g6 CCCS" tempo-template-spice-spice2g6-ccvs t]
  6077. )
  6078. '("Waveforms"
  6079. ["PWL" (spice-pwl) t]
  6080. ["pulse" tempo-template-spice-pulse t]
  6081. ; ["ac" tempo-template-eldo-ac t]
  6082. ["sine" tempo-template-spice-sine t]
  6083. ["exp" tempo-template-spice-exp t]
  6084. ["hspice sffm" tempo-template-spice-hspice-sffm (spice-standard-p 'hspice)]
  6085. ["hspice am" tempo-template-spice-hspice-am (spice-standard-p 'hspice)]
  6086. ["eldo pattern" tempo-template-spice-eldo-pattern (spice-standard-p 'eldo)]
  6087. ["eldo noise" tempo-template-spice-eldo-noise (spice-standard-p 'eldo)]
  6088. ["eldoRF four" tempo-template-spice-eldorf-four (spice-standard-p 'eldorf)]
  6089. ["eldoRF fpulse" tempo-template-spice-eldorf-fpulse (spice-standard-p 'eldorf)]
  6090. )
  6091. "--"
  6092. '("Eldo Macromodels"
  6093. ("Analog"
  6094. ["SO Comparator" tempo-template-spice-eldo-comp (spice-standard-p 'eldo)]
  6095. ["DO Comparator" tempo-template-spice-eldo-compd (spice-standard-p 'eldo)]
  6096. ["SO Linear Opamp" tempo-template-spice-eldo-linear-opa0 (spice-standard-p 'eldo)]
  6097. ["DO Linear Opamp" tempo-template-spice-eldo-linear-opa0d (spice-standard-p 'eldo)]
  6098. ["SO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1 (spice-standard-p 'eldo)]
  6099. ["DO Linear 1-pole Opamp" tempo-template-spice-eldo-linear-opa1d (spice-standard-p 'eldo)]
  6100. ["SO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2 (spice-standard-p 'eldo)]
  6101. ["DO Linear 2-pole Opamp" tempo-template-spice-eldo-linear-opa2d (spice-standard-p 'eldo)]
  6102. ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
  6103. ["Saturating Resistor" tempo-template-spice-eldo-satr (spice-standard-p 'eldo)]
  6104. ["Voltage Limiter" tempo-template-spice-eldo-satv (spice-standard-p 'eldo)]
  6105. ["Voltage cont. switch" tempo-template-spice-eldo-vswitch (spice-standard-p 'eldo)]
  6106. ["Current cont. switch" tempo-template-spice-eldo-cswitch (spice-standard-p 'eldo)]
  6107. ["Triangular to sine converter" tempo-template-spice-eldo-tri2sin (spice-standard-p 'eldo)]
  6108. ["Staircase generator" tempo-template-spice-eldo-stairgen (spice-standard-p 'eldo)]
  6109. ["Sawtooth generator" tempo-template-spice-eldo-sawgen (spice-standard-p 'eldo)]
  6110. ["Triangle generator" tempo-template-spice-eldo-trigen (spice-standard-p 'eldo)]
  6111. ["Amplitude modulator" tempo-template-spice-eldo-amm (spice-standard-p 'eldo)]
  6112. ["Pulse amplitude modulator" tempo-template-spice-eldo-pam (spice-standard-p 'eldo)]
  6113. ["Sample&Hold" tempo-template-spice-eldo-saho (spice-standard-p 'eldo)]
  6114. ["Track&Hold" tempo-template-spice-eldo-trho (spice-standard-p 'eldo)]
  6115. ["Peak Detector" tempo-template-spice-eldo-peakd (spice-standard-p 'eldo)]
  6116. ["SO Level Detector" tempo-template-spice-eldo-levdso (spice-standard-p 'eldo)]
  6117. ["DO Level Detector" tempo-template-spice-eldo-levddo (spice-standard-p 'eldo)]
  6118. ["Log Amplifier" tempo-template-spice-eldo-logamp (spice-standard-p 'eldo)]
  6119. ["Antilog Amplifier" tempo-template-spice-eldo-antilog (spice-standard-p 'eldo)]
  6120. ["Differentiator" tempo-template-spice-eldo-diff (spice-standard-p 'eldo)]
  6121. ["Integrator" tempo-template-spice-eldo-integ (spice-standard-p 'eldo)]
  6122. ["Add/Sub/Mult/Div" tempo-template-spice-eldo-adder (spice-standard-p 'eldo)]
  6123. )
  6124. ("Digital"
  6125. ["Delay" tempo-template-spice-eldo-delay (spice-standard-p 'eldo)]
  6126. ["Inverter" tempo-template-spice-eldo-inv (spice-standard-p 'eldo)]
  6127. ["XOR gate" tempo-template-spice-eldo-xor (spice-standard-p 'eldo)]
  6128. ["2 input AND gate" tempo-template-spice-eldo-and2 (spice-standard-p 'eldo)]
  6129. ["2 input NAND gate" tempo-template-spice-eldo-nand2 (spice-standard-p 'eldo)]
  6130. ["2 input OR gate" tempo-template-spice-eldo-or2 (spice-standard-p 'eldo)]
  6131. ["2 input NOR gate" tempo-template-spice-eldo-nor2 (spice-standard-p 'eldo)]
  6132. ["3 input AND gate" tempo-template-spice-eldo-and3 (spice-standard-p 'eldo)]
  6133. ["3 input NAND gate" tempo-template-spice-eldo-nand3 (spice-standard-p 'eldo)]
  6134. ["3 input OR gate" tempo-template-spice-eldo-or3 (spice-standard-p 'eldo)]
  6135. ["3 input NOR gate" tempo-template-spice-eldo-nor3 (spice-standard-p 'eldo)]
  6136. )
  6137. ("Mixed Signal"
  6138. ["AD Converter" tempo-template-spice-eldo-adc (spice-standard-p 'eldo)]
  6139. ["DA Converter" tempo-template-spice-eldo-dac (spice-standard-p 'eldo)]
  6140. )
  6141. ("Switched Cap"
  6142. ["Opamp" tempo-template-spice-eldo-switchcap-opa (spice-standard-p 'eldo)]
  6143. ["Switch" tempo-template-spice-eldo-switch (spice-standard-p 'eldo)]
  6144. )
  6145. )
  6146. "--"
  6147. '("Layla Objects"
  6148. ["Port" tempo-template-layla-port (spice-standard-p 'layla)]
  6149. ["Performance" tempo-template-layla-performance (spice-standard-p 'layla)]
  6150. ["Net" tempo-template-layla-net (spice-standard-p 'layla)]
  6151. ["Bus" tempo-template-layla-bus (spice-standard-p 'layla)]
  6152. ; ["ac" tempo-template-eldo-ac t]
  6153. )
  6154. '("Layla Properties"
  6155. ("Port"
  6156. ["Port double" tempo-template-layla-port-double (spice-standard-p 'layla)]
  6157. ["Port integer" tempo-template-layla-port-integer (spice-standard-p 'layla)]
  6158. ["Port string" tempo-template-layla-port-string (spice-standard-p 'layla)]
  6159. )
  6160. ("Placement"
  6161. ["Placement double" tempo-template-layla-placement-double (spice-standard-p 'layla)]
  6162. ["Placement integer" tempo-template-layla-placement-integer (spice-standard-p 'layla)]
  6163. ["Placement string" tempo-template-layla-placement-string (spice-standard-p 'layla)]
  6164. )
  6165. ("Symmetry"
  6166. ["Symmetry double" tempo-template-layla-symmetry-double (spice-standard-p 'layla)]
  6167. ["Symmetry integer" tempo-template-layla-symmetry-integer (spice-standard-p 'layla)]
  6168. ["Symmetry string" tempo-template-layla-symmetry-string (spice-standard-p 'layla)]
  6169. )
  6170. ("Net"
  6171. ["Net double" tempo-template-layla-net-double (spice-standard-p 'layla)]
  6172. ["Net integer" tempo-template-layla-net-integer (spice-standard-p 'layla)]
  6173. ["Net string" tempo-template-layla-net-string (spice-standard-p 'layla)]
  6174. )
  6175. ("Device"
  6176. ["Device double" tempo-template-layla-device-double (spice-standard-p 'layla)]
  6177. ["Device integer" tempo-template-layla-device-integer (spice-standard-p 'layla)]
  6178. ["Device string" tempo-template-layla-device-string (spice-standard-p 'layla)]
  6179. )
  6180. ("Bus"
  6181. ["Bus double" tempo-template-layla-bus-double (spice-standard-p 'layla)]
  6182. ["Bus integer" tempo-template-layla-bus-integer (spice-standard-p 'layla)]
  6183. ["Bus string" tempo-template-layla-bus-string (spice-standard-p 'layla)]
  6184. )
  6185. )
  6186. "--"
  6187. (append
  6188. '("Goto Section")
  6189. (let ((section-alist spice-section-alist) menu-alist name str)
  6190. (setq menu-alist
  6191. (cons "--"
  6192. (cons '["Changelog"
  6193. (spice-goto-section "changelog")
  6194. ; (setq menu-sec (current-time))
  6195. (spice-cache-section-p "changelog")
  6196. ] menu-alist)))
  6197. (while section-alist
  6198. (setq name (car (car section-alist)))
  6199. (setq str (downcase (car (cdr (car section-alist)))))
  6200. (setq menu-alist (cons (vector name
  6201. (list 'spice-goto-section str)
  6202. (list 'spice-section-p str)
  6203. )
  6204. menu-alist))
  6205. (setq section-alist (cdr section-alist)))
  6206. (setq menu-alist
  6207. (cons '["Specify..."
  6208. spice-goto-section t]
  6209. (cons "--" menu-alist)))
  6210. (nreverse menu-alist))
  6211. )
  6212. (append
  6213. '("Add Section Header")
  6214. (let ((section-alist spice-section-alist) menu-alist name str)
  6215. (setq menu-alist
  6216. (cons "--"
  6217. (cons '["Changelog"
  6218. (spice-add-section "Changelog")
  6219. (not (spice-section-p "changelog"))] menu-alist)))
  6220. (while section-alist
  6221. (setq name (car (car section-alist)))
  6222. (setq str (car (cdr (car section-alist))))
  6223. (setq menu-alist (cons (vector name
  6224. (list 'spice-add-section str)
  6225. (list 'not (list 'spice-section-p (downcase str)))
  6226. )
  6227. menu-alist))
  6228. (setq section-alist (cdr section-alist)))
  6229. (setq menu-alist
  6230. (cons '["Specify..."
  6231. spice-add-section t]
  6232. (cons "--" menu-alist)))
  6233. (nreverse menu-alist))
  6234. )
  6235. )
  6236. (spice-common-menu-tail-entries))
  6237. )
  6238. (defun spice-create-output-mode-menu ()
  6239. "Create Spice-output Mode menu."
  6240. (append
  6241. (list
  6242. "Spice-output"
  6243. '("Edit"
  6244. ["Fontify..." font-lock-fontify-buffer t]
  6245. "--"
  6246. ["Unload all other spice files" spice-unload-other-decks t]
  6247. "--"
  6248. ["Create <name>_guess.cir file" (spice-create-guess-nodeset-file "guess") (spice-output-p)]
  6249. ["Create <name>_nodeset.cir file" (spice-create-guess-nodeset-file "nodeset") (spice-output-p)]
  6250. )
  6251. )
  6252. (spice-common-menu-tail-entries))
  6253. )
  6254. (defun spice-common-menu-tail-entries ()
  6255. "Creat Common Spice and Spice-output Mode menu entries."
  6256. (list
  6257. "--"
  6258. ;; customize sub menu
  6259. '("Customize"
  6260. ["Browse Spice Group" (customize-browse 'spice) t]
  6261. ["Spice Standard" (customize-variable 'spice-standard) t]
  6262. ["Spice Faces" (customize-group 'spice-faces) t]
  6263. ["Section Header list" (customize-variable 'spice-section-alist) t]
  6264. ;; "--"
  6265. ;; ["Activate Customizations in Buffer" spice-activate-customizations t]
  6266. ;; (not (equal spice-standard-local spice-standard))]
  6267. )
  6268. ;; settings sub menu
  6269. (append '("Settings")
  6270. (when (fboundp 'speedbar)
  6271. (list '["Speedbar" speedbar-frame-mode
  6272. :style toggle
  6273. :selected (and (boundp 'speedbar-frame)
  6274. (frame-live-p speedbar-frame)
  6275. (frame-visible-p speedbar-frame))]))
  6276. (list
  6277. '["Abbrevs" abbrev-mode :style toggle :selected abbrev-mode]
  6278. '["List abbrevs" list-abbrevs abbrev-mode]
  6279. '["Auto fill" auto-fill-mode :style toggle
  6280. :selected auto-fill-function]))
  6281. "--"
  6282. ["About Spice-Mode" spice-about t]
  6283. )
  6284. )
  6285. (defvar spice-menu-list nil
  6286. "Spice Mode menu.") ; global variable
  6287. (defvar spice-output-menu-list nil
  6288. "Spice-output Mode menu.") ; global variable
  6289. (require 'easymenu)
  6290. (defun spice-menu-init ()
  6291. "Initializes global vars for Spice menu's"
  6292. (setq spice-menu-list (spice-create-mode-menu))
  6293. (setq spice-output-menu-list (spice-create-output-mode-menu))
  6294. )
  6295. (defun spice-update-mode-menu ()
  6296. "Updates Spice mode menu for current buffer." ; assumes globals have
  6297. ; been updated
  6298. (interactive)
  6299. (if (spice-output-p)
  6300. (progn
  6301. (easy-menu-remove spice-output-menu-list) ; for XEmacs
  6302. ;; (setq spice-output-menu-list (spice-create-output-mode-menu))
  6303. (easy-menu-add spice-output-menu-list) ; for XEmacs
  6304. (easy-menu-define spice-output-menu spice-output-mode-map
  6305. "Menu keymap for Spice-output Mode." spice-output-menu-list))
  6306. (easy-menu-remove spice-menu-list) ; for XEmacs
  6307. ;; (setq spice-menu-list (spice-create-mode-menu))
  6308. (easy-menu-add spice-menu-list) ; for XEmacs
  6309. (easy-menu-define spice-menu spice-mode-map
  6310. "Menu keymap for Spice Mode." spice-menu-list)))
  6311. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6312. ;; spice mode syntax table
  6313. (defvar spice-mode-syntax-table nil
  6314. "Syntax table used in spice-mode buffers.")
  6315. (defun spice-mode-syntax-table-init ()
  6316. "initialize syntax table from scratch."
  6317. (setq spice-mode-syntax-table (make-syntax-table))
  6318. (modify-syntax-entry ?$ "w" spice-mode-syntax-table)
  6319. (modify-syntax-entry ?! "w" spice-mode-syntax-table)
  6320. (modify-syntax-entry ?* "w" spice-mode-syntax-table) ; not < !!!!
  6321. (if (spice-standard-p 'eldo)
  6322. (progn (modify-syntax-entry ?# "w 13" spice-mode-syntax-table)
  6323. (modify-syntax-entry ?c "w 2" spice-mode-syntax-table)
  6324. (modify-syntax-entry ?e "w 4" spice-mode-syntax-table)))
  6325. ;; (modify-syntax-entry ?\n "> b" spice-mode-syntax-table) ;; no no, comments are handled by spice-mode, not by syntax-table !!!
  6326. (modify-syntax-entry ?\n "." spice-mode-syntax-table) ;; make it punctuation ?
  6327. (modify-syntax-entry ?\" "\"" spice-mode-syntax-table) ;; font-lock prob
  6328. ;; (modify-syntax-entry ?\" "w" spice-mode-syntax-table)
  6329. (modify-syntax-entry ?. "w" spice-mode-syntax-table)
  6330. (modify-syntax-entry ?, "w" spice-mode-syntax-table)
  6331. (modify-syntax-entry ?_ "w" spice-mode-syntax-table)
  6332. (modify-syntax-entry ?@ "w" spice-mode-syntax-table)
  6333. (modify-syntax-entry ?/ "w" spice-mode-syntax-table)
  6334. ;; (modify-syntax-entry ?< "(>" spice-mode-syntax-table) ; can be in symbols
  6335. ;; (modify-syntax-entry ?> ")<" spice-mode-syntax-table) ; can be in symbols
  6336. ;; (modify-syntax-entry ?+ "w" spice-mode-syntax-table) ; can be in expr
  6337. ;; (modify-syntax-entry ?- "w" spice-mode-syntax-table) ; can be in expr
  6338. ;; (modify-syntax-entry ?= "." spice-mode-syntax-table) ; can be in expr
  6339. )
  6340. ;;;
  6341. ;;; speedbar stuff
  6342. ;;;
  6343. (eval-and-compile
  6344. (when (fboundp 'speedbar)
  6345. (require 'speedbar)
  6346. (defun spice-speedbar-init ()
  6347. "Initialize speedbar."
  6348. ;; general settings, depends on auto-mode-alist, so should be
  6349. ;; called every time auto-mode-alist is modified (set
  6350. ;; (make-local-variable 'speedbar-tag-hierarchy-method) nil)
  6351. ;; SPICE file extensions (extracted from `auto-mode-alist')
  6352. (let ((mode-alist auto-mode-alist))
  6353. (while mode-alist
  6354. (when (eq (cdr (car mode-alist)) 'spice-mode)
  6355. (speedbar-add-supported-extension (car (car mode-alist))))
  6356. (setq mode-alist (cdr mode-alist)))))
  6357. (defun spice-speedbar (&optional arg)
  6358. "Open/close speedbar."
  6359. (interactive)
  6360. (if (not (fboundp 'speedbar))
  6361. (error "WARNING: Speedbar is only available in newer Emacs versions")
  6362. (condition-case () ; due to bug in `speedbar-el' v0.7.2a
  6363. (speedbar-frame-mode arg)
  6364. (error "WARNING: Install included `speedbar.el' patch first"))))
  6365. )
  6366. )
  6367. ;;; speedbar end
  6368. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6369. ;;; Imenu: S-mouse3 in emacs to find spice objects quickly (xemacs ?)
  6370. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6371. (require 'imenu)
  6372. (defvar spice-imenu-generic-expression nil
  6373. "Imenu generic expression for spice mode. See `imenu-generic-expression'.")
  6374. (defconst spice-imenu-end-submenu-name "*End*"
  6375. "label of End submenu in imenu")
  6376. (defconst spice-imenu-libraries-submenu-name "*Libraries*"
  6377. "label of Libraries submenu in imenu")
  6378. (defun spice-imenu-init ()
  6379. "initialize imenu generic expression and pass to imenu"
  6380. (setq spice-imenu-generic-expression
  6381. (append
  6382. (list
  6383. (list spice-imenu-end-submenu-name
  6384. (concat
  6385. "^"
  6386. "\\.\\(end\\)\\>"
  6387. ) 1))
  6388. (when (spice-standard-p 'layla)
  6389. (list
  6390. (list "*Nets*" (concat
  6391. "^\\*?"
  6392. "[\.]\\(net\\)\\s-+"
  6393. "\\([a-z0-9]\\w*\\)\\>"
  6394. ) 2)
  6395. (list "*Ports*"
  6396. (concat
  6397. "^\\*?"
  6398. "\\.\\(port\\)\\s-+"
  6399. "\\([a-z0-9]\\w*\\)\\>"
  6400. ) 2)
  6401. (list "*Performances*"
  6402. (concat
  6403. "^\\*?"
  6404. "\\.\\(performance\\)\\s-+"
  6405. "\\([a-z]\\w*\\)\\>"
  6406. ) 2)) ; list
  6407. )
  6408. (list
  6409. (list
  6410. "*Misc*"
  6411. (concat
  6412. "^\\s-*\\.model\\s-+" spice-model-name spice-line-break
  6413. "\\s-+\\("
  6414. (regexp-opt spice-misc-model-type-names)
  6415. "\\)\\>" )
  6416. 1)
  6417. (list
  6418. "*Diodes*"
  6419. (concat "^\\s-*\\.model\\s-+" spice-model-name
  6420. spice-line-break "\\s-+d\\>")
  6421. 1)
  6422. (list
  6423. "*Bipolars*"
  6424. (concat "^\\s-*\\.model\\s-+" spice-model-name
  6425. spice-line-break "\\s-+\\(npn\\|pnp\\)\\>")
  6426. 1)
  6427. (list
  6428. "*Mosfets*"
  6429. (concat "^\\s-*\\.model\\s-+" spice-model-name
  6430. spice-line-break "\\s-+\\(n\\|p\\)mos\\>")
  6431. 1)
  6432. (list spice-imenu-libraries-submenu-name
  6433. (concat spice-library-regexp-start
  6434. spice-library-regexp-end)
  6435. 3)
  6436. (list
  6437. "*Analyses*"
  6438. (concat "^\\s-*\\.\\("
  6439. (regexp-opt spice-analyses)
  6440. "\\)\\>")
  6441. 1)
  6442. (list "*Sections*"
  6443. spice-section-headings-regexp 2)
  6444. (list nil
  6445. (concat
  6446. "^\\.\\(subckt\\s-+"
  6447. (when (spice-standard-p 'eldo)
  6448. "\\(lib\\s-+[^ \t\n]+\\s-+\\)?")
  6449. "\\|macro\\s-+\\)"
  6450. "\\([a-z]\\w*\\)\\>"
  6451. ) (if (spice-standard-p 'eldo) 3 2))
  6452. )
  6453. )))
  6454. ;; ======================================================================
  6455. ;; Support for compilation (simulation) - doesn't work 100% currently
  6456. ;; and probably never will ...
  6457. ;; ======================================================================
  6458. (defun spice-simulation-buffer-name-function (arg)
  6459. "Derives unique spice simulation buffer for simulator output"
  6460. (concat "*Spice-simulation-" (buffer-name) "*"))
  6461. (defun spice-get-simulator ()
  6462. "Make an educated guess on what simulator a user likely wants to use"
  6463. (if (and spice-simulator
  6464. (assoc spice-simulator spice-simulator-alist))
  6465. spice-simulator ;; is specified by user, take his choice
  6466. (if (spice-standard-p 'eldo) "Eldo" ;; eldo
  6467. (if (spice-standard-p 'hspice) "Hspice" ;; Hspice
  6468. "Spice3")))) ;; fallback Spice3
  6469. (defun spice-set-simulator-command ()
  6470. (interactive)
  6471. (setq compile-command
  6472. (let ((commands-alist spice-simulator-alist)
  6473. command)
  6474. (while commands-alist
  6475. (when (equal (spice-get-simulator) (nth 0 (car commands-alist)))
  6476. (setq command
  6477. (concat
  6478. (nth 1 (car commands-alist)) " "
  6479. spice-simulator-switches
  6480. (unless
  6481. (string-equal spice-simulator-switches "") " ")
  6482. (file-name-nondirectory (if buffer-file-name
  6483. buffer-file-name ""))
  6484. (unless
  6485. (string-equal (nth 2 (car commands-alist)) "") " ")
  6486. (nth 2 (car commands-alist))
  6487. )))
  6488. (setq commands-alist (cdr commands-alist)))
  6489. command)))
  6490. (defun spice-set-simulator (name)
  6491. (setq spice-simulator name)
  6492. (spice-set-simulator-command))
  6493. (require 'compile)
  6494. (defvar spice-compilation-error-regexp-alist nil)
  6495. (defvar spice-compilation-file-regexp-alist nil)
  6496. (defun spice-compile ()
  6497. "spice wrapper function for compile."
  6498. (interactive)
  6499. (spice-set-simulator-command)
  6500. (call-interactively 'compile nil)
  6501. )
  6502. (defun spice-compile-variables-init ()
  6503. "build variable lists."
  6504. (setq spice-compilation-error-regexp-alist
  6505. (let ((commands-alist spice-simulator-alist)
  6506. regexp-alist sublist)
  6507. (while commands-alist
  6508. (setq sublist (nth 3 (car commands-alist)))
  6509. (unless (equal "" (car sublist))
  6510. (setq regexp-alist
  6511. (cons (append
  6512. (list (nth 0 sublist)
  6513. (if (= 0 (nth 1 sublist))
  6514. (if spice-running-xemacs 9 nil)
  6515. (nth 1 sublist))
  6516. (if (numberp (nth 2 sublist))
  6517. (nth 2 sublist)
  6518. (if spice-running-xemacs 0
  6519. (nth 2 sublist))))
  6520. (list (nth 3 sublist))
  6521. (if (nth 4 sublist)
  6522. (if (stringp (nth 4 sublist))
  6523. (list (nth 4 sublist))
  6524. (list (eval (nth 4 sublist))))))
  6525. regexp-alist)))
  6526. (setq commands-alist (cdr commands-alist)))
  6527. regexp-alist))
  6528. ; (message "setting compilation file regexps command")
  6529. (setq spice-compilation-file-regexp-alist
  6530. (let ((commands-alist spice-simulator-alist)
  6531. regexp-alist)
  6532. (while commands-alist
  6533. (unless (equal "" (car (nth 4 (car commands-alist))))
  6534. (setq regexp-alist
  6535. (append regexp-alist
  6536. (list (nth 4 (car commands-alist))))))
  6537. (setq commands-alist (cdr commands-alist)))
  6538. regexp-alist))
  6539. )
  6540. (defun spice-compile-init ()
  6541. "Initialize for simulation(/compilation)."
  6542. ;;------------------------------------------------------------
  6543. ;; use Eldo/Hspice as compiler, on current buffer
  6544. (make-local-variable 'compile-command)
  6545. (make-local-variable 'compilation-read-command)
  6546. (make-local-variable 'compilation-buffer-name-function)
  6547. (make-local-variable 'compilation-error-regexp-alist)
  6548. (make-local-variable 'compilation-file-regexp-alist)
  6549. (setq compilation-read-command 't)
  6550. (setq compilation-buffer-name-function
  6551. 'spice-simulation-buffer-name-function)
  6552. ; (message "setting compilation error regexps command")
  6553. (setq compilation-error-regexp-alist spice-compilation-error-regexp-alist
  6554. compilation-file-regexp-alist spice-compilation-file-regexp-alist)
  6555. )
  6556. (defvar spice-column 1
  6557. "global variable to do column hack. Why ? Compile.el requires that
  6558. every error is 'special', ie. different from the previous one. This is
  6559. either the file is different, the line number is different or the column
  6560. number is different. Prob: the file is always the same, the simulator
  6561. guys never output the file name of the file that is being read, so that
  6562. one doesn't change; the line number can not be found either; the column
  6563. number is same problem; Solution: always take line number one, then take
  6564. the column number 1 or 2 alternatingly, remember previous value here !
  6565. This is ugly, I know, but it's the only way I could think of to find
  6566. the errors in the simulation buffer with compile.el")
  6567. (defun spice-linenum (f c)
  6568. ;(message (format "calling linenum fun '%s'" f))
  6569. (save-excursion
  6570. (set-buffer compilation-last-buffer)
  6571. ;(message (format "buffer '%s'" (buffer-name)))
  6572. )
  6573. (list (point-marker) f 1 (if (= spice-column 1)
  6574. (setq spice-column 2)
  6575. (setq spice-column 1))))
  6576. (defun spice-next-error (n)
  6577. "Move point to the next error in the compilation buffer.
  6578. Does NOT find the source line like \\[next-error] does, is defined
  6579. in spice-mode since many simulators don't output errors with source line
  6580. numbers included, so finding the error is still difficult."
  6581. (interactive "p")
  6582. (save-excursion
  6583. (let (prev-buffer)
  6584. (setq prev-buffer (buffer-name))
  6585. (pop-to-buffer compilation-last-buffer)
  6586. (compilation-next-error n)
  6587. (recenter)
  6588. (pop-to-buffer prev-buffer))))
  6589. (defun spice-previous-error (n)
  6590. "Move point to the previous error in the compilation buffer.
  6591. Does NOT find the source line like \\[next-error] does, is defined
  6592. in spice-mode since many simulators don't output errors with source line
  6593. numbers included, so finding the error is still difficult."
  6594. (interactive "p")
  6595. (save-excursion
  6596. (let (prev-buffer)
  6597. (setq prev-buffer (buffer-name))
  6598. (pop-to-buffer compilation-last-buffer)
  6599. (compilation-previous-error n)
  6600. (recenter)
  6601. (pop-to-buffer prev-buffer))))
  6602. ;;------------------------------------------------------------
  6603. ;; Waveform viewer support
  6604. ;;------------------------------------------------------------
  6605. ;; This is work in progress; (user) interface might change
  6606. (defun spice-waveform-buffer-name-function (arg)
  6607. "check running process"
  6608. (let ((name (if arg arg (buffer-name))))
  6609. (concat "*Spice-waveform-" name "*")))
  6610. (defun spice-set-waveform-viewer (name)
  6611. (setq spice-waveform-viewer name)
  6612. (spice-set-waveform-viewer-command))
  6613. (defun spice-get-waveform-viewer ()
  6614. "Make an educated guess on what waveform viewer a user likely would want"
  6615. (if (and spice-waveform-viewer
  6616. (assoc spice-waveform-viewer spice-waveform-viewer-alist))
  6617. spice-waveform-viewer ;; is specified by user, take his choice
  6618. (if (spice-standard-p 'eldo) "Xelga" ;; eldo's viewer is xelga
  6619. (if (spice-standard-p 'hspice) "Awaves" ;; Hspice's viewer is awaves
  6620. "Nutmeg")))) ;; fallback Spice3's viewer nutmeg ...
  6621. (defun spice-waveform-viewer-derive-filename (arg)
  6622. "Derive from the buffer file name the name of a derived file. If ARG is
  6623. a string, it is a suffix to replace the buffer's suffix, if ARG is a list
  6624. , , if ARG is a function, the function is called without arguments and it
  6625. should return the derived filename, if ARG is nil, nil is returned, if ARG
  6626. is t, the filename itself is returned unmodified."
  6627. (cond ((stringp arg)
  6628. (concat (file-name-sans-extension buffer-file-name) arg))
  6629. ((listp arg)
  6630. (let ((alist arg)
  6631. filename)
  6632. ;(message alist)
  6633. (while alist
  6634. (message (concat (file-name-sans-extension buffer-file-name) (car alist)))
  6635. (setq
  6636. filename
  6637. (concat (file-name-sans-extension buffer-file-name) (car alist)))
  6638. (setq alist (cdr alist)))
  6639. filename))
  6640. ((functionp arg)
  6641. (funcall arg))
  6642. (nil
  6643. nil) ;; nil if nil ...
  6644. (t
  6645. buffer-file-name) ;; fallback if t ...
  6646. )
  6647. )
  6648. (defvar spice-waveform-viewer-command ""
  6649. "variable containing buffer local waveform viewer command")
  6650. (defvar spice-waveform-viewer-filename nil
  6651. "variable filename field of waveform viewer structure")
  6652. (defvar spice-waveform-viewer-alist-entry nil
  6653. "variable holding selected entry of waveform viewer")
  6654. (defvar spice-waveform-viewer-read-command t
  6655. "variable containing boolean indicating reading of buffer local waveform viewer command")
  6656. (defvar spice-after-start-process-function nil
  6657. "variable containing after start process function")
  6658. (defun spice-set-waveform-viewer-command ()
  6659. (interactive)
  6660. (setq spice-waveform-viewer-alist-entry nil)
  6661. (let ((commands-alist spice-waveform-viewer-alist))
  6662. (while commands-alist
  6663. (when (equal (spice-get-waveform-viewer)
  6664. (nth 0 (car commands-alist)))
  6665. (setq spice-waveform-viewer-alist-entry (car commands-alist))
  6666. )
  6667. (setq commands-alist (cdr commands-alist)))))
  6668. (defun spice-waveform-viewer-init ()
  6669. "Initialize for waveform viewer."
  6670. ;;------------------------------------------------------------
  6671. (make-local-variable 'spice-waveform-viewer-command)
  6672. (make-local-variable 'spice-waveform-viewer-read-command)
  6673. (make-local-variable 'spice-waveform-viewer-filename)
  6674. (make-local-variable 'spice-waveform-viewer-alist-entry)
  6675. (make-local-variable 'spice-after-start-process-function)
  6676. (setq spice-waveform-viewer-read-command 't)
  6677. (spice-set-waveform-viewer-command))
  6678. (defun spice-run-waveform-viewer ()
  6679. "run the waveform viewer if it is not yet running."
  6680. (interactive)
  6681. (if (not buffer-file-name)
  6682. (message "Can not run waveform viewer on unsaved file-less buffers.")
  6683. (let (name command file)
  6684. (setq name (nth 0 spice-waveform-viewer-alist-entry)
  6685. command (concat (nth 1 spice-waveform-viewer-alist-entry)
  6686. " "
  6687. (nth 2 spice-waveform-viewer-alist-entry)
  6688. " "
  6689. (spice-waveform-viewer-derive-filename
  6690. (nth 4 spice-waveform-viewer-alist-entry)))
  6691. file (buffer-name))
  6692. (spice-process-check file)
  6693. (message "Starting waveform viewer %s" name)
  6694. (funcall (nth 3 spice-waveform-viewer-alist-entry) name command file))
  6695. ) ; if (else part)
  6696. )
  6697. (defun spice-master-directory ()
  6698. "Directory of master file."
  6699. (abbreviate-file-name
  6700. (expand-file-name
  6701. (file-name-directory (buffer-file-name)))))
  6702. (defun spice-run-silent (name command file)
  6703. "Start process with (optional) second argument."
  6704. (let ((dir (spice-master-directory)))
  6705. (set-buffer (get-buffer-create "*spice silent*"))
  6706. (erase-buffer)
  6707. (if dir (cd dir))
  6708. ; (message "cd to %s" dir)
  6709. (let ((process (start-process (concat name " silent")
  6710. (current-buffer) ; can be nil
  6711. spice-shell
  6712. spice-shell-command-option
  6713. command)))
  6714. (message "started %s" command)
  6715. (if spice-after-start-process-function
  6716. (funcall spice-after-start-process-function process))
  6717. (process-query-on-exit-flag process))))
  6718. (defun spice-run-interactive (name command file)
  6719. "Run waveform viewer interactively.
  6720. Run command in a buffer (in comint-shell-mode) so that it accepts user
  6721. interaction."
  6722. (require 'comint)
  6723. (let (; (default spice-command-default)
  6724. (buffer (spice-waveform-buffer-name-function file))
  6725. (process nil)
  6726. (dir (spice-master-directory)))
  6727. (spice-process-check file) ; Check that no process is running
  6728. ; (setq spice-command-buffer (current-buffer))
  6729. (with-output-to-temp-buffer buffer)
  6730. (set-buffer buffer)
  6731. (setq buffer-read-only nil)
  6732. (if dir (cd dir))
  6733. (insert "Running `" name "' on `" file "' with ``" command "''\n")
  6734. (comint-exec buffer name spice-shell nil
  6735. (list spice-shell-command-option command))
  6736. (comint-mode)
  6737. (setq mode-name name)
  6738. ; (setq spice-command-default default)
  6739. (setq process (get-buffer-process buffer))
  6740. (if spice-after-start-process-function
  6741. (funcall spice-after-start-process-function process))
  6742. ; (spice-command-mode-line process) ; mode line setting
  6743. ; (set-process-sentinel process 'spice-command-sentinel)
  6744. (set-marker (process-mark process) (point-max))
  6745. ;;; (setq compilation-in-progress (cons process compilation-in-progress))
  6746. ; (spice-parse-reset)
  6747. ; (setq spice-parse-function 'spice-parse-spice)
  6748. ; (setq spice-sentinel-function 'spice-LaTeX-sentinel)
  6749. ))
  6750. (defun spice-command-mode-line (process)
  6751. "Format the mode line for a buffer containing output from PROCESS."
  6752. (setq mode-line-process (concat ": "
  6753. (symbol-name (process-status process))))
  6754. (set-buffer-modified-p (buffer-modified-p)))
  6755. (defun spice-process-check (name)
  6756. "Check if a process for the spice deck NAME already exist.
  6757. If so, give the user the choice of aborting the process or the current
  6758. command."
  6759. (let ((process (get-buffer-process
  6760. (spice-waveform-buffer-name-function name))))
  6761. ; (message "checking %s for running process" (spice-waveform-buffer-name-function name))
  6762. (cond ((null process))
  6763. ((not (eq (process-status process) 'run)))
  6764. ((yes-or-no-p (concat "Process `"
  6765. (process-name process)
  6766. "' for deck `"
  6767. name
  6768. "' running, kill it? "))
  6769. (delete-process process))
  6770. (t
  6771. (error "Cannot have two processes for the spice deck")))))
  6772. ;; ---- setting commands ?
  6773. (defun spice-set-command ()
  6774. "Sets both simulator an waveform viewer commands for current buffer."
  6775. (interactive)
  6776. (spice-set-simulator-command)
  6777. (spice-set-waveform-viewer-command)
  6778. )
  6779. ;;------------------------------------------------------------
  6780. ;; File initialization support, code taken from eldo-mode and
  6781. ;; modified/extended
  6782. ;;------------------------------------------------------------
  6783. ;; initialize empty file:
  6784. (defun spice-initialize-empty-file ()
  6785. "Create a standard template for a new/empty file.
  6786. This is the default initialization function. If the user has specified
  6787. an initialization function, by setting
  6788. `spice-initialize-file-function', the user-specified function is
  6789. called instead. This function first checks for the template file
  6790. specified in `spice-initialization-file' which is inserted and a default
  6791. changelog entry is added. If this file isn't readable, a default
  6792. template is inserted depending on the submode (eldo, hspice or layla)
  6793. that has been selected."
  6794. (interactive "*") ; read-only check
  6795. (if (file-readable-p spice-initialize-template-file) ;; template file
  6796. (insert-file-contents spice-initialize-template-file)
  6797. ;; this has been taken from eldo-mode and thus only applies if
  6798. ;; eldo is selected
  6799. (if (spice-standard-p 'eldo)
  6800. (progn
  6801. (insert
  6802. (concat "# " (buffer-name) " "
  6803. "\n.notrc\n.nocom"
  6804. "\n\n"
  6805. spice-default-header
  6806. "\n\n"))
  6807. (spice-add-section "LIBRARIES")
  6808. (insert "\n\n\n")
  6809. (spice-add-section "SIMULATION OPTIONS")
  6810. (insert
  6811. (concat "\n\n"
  6812. ".options STAT=1 SIMUDIV=10 !Status reports\n"
  6813. ".options noascii nomod \n"
  6814. ".options eps=1e-7 itol=1e-6 gmin=1e-16 analog \n"
  6815. ".options nobound_phase"
  6816. ".width out=80 \n"
  6817. ".temp=27 \n"
  6818. "\n\n\n"))
  6819. (spice-add-section "SUPPLIES/REFERENCES")
  6820. (insert "\n\n.END\n\n\n\n")
  6821. (spice-add-section "Changelog")
  6822. (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
  6823. )
  6824. (if (spice-standard-p 'hspice) ;; hspice specific options
  6825. (progn
  6826. (insert
  6827. (concat "* " (buffer-name) " "
  6828. "\n\n"
  6829. spice-default-header
  6830. "\n\n"))
  6831. (spice-add-section "LIBRARIES")
  6832. (insert "\n\n\n")
  6833. (spice-add-section "SIMULATION OPTIONS")
  6834. (insert
  6835. (concat "\n\n"
  6836. ".options nomod nopage opts \n"
  6837. ".options itl1=5000 itl2=2500 itl3=20 itl4=20 itl5=0 \n"
  6838. ".options numdgt=10 $ print 10 digits in output \n"
  6839. ".width out=80 \n"
  6840. ".temp=27 \n"
  6841. "\n\n\n"))
  6842. (spice-add-section "SUPPLIES/REFERENCES")
  6843. (insert "\n\n.end\n\n\n\n")
  6844. (spice-add-section "Changelog")
  6845. (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
  6846. )
  6847. (if (spice-standard-p 'layla) ;; layla specific options
  6848. (progn
  6849. (insert
  6850. (concat "* " (buffer-name) " "
  6851. "\n"
  6852. spice-default-header
  6853. "\n\n"))
  6854. (spice-add-section "MAIN CIRCUIT")
  6855. (insert "\n\n\n")
  6856. (spice-add-section "PORTS")
  6857. (insert "\n\n.end\n\n\n\n")
  6858. (spice-add-section "Changelog")
  6859. (insert "\n\n*** Local Variables:\n*** mode:spice\n*** End:\n")
  6860. )
  6861. )
  6862. )
  6863. )
  6864. )
  6865. (spice-add-changelog-entry "File created") ; in any case
  6866. )
  6867. ;;------------------------------------------------------------
  6868. ;; Hacks to implement the find function menu bar for spice-mode
  6869. ;; subckts/models Fortunately spice-mode only provides one means of
  6870. ;; abstraction so the parsing is very easy. (only available in
  6871. ;; XEmacs, remove this and spice-mode entry when compiling for emacs
  6872. ;; to avoid warnings) This code has been taken from eldo-mode.el
  6873. ;; (E. Rouat)
  6874. ;;------------------------------------------------------------
  6875. (eval-and-compile
  6876. (when (fboundp 'function-menu)
  6877. (require 'func-menu)
  6878. (defconst fume-function-name-regexp-spice
  6879. "^\\.\\(subckt\\|model\\|macro\\)\\s-+\\([a-z]\\w*\\)"
  6880. "Expression to parse Spice subcircuit and model names.")
  6881. (defun fume-find-next-spice-function-name (buffer)
  6882. "Searches for the next spice subcircuit name in BUFFER."
  6883. (set-buffer buffer)
  6884. (setq case-fold-search 't) ;;otherwise func-menu bombs....
  6885. (if (re-search-forward fume-function-name-regexp nil t)
  6886. (let ((beg (match-beginning 2))
  6887. (end (match-end 2)))
  6888. (cons (buffer-substring beg end) beg))))
  6889. ) ; when
  6890. )
  6891. (defun spice-func-menu-init ()
  6892. "Initialize function menu." ; buffer local stuff
  6893. ;; hook in the spice-mode mode regular expression above into the
  6894. ;; association list of regexps used by the function menu generator
  6895. (setq fume-function-name-regexp-alist
  6896. (purecopy
  6897. (append
  6898. fume-function-name-regexp-alist
  6899. (list
  6900. '(spice-mode . fume-function-name-regexp-spice)))))
  6901. ;; hook in the search method above into the association list used by the
  6902. ;; function menu generating code
  6903. (setq fume-find-function-name-method-alist
  6904. (purecopy
  6905. (append
  6906. fume-find-function-name-method-alist
  6907. (list '(spice-mode . fume-find-next-spice-function-name)))))
  6908. ;; Now activate func-menu - I hope that these settings don't
  6909. ;; interfere with users settings
  6910. (make-local-variable 'fume-menubar-menu-name)
  6911. (make-local-variable 'fume-buffer-name)
  6912. (make-local-variable 'fume-index-method)
  6913. (setq fume-menubar-menu-name "Subckts"
  6914. fume-buffer-name "*Subcircuits List*"
  6915. fume-index-method 2)
  6916. ;; (make-local-hook 'find-file-hooks) not available since Emacs 21.1
  6917. (add-hook 'find-file-hooks 'fume-add-menubar-entry)
  6918. (define-key global-map '(shift button2) 'fume-mouse-function-goto)
  6919. (fume-add-menubar-entry))
  6920. ;; ======================================================================
  6921. ;; Support for .subckt search !?
  6922. ;; ======================================================================
  6923. ;; What about searching from an included file, how to find the
  6924. ;; top-level then ? think I've cracked it: .end identifies top-level
  6925. ;; spice files so remember the last one to start search from if the
  6926. ;; search fails
  6927. ;; BUG: doesn't handle nested .subckt defs ! Reports first found match...
  6928. (defun spice-search-included-files (subckt)
  6929. (save-excursion
  6930. (let ((mrk nil))
  6931. (goto-char (point-min))
  6932. (while (and
  6933. (search-forward-regexp spice-library-regexp-start
  6934. (point-max) t)
  6935. (not mrk))
  6936. (beginning-of-line)
  6937. (if (looking-at (concat spice-library-regexp-start
  6938. spice-library-regexp-end))
  6939. (if (file-readable-p (substitute-in-file-name (match-string 3)))
  6940. (setq mrk
  6941. (spice-search-file-for-subckt
  6942. (substitute-in-file-name (match-string 3)) subckt))
  6943. (message "File '%s' isn't readable" (match-string 3))) ; if
  6944. ) ; if
  6945. (end-of-line)) ; while
  6946. mrk) ; let
  6947. ) ; save-
  6948. )
  6949. (defvar spice-subckt-search-master-filename nil
  6950. "latest top-level (identified by .end in file) .cir file used in
  6951. subcircuit searches.")
  6952. (defun spice-search-file-for-subckt (filename subckt)
  6953. "Searches a file for a .subckt definition. Remembers
  6954. `spice-subckt-search-master-filename' for future subckt searches."
  6955. (save-excursion
  6956. (set-buffer (find-file-noselect filename))
  6957. (condition-case nil
  6958. (let ((index-alist (imenu--make-index-alist t))
  6959. (mrk nil))
  6960. (if (assoc spice-imenu-end-submenu-name index-alist)
  6961. (setq spice-subckt-search-master-filename buffer-file-name))
  6962. (setq mrk (assoc-ignore-case subckt index-alist))
  6963. (if mrk mrk
  6964. (spice-search-included-files subckt))
  6965. )
  6966. (error nil))))
  6967. ;; History of subckt searches.
  6968. (defvar spice-subckt-search-history nil
  6969. "History of subcircuit searches.")
  6970. (defun spice-guess-subckt-name ()
  6971. "guesses name of subckt from context, multiple lines"
  6972. (let ((subckt "")) ; (current-word)
  6973. (save-excursion
  6974. (beginning-of-line)
  6975. (while (and (looking-at "^+")
  6976. (not (forward-line -1))))
  6977. (if (looking-at spice-xinstance-regexp)
  6978. (progn
  6979. ;; (message "Could it be '%s' ?" (match-string 3))
  6980. (setq subckt (match-string 5))
  6981. (remove-text-properties 0 (length subckt) '(face nil) subckt)
  6982. ))) ; save-
  6983. subckt))
  6984. (defun spice-visit-subckt-def (mrk)
  6985. "Helper function visiting buffer and mark specified."
  6986. (if (eq (marker-buffer (cdr mrk))
  6987. (current-buffer))
  6988. (if (or
  6989. spice-running-xemacs ; then push mark always
  6990. (not (and transient-mark-mode mark-active))) ; emacs, check if active region
  6991. (push-mark)))
  6992. (pop-to-buffer (marker-buffer (cdr mrk)) t)
  6993. (widen)
  6994. (goto-char (cdr mrk)))
  6995. (defun spice-search-subckt (subckt-args)
  6996. "Searches for the .subckt definition with name under cursor, or any other
  6997. name specified by user. Be CAREFUL using this command. Depending on the
  6998. structure of your spice decks this might find wrong definitions. To AVOID any
  6999. such problems always start searching from the TOP-LEVEL spice deck (ie. the
  7000. file that is supplied to the simulator). If you start searching from an
  7001. included file, potentially the definition is not found or it is found starting
  7002. from ANOTHER top-level file (which could result in a completely wrong
  7003. search result).
  7004. This search command places the mark if search result is in the same file,
  7005. return to the search start position by using C-u C-<SPC> or C-u C-@."
  7006. (interactive
  7007. (list (let* ((default-subckt (spice-guess-subckt-name))
  7008. (input (read-from-minibuffer
  7009. "Subcircuit name: "
  7010. default-subckt nil nil
  7011. spice-subckt-search-history)))
  7012. (if (string= input "")
  7013. (if (string= default-subckt "")
  7014. (error "No subckt args given")
  7015. default-subckt)
  7016. input))))
  7017. ;(message (format "name of subckt is %s" subckt-args))
  7018. (let (mrk)
  7019. (setq mrk (spice-search-file-for-subckt buffer-file-name subckt-args))
  7020. ; (message (format "mark is %s" (cdr mrk)))
  7021. (if (and (cdr mrk) (markerp (cdr mrk)))
  7022. (spice-visit-subckt-def mrk)
  7023. (progn
  7024. (message "Couldn't find subcircuit '%s', retrying search in top-level file"
  7025. subckt-args))) ; if
  7026. (if (and (not mrk)
  7027. spice-subckt-search-master-filename)
  7028. (progn
  7029. (setq mrk (spice-search-file-for-subckt
  7030. spice-subckt-search-master-filename subckt-args))
  7031. (if (and (cdr mrk) (markerp (cdr mrk)))
  7032. (progn
  7033. (spice-visit-subckt-def mrk)
  7034. (message "Used top-level file '%s' to find '%s'"
  7035. spice-subckt-search-master-filename subckt-args)
  7036. )
  7037. (progn
  7038. (message
  7039. (format "Couldn't find subcircuit '%s', retry search in top-level file"
  7040. subckt-args))
  7041. ))))))
  7042. ;; ======================================================================
  7043. ;; loading of include files of current deck.
  7044. (defun spice-load-include-files (&optional non-recursive)
  7045. "Loads all files that are included in this deck. Makes it more easy
  7046. to load a project. This loading occurs recursively. Files already
  7047. loaded are not reloaded or scanned for .includes. This function is
  7048. only guaranteed to work when all included files are not already loaded."
  7049. (interactive)
  7050. (let ((index-alist (imenu--make-index-alist t))
  7051. l filename)
  7052. (if (setq l (cdr (assoc spice-imenu-libraries-submenu-name index-alist))) ;; file contains include files/libraries
  7053. (while l
  7054. (setq filename (expand-file-name
  7055. (substitute-in-file-name (car (car l)))))
  7056. ;;(message "Trying to load %s" filename)
  7057. (if (and (file-readable-p filename)
  7058. (not
  7059. (assoc filename ;; already loaded
  7060. (mapcar
  7061. (lambda (buffer)
  7062. (cons (buffer-file-name buffer) buffer))
  7063. (buffer-list)))))
  7064. (save-excursion
  7065. ;; (message "filename is %s" filename)
  7066. (set-buffer (find-file-noselect filename))
  7067. ;; (spice-mode) ? ref. discussion Manu
  7068. (unless (or non-recursive
  7069. (not (eq major-mode 'spice-mode)))
  7070. (spice-load-include-files))))
  7071. (setq l (cdr l))))))
  7072. ;; ======================================================================
  7073. ;; unloading of spice files except current deck.
  7074. (defun spice-unload-other-decks ()
  7075. "Kills all other spice files except current one. Makes it easy to
  7076. unload a lot of spice files without restarting emacs."
  7077. (interactive)
  7078. (save-excursion
  7079. (let ((current (current-buffer)))
  7080. (mapcar
  7081. (lambda (buffer)
  7082. (set-buffer buffer)
  7083. (if (and (eq major-mode 'spice-mode)
  7084. (not (eq current buffer)))
  7085. (progn
  7086. (message "Killing %s" buffer)
  7087. (kill-buffer buffer))))
  7088. (buffer-list)))))
  7089. ;; ======================================================================
  7090. ;; folding for commented out regions ...
  7091. ;;; taken from and adapted:
  7092. ;;; Filename: foldingo.el
  7093. ;;; Author: Christian Queinnec <Christian.Queinnec@lip6.fr>
  7094. ;; This is work in progress; (user) interface might change
  7095. (defvar spice-some-comment-regions-are-hidden nil
  7096. "Keeps track if some comment regions are hidden.")
  7097. (make-variable-buffer-local 'spice-some-comment-regions-are-hidden)
  7098. (defvar spice-last-hide-comment-regions-tick nil
  7099. "Keeps track when last time comment hiding was called.")
  7100. (make-variable-buffer-local 'spice-last-hide-comment-regions-tick)
  7101. (defun spice-hide-init ()
  7102. "Initialize buffer local variables to make hiding of spice regions
  7103. effective"
  7104. ;; trick to make a comment-start/padding dependent regexp:
  7105. (custom-initialize-reset 'spice-hide-line-prefix
  7106. (car (get 'spice-hide-line-prefix
  7107. 'standard-value)))
  7108. ;; make sure we have invisibility property working, local for a buffer
  7109. (if (fboundp 'add-to-invisibility-spec)
  7110. (add-to-invisibility-spec 'spice-mode))
  7111. ;; (remove-from-invisibility-spec '(spice-mode . t))
  7112. ;; local for buffers:
  7113. (set (make-local-variable 'line-move-ignore-invisible) t)
  7114. (if spice-auto-hide-comments
  7115. (spice-hide-all-comments))
  7116. )
  7117. (defun spice-hide (from to)
  7118. "Not supported, don't use this."
  7119. (interactive "*r")
  7120. (spice-hide-region from to t))
  7121. (defun spice-unhide (from to)
  7122. "Not supported, don't use this."
  7123. (interactive "*r")
  7124. (spice-hide-region from to nil))
  7125. (defun spice-hide-all-comments-p ()
  7126. "Checks if there are comments that can be hidden...; assumes that if
  7127. the user edited the file, new comments might have been created and
  7128. thus hide all comments must be activated. This is not the best
  7129. criterion, but it is safe."
  7130. ;; (interactive)
  7131. ;; (message "buffer tick is %s, last hide comment is %s"
  7132. ;; (buffer-modified-tick) spice-last-hide-comment-regions-tick)
  7133. (if (and
  7134. spice-last-hide-comment-regions-tick ; can be nil
  7135. (= spice-last-hide-comment-regions-tick (buffer-modified-tick)))
  7136. nil t))
  7137. (defun spice-hide-all-comments ()
  7138. "Hides all commented out regions in the current spice deck. Allows
  7139. to get a better overview of the deck if many lines are commented out.
  7140. It relies on having all regions being commented out using the
  7141. \"Comment Region\" menu entry that uses `comment-region'. The regexp
  7142. used to match comment lines, `spice-hide-line-prefix', might identify
  7143. standard spice comment lines used for documentation. To avoid
  7144. problems, make sure documentation is not part of comments. For
  7145. instance by using the doc starters available in the spice languages,
  7146. or by making sure they are different from the comment lines generated
  7147. with the menu entry, by placing two *'s when the default comment is
  7148. only one *. If you want to unhide all the hidden comment lines, use
  7149. `spice-unhide-all-comments'."
  7150. (interactive)
  7151. (spice-unhide-all-comments)
  7152. (setq spice-last-hide-comment-regions-tick (buffer-modified-tick))
  7153. (save-excursion
  7154. (goto-char (point-min))
  7155. ;; (message "beginning of buffer reached %s" (point))
  7156. (forward-line)
  7157. (while (search-forward-regexp (concat "^" spice-hide-line-prefix)
  7158. (point-max) t)
  7159. (beginning-of-line)
  7160. ;; (message "reached %s" (point))
  7161. (let ((beg (point))
  7162. end
  7163. lines)
  7164. ;; (message "found start of regexp %s" (point))
  7165. (setq lines (forward-line))
  7166. ;; (message "%s left" lines)
  7167. ;; the empty lines following commented lines are also hidden
  7168. (while (and (looking-at (concat "^\\(" spice-hide-line-prefix "\\|[ ]*$\\)"))
  7169. (= (setq lines (forward-line)) 0))
  7170. ;; (message "%s left" lines)
  7171. )
  7172. (setq end (point))
  7173. (spice-hide-region beg end t))))
  7174. (set-spice-name)
  7175. )
  7176. (defun spice-unhide-all-comments ()
  7177. "Unhides all hidden comment regions."
  7178. (interactive)
  7179. (setq spice-some-comment-regions-are-hidden nil)
  7180. (setq spice-last-hide-comment-regions-tick nil)
  7181. (spice-hide-region (point-min) (point-max) nil)
  7182. (set-spice-name)) ;; update mode-line
  7183. (defun spice-hide-region (from to flag)
  7184. "Hides or shows lines from FROM to TO, according to FLAG. If FLAG
  7185. is nil then the text is shown, while if FLAG is t the text is hidden."
  7186. (let ((inhibit-read-only t))
  7187. (save-excursion
  7188. (goto-char from)
  7189. ; (foldingo-discard-overlays (point) to 'invisible 'spice-comment)
  7190. (spice-discard-overlays from to 'spice-comment)
  7191. (if flag
  7192. (let ((overlay (make-overlay (point) to)))
  7193. (spice-make-overlay-hidden overlay))))))
  7194. (defun spice-make-overlay-hidden (overlay)
  7195. ;; Make overlay hidden and intangible.
  7196. ;; (overlay-put overlay 'intangible t)
  7197. (overlay-put overlay 'invisible 'spice-mode)
  7198. (overlay-put overlay 'spice-comment t)
  7199. (setq spice-some-comment-regions-are-hidden t)
  7200. ;; (overlay-put overlay 'intangible t)
  7201. )
  7202. (defun spice-discard-overlays (from to prop)
  7203. "discards overlays in region FROM to TO that have property PROP set."
  7204. (let ((inhibit-read-only t))
  7205. (save-excursion
  7206. (goto-char from)
  7207. (while (< (point) to)
  7208. (let ((overlays (overlays-at (point))))
  7209. (while overlays
  7210. (let ((o (car overlays)))
  7211. (if (overlay-get o prop)
  7212. (delete-overlay o)))
  7213. (setq overlays (cdr overlays))))
  7214. (goto-char (next-overlay-change (point)))))))
  7215. ;; ======================================================================
  7216. ;; utility spice-mode-output functions
  7217. (defun spice-check-output-mode ()
  7218. "Check if current buffer is output file and return symbol or NIL."
  7219. (save-excursion
  7220. (goto-char (point-min))
  7221. (if (looking-at "1\\*\\*\\*\\*\\*\\*\\*") ; eldo
  7222. 'eldo
  7223. (if (or (looking-at "Using: ")
  7224. (looking-at " \\*\\*\\*\\*\\*\\* Star-HSPICE")) ; hspice
  7225. 'hspice
  7226. nil))))
  7227. (defun spice-output-p ()
  7228. "Check if current buffer is output file."
  7229. (interactive)
  7230. (if spice-output-local t nil))
  7231. (defconst spice-output-sections-regexp
  7232. (concat
  7233. "^"
  7234. "\\(0\\*\\*\\*\\*\\| \\*\\*\\*\\*\\*\\*\\) *"
  7235. "\\( [a-z0-9]\\w*\\(\\s-+\\w+\\)* \\)\\s-+\\(t[a-z]*\\) ?=.*$")
  7236. "Regexp identifying spice output headers (both hspice and eldo).")
  7237. (defvar spice-output-font-lock-keywords
  7238. (list
  7239. (list spice-output-sections-regexp
  7240. '(1 font-lock-comment-face)
  7241. '(2 spice-title-face)
  7242. (list 4 spice-constant-face))
  7243. (list "^[0-1] ?\\*.*$" 0 font-lock-comment-face)
  7244. (list "^ \\(\\*\\*\\*\\*\\*?\\) \\(.*\\)$"
  7245. '(1 font-lock-comment-face)
  7246. '(2 font-lock-type-face))
  7247. (list "^\\(FATAL \\)?ERROR.+$" 0 'font-lock-warning-face) ; eldo errors
  7248. (list "^\\s-*\\(..?error..?[: ]\\).+$" 0 'font-lock-warning-face) ; hspice errors
  7249. )
  7250. "List of regexps for font-lock in output mode."
  7251. )
  7252. (defun spice-mode-output ()
  7253. "Spice major mode start up function for spice output files. Experimental ;)"
  7254. (setq buffer-read-only t) ; don't want to edit output files, do we
  7255. ; common mistake in hspice output files!
  7256. ;; use local keymap (for keys and menu)
  7257. (use-local-map spice-output-mode-map)
  7258. ;; set menu for local buffer
  7259. (easy-menu-add spice-menu-list) ; for XEmacs
  7260. (easy-menu-define spice-output-menu spice-output-mode-map
  7261. "Menu keymap for Spice Output Mode." spice-output-menu-list)
  7262. ;; font-lock local start-up
  7263. (set (make-local-variable 'font-lock-defaults)
  7264. (list 'spice-output-font-lock-keywords
  7265. nil t (list (cons ?\" "w")))) ; nil, t (do multiline
  7266. ; comments)
  7267. ;; imenu buffer local init
  7268. (set (make-local-variable 'imenu-case-fold-search) t)
  7269. (set (make-local-variable 'imenu-generic-expression)
  7270. (list (list "*Errors*"
  7271. "^\\s-*\\(\\(..?error..?[: ]\\|\\(FATAL \\)?ERROR\\).+$\\)"
  7272. 1)
  7273. (list nil ;; "*Sections*"
  7274. spice-output-sections-regexp
  7275. 2)))
  7276. )
  7277. (defun spice-output-filename ()
  7278. "Determines output filename of current spice deck."
  7279. (interactive)
  7280. (let ((filename nil)
  7281. (l spice-output-filename-alist))
  7282. (while l
  7283. (if (spice-standard-p (car (car l)))
  7284. (progn
  7285. (setq filename (eval (car (cdr (car l)))))
  7286. ;; (message "Checking filename %s" filename)
  7287. (if (file-readable-p filename)
  7288. (setq l nil)
  7289. (setq filename nil))))
  7290. (setq l (cdr l)))
  7291. filename))
  7292. (defun spice-output-file-p ()
  7293. "Checks if an output file is available for current spice deck."
  7294. (interactive)
  7295. (and (not spice-output-local)
  7296. (buffer-file-name)
  7297. (spice-output-filename)))
  7298. (defun spice-load-output-file-internal (filename)
  7299. "Loads output file into emacs and sets major mode"
  7300. (interactive)
  7301. (if (and
  7302. (stringp filename)
  7303. (file-readable-p filename))
  7304. (progn
  7305. (find-file-other-window filename)
  7306. (spice-mode))))
  7307. (defun spice-load-output-file ()
  7308. "Loads output file into spice, calls `spice-load-output-file-internal'
  7309. to do the actual work, this is called from the menu or key binding"
  7310. (interactive)
  7311. (let (filename)
  7312. (setq filename (spice-output-filename))
  7313. (spice-load-output-file-internal filename)))
  7314. ;; ======================================================================
  7315. ;; .guess statement auxiliary functions (eldo !)
  7316. (defvar spice-guess-nodeset-statements nil
  7317. "holds temp .guess/nodeset statements")
  7318. (defun spice-derive-guess-nodeset-statements (from to)
  7319. "Derives .guess/nodeset statements from DC operating point
  7320. lines. This implements the hspice functionality of .ic0 files for
  7321. eldo..."
  7322. (save-excursion
  7323. (let ( ;; (count 0)
  7324. m1)
  7325. (goto-char (max from to))
  7326. (setq m1 (make-marker))
  7327. (set-marker m1 (point))
  7328. (goto-char (min from to))
  7329. (while (re-search-forward "^\\s-*\\(\\S-+\\)\\s-+\\([-0-9\.E+]+\\)"
  7330. m1 t)
  7331. (progn
  7332. ;;(message "Inserting .guess...(%s)" (make-string (incf count) ?.))
  7333. ;;(beginning-of-line)
  7334. ;;(insert ".guess V(" (match-string 1) ") = " (match-string 2) "\n*")
  7335. (setq spice-guess-nodeset-statements
  7336. (append spice-guess-nodeset-statements
  7337. (list (concat " V("
  7338. (spice-match-string-no-properties 1)
  7339. ") = "
  7340. (spice-match-string-no-properties 2)))
  7341. ))
  7342. )))))
  7343. (defun spice-create-guess-nodeset-file (str)
  7344. "Creates a <buffer-file-name>_guess/nodeset.cir file from node
  7345. voltage pairs in the current output file."
  7346. (interactive)
  7347. (setq spice-guess-nodeset-statements nil)
  7348. (let (from to outbuf stats filename)
  7349. (setq filename (file-name-nondirectory buffer-file-name))
  7350. (save-excursion
  7351. (goto-char (point-min))
  7352. (setq from (re-search-forward "^\\s-+NODE\\s-+VOLTAGE\\s-*$" (point-max) t))
  7353. (if from
  7354. (setq to (re-search-forward "^$" (point-max) t)))
  7355. (if (and from to)
  7356. (spice-derive-guess-nodeset-statements from to)))
  7357. (if (not spice-guess-nodeset-statements)
  7358. (message "Didn't find 'node -- voltage' pairs in output file...")
  7359. (setq outbuf
  7360. (find-file-noselect (concat
  7361. (file-name-sans-extension buffer-file-name)
  7362. "_" str ".cir")))
  7363. (switch-to-buffer-other-window outbuf)
  7364. (erase-buffer)
  7365. (insert "* ." str " statements derived from " filename " ["
  7366. (format-time-string "%b %d %Y") " " (format-time-string "%T")
  7367. "]\n\n")
  7368. (setq stats spice-guess-nodeset-statements)
  7369. (while stats
  7370. (insert ".")
  7371. (insert str)
  7372. (insert " ")
  7373. (insert (car stats))
  7374. (insert "\n")
  7375. (setq stats (cdr stats)))
  7376. (insert "\n\n* ." str " statements derived "
  7377. (format-time-string "%b %d %Y") " "
  7378. (format-time-string "%T") "\n\n")
  7379. (save-buffer)
  7380. (goto-char (point-min))
  7381. ) ; when
  7382. ) ; let
  7383. )
  7384. (defun spice-replace-with-guess-statements (from to)
  7385. "replace with .guess statements."
  7386. (interactive "*r")
  7387. (spice-replace-with-guess-nodeset-statements "guess" from to))
  7388. (defun spice-replace-with-nodeset-statements (from to)
  7389. "replace with .nodeset statements."
  7390. (interactive "*r")
  7391. (spice-replace-with-guess-nodeset-statements "nodeset" from to))
  7392. (defun spice-replace-with-guess-nodeset-statements (str from to)
  7393. "Replaces selected region with .guess/nodeset statements."
  7394. (interactive)
  7395. (setq spice-guess-nodeset-statements nil)
  7396. (if (and from to)
  7397. (spice-derive-guess-nodeset-statements from to))
  7398. (if (not spice-guess-nodeset-statements)
  7399. (message "Didn't find any 'node -- voltage' pairs in region...")
  7400. (let (stats)
  7401. (kill-region from to)
  7402. (setq stats spice-guess-nodeset-statements)
  7403. (while stats
  7404. (insert ".")
  7405. (insert str)
  7406. (insert " ")
  7407. (insert (car stats))
  7408. (insert "\n")
  7409. (setq stats (cdr stats))))
  7410. ))
  7411. ;; ======================================================================
  7412. ;; fill-prefix related functions
  7413. (defvar spice-save-comment-line-break-function nil
  7414. "*Mode specific variable to save previous line break function in.")
  7415. (defun spice-comment-indent-new-line (&optional soft)
  7416. "Spice mode comment-indent-new-line function, used by `auto-fill'. Sets
  7417. `fill-prefix' depending on context: comment prefix if in comment with special
  7418. layla handling (!); \"!\" doc prefix if in hspice mode; \"$\" doc prefix
  7419. in eldo mode, otherwise uses \"+ \" prefix."
  7420. (interactive)
  7421. (let ((fpx fill-prefix) ; remember prefix
  7422. (end (point))) ; don't look beyond point for doc starters
  7423. (if (save-excursion
  7424. (beginning-of-line)
  7425. (or
  7426. (looking-at (concat "\\([" comment-start
  7427. (when (spice-standard-p 'layla)
  7428. spice-continuation-prefix)
  7429. (when (spice-standard-p 'hspice)
  7430. "$")
  7431. (when (spice-standard-p 'eldo)
  7432. "!")
  7433. "]+\\)"))
  7434. (and
  7435. (spice-standard-p 'hspice)
  7436. (re-search-forward "\\s-\\([$]\\)" end t))
  7437. (and
  7438. (spice-standard-p 'eldo)
  7439. (re-search-forward "\\s-\\([!]\\)" end t))))
  7440. (setq fill-prefix (concat (spice-match-string-no-properties 1) " "))
  7441. (setq fill-prefix (concat spice-continuation-prefix " ")))
  7442. ;(comment-indent-new-line) ;;call standard comment-indent-new-line function
  7443. (when spice-save-comment-line-break-function
  7444. (funcall spice-save-comment-line-break-function))
  7445. (setq fill-prefix fpx)))
  7446. (defun spice-fill-context-prefix () ; ???
  7447. "Calculates prefix from current position (move-to-left-margin), and
  7448. returns it. Non-comment paragraphs can also be filled correctly."
  7449. ;; (message "deriving fill prefix")
  7450. (let ((result
  7451. (if (or (looking-at (concat "\\([" comment-start
  7452. (when (spice-standard-p 'layla)
  7453. spice-continuation-prefix)
  7454. "]+\\)"))
  7455. (looking-at "\\([$!]+\\)"))
  7456. (concat (spice-match-string-no-properties 1) " ")
  7457. (concat spice-continuation-prefix " "))))
  7458. ;; (message (format "result is '%s'" result))
  7459. result))
  7460. (defun spice-delete-indentation (&optional arg)
  7461. "Wrapper for `delete-indentation', sets `fill-prefix' to adequate value."
  7462. (interactive "*P")
  7463. (let ((fillpfx fill-prefix))
  7464. (beginning-of-line)
  7465. (if arg (forward-line 1))
  7466. (if (looking-at "\\([+$!*]+\\)") ;; don't check submodes here ?
  7467. (setq fill-prefix (spice-match-string-no-properties 1)))
  7468. (delete-indentation)
  7469. (setq fill-prefix fillpfx)))
  7470. ;; ======================================================================
  7471. ;; msb fix (from cperl-mode.el)
  7472. (defvar spice-msb-fixed nil) ;; global variable keeping track of addition
  7473. (defun spice-msb-fix ()
  7474. "Adds \"Spice Decks\" entry in msb menu, assumes that msb is already loaded"
  7475. (setq spice-msb-fixed t)
  7476. (let* ((l (length msb-menu-cond))
  7477. (last (nth (1- l) msb-menu-cond))
  7478. (precdr (nthcdr (- l 2) msb-menu-cond)) ; cdr of this is last
  7479. (handle (1- (nth 1 last))))
  7480. (setcdr precdr (list
  7481. (list
  7482. '(eq major-mode 'spice-mode)
  7483. handle
  7484. "Spice Decks (%d)")
  7485. last))))
  7486. ;; ======================================================================
  7487. ;; utility spice-mode functions
  7488. (defun spice-about ()
  7489. (interactive)
  7490. (sit-for 0)
  7491. (message "spice-mode version %s, Š %s" spice-version spice-developer))
  7492. (defun set-spice-name ()
  7493. "Set mode line name of spice mode"
  7494. (setq mode-name
  7495. (concat
  7496. "Spice"
  7497. (when spice-output-local "-output")
  7498. (when spice-some-comment-regions-are-hidden " H+"))))
  7499. (defun spice-check-spice-standard ()
  7500. "checks if spice-standard is set to a correct value."
  7501. ;; if mondriaan then also layla
  7502. (when (spice-standard-p 'mondriaan)
  7503. (unless (spice-standard-p 'layla)
  7504. (error "Error: turn on Layla when you want to use Mondriaan")))
  7505. ;; if eldoRf then also eldo
  7506. (when (spice-standard-p 'eldorf)
  7507. (unless (spice-standard-p 'eldo)
  7508. (error "Error: turn on Eldo when you want to use Eldo RF")))
  7509. ;; if eldo verilog-A then also eldo
  7510. (when (spice-standard-p 'eldovloga)
  7511. (unless (spice-standard-p 'eldo)
  7512. (error "Error: turn on Eldo when you want to use Eldo Verilog-A")))
  7513. )
  7514. ;; xemacs - emacs compatibility wrapper
  7515. (defun spice-match-string-no-properties (num)
  7516. "wrapper for no properties string matcher"
  7517. (if spice-running-xemacs
  7518. (match-string num)
  7519. (match-string-no-properties num)))
  7520. (defun spice-update-existing-buffers ()
  7521. "updates all spice-mode buffers with new customization"
  7522. (save-excursion
  7523. (let ((current (current-buffer)))
  7524. (mapcar
  7525. (lambda (buffer)
  7526. (set-buffer buffer)
  7527. (if (and (eq major-mode 'spice-mode)
  7528. (not (eq current buffer)))
  7529. (progn
  7530. (message "Activating customizations in %s" buffer)
  7531. (spice-activate-customizations-local))))
  7532. (buffer-list))))
  7533. )
  7534. (defun spice-activate-customizations-local ()
  7535. "Activates customization (of global variables) in current buffer"
  7536. (if (spice-output-p)
  7537. (use-local-map spice-output-mode-map)
  7538. (use-local-map spice-mode-map))
  7539. (set-spice-name)
  7540. (spice-update-mode-menu)
  7541. (set-syntax-table spice-mode-syntax-table)
  7542. (if spice-use-func-menu
  7543. (if (fboundp 'function-menu)
  7544. (funcall 'spice-func-menu-init)))
  7545. (if (not (spice-output-p))
  7546. (setq imenu-generic-expression spice-imenu-generic-expression))
  7547. (when spice-imenu-add-to-menubar
  7548. (imenu-add-to-menubar "Index"))
  7549. ;; rebuild menu:
  7550. (setq imenu--index-alist nil)
  7551. (imenu--make-index-alist t)
  7552. (spice-compile-init)
  7553. (spice-waveform-viewer-init)
  7554. (if (fboundp 'font-lock-unset-defaults)
  7555. (font-lock-unset-defaults))
  7556. (font-lock-set-defaults)
  7557. (if (not (and spice-running-xemacs font-lock-mode))
  7558. (font-lock-fontify-buffer)
  7559. (font-lock-mode)
  7560. (font-lock-mode))
  7561. )
  7562. (defun spice-activate-customizations-obsolete ()
  7563. "Activate all customizations on local variables. Run this if you set
  7564. the spice-standard variable to modify spice-mode's behaviour in the local
  7565. buffer. It sets up the buffer local variables using the modified global
  7566. variables of the customization buffer."
  7567. (interactive)
  7568. (if (spice-output-p)
  7569. (use-local-map spice-output-mode-map)
  7570. (use-local-map spice-mode-map))
  7571. ;; (setq spice-standard-local spice-standard)
  7572. (set-spice-name)
  7573. (spice-menu-init)
  7574. (spice-update-mode-menu)
  7575. (spice-mode-syntax-table-init)
  7576. (set-syntax-table spice-mode-syntax-table)
  7577. (spice-keywords-init)
  7578. (spice-font-lock-init)
  7579. (if spice-use-func-menu
  7580. (if (fboundp 'function-menu)
  7581. (funcall 'spice-func-menu-init)))
  7582. (spice-imenu-init)
  7583. (if (not (spice-output-p))
  7584. (setq imenu-generic-expression spice-imenu-generic-expression))
  7585. ;; add imenu to menubar ?
  7586. (when spice-imenu-add-to-menubar
  7587. (imenu-add-to-menubar "Index"))
  7588. (spice-compile-variables-init)
  7589. (spice-compile-init)
  7590. (spice-waveform-viewer-init)
  7591. (if (fboundp 'font-lock-unset-defaults)
  7592. (font-lock-unset-defaults))
  7593. ;; (setq font-lock-defaults
  7594. ;; (list 'spice-font-lock-keywords nil t (list (cons ?\" "w"))))
  7595. (font-lock-set-defaults)
  7596. (font-lock-fontify-buffer))
  7597. ;; ======================================================================
  7598. ;; spice-mode main entry point
  7599. ;; ======================================================================
  7600. ;;;###autoload
  7601. (defun spice-mode ()
  7602. "Major mode for editing spice decks in (X)Emacs.
  7603. Entry to Spice mode calls the value of the variable `spice-mode-hook'
  7604. with no args, if that value is non-nil after initialization is finished.
  7605. Usage & Features:
  7606. -----------------
  7607. - Comprehensive menu
  7608. - Highlighting of (extended) SPICE syntax, with (limited) ERROR notification
  7609. Please setup spice-mode to recognize the correct syntax through
  7610. customization of the `spice-standard' variable. You can use the menu
  7611. entry Spice->Customize->Spice Standard to do this interactively.
  7612. - Template insertion (abbrev/electrification) for many spice constructs,
  7613. two alternatives are available: Abbrev minor mode and `tempo-complete-tag'
  7614. + Abbrevs can be turned on and off via the Settings submenu.
  7615. To see the available abbrevs, use `M-x list-abbrevs' or use the menu
  7616. after enabling abbrev minor mode. To find out what key sequence
  7617. triggers an expand do 'C-h w expand-abbrev'.
  7618. + `tempo-complete-tag' is bound to <tab> - for example, type 'M<tab>'
  7619. at the beginning of a line and you will be prompted with a complete
  7620. Mosfet template. Most tags are pretty straightforward i.e 'C' for a
  7621. capacitor, 'L' for an inductance etc...
  7622. You can type `C-h v tempo-tags'for a complete list of tags and
  7623. associated templates. Note: to insert a real <TAB>, use <C-q TAB> or
  7624. <shift TAB>.
  7625. - Comment & documentation string handling
  7626. + the '*' symbol is used to comment out a whole line - that symbol has
  7627. to be at the beginning of a line
  7628. + the '!' and '$' symbols are used to document your netlist in eldo
  7629. and hspice/layla mode respectively
  7630. + menu entry to comment out region/uncomment region
  7631. + key bindings for commenting/uncommenting a region as in `auctex-mode'.
  7632. - Comment hiding support
  7633. + Can hide all commented out regions in a buffer to improve readability
  7634. + prefix string is customizable: `spice-hide-line-prefix'.
  7635. + custom variable can be set to automatically hide all commented regions
  7636. at load time (`spice-auto-hide-comments')
  7637. + requires use of doc strings, otherwise also documentation might be
  7638. hidden
  7639. + When parts of the deck are hidden the string \"H+\" appears in the
  7640. modeline.
  7641. - Imenu (Index menu and/or shift right click in emacs if configured)
  7642. + shows subcircuit definitions
  7643. + shows .end statements in submenu
  7644. + shows device models in submenus
  7645. + shows libraries (.lib/.inc) in submenu
  7646. + shows analyses in submenu
  7647. + shows sections in submenu
  7648. + shows output file sections in menu
  7649. + shows LAYLA objects in submenus if layla submode has been enabled
  7650. + can be added to the menubar by setting `spice-imenu-add-to-menubar'
  7651. (uses `imenu-add-to-menubar' to add an Imenu entry to the menubar).
  7652. - File browser using Speedbar (`speedbar') and/or index/sources menu
  7653. - .inc/.include/.lib/.libfas access
  7654. + through mouse-2 click (`ffap-at-mouse' or `spice-load-file-at-mouse')
  7655. + using \\r (ie. <return>), (`ffap')
  7656. + through menu entry all include/lib files of a deck can be loaded at
  7657. once (`spice-load-include-files'), recursively.
  7658. - Searching for .subckt defs: `spice-search-subckt' or `C-c C-s'
  7659. + extracts subcircuit name from context
  7660. + search history
  7661. + mark is set where search has been started if the definition is found
  7662. in the same file. Return to mark with `C-u C-<SPC>' (or `C-u C-@')
  7663. as with interactive searches (fi `isearch-forward')
  7664. + be careful when starting the search from an included file,
  7665. correctness can not be guaranteed. Starting a search from
  7666. a top-level .cir file gives correct results. The latest used
  7667. top-level file is stored (a top-level file contains a .end
  7668. statement !), and also searched if the subckt def is not found in
  7669. a first pass (for instance when starting from an included file).
  7670. - Postscript printing with fontification (through `ps-print' package).
  7671. - Addition of Spice Deck submenu in msb mode, see `msb', `spice-msb-fix'.
  7672. - Section support (as in eldo-mode):
  7673. + add section headers, goto section through menu entries or interactive
  7674. + customizable through `spice-section-alist', you can add your
  7675. own section headers, alter the list of predefined sections, ...
  7676. + Changelog addition through `spice-add-changelog-entry', or
  7677. use `C-c a c'.
  7678. - Simulator support
  7679. + use `spice-simulator' and `spice-simulator-switches' to
  7680. select your simulator from `spice-simulator-alist'.
  7681. + Support for error parsing of spice3 (batch-mode, -b),
  7682. hspice, eldo and spectre. Add your own in spice-mode or through
  7683. customization in `.emacs'.
  7684. + use local file variables to customize per file as follows:
  7685. <<< test.cir >>>
  7686. .op
  7687. .end
  7688. * Local Variables:
  7689. * mode: spice
  7690. * spice-simulator: \"Hspice\"
  7691. * spice-simulator-switches: \"\"
  7692. * eval: (spice-set-command)
  7693. * End:
  7694. <<< test.cir ends here >>>
  7695. - Waveform viewer support (beta)
  7696. + use `spice-waveform-viewer' and `spice-waveform-viewer-switches' to
  7697. select your waveform from `spice-waveform-viewer-alist'.
  7698. + Support for interactive (command-line) waveform viewer such as
  7699. nutmeg, or batch (GUI) type waveform viewer such as xelga or gsi.
  7700. - Output file support
  7701. + can load output file from menu (checks if file exists and is readable)
  7702. + imenu in output files shows output file sections
  7703. + for eldo .chi files: can create <file>_guess.cir files automatically
  7704. for inclusion in <file>.cir file through
  7705. `spice-create-guess-nodeset-file'
  7706. or `spice-replace-with-guess-nodeset-statements'; this speeds up DC
  7707. convergence for AC analyses.
  7708. - (Fully) customizable
  7709. + can select spice compatibility mode:
  7710. * spice2g6/3 (default)
  7711. * hspice (default)
  7712. * eldo (default), RF and verilog-A extensions
  7713. * fasthenry (default)
  7714. * Dracula CDL
  7715. * LAYLA, Mondriaan extensions
  7716. * any combination of the above (there are conflicts however, so not
  7717. all keyword fontification is correct in the latter case)
  7718. + spice-mode font-lock faces
  7719. + spice-mode default initialization of empty/new files determined by
  7720. `spice-initialize-empty-file', `spice-initialize-template-file',
  7721. `spice-default-header' and `spice-initialize-file-function'.
  7722. + see the customization examples in the `spice-mode.el' file header
  7723. + You can adapt `spice-simulator-alist' for your local site in
  7724. `spice-mode.el' or in `.emacs' through customization.
  7725. + You can adapt `spice-waveform-viewer-alist' for your local site in
  7726. `spice-mode.el' or in `.emacs' through customization.
  7727. + You can adapt `spice-section-alist' for your local site in
  7728. `spice-mode.el' or in `.emacs' through customization.
  7729. - Auto fill minor mode support
  7730. + can be turned on from the Settings menu
  7731. + auto fill works both for element where the continuation character
  7732. is a '+', as well as in comment/doc mode where the continuation
  7733. character is a '*', '$' or a '!'.
  7734. + uses `fill-column' to determine where to wrap the line
  7735. + doesn't use `fill-prefix'. A context dependent prefix is calculated
  7736. through the `spice-comment-indent-new-line' function. This function
  7737. is used as `comment-line-break-function' instead of the default line
  7738. break function (in emacs: `comment-indent-new-line').
  7739. - Paragraph support: [a-z] starts dev lines, '+' continues dev lines,
  7740. [*!$] start paragraphs.
  7741. - Works under GNU Emacs20.6/21.[123], also tested under XEmacs21.1/21.4.5,
  7742. requires fsf-compat package for XEmacs 21.4.5.
  7743. Do not use a -*- Mode -*- line in a spice deck as the first card in
  7744. the deck is defined to be the title card. Rather, autoload spice-mode
  7745. through your .emacs file:
  7746. (autoload 'spice-mode \"spice-mode\" \"Spice/Layla Editing Mode\" t)
  7747. (setq auto-mode-alist (append (list (cons \"\\\\.sp$\" 'spice-mode)
  7748. (cons \"\\\\.cir$\" 'spice-mode)
  7749. (cons \"\\\\.cdl$\" 'spice-mode)
  7750. (cons \"\\\\.chi$\" 'spice-mode) ; output
  7751. (cons \"\\\\.mod$\" 'spice-mode)); models
  7752. auto-mode-alist))
  7753. Alternative methods are provided in the spice-mode.el file header.
  7754. Key bindings in highlighted include file lines:
  7755. -----------------------------------------------
  7756. \\{spice-mode-mouse-map}
  7757. Key bindings for other parts in the file:
  7758. -----------------------------------------
  7759. \\{spice-mode-map}
  7760. "
  7761. ;;Key bindings for output files:
  7762. ;;------------------------------
  7763. ;;
  7764. ;;\\{spice-output-mode-map}
  7765. ;;"
  7766. (interactive)
  7767. (kill-all-local-variables) ; important !
  7768. (setq major-mode 'spice-mode)
  7769. (setq mode-name "Spice")
  7770. ;; remember if this file is an output type
  7771. (set (make-local-variable 'spice-output-local) (spice-check-output-mode))
  7772. ;; set mode name
  7773. (set-spice-name)
  7774. ;; build global syntax table
  7775. (unless spice-mode-syntax-table
  7776. (spice-mode-syntax-table-init))
  7777. ;; set it for local buffer
  7778. (set-syntax-table spice-mode-syntax-table)
  7779. ;; initialize global spice keywords, required for output mode !
  7780. (unless spice-keywords
  7781. (spice-keywords-init))
  7782. ;; global font-lock start-up
  7783. (unless spice-font-lock-keywords
  7784. (spice-font-lock-init))
  7785. ;; create global Spice mode menu's: mode-menu and output-mode-menu
  7786. (unless (and spice-menu-list spice-output-menu-list)
  7787. (spice-menu-init))
  7788. ;; global spice-imenu init (not output mode !)
  7789. (unless spice-imenu-generic-expression
  7790. (spice-imenu-init))
  7791. ;; global vars for compile init
  7792. (unless spice-compilation-error-regexp-alist
  7793. (spice-compile-variables-init))
  7794. (set (make-local-variable 'parse-sexp-ignore-comments) nil)
  7795. (set (make-local-variable 'tempo-interactive) t)
  7796. (set (make-local-variable 'require-final-newline) t) ; hspice empty deck errors
  7797. (set (make-local-variable 'comment-start) "*")
  7798. (set (make-local-variable 'comment-end) "")
  7799. (set (make-local-variable 'comment-start-skip) "\*")
  7800. (set (make-local-variable 'comment-multi-line) nil)
  7801. ;;------------------------------------------------------------
  7802. ;; initialize hiding functions, mix of global and buffer local settings
  7803. (spice-hide-init)
  7804. (if (spice-output-p)
  7805. (spice-mode-output)
  7806. ;; use local keymap (for keys and menu)
  7807. (use-local-map spice-mode-map)
  7808. ;; set menu for local buffer
  7809. (easy-menu-add spice-menu-list) ; for XEmacs
  7810. (easy-menu-define spice-menu spice-mode-map
  7811. "Menu keymap for Spice Mode." spice-menu-list)
  7812. ;; abbreviations table: buffer local
  7813. (setq local-abbrev-table spice-mode-abbrev-table)
  7814. ;; buffer local init
  7815. (set (make-local-variable 'fill-prefix) nil) ; automatically derived
  7816. ;; remove auto-fill-inhibit and added spice-comment-indent... function
  7817. ;; (set (make-local-variable 'auto-fill-inhibit-regexp) "^\*[^\.\+].*")
  7818. ;; buffer local init for indentation of comment
  7819. (set (make-local-variable 'spice-save-comment-line-break-function)
  7820. comment-line-break-function)
  7821. (set (make-local-variable 'comment-line-break-function)
  7822. 'spice-comment-indent-new-line)
  7823. (set (make-local-variable 'fill-column) 78) ;; was 80
  7824. ;; support for paragraphs (is it useful?) ; this is really arbitrary
  7825. ;; all buffer local
  7826. ;; (set (make-local-variable 'paragraph-start) "^[!$*]-.*$")
  7827. ;; (set (make-local-variable 'paragraph-separate) "^[!$*]-.*$")
  7828. (set (make-local-variable 'paragraph-start)
  7829. "\\([a-z\\.].*\\([\n][+].*\\)*\\|[$]...+\\|[!]...+\\|[ \t\f]*$\\|\\*...+\\|.*\\s-[$!].*$\\)")
  7830. ;; (set (make-local-variable 'paragraph-separate) "[a-z$!*]")
  7831. (set (make-local-variable 'paragraph-separate) "\\([ \t\f]*\\|.*\\s-[$!].*\\)$")
  7832. (set (make-local-variable 'adaptive-fill-regexp) nil)
  7833. (set (make-local-variable 'adaptive-fill-function) 'spice-fill-context-prefix)
  7834. (set (make-local-variable 'adaptive-fill-first-line-regexp) "[*$!+]\\s-+")
  7835. ;; Tempo tags - using 'tempo-local-tags' doesn't work (why??)
  7836. (set (make-local-variable 'tempo-tags)
  7837. (append spice-tempo-tags tempo-tags))
  7838. ;; buffer local font lock
  7839. (set (make-local-variable 'font-lock-defaults)
  7840. (list 'spice-font-lock-keywords nil t (list (cons ?\" "w")))) ;; nil, t (do multiline comments)
  7841. (set (make-local-variable 'font-lock-multiline) t)
  7842. (font-lock-set-defaults)
  7843. ;; imenu init:
  7844. (set (make-local-variable 'imenu-case-fold-search) t)
  7845. ;; buffer local imenu init
  7846. (set (make-local-variable 'imenu-generic-expression)
  7847. spice-imenu-generic-expression)
  7848. ;; add speedbar (global, can be moved ?)
  7849. (spice-speedbar-init)
  7850. ;; func-menu stuff, all buffer local
  7851. (if spice-use-func-menu
  7852. (if (fboundp 'function-menu)
  7853. (funcall 'spice-func-menu-init)))
  7854. ;;------------------------------------------------------------
  7855. ;; now hook in 'spice-colorize-libraries (eldo-mode.el)
  7856. ;; all buffer local:
  7857. ;;(make-local-hook 'font-lock-mode-hook) ; not available since emacs 21.1
  7858. ;; (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
  7859. ;;(add-hook 'font-lock-mode-hook 'spice-colorize-libraries-buffer t t)
  7860. (add-hook 'font-lock-after-fontify-buffer-hook 'spice-colorize-libraries-buffer t t) ; not in emacs 20
  7861. ;; (make-local-hook 'after-change-functions) ; not available since emacs 21.1
  7862. (add-hook 'after-change-functions 'spice-colorize-libraries t t)
  7863. (spice-colorize-libraries-buffer)
  7864. ;;------------------------------------------------------------
  7865. ;; compile buffer local init
  7866. (spice-compile-init)
  7867. ;;------------------------------------------------------------
  7868. ;; buffer local init
  7869. (spice-waveform-viewer-init)
  7870. ;; if new file add a default template
  7871. (if (and (= (buffer-size) 0)
  7872. (not buffer-read-only)
  7873. spice-initialize-empty-file
  7874. (functionp spice-initialize-file-function))
  7875. (funcall spice-initialize-file-function))
  7876. ) ;; matches big if (normal spice or spice output mode)
  7877. ;; build imenu, buffer local
  7878. (imenu--make-index-alist t)
  7879. ;; add imenu to menubar, buffer local
  7880. (when spice-imenu-add-to-menubar
  7881. (imenu-add-to-menubar "Index"))
  7882. ;; msb fix, run only once
  7883. (and (featurep 'msb) ;; have we got this feature ?
  7884. msb-mode ;; is it on ?
  7885. (boundp 'msb-menu-cond) ;; still using msb-menu-cond ?
  7886. (not spice-msb-fixed) ;; haven't yet added spice decks category ?
  7887. (spice-msb-fix)) ;; add category
  7888. ;; open describe window, hope this doesn't annoy people too much...
  7889. (if spice-show-describe-mode
  7890. (save-excursion
  7891. (describe-mode) ;; aha...
  7892. (setq spice-show-describe-mode nil)) ;; but only once in a session !!
  7893. )
  7894. (if spice-echo-intro
  7895. (message "Spice mode %s. Type C-h m for documentation." ;; always
  7896. spice-version))
  7897. ;; run spice-mode hooks
  7898. (run-hooks 'spice-mode-hook)
  7899. )
  7900. ;; this is sometimes useful
  7901. (provide 'spice-mode)
  7902. ;;; spice-mode.el ends here
  7903. ;;; Local Variables:
  7904. ;;; mode:Emacs-lisp
  7905. ;;; End: