1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 2008-2010 Ales Hvezda
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ;; --------------------------------------------------------------------------
21 ;; liquid pcb gnetlist backend
27 (define liquidpcb:write-top-header
29 (display "<LiquidPCB>" p)
35 (define liquidpcb:write-bottom-footer
37 (display "</LiquidPCB>" p)
41 ;; Header for netlist section
43 (define liquidpcb:start-netlist
45 (display " <netlist name=\"Main netlist\">" p)
49 ;; footer for netlist section
51 (define liquidpcb:end-netlist
53 (display " </netlist>" p)
57 ;; Write the individual net connections
59 (define liquidpcb:write-connections
61 (if (not (null? nets))
63 (display " <netnode component=\"" port)
64 (display (car (car nets)) port)
65 (display "\" pin=" port)
66 (display (car (cdr (car nets))) port)
69 (liquidpcb:write-connections (cdr nets) port)))))
73 ;; Write netname : uref pin, uref pin, ...
75 (define liquidpcb:write-net
76 (lambda (port netnames)
77 (if (not (null? netnames))
78 (let ((netname (car netnames)))
80 (display " <net name=\"" port)
81 (display netname port)
84 (liquidpcb:write-connections (gnetlist:get-all-connections netname) port)
85 (display " </net>" port)
87 (liquidpcb:write-net port (cdr netnames)))))))
90 ;; Write the netlist section of the liquidPCB format
92 (define liquidpcb:write-netlist
94 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy")))
95 (liquidpcb:write-net port all-uniq-nets))))
98 ;; Highest level function
101 (lambda (output-filename)
102 (let ((port (open-output-file output-filename)))
104 (liquidpcb:write-top-header port)
105 (liquidpcb:start-netlist port)
106 (liquidpcb:write-netlist port)
107 (liquidpcb:end-netlist port))
108 (liquidpcb:write-bottom-footer port)
109 (close-output-port port))))
112 ;; liquid PCB netlist backend ends
114 ;; --------------------------------------------------------------------------