1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 1998-2010 Ales Hvezda
4 ;;; Copyright (C) 1998-2020 gEDA Contributors (see ChangeLog for details)
6 ;;; This program is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 2 of the License, or
9 ;;; (at your option) any later version.
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program; if not, write to the Free Software
18 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 ;;; MA 02111-1301 USA.
21 ;; --------------------------------------------------------------------------
23 ;; SPICE netlist backend written by S. Gieltjes starts here
26 ;; Common functions for the `spice' and `spice-sdb' backends
27 (load-from-path "spice-common.scm")
30 ;; write mos transistor
32 (define spice:write-mos-transistor
34 (spice:write-one-component package)
35 ;; create list of attributes which can be attached to a mosfet
36 (let ((attrib-list (list "l" "w" "as" "ad" "pd" "ps" "nrd" "nrs" "temp" "ic")))
37 (spice:write-list-of-attributes package attrib-list))
38 ;; write the off attribute separately
39 (let ((off-value (gnetlist:get-package-attribute package "off")))
40 (cond ((string=? off-value "#t") (display " off"))
41 ((string=? off-value "1" ) (display " off"))))
48 (define spice:write-include
50 (display (string-append package " " (spice:component-value package) "\n"))))
54 ;; write the refdes, the net name connected to pin# and the component value. No extra attributes.
56 (define spice:write-one-component
58 (display (string-append package " "))
59 ;; write net names, slotted components not implemented
60 (spice:write-net-names-on-component package)
61 ;; write component value, if components have a label "value=#"
62 ;; what if a component has no value label, currently unknown is written
63 (display (spice:component-value package))))
67 ;; write the refdes, to the pin# connected net and component value and optional extra attributes
68 ;; check if the component is a special spice component
70 (define spice:write-netlist
73 (let ((package (car ls))) ;; search for specific device labels
75 ( (string=? (get-device package) "SPICE-ccvs")
76 (spice:write-ccvs package))
77 ( (string=? (get-device package) "SPICE-cccs")
78 (spice:write-cccs package))
79 ( (string=? (get-device package) "SPICE-vcvs")
80 (spice:write-vcvs package))
81 ( (string=? (get-device package) "SPICE-vccs")
82 (spice:write-vccs package))
83 ( (string=? (get-device package) "SPICE-nullor")
84 (spice:write-nullor package))
85 ( (string=? (get-device package) "PMOS_TRANSISTOR")
86 (spice:write-mos-transistor package))
87 ( (string=? (get-device package) "NMOS_TRANSISTOR")
88 (spice:write-mos-transistor package))
89 ( (string=? (get-device package) "include")
90 (spice:write-include package))
91 ( else (spice:write-one-component package)
93 (spice:write-netlist (cdr ls)) ))))
97 ;; Spice netlist header
99 (define (spice:write-top-header)
100 (display "* Spice netlister for gnetlist\n"))
104 ;; Write the .END line
106 (define (spice:write-bottom-footer)
111 ;; Spice netlist generation
113 (define (spice output-filename)
114 (set-current-output-port (gnetlist:output-port output-filename))
115 (spice:write-top-header)
116 (spice:write-netlist packages)
117 (spice:write-bottom-footer)
118 (close-output-port (current-output-port)))
121 ;; SPICE netlist backend written by S. Gieltjes ends here
123 ;; --------------------------------------------------------------------------