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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 ;; --------------------------------------------------------------------------
22 ;; TANGO netlist backend written by Nuno Sucena starts here
26 ;; Given a uref, returns the device attribute value (for tango-netlist)
28 (define tango:get-device
30 (gnetlist:get-package-attribute package "device")))
33 ;; Given a uref, returns the footprint attribute value (PATTERN if not defined)
35 (define tango:get-pattern
37 (define pattern (gnetlist:get-package-attribute package "footprint"))
38 (if (string=? "unknown" pattern)
41 ; how do i return "PATTERN" if not defined? humm... need to read some
42 ; guile stuff... i did, and see the result :)
45 ;; Given a uref, returns the value attribute (empty if not defined)
47 (define tango:get-value
49 (define value (gnetlist:get-package-attribute package "value"))
50 (if (string=? "unknown" value)
57 (define tango:write-top-header
59 (display "START header" p)
62 (display "TANGO netlist for gnetlist" p)
64 (display "TANGO gnetlist backend written by Nuno Sucena" port)
66 (display "END header" p)
71 ;; Top level component writing
73 (define tango:components
76 (let ((package (car ls)))
80 (display package port)
82 (display (tango:get-pattern package) port)
84 (display (tango:get-device package) port)
86 (display (tango:get-value package) port)
91 (tango:components port (cdr ls)))))))
94 ;; Display the individual net connections
96 (define tango:display-connections
98 (if (not (null? nets))
100 (display (car (car nets)) port)
102 (display (car (cdr (car nets))) port)
103 (if (not (null? (cdr nets)))
106 (tango:display-connections (cdr nets) port)))))
110 ;; Properly format the name of the net and the actual net connections
112 (define tango:display-name-nets
115 (tango:display-connections nets port))))
118 ;; Write out a net associated with a particular package and pin
120 (define tango:write-net
121 (lambda (port netnames)
122 (if (not (null? netnames))
123 (let ((netname (car netnames)))
127 (display netname port)
130 (tango:display-name-nets port (gnetlist:get-all-connections netname))
134 (tango:write-net port (cdr netnames)))))))
138 ;; Top level function to write out nets associated with a particular component
142 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy")))
143 (tango:write-net port all-uniq-nets))))
145 ;;; Highest level function
146 ;;; Write tango netlist format
149 (lambda (output-filename)
150 (let ((port (open-output-file output-filename)))
152 ;;; (gnetlist:set-netlist-mode "TANGO") No longer needed
153 (tango:components port packages)
155 (close-output-port port))))
158 ;; TANGO netlist backend written by Nuno Sucena ends here
160 ;; --------------------------------------------------------------------------