X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=fegxJiruYykIQaqV8SELJeOLhwyDsBm+IMAOG1wGgMk=; b=OGNuEgIRcE/RkyZs4tjYGdNuhz/w/+Dz5Q+IXTfJFL0JilVeUscWqyKWV18SWvl3Gu oKGqyPib4I648+UsOap37HOXRLkFonA/YceGhdQR2lM13JxM1bgYyWIA7hps9YunlJtu zmOFEbFtrsNuKDut1L05X59Jbg2rYbOwvB/U2E3tlNr6vyw0YfZnOqDujlfB14hiHph6 UJ/YykcyYRT7gfGjHVV+Bg1aTP09DdrTRp/Ex5lIZaxdaLlalqtDsWqG6+XfIJzPzW/o VDmSWsA5U3TVdCz+TrAQHcRj3oRk7Qq/BY26ZlD3dWjRe6uDzP8U7aMWtcdIfwTbVOrE FYuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=fegxJiruYykIQaqV8SELJeOLhwyDsBm+IMAOG1wGgMk=; b=htuei8gi9NFPyE/nUHZtTZsdfzzLYSQ453hCeN4SGw23HXYsMr21AZgsMA1ySbadZH 4U6pBNwwlOSEV9KFSWbDLvTsVbACp5C23vGj1CAwrYaPLD+Dt1f4oQ8WHZUPSNX0lPN1 G2DtI3fP4YKI6QdXOlorjIclK2dRcGaxFEv6alEmFAvr8oug86cgIVgnc/qxguk1SZDy cFYqweNwt+ITugBsWUzjpooNfPQC+2196zCc/Na3kijFbOn49prf1sK4oXNO3mn2la0H XQ/ARZjeAYygagfWspHeQt3uJvRiA3xs0/9Ro7kZmQVcxgDaBSo06GJe6agy8WyDx4ec EXng== X-Gm-Message-State: AOAM533CxHibUwy6QDMp6tNf5O321hYU2nwQQfV31d+W0pW5DF6mDOKL SN36RGZ318mQg17ZXfPbT2TawdPCCAc= X-Google-Smtp-Source: ABdhPJxAppieG22lr73ksSGvjjC3AQxfCEX4dS6BbGT0nPnw2AhiDfPgmuU/p3f/bMWt3XZUarTgMQ== X-Received: by 2002:a2e:a408:: with SMTP id p8mr3715478ljn.154.1601223738674; Sun, 27 Sep 2020 09:22:18 -0700 (PDT) Date: Sun, 27 Sep 2020 19:21:46 +0300 From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] lepton-netlist add attribute for net Message-ID: <20200927162146.GA1582@newvzh.lokolhoz> Mail-Followup-To: geda-user AT delorie DOT com References: <20200916195416 DOT 5c5aab17c30822d03dfc8ba9 AT gmail DOT com> <20200916222355 DOT GA31062 AT newvzh DOT lokolhoz> <20200917192250 DOT 61a407be109038d62c753807 AT gmail DOT com> <20200918115454 DOT GA32474 AT newvzh DOT lokolhoz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200918115454.GA32474@newvzh.lokolhoz> User-Agent: Mutt/1.10.1 (2018-07-13) Note-from-DJ: This may be spam Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi Nicklas, IIUC (after looking at your last reply in another thread), you want to add "nettag" lines in tEDAx backend reflecting attributes of nets in your schematic. If so, please see attached script. -- Vladimir (λ)επτόν EDA — https://github.com/lepton-eda --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="gnet-tEDAxN.scm" ;;; Lepton EDA netlister ;;; tEDAxN plug-in for lepton-netlist ;;; Copyright (C) 2018 Bdale Garbee ;;; Copyright (C) 2018 Lepton EDA Contributors ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software ;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ;; -------------------------------------------------------------------------- ;; The tEDAx format is documented at http://repo.hu/projects/tedax/ ;; -------------------------------------------------------------------------- (use-modules (netlist schematic) (netlist schematic toplevel) (netlist schematic-connection) (netlist net) (lepton object) (lepton attrib) (srfi srfi-1)) ;; ;; return device attribute ;; (define (tEDAxN:get-device package) (gnetlist:get-package-attribute package "device")) ;; ;; return footprint attribute (UNKNOWN if not defined) ;; (define (tEDAxN:get-pattern package) (let ((pattern (gnetlist:get-package-attribute package "footprint"))) (if (unknown? pattern) "UNKNOWN" pattern))) ;; ;; returns value attribute (empty if not defined) ;; (define (tEDAxN:get-value package) (let ((value (gnetlist:get-package-attribute package "value"))) (if (unknown? value) "" value))) ;; ;; emit header ;; (define (tEDAxN:header) (format #t "tEDAxN v1\nbegin netlist v1 netlist\n\n")) ;; ;; emit trailer ;; (define (tEDAxN:trailer) (format #t "end netlist\n")) ;; ;; emit component related lines ;; (define (tEDAxN:components ls) (for-each (lambda (package) (format #t "\tfootprint ~A ~A\n\tdevice ~A ~A\n\tvalue ~A ~A\n\n" package (tEDAxN:get-pattern package) package (tEDAxN:get-device package) package (tEDAxN:get-value package))) ls)) ;; ;; emit network related lines for current net ;; (define (tEDAxN:display-connections netname nets) (define package car) (define pinnumber cdr) (string-join (map (lambda (net) (format #f "\tconn ~A ~A ~A\n" netname (package net) (pinnumber net))) nets) "")) ;; ;; iterate over all nets ;; (define (tEDAxN:connections netnames) (for-each (lambda (netname) (format #t "~A\n" (tEDAxN:display-connections netname (get-all-connections netname)))) netnames)) ;;; Output all net attributes for all CONNECTIONS in the format ;;; "nettag connection-name attrib-name attrib-value". ;;; Attributes "netname=" are filtered out from the list. (define (tEDAxN:netattributes connections) (define (output-list ls) (unless (null? ls) (apply format #t "\tnettag ~A ~A ~A\n" ls))) (define (conn-attrib->name-ls conn attrib) (if (string= (attrib-name attrib) "netname") ;; If attrib is "netname=", skip it. '() ;; Otherwise, create the list in the form: ;; '(connection-name attrib-name attrib-value) (list (schematic-connection-override-name conn) (attrib-name attrib) (attrib-value attrib)))) (define (connection-nets conn) (filter net? (schematic-connection-objects conn))) (define (connection-attribs conn) (append-map object-attribs (connection-nets conn))) (define (connection->name-attrib-lists conn) (map (lambda (attrib) (conn-attrib->name-ls conn attrib)) (connection-attribs conn))) (define list-of-conn-attrib-lists (append-map connection->name-attrib-lists connections)) (for-each output-list list-of-conn-attrib-lists)) ;;; ;;; emit netlist in tEDAxN interchange format ;;; (define (tEDAxN output-filename) (let ((nets (schematic-nets (toplevel-schematic))) (packages (schematic-package-names (toplevel-schematic))) (connections (schematic-connections (toplevel-schematic)))) (tEDAxN:header) (tEDAxN:components packages) (tEDAxN:netattributes connections) (tEDAxN:connections nets) (tEDAxN:trailer))) ;; -------------------------------------------------------------------------- --k1lZvvs/B4yU6o8G--