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 ;; protelII netlist format specific functions go here
25 ;; [ -- element for list of components
29 ;; FOOTPRINT attrbute.
32 ;; If VALUE attribute exists, output VALUE attribute.
33 ;; Otherwise, output DEVICE attrbute.
34 ;; (This covers the case of ICs, which usually carry their part no (e.g. uA741) in the DEVICE attribute.)
87 ;; ... other components ...
89 ;; ( -- element for list of nets
91 ;; PART-PIN# VALUE-PINNAME PINTYPE -- use PASSIVE for PINTYPE
92 ;; ...more connections...
97 ;; { -- element for net option list
113 ;; ...more net options...
120 (define protelII:write-top-header
122 (display "PROTEL NETLIST 2.0" p)
126 ;; header for components section
128 (define protelII:start-components
131 ;; no header for components
134 ;; footer for components section
136 (define protelII:end-components
141 ;; header for renamed section
143 (define protelII:start-renamed-nets
148 ;; footer for renamed section
150 (define protelII:end-renamed-nets
155 ;; header for nets section
157 (define protelII:start-nets
162 ;; footer for net section
164 (define protelII:end-nets
169 ;; Top level component writing
171 (define protelII:components
174 (let ((package (car ls)))
178 (display "DESIGNATOR" port)
180 (display package port)
182 (display "FOOTPRINT" port)
184 (display (gnetlist:get-package-attribute package "footprint") port)
186 (display "PARTTYPE" port)
188 (let ((value (get-value package))) ;; This change by SDB on 10.12.2003.
189 (if (string-ci=? value "unknown")
190 (display (get-device package) port)
195 (display "DESCRIPTION" port)
197 (display (get-device package) port)
199 (display "Part Field 1" port)
203 (display "Part Field 2" port)
207 (display "Part Field 3" port)
211 (display "Part Field 4" port)
215 (display "Part Field 5" port)
219 (display "Part Field 6" port)
223 (display "Part Field 7" port)
227 (display "Part Field 8" port)
231 (display "Part Field 9" port)
235 (display "Part Field 10" port)
239 (display "Part Field 11" port)
243 (display "Part Field 12" port)
247 (display "Part Field 13" port)
251 (display "Part Field 14" port)
255 (display "Part Field 15" port)
259 (display "Part Field 16" port)
263 (display "LIBRARYFIELD1" port)
267 (display "LIBRARYFIELD2" port)
271 (display "LIBRARYFIELD3" port)
275 (display "LIBRARYFIELD4" port)
279 (display "LIBRARYFIELD5" port)
283 (display "LIBRARYFIELD6" port)
287 (display "LIBRARYFIELD7" port)
291 (display "LIBRARYFIELD8" port)
297 (protelII:components port (cdr ls)))))))
300 ;; renamed nets writing
302 (define protelII:renamed-nets
305 (let ((renamed-pair (car ls)))
307 ;;; (display renamed-pair) (newline)
308 ;;; (display (car renamed-pair) port)
309 ;;; (display " -> " port)
310 ;;; (display (car (cdr renamed-pair)) port)
313 (protelII:renamed-nets port (cdr ls)))))))
316 ;; Display the individual net connections
318 (define protelII:display-connections
320 (if (not (null? nets))
322 (let ((package (car (car nets))))
323 (display package port)
324 (write-char #\- port)
325 (display (car (cdr (car nets))) port)
327 (display (get-device package) port)
329 (display (car (cdr (car nets))) port)
330 (display " PASSIVE" port))
331 (if (not (null? (cdr nets)))
334 (protelII:display-connections (cdr nets) port)))))
339 (define protelII:display-name-nets
342 (protelII:display-connections nets port)
343 (write-char #\space port)
347 ;; Write netname : uref pin, uref pin, ...
349 (define protelII:write-net
350 (lambda (port netnames)
351 (if (not (null? netnames))
352 (let ((netname (car netnames)))
356 (display netname port)
358 (protelII:display-name-nets port (gnetlist:get-all-connections netname))
361 (protelII:write-net port (cdr netnames)))))))
364 ;; Write the net part of the gEDA format
366 (define protelII:nets
368 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy")))
369 (protelII:write-net port all-uniq-nets))))
371 ;;; Highest level function
372 ;;; Write my special testing netlist format
375 (lambda (output-filename)
376 (let ((port (open-output-file output-filename)))
378 ;;; (gnetlist:set-netlist-mode "gEDA") No longer needed
379 (protelII:write-top-header port)
380 (protelII:start-components port)
381 (protelII:components port packages)
382 (protelII:end-components port)
383 (protelII:start-renamed-nets port)
384 (protelII:renamed-nets port (gnetlist:get-renamed-nets "dummy"))
385 (protelII:end-renamed-nets port)
386 (protelII:start-nets port)
388 (protelII:end-nets port))
389 (close-output-port port))))
392 ;; gEDA's native test netlist format specific functions ends
394 ;; --------------------------------------------------------------------------