1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
4 ;;; Copyright (C) 2003, 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ;;; Notes about futurenet2 (.NV2) format pinlists
23 ;;; - Case does not seem to be preserved so to avoid issues,
24 ;;; simply output the netnames in all caps.
26 ;;; - Netname length is 8 characters max. +,-, and _ are allowed
28 ;;; - How are DATA,3 and DATA,4 used? In one example, DATA,4 is
29 ;;; not used. In the other DATA,3 and DATA,4 are identical and
30 ;;; appear to be set to the value (10.0k for example) of the part.
32 ;;; From Ferenc Marton (martonf at datapress dot hu):
34 ;;; These get combined in Ranger2 to produce the device
35 ;;; description with a "," separating the two entries.
36 ;;; DATA,3 is the "device name", max of 5 characters
37 ;;; DATA,4 is the "device value", max of 13 characters.
38 ;;; We could put the footprint into DATA,4
40 ;;; - In the "PIN" and "SIG" lines, what are the various fields really
43 ;;; It seems that for a PIN line, the format is:
45 ;;; PIN,,<netname>,1-1,5,<net attribute number>,<pinnumber>
47 ;;; What are the "1-1" and the "5"? On the <net attribute
48 ;;; number> I've seen "23", "25", and "100". Maybe these
49 ;;; indicate signal vs power or some sort of routing preference?
51 ;;; For a SIG line, the format seems to be:
53 ;;; SIG,<netname>,1-1,5,<netname>
55 ;;; What exactly are "1-1" and "5"? I think maybe the "1-1" part
56 ;;; has something to do with sheet number in a multipage schematic.
60 ;; This procedure takes a net name as determined by gnetlist and
61 ;; modifies it to be a valid FutureNet2 net name.
63 (define futurenet2:map-net-names
65 (let ((rx (make-regexp "^unnamed_net"))
68 ;; XXX we should use a dynamic regexp based on the current value
69 ;; for the unnamed net base string.
71 ;; Remove "unnamed_net" and replace with "NET"
72 (if (regexp-exec rx net-name)
73 (set! net-alias (string-append "NET" (substring net-name 11)))
76 ;; Truncate to 8 characters
77 (if (> (string-length net-alias) 8)
78 (set! net-alias (substring net-alias 0 8))
80 ;; Convert to all upper case
81 (string-upcase net-alias)
86 ;; This procedure takes a refdes as determined by gnetlist and
87 ;; modifies it to be a valid FutureNet2 refdes.
89 (define futurenet2:map-refdes
91 (let ((refdes-alias refdes)
94 ;; XXX do we need to truncate to 8 characters
95 ;; like with net names?
96 ;; (if (> (string-length refdes-alias) 8)
97 ;; (set! refdes-alias (substring refdes-alias 0 8))
100 ;; Convert to all upper case
101 (string-upcase refdes-alias)
106 ;; write out the pins for a particular component
107 (define futurenet2:component_pins
108 (lambda (port package pins)
109 (if (and (not (null? package)) (not (null? pins)))
113 ;; PIN,,NetName,1-1,5,20/23,pinnum
114 (display "PIN,," port)
117 (gnetlist:alias-net (car (gnetlist:get-nets package pin)))
120 ;; XXX I've seen 20, 23, and 100 in the position where the
121 ;; "23" is here. Seems to be a property like signal vs
122 ;; power net. Not sure how to support that.
123 (display ",1-1,5,23," port)
126 (gnetlist:get-attribute-by-pinnumber package pin "pinnumber")
130 (futurenet2:component_pins port package (cdr pins))
137 ;; write out the components
138 (define futurenet2:components
139 (lambda (port packages symcnt)
140 (if (not (null? packages))
142 (let ((pattern (gnetlist:get-package-attribute (car packages)
144 ;; The above pattern should stay as "pattern" and not "footprint"
145 (package (car packages)))
146 (display "(SYM," port)
147 (display symcnt port)
149 ;; write the reference designator
150 (display "\nDATA,2," port)
151 (display (gnetlist:alias-refdes package) port)
153 ;; If there is a "value" attribute, output that.
154 ;; Otherwise output the "device" attribute (the symbol name).
155 (display "\nDATA,3," port)
157 ((val (gnetlist:get-package-attribute package
159 (if (string=? val "unknown")
160 (set! val (gnetlist:get-package-attribute package "device") )
166 ;; write the footprint
167 (display "DATA,4," port)
168 (display (gnetlist:get-package-attribute package
174 (futurenet2:component_pins port package
175 (gnetlist:get-pins package))
181 (futurenet2:components port (cdr packages) (+ symcnt 1))
187 ;; write out the nets
188 (define futurenet2:write-net
189 (lambda (port netnames)
190 (if (not (null? netnames))
192 (netname (car netnames))
193 (alias (gnetlist:alias-net (car netnames)))
195 (display "SIG," port)
197 (display ",1-1,5," port)
200 (futurenet2:write-net port (cdr netnames))
206 ;; The top level netlister for futurenet2
210 (display "---------------------------------\n")
211 (display "gEDA/gnetlist FutureNet2 Backend\n")
212 (display "This backend is EXPERIMENTAL\n")
213 (display "Use at your own risk!\n")
215 (display "You may need to run the output netlist\n")
216 (display "through unix2dos before importing to\n")
217 (display "Ranger2 or other windows based layout tools\n")
218 (display "---------------------------------\n\n")
220 (let ((port (open-output-file filename))
221 (all-nets (gnetlist:get-all-unique-nets "dummy"))
224 ;; initialize the net-name aliasing
225 (gnetlist:build-net-aliases futurenet2:map-net-names all-unique-nets)
227 ;; initialize the refdes aliasing
228 (gnetlist:build-refdes-aliases futurenet2:map-refdes packages)
231 (display "PINLIST,2\n" port)
232 (display "(DRAWING,GEDA.PIN,1-1\n" port)
234 ;; write the components
235 (futurenet2:components port packages 1)
239 (futurenet2:write-net port all-nets)
245 (close-output-port port)