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 " port)
60 (display "projectname" port)
69 (display "end netlist" port)
73 ;; component related lines
75 (define tEDAx:components
78 (let ((package (car ls)))
80 (display "\tfootprint " port)
81 (display package port)
83 (display (tEDAx:get-pattern package) port)
86 (display "\tdevice " port)
87 (display package port)
89 (display (tEDAx:get-device package) port)
92 (display "\tvalue " port)
93 (display package port)
95 (display (tEDAx:get-value package) port)
99 (tEDAx:components port (cdr ls)))))))
101 (define (tEDAx:pinfmt pin)
102 (format #f "~a ~a" (car pin) (car (cdr pin)))
105 (define (tEDAx:each-pin net pins port)
106 (if (not (null? pins))
107 (let ((pin (car pins)))
108 (format port "\tconn ~a ~a~%" net (tEDAx:pinfmt pin))
109 (tEDAx:each-pin net (cdr pins) port))))
112 ;; network related lines
114 (define (tEDAx:each-net netnames port)
115 (if (not (null? netnames))
116 (let ((netname (car netnames)))
117 (tEDAx:each-pin netname (gnetlist:get-all-connections netname) port)
118 (tEDAx:each-net (cdr netnames) port))))
121 ;;; output a tEDAx formatted netlist
124 (lambda (output-filename)
125 (let ((port (open-output-file output-filename)))
128 (tEDAx:components port packages)
129 (tEDAx:each-net (gnetlist:get-all-unique-nets "dummy") port)
130 (tEDAx:trailer port))
131 (close-output-port port))))
133 ;; --------------------------------------------------------------------------