1 ;;; tEDAx plug-in for lepton-netlist
2 ;;; Copyright (C) 2018 Bdale Garbee
4 ;;; This program is free software; you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 2 of the License, or
7 ;;; (at your option) any later version.
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;;; GNU General Public License for more details.
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program; if not, write to the Free Software
16 ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 ;;; MA 02111-1301 USA.
19 ;; --------------------------------------------------------------------------
20 ;; The tEDAx format is documented at http://repo.hu/projects/tedax/
21 ;; --------------------------------------------------------------------------
23 (use-modules (gnetlist schematic))
26 ;; return device attribute
28 (define (tEDAx:get-device package)
29 (gnetlist:get-package-attribute package "device"))
32 ;; return footprint attribute (UNKNOWN if not defined)
34 (define (tEDAx:get-pattern package)
35 (let ((pattern (gnetlist:get-package-attribute package "footprint")))
36 (if (unknown? pattern) "UNKNOWN" pattern)))
39 ;; returns value attribute (empty if not defined)
41 (define (tEDAx:get-value package)
42 (let ((value (gnetlist:get-package-attribute package "value")))
43 (if (unknown? value) "" value)))
48 (define (tEDAx:header)
49 (format #t "tEDAx v1\nbegin netlist v1 netlist\n\n"))
54 (define (tEDAx:trailer)
55 (format #t "end netlist\n"))
58 ;; emit component related lines
60 (define (tEDAx:components ls)
63 (format #t "\tfootprint ~A ~A\n\tdevice ~A ~A\n\tvalue ~A ~A\n\n"
65 (tEDAx:get-pattern package)
67 (tEDAx:get-device package)
69 (tEDAx:get-value package)))
73 ;; emit network related lines for current net
75 (define (tEDAx:display-connections netname nets)
77 (define pinnumber cdr)
81 (format #f "\tconn ~A ~A ~A\n"
89 ;; iterate over all nets
91 (define (tEDAx:nets netnames)
95 (tEDAx:display-connections netname (get-all-connections netname))))
99 ;;; emit netlist in tEDAx interchange format
101 (define (tEDAx output-filename)
102 (let ((nets (schematic-nets toplevel-schematic))
103 (packages (schematic-packages toplevel-schematic)))
105 (tEDAx:components packages)
109 ;; --------------------------------------------------------------------------