1;;; gEDA - GPL Electronic Design Automation 2;;; gnetlist - gEDA Netlist 3;;; Ultiboard (ewnet) backend 4;;; Copyright (C) 2011 Dan McMahill 5;;; 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. 10;;; 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. 15;;; 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. 20 21 22;;; Notes about Ultiboard (.ewnet) netlists. "ew" 23;;; stands for Electronic Workbench. 24;;; 25 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! 31 32;; Function: ewnet:map-net-names 33;; 34;; This procedure takes a net name as determined by gnetlist and 35;; modifies it to be a valid ewnet net name. 36;; 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? 41;; - max length 42;; 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 48 (lambda (net-name) 49 (let ((net-alias net-name) 50 ) 51 net-alias 52 ) 53 ) 54 ) 55 56;; Function: ewnet:map-refdes 57;; 58;; This procedure takes a refdes as determined by gnetlist and 59;; modifies it to be a valid ewnet refdes. 60;; 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? 65;; - max length 66;; 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 72 (lambda (refdes) 73 (let ((refdes-alias refdes) 74 ) 75 76 refdes-alias 77 ) 78 ) 79 ) 80 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))) 85 (begin 86 (let ( 87 (pin (car pins))) 88 89 ;; pin number 90 (display "\t\t(pin \"" port) 91 (display 92 (gnetlist:get-attribute-by-pinnumber package pin "pinnumber") 93 port) 94 (display "\"\n" port) 95 96 ;; net 97 (display "\t\t\t(net \"" port) 98 (display 99 (gnetlist:alias-net (car (gnetlist:get-nets package pin))) 100 port) 101 (display "\")\n" port) 102 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 106 ;; ewnet types here 107 (display "BIDIR" port) 108 (display "\")\n" port) 109 110 (display "\t\t\t(gategroup \"\")\n" port) 111 (display "\t\t\t(pingroup \"\")\n" port) 112 113 ;; label (pin name) 114 (display "\t\t\t(label \"" port) 115 (display pin port) 116 (display "\")\n" port) 117 118 ;; gate 119 (display "\t\t\t(gate \"\")\n" port) 120 121 122 (display "\t\t)\n" port) 123 ) 124 (ewnet:component_pins port package (cdr pins)) 125 ) 126 ) 127 ) 128 ) 129 130 131;; write out the components 132(define ewnet:components 133 (lambda (port packages) 134 (if (not (null? packages)) 135 (begin 136 (let ( 137 (device (gnetlist:get-package-attribute (car packages) 138 "device")) 139 (pattern (gnetlist:get-package-attribute (car packages) 140 "pattern")) 141 (value (gnetlist:get-package-attribute (car packages) 142 "value")) 143 ;; The above pattern should stay as "pattern" and not "footprint" 144 (package (car packages))) 145 146 ;; start the instance 147 (display "\t(instance \"" port) 148 149 ;; write the footprint 150 (display (gnetlist:get-package-attribute package 151 "footprint") 152 port) 153 (display "\" \"" port) 154 155 ;; write the reference designator 156 (display (gnetlist:alias-refdes package) port) 157 (display "\"\n" port) 158 159 160 ;; device 161 (display "\t\t(device \"" port) 162 (display device port) 163 (display "\")\n" port) 164 165 ;; If there is a "value" attribute, output that. 166 ;; Otherwise output the "device" attribute (the symbol name). 167 (if (string=? value "unknown") 168 (set! value device ) 169 ) 170 171 ;; value 172 (display "\t\t(value \"" port) 173 (display value port) 174 (display "\")\n" port) 175 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) 183 184 ;; write the pins 185 (ewnet:component_pins port package 186 (gnetlist:get-pins package)) 187 188 ;; close the part 189 (display "\t)\n" port) 190 191 ) 192 (ewnet:components port (cdr packages) ) 193 ) 194 ) 195 ) 196 ) 197 198;; write out the nets 199(define ewnet:write-net 200 (lambda (port netnames) 201 (if (not (null? netnames)) 202 (let ( 203 (netname (car netnames)) 204 (alias (gnetlist:alias-net (car netnames))) 205 ) 206 (display "\t( net \"" port) 207 (display alias port) 208 (display "\"\n" port) 209 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) 223 224 (ewnet:write-net port (cdr netnames)) 225 ) 226 ) 227 ) 228 ) 229 230;; write out the header 231(define ewnet:write-header 232 (lambda (port) 233 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) 243 (display ")\n" port) 244 ) 245) 246 247 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? 251(define ewnet:layers 252 (lambda (port) 253 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) 262 ) 263) 264 265;; The top level netlister for ewnet 266(define ewnet 267 (lambda (filename) 268 (newline) 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") 273 (display "\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") 278 279 (let ((port (open-output-file filename)) 280 (all-nets (gnetlist:get-all-unique-nets "dummy")) 281 ) 282 283 ;; initialize the net-name aliasing 284 (gnetlist:build-net-aliases ewnet:map-net-names all-unique-nets) 285 286 ;; initialize the refdes aliasing 287 (gnetlist:build-refdes-aliases ewnet:map-refdes packages) 288 289 ;; write the header 290 (ewnet:write-header port) 291 292 ;; write the nets 293 (display "(nets\n" port) 294 (ewnet:write-net port all-nets) 295 (display ")\n" port) 296 297 ;; write the components 298 (display "(components\n" port) 299 (ewnet:components port packages) 300 (display ")\n" port) 301 302 ;; write the board layers 303 (display "(layers\n" port) 304 (ewnet:layers port) 305 (display ")\n" port) 306 307 ;; close netlist 308 (close-output-port port) 309 ) 310 ) 311 ) 312 313 314 315