;; initialize the net-name aliasing (gnetlist:build-net-aliases switcap:map-net-names all-unique-nets)
The function ``switcap:map-net-names'' is a backend specific (switcap in this case) function which accepts a gschem net name as an argument and returns a modified net name which meets the requirements for the output netlist format. In the case of switcap, the requirement is ground must be called ``0'', nets may have no more than 7 characters, and the netlist is not case sensitive.
;; This procedure takes a net name as determined by ;; gnetlist and modifies it to be a valid SWITCAP net name. ;; (define switcap:map-net-names (lambda (net-name) (let ((rx (make-regexp "^unnamed_net")) (net-alias net-name) ) ;; XXX we should use a dynamic regexp based on the ;; current value for the unnamed net base string. (cond ;; Change "GND" to "0" ((string=? net-name "GND") (set! net-alias "0")) ;; remove the 'unnamed_net' part ((regexp-exec rx net-name) (set! net-alias (substring net-name 11))) (else net-name) ) ;; Truncate to 7 characters (if (> (string-length net-alias) 7) (set! net-alias (substring net-alias 0 7)) ) ;; Convert to all upper case (string-upcase net-alias) ) ) )
The function ``gnetlist:build-net-aliases'' creates a database which later on lets you look up the output net name from the gschem net name or the gschem net name from the output net name. In addition it does the very important task of ensuring that no shorts are created by modifying the net names. As an example suppose you had a net called ``MyNet'' and another called ``mynet'' in the schematic. Those are unique but after converting both to upper case they become a single net. ``gnetlist:build-net-aliases'' will detect this condition and issue an error and stop netlisting.
Now that the database has been initialized, the netlister simply uses
(gnetlist:alias-net somenet)to retrive the netlist net name from the gschem net name.
A similar set of functions are provided for reference designator aliasing.
Ales Hvezda 2005-03-15