1;;; gEDA - GPL Electronic Design Automation 2;;; gnetlist - gEDA Netlist 3;;; Copyright (C) 2008-2010 Ales Hvezda 4;;; 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. 9;;; 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. 14;;; 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., 51 Franklin Street, Fifth Floor, Boston, 18;;; MA 02111-1301 USA 19 20;; -------------------------------------------------------------------------- 21;; 22;; liquid pcb gnetlist backend 23;; 24 25;; 26;; Top level header 27;; 28(define liquidpcb:write-top-header 29 (lambda (p) 30 (display "<LiquidPCB>" p) 31 (newline p))) 32 33;; 34;; Bottom footer 35;; 36(define liquidpcb:write-bottom-footer 37 (lambda (p) 38 (display "</LiquidPCB>" p) 39 (newline p))) 40 41;; 42;; Header for netlist section 43;; 44(define liquidpcb:start-netlist 45 (lambda (p) 46 (display " <netlist name=\"Main netlist\">" p) 47 (newline p))) 48 49;; 50;; footer for netlist section 51;; 52(define liquidpcb:end-netlist 53 (lambda (p) 54 (display " </netlist>" p) 55 (newline p))) 56 57;; 58;; Write the individual net connections 59;; 60(define liquidpcb:write-connections 61 (lambda (nets port) 62 (if (not (null? nets)) 63 (begin 64 (display " <netnode component=\"" port) 65 (display (car (car nets)) port) 66 (display "\" pin=" port) 67 (display (car (cdr (car nets))) port) 68 (display " />" port) 69 (newline port) 70 (liquidpcb:write-connections (cdr nets) port))))) 71 72 73;; 74;; Write netname : uref pin, uref pin, ... 75;; 76(define liquidpcb:write-net 77 (lambda (port netnames) 78 (if (not (null? netnames)) 79 (let ((netname (car netnames))) 80 (begin 81 (display " <net name=\"" port) 82 (display netname port) 83 (display "\">" port) 84 (newline port) 85 (liquidpcb:write-connections (gnetlist:get-all-connections netname) port) 86 (display " </net>" port) 87 (newline port) 88 (liquidpcb:write-net port (cdr netnames))))))) 89 90;; 91;; Write the netlist section of the liquidPCB format 92;; 93(define liquidpcb:write-netlist 94 (lambda (port) 95 (let ((all-uniq-nets (gnetlist:get-all-unique-nets "dummy"))) 96 (liquidpcb:write-net port all-uniq-nets)))) 97 98;; 99;; Highest level function 100;; 101(define liquidpcb 102 (lambda (output-filename) 103 (let ((port (open-output-file output-filename))) 104 (begin 105 (liquidpcb:write-top-header port) 106 (liquidpcb:start-netlist port) 107 (liquidpcb:write-netlist port) 108 (liquidpcb:end-netlist port)) 109 (liquidpcb:write-bottom-footer port) 110 (close-output-port port)))) 111 112;; 113;; liquid PCB netlist backend ends 114;; 115;; -------------------------------------------------------------------------- 116 117