1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 1998-2010 Ales Hvezda
4 ;;; Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
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.
20 ;; --------------------------------------------------------------------------
22 ;; Netlister for GOSSIP system simulation system, based on GUILE
23 ;; For more info see http://gossip.sourceforge.net
26 (define gossip:write-top-header
28 (display ";; Gossip Netlist Created by gNetlist" p)
31 (display ";; Created By Matt Ettus <matt@ettus.com>" p)
33 (display ";; Libraries:" p)
37 (define gossip:get-libraries
38 (lambda (p components done)
39 (if (not (null? components))
40 (let ((lib (gnetlist:get-package-attribute (car components) "library")))
41 (if (string=? "unknown" lib)
43 (display "Component ")
44 (display (car components))
45 (display " does not have a library attribute\n")))
46 (if (contains? done lib)
47 (gossip:get-libraries p (cdr components) done)
49 (display "(use-library " p)
53 (gossip:get-libraries p (cdr components) (cons lib done))))))))
55 (define gossip:list-pins
56 (lambda (allnets uref pin port)
57 (let ((pinname (gnetlist:get-attribute-by-pinnumber uref (number->string pin) "label")))
58 (if (string=? "unknown" pinname)
62 (display pinname port)
63 (write-char #\space port)
64 (display (gossip:find-net uref pin allnets) port)
65 (gossip:list-pins allnets uref (+ 1 pin) port))))))
67 ;(define gossip:reverse-netlist
71 ; (let ((connections (gnetlist:get-all-connections (car allnets))))
72 ; (cons (gossip:connectionlist connections)
73 ; (gossip:reverse-netlist (cdr allnets))))))
75 (define gossip:find-net
76 (lambda (uref pin allnets)
78 ((null? allnets) "Not Connected" )
79 ((gossip:finder uref pin (gnetlist:get-all-connections (car allnets)))(car allnets))
80 (#t (gossip:find-net uref pin (cdr allnets))))))
83 (lambda (uref pin list)
86 ((and (string=? uref (caar list)) (string=? (number->string pin) (cadar list))) #t)
87 (#t (gossip:finder uref pin (cdr list))))))
89 (define gossip:display-connections
91 (if (not (null? nets))
93 (display (car (car nets)) port)
94 (write-char #\space port)
95 (display (car (cdr (car nets))) port)
96 (if (not (null? (cdr nets)))
99 (write-char #\space port)))
100 (gossip:display-connections (cdr nets) port)))))
102 (define gossip:display-name-nets
105 (gossip:display-connections nets port)
106 (write-char #\space port)
109 (define gossip:blocks
110 (lambda (port ls allnets)
112 (let ((package (car ls)))
114 (display package port)
115 (gossip:list-pins allnets package 1 port)
116 (gossip:blocks port (cdr ls) allnets)))))
118 (define gossip:signals
120 (display "(signals " port)
121 (display (gnetlist:get-all-unique-nets "dummy") port)
122 (display ")\n" port)))
124 (define gossip:write-block-header
126 (let ((blockname (gnetlist:get-toplevel-attribute "blockname")))
127 (display "(define-block (" port)
128 (display blockname port)
133 (lambda (output-filename)
134 (let ((port (open-output-file output-filename)))
136 (gossip:write-top-header port)
137 (gossip:get-libraries port packages '())
138 (gossip:write-block-header port)
139 (gossip:signals port)
140 (gossip:blocks port packages (gnetlist:get-all-unique-nets "dummy")))
141 (close-output-port port))))