1 ;;; tEDAx plug-in for gnetlist
2 ;;; Copyright (C) 2018 Bdale Garbee
4 ;;; This program is free software; you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 2 of the License, or
7 ;;; (at your option) any later version.
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;;; GNU General Public License for more details.
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program; if not, write to the Free Software
16 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 ;;; MA 02111-1301 USA.
19 ;; --------------------------------------------------------------------------
22 ;; returns the device attribute value
24 (define tEDAx:get-device
26 (gnetlist:get-package-attribute package "device")))
29 ;; returns the footprint attribute value (PATTERN if not defined)
31 (define tEDAx:get-pattern
33 (define pattern (gnetlist:get-package-attribute package "footprint"))
34 (if (string=? "unknown" pattern)
37 ; how do i return "PATTERN" if not defined? humm... need to read some
38 ; guile stuff... i did, and see the result :)
41 ;; returns the value attribute (empty if not defined)
43 (define tEDAx:get-value
45 (define value (gnetlist:get-package-attribute package "value"))
46 (if (string=? "unknown" value)
55 (display "tEDAx v1" port)
58 (display "begin netlist v1 netlist" port)
67 (display "end netlist" port)
71 ;; component related lines
73 (define tEDAx:components
76 (let ((package (car ls)))
78 (display "\tfootprint " port)
79 (display package port)
81 (display (tEDAx:get-pattern package) port)
84 (display "\tdevice " port)
85 (display package port)
87 (display (tEDAx:get-device package) port)
90 (display "\tvalue " port)
91 (display package port)
93 (display (tEDAx:get-value package) port)
97 (tEDAx:components port (cdr ls)))))))
99 (define (tEDAx:pinfmt pin)
100 (format #f "~a ~a" (car pin) (car (cdr pin)))
103 (define (tEDAx:each-pin net pins port)
104 (if (not (null? pins))
105 (let ((pin (car pins)))
106 (format port "\tconn ~a ~a~%" net (tEDAx:pinfmt pin))
107 (tEDAx:each-pin net (cdr pins) port))))
110 ;; network related lines
112 (define (tEDAx:each-net netnames port)
113 (if (not (null? netnames))
114 (let ((netname (car netnames)))
115 (tEDAx:each-pin netname (gnetlist:get-all-connections netname) port)
116 (tEDAx:each-net (cdr netnames) port))))
119 ;;; output a tEDAx formatted netlist
122 (lambda (output-filename)
123 (let ((port (open-output-file output-filename)))
126 (tEDAx:components port packages)
127 (tEDAx:each-net (gnetlist:get-all-unique-nets "dummy") port)
128 (tEDAx:trailer port))
129 (close-output-port port))))
131 ;; --------------------------------------------------------------------------