1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Ultiboard (ewnet) backend
4 ;;; Copyright (C) 2011 Dan McMahill
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., 51 Franklin Street, Fifth Floor, Boston,
19 ;;; MA 02111-1301 USA.
22 ;;; Notes about Ultiboard (.ewnet) netlists. "ew"
23 ;;; stands for Electronic Workbench.
26 ;;; FIXME -- the biggest problem with this backend is that I
27 ;;; had no documentation at all on the file format. I just
28 ;;; found a .ewnet file online somewhere, read it, and guessed
29 ;;; as to the right way to create these. Full documentation would
30 ;;; help considerably!
32 ;; Function: ewnet:map-net-names
34 ;; This procedure takes a net name as determined by gnetlist and
35 ;; modifies it to be a valid ewnet net name.
37 ;; FIXME -- need to determine what restrictions there may be on
38 ;; ewnet net names. For example:
39 ;; - allowed characters
40 ;; - case sensitive or not?
43 ;; See the futurenet2 backend for examples of some of what may go
44 ;; into a net name aliasing function. For now this function just returns
45 ;; the input string and acts as a placeholder in case we find
46 ;; that net name mapping is required.
47 (define ewnet:map-net-names
49 (let ((net-alias net-name)
56 ;; Function: ewnet:map-refdes
58 ;; This procedure takes a refdes as determined by gnetlist and
59 ;; modifies it to be a valid ewnet refdes.
61 ;; FIXME -- need to determine what restrictions there may be on
62 ;; ewnet instance names (refdes). For example:
63 ;; - allowed characters
64 ;; - case sensitive or not?
67 ;; See the futurenet2 backend for examples of some of what may go
68 ;; into a instance name aliasing function. For now this function
69 ;; just returns the input string and acts as a placeholder in
70 ;; case we find that instance name mapping is required.
71 (define ewnet:map-refdes
73 (let ((refdes-alias refdes)
81 ;; write out the pins for a particular component
82 (define ewnet:component_pins
83 (lambda (port package pins)
84 (if (and (not (null? package)) (not (null? pins)))
90 (display "\t\t(pin \"" port)
92 (gnetlist:get-attribute-by-pinnumber package pin "pinnumber")
97 (display "\t\t\t(net \"" port)
99 (gnetlist:alias-net (car (gnetlist:get-nets package pin)))
101 (display "\")\n" port)
103 ;; pin type. I have seen "PWR", "GND", "IN", "OUT", "BIDIR"
104 (display "\t\t\t(pintype \"" port)
105 ;; FIXME -- need to translate between geda and the allowed
107 (display "BIDIR" port)
108 (display "\")\n" port)
110 (display "\t\t\t(gategroup \"\")\n" port)
111 (display "\t\t\t(pingroup \"\")\n" port)
114 (display "\t\t\t(label \"" port)
116 (display "\")\n" port)
119 (display "\t\t\t(gate \"\")\n" port)
122 (display "\t\t)\n" port)
124 (ewnet:component_pins port package (cdr pins))
131 ;; write out the components
132 (define ewnet:components
133 (lambda (port packages)
134 (if (not (null? packages))
137 (device (gnetlist:get-package-attribute (car packages)
139 (pattern (gnetlist:get-package-attribute (car packages)
141 (value (gnetlist:get-package-attribute (car packages)
143 ;; The above pattern should stay as "pattern" and not "footprint"
144 (package (car packages)))
146 ;; start the instance
147 (display "\t(instance \"" port)
149 ;; write the footprint
150 (display (gnetlist:get-package-attribute package
153 (display "\" \"" port)
155 ;; write the reference designator
156 (display (gnetlist:alias-refdes package) port)
157 (display "\"\n" port)
161 (display "\t\t(device \"" port)
162 (display device port)
163 (display "\")\n" port)
165 ;; If there is a "value" attribute, output that.
166 ;; Otherwise output the "device" attribute (the symbol name).
167 (if (string=? value "unknown")
172 (display "\t\t(value \"" port)
174 (display "\")\n" port)
176 (display "\t\t(gateswap \"0\")\n" port)
177 (display "\t\t(pinswap \"0\")\n" port)
178 (display "\t\t(component_space \"0.00000000e+000\")\n" port)
179 (display "\t\t(component_group \"\")\n" port)
180 (display "\t\t(settings_locked \"0\")\n" port)
181 (display "\t\t(comp_variants \"Default1;\")\n" port)
182 (display "\t\t(comp_variant_independent \"0\")\n" port)
185 (ewnet:component_pins port package
186 (gnetlist:get-pins package))
189 (display "\t)\n" port)
192 (ewnet:components port (cdr packages) )
198 ;; write out the nets
199 (define ewnet:write-net
200 (lambda (port netnames)
201 (if (not (null? netnames))
203 (netname (car netnames))
204 (alias (gnetlist:alias-net (car netnames)))
206 (display "\t( net \"" port)
208 (display "\"\n" port)
210 (display "\t\t(trackwidth \"-1.00000000e+000\")\n" port)
211 (display "\t\t(trackwidth_max \"-1.00000000e+000\")\n" port)
212 (display "\t\t(trackwidth_min \"-1.00000000e+000\")\n" port)
213 (display "\t\t(tracklength_max \"-1.00000000e+000\")\n" port)
214 (display "\t\t(tracklength_min \"-1.00000000e+000\")\n" port)
215 (display "\t\t(clearance_to_trace \"-1.00000000e+000\")\n" port)
216 (display "\t\t(clearance_to_pad \"-1.00000000e+000\")\n" port)
217 (display "\t\t(clearance_to_via \"-1.00000000e+000\")\n" port)
218 (display "\t\t(clearance_to_copper \"-1.00000000e+000\")\n" port)
219 (display "\t\t(routing_layer \"\")\n" port)
220 (display "\t\t(settings_locked \"0\")\n" port)
221 (display "\t\t(net_group \"\")\n" port)
222 (display "\t)\n" port)
224 (ewnet:write-net port (cdr netnames))
230 ;; write out the header
231 (define ewnet:write-header
234 (display "(ToolInfo\n" port)
235 (display "\t(netlist \"ULTIboard\" 7 0 0)\n" port)
236 (display "\t(tool \"Multisim\" 7 0 0)\n" port)
237 (display "\t(timestamp \"15:19:8\" \"9-6-2006\")\n" port)
238 (display "\t(version 3 0 0)\n" port)
239 (display "\t(gateswap 2)\n" port)
240 (display "\t(pinswap 1)\n" port)
241 (display "\t(crossprobe {D6EE9C01-C93E-4246-9BC1-214A35C4954C})\n" port)
242 (display "\t(units Mil)\n" port)
248 ;; write out the layer information
249 ;; FIXME -- can this just be left out? If not, how shall we define
250 ;; stackup in a way where gnetlist can find it?
254 (display "\t(layer \"Copper Bottom\"\n" port)
255 (display "\t\t(routable \"1\")\n" port)
256 (display "\t\t(type \"Signal\")\n" port)
257 (display "\t)\n" port)
258 (display "\t(layer \"Copper Top\"\n" port)
259 (display "\t\t(routable \"1\")\n" port)
260 (display "\t\t(type \"Signal\")\n" port)
261 (display "\t)\n" port)
265 ;; The top level netlister for ewnet
269 (display "---------------------------------\n")
270 (display "gEDA/gnetlist ewnet Backend\n")
271 (display "This backend is EXPERIMENTAL\n")
272 (display "Use at your own risk!\n")
274 (display "You may need to run the output netlist\n")
275 (display "through unix2dos before importing to\n")
276 (display "windows based layout tools\n")
277 (display "---------------------------------\n\n")
279 (let ((port (open-output-file filename))
280 (all-nets (gnetlist:get-all-unique-nets "dummy"))
283 ;; initialize the net-name aliasing
284 (gnetlist:build-net-aliases ewnet:map-net-names all-unique-nets)
286 ;; initialize the refdes aliasing
287 (gnetlist:build-refdes-aliases ewnet:map-refdes packages)
290 (ewnet:write-header port)
293 (display "(nets\n" port)
294 (ewnet:write-net port all-nets)
297 ;; write the components
298 (display "(components\n" port)
299 (ewnet:components port packages)
302 ;; write the board layers
303 (display "(layers\n" port)
308 (close-output-port port)