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) 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;; 23;; Netlister for GOSSIP system simulation system, based on GUILE 24;; For more info see http://gossip.sourceforge.net 25;; 26 27(define gossip:write-top-header 28 (lambda (p) 29 (display ";; Gossip Netlist Created by gNetlist" p) 30 (newline p) 31 (newline p) 32 (display ";; Created By Matt Ettus <matt@ettus.com>" p) 33 (newline p) 34 (display ";; Libraries:" p) 35 (newline p) 36 (newline p))) 37 38(define gossip:get-libraries 39 (lambda (p components done) 40 (if (not (null? components)) 41 (let ((lib (gnetlist:get-package-attribute (car components) "library"))) 42 (if (string=? "unknown" lib) 43 (begin 44 (display "Component ") 45 (display (car components)) 46 (display " does not have a library attribute\n"))) 47 (if (contains? done lib) 48 (gossip:get-libraries p (cdr components) done) 49 (begin 50 (display "(use-library " p) 51 (display lib p) 52 (display " *)" p) 53 (newline p) 54 (gossip:get-libraries p (cdr components) (cons lib done)))))))) 55 56(define gossip:list-pins 57 (lambda (allnets uref pin port) 58 (let ((pinname (gnetlist:get-attribute-by-pinnumber uref (number->string pin) "label"))) 59 (if (string=? "unknown" pinname) 60 (display ")\n" port) 61 (begin 62 (display " :" port) 63 (display pinname port) 64 (write-char #\space port) 65 (display (gossip:find-net uref pin allnets) port) 66 (gossip:list-pins allnets uref (+ 1 pin) port)))))) 67 68;(define gossip:reverse-netlist 69; (lambda (allnets) 70; (if (null? allnets) 71; '() 72; (let ((connections (gnetlist:get-all-connections (car allnets)))) 73; (cons (gossip:connectionlist connections) 74; (gossip:reverse-netlist (cdr allnets)))))) 75 76(define gossip:find-net 77 (lambda (uref pin allnets) 78 (cond 79 ((null? allnets) "Not Connected" ) 80 ((gossip:finder uref pin (gnetlist:get-all-connections (car allnets)))(car allnets)) 81 (#t (gossip:find-net uref pin (cdr allnets)))))) 82 83(define gossip:finder 84 (lambda (uref pin list) 85 (cond 86 ((null? list)#f) 87 ((and (string=? uref (caar list)) (string=? (number->string pin) (cadar list))) #t) 88 (#t (gossip:finder uref pin (cdr list)))))) 89 90(define gossip:display-connections 91 (lambda (nets port) 92 (if (not (null? nets)) 93 (begin 94 (display (car (car nets)) port) 95 (write-char #\space port) 96 (display (car (cdr (car nets))) port) 97 (if (not (null? (cdr nets))) 98 (begin 99 (write-char #\, port) 100 (write-char #\space port))) 101 (gossip:display-connections (cdr nets) port))))) 102 103(define gossip:display-name-nets 104 (lambda (port nets) 105 (begin 106 (gossip:display-connections nets port) 107 (write-char #\space port) 108 (newline port)))) 109 110(define gossip:blocks 111 (lambda (port ls allnets) 112 (if (not (null? ls)) 113 (let ((package (car ls))) 114 (display " (" port) 115 (display package port) 116 (gossip:list-pins allnets package 1 port) 117 (gossip:blocks port (cdr ls) allnets))))) 118 119(define gossip:signals 120 (lambda (port) 121 (display "(signals " port) 122 (display (gnetlist:get-all-unique-nets "dummy") port) 123 (display ")\n" port))) 124 125(define gossip:write-block-header 126 (lambda (port) 127 (let ((blockname (gnetlist:get-toplevel-attribute "blockname"))) 128 (display "(define-block (" port) 129 (display blockname port) 130 (display " (" port) 131 (newline port)))) 132 133(define gossip 134 (lambda (output-filename) 135 (let ((port (open-output-file output-filename))) 136 (begin 137 (gossip:write-top-header port) 138 (gossip:get-libraries port packages '()) 139 (gossip:write-block-header port) 140 (gossip:signals port) 141 (gossip:blocks port packages (gnetlist:get-all-unique-nets "dummy"))) 142 (close-output-port port)))) 143 144 145