1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 1998-2010 Ales Hvezda
4 ;;; Copyright (C) 1998-2010 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 ;; TANGO netlist backend written by Nuno Sucena starts here
27 ;; Given a uref, returns the device attribute value (for tango-netlist)
29 (define tango:get-device
31 (gnetlist:get-package-attribute package "device")))
34 ;; Given a uref, returns the footprint attribute value (PATTERN if not defined)
36 (define tango:get-pattern
38 (define pattern (gnetlist:get-package-attribute package "footprint"))
39 (if (string=? "unknown" pattern)
42 ; how do i return "PATTERN" if not defined? humm... need to read some
43 ; guile stuff... i did, and see the result :)
46 ;; Given a uref, returns the value attribute (empty if not defined)
48 (define tango:get-value
50 (define value (gnetlist:get-package-attribute package "value"))
51 (if (string=? "unknown" value)
58 (define tango:write-top-header
60 (display "START header" p)
63 (display "TANGO netlist for gnetlist" p)
65 (display "TANGO gnetlist backend written by Nuno Sucena" port)
67 (display "END header" p)
72 ;; Top level component writing
74 (define tango:components
77 (let ((package (car ls)))
81 (display package port)
83 (display (tango:get-pattern package) port)
85 (display (tango:get-device package) port)
87 (display (tango:get-value package) port)
92 (tango:components port (cdr ls)))))))
95 ;; Display the individual net connections
97 (define tango:display-connections
99 (if (not (null? nets))
101 (display (car (car nets)) port)
103 (display (car (cdr (car nets))) port)
104 (if (not (null? (cdr nets)))
107 (tango:display-connections (cdr nets) port)))))
111 ;; Properly format the name of the net and the actual net connections
113 (define tango:display-name-nets
116 (tango:display-connections nets port))))
119 ;; Write out a net associated with a particular package and pin
121 (define tango:write-net
122 (lambda (port netnames)
123 (if (not (null? netnames))
124 (let ((netname (car netnames)))
128 (display netname port)
131 (tango:display-name-nets port (gnetlist:get-all-connections netname))
135 (tango:write-net port (cdr netnames)))))))
139 ;; Top level function to write out nets associated with a particular component
143 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy")))
144 (tango:write-net port all-uniq-nets))))
146 ;;; Highest level function
147 ;;; Write tango netlist format
150 (lambda (output-filename)
151 (let ((port (open-output-file output-filename)))
153 ;;; (gnetlist:set-netlist-mode "TANGO") No longer needed
154 (tango:components port packages)
156 (close-output-port port))))
159 ;; TANGO netlist backend written by Nuno Sucena ends here
161 ;; --------------------------------------------------------------------------