1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist plug-in for tEDAx
3 ;;; Copyright (C) 2018 Bdale Garbee
5 ;;; This program is free software; you can redistribute it and/or modify
6 ;;; it under the terms of the GNU General Public License as published by
7 ;;; the Free Software Foundation; either version 2 of the License, or
8 ;;; (at your option) any later version.
10 ;;; This program is distributed in the hope that it will be useful,
11 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;;; GNU General Public License for more details.
15 ;;; You should have received a copy of the GNU General Public License
16 ;;; along with this program; if not, write to the Free Software
17 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 ;;; MA 02111-1301 USA.
20 ;; --------------------------------------------------------------------------
23 ;; returns the device attribute value
25 (define tEDAx:get-device
27 (gnetlist:get-package-attribute package "device")))
30 ;; returns the footprint attribute value (PATTERN if not defined)
32 (define tEDAx:get-pattern
34 (define pattern (gnetlist:get-package-attribute package "footprint"))
35 (if (string=? "unknown" pattern)
38 ; how do i return "PATTERN" if not defined? humm... need to read some
39 ; guile stuff... i did, and see the result :)
42 ;; returns the value attribute (empty if not defined)
44 (define tEDAx:get-value
46 (define value (gnetlist:get-package-attribute package "value"))
47 (if (string=? "unknown" value)
56 (display "tEDAx v1" port)
59 (display "begin netlist v1 netlist" port)
68 (display "end netlist" port)
72 ;; component related lines
74 (define tEDAx:components
77 (let ((package (car ls)))
79 (display "\tfootprint " port)
80 (display package port)
82 (display (tEDAx:get-pattern package) port)
85 (display "\tdevice " port)
86 (display package port)
88 (display (tEDAx:get-device package) port)
91 (display "\tvalue " port)
92 (display package port)
94 (display (tEDAx:get-value package) port)
98 (tEDAx:components port (cdr ls)))))))
100 (define (tEDAx:pinfmt pin)
101 (format #f "~a ~a" (car pin) (car (cdr pin)))
104 (define (tEDAx:each-pin net pins port)
105 (if (not (null? pins))
106 (let ((pin (car pins)))
107 (format port "\tconn ~a ~a~%" net (tEDAx:pinfmt pin))
108 (tEDAx:each-pin net (cdr pins) port))))
111 ;; network related lines
113 (define (tEDAx:each-net netnames port)
114 (if (not (null? netnames))
115 (let ((netname (car netnames)))
116 (tEDAx:each-pin netname (gnetlist:get-all-connections netname) port)
117 (tEDAx:each-net (cdr netnames) port))))
120 ;;; output a tEDAx formatted netlist
123 (lambda (output-filename)
124 (let ((port (open-output-file output-filename)))
127 (tEDAx:components port packages)
128 (tEDAx:each-net (gnetlist:get-all-unique-nets "dummy") port)
129 (tEDAx:trailer port))
130 (close-output-port port))))
132 ;; --------------------------------------------------------------------------