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 ;; gEDA's native test netlist format specific functions go here
28 (define geda:write-top-header
30 (display "START header" p)
33 (display "gEDA's netlist format" p)
35 (display "Created specifically for testing of gnetlist" p)
38 (display "END header" p)
43 ;; header for components section
45 (define geda:start-components
47 (display "START components" p)
52 ;; footer for components section
54 (define geda:end-components
57 (display "END components" p)
62 ;; header for renamed section
64 (define geda:start-renamed-nets
66 (display "START renamed-nets" p)
71 ;; footer for renamed section
73 (define geda:end-renamed-nets
76 (display "END renamed-nets" p)
81 ;; header for nets section
83 (define geda:start-nets
85 (display "START nets" p)
90 ;; footer for net section
95 (display "END nets" p)
100 ;; Top level component writing
102 (define geda:components
105 (let ((package (car ls)))
107 (display package port)
108 (write-char #\space port)
109 (display "device=" port)
110 (display (get-device package) port)
112 (geda:components port (cdr ls)))))))
115 ;; renamed nets writing
117 (define geda:renamed-nets
120 (let ((renamed-pair (car ls)))
122 ;;; (display renamed-pair) (newline)
123 (display (car renamed-pair) port)
124 (display " -> " port)
125 (display (car (cdr renamed-pair)) port)
127 (geda:renamed-nets port (cdr ls)))))))
130 ;; Display the individual net connections
132 (define geda:display-connections
134 (if (not (null? nets))
136 (display (car (car nets)) port)
137 (write-char #\space port)
138 (display (car (cdr (car nets))) port)
139 (if (not (null? (cdr nets)))
141 (write-char #\, port)
142 (write-char #\space port)))
143 (geda:display-connections (cdr nets) port)))))
148 (define geda:display-name-nets
151 (geda:display-connections nets port)
152 (write-char #\space port)
156 ;; Write netname : uref pin, uref pin, ...
158 (define geda:write-net
159 (lambda (port netnames)
160 (if (not (null? netnames))
161 (let ((netname (car netnames)))
163 (display netname port)
165 (geda:display-name-nets port (gnetlist:get-all-connections netname))
166 (geda:write-net port (cdr netnames)))))))
169 ;; Write the net part of the gEDA format
173 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy")))
174 (geda:write-net port all-uniq-nets))))
176 ;;; Highest level function
177 ;;; Write my special testing netlist format
180 (lambda (output-filename)
181 (let ((port (open-output-file output-filename)))
183 ;;; (gnetlist:set-netlist-mode "gEDA") No longer needed
184 (geda:write-top-header port)
185 (geda:start-components port)
186 (geda:components port packages)
187 (geda:end-components port)
188 (geda:start-renamed-nets port)
189 (geda:renamed-nets port (gnetlist:get-renamed-nets "dummy"))
190 (geda:end-renamed-nets port)
191 (geda:start-nets port)
193 (geda:end-nets port))
194 (close-output-port port))))
197 ;; gEDA's native test netlist format specific functions ends
199 ;; --------------------------------------------------------------------------