delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2020/09/18/08:15:15

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=EAs8zvB6InQ9PEOLypNoAKdj8OIC3IWMCZzAxjkxHoY=;
b=FTNjlOcLogFk2FgTkmUZq6Az/3h3iRh95l5+1OPENm9VEE0Av/sgNtabSzTFWZmpkn
SjtrkTGvayvmDVkAjr6lC71YhVV5vdg88MUKsG/OYDer3yygmO5kpBVw4tSet/JeSymO
GHlpJOBJjRGFBfYN/5HTQATMtHbZHRrG/+x9GWy/q325ZB8BLgOJFd0RL+6voXAlDBpS
mIZ1LPu7J1VHwAVS/hUC/8JYhIrYKbBrvk9fn0JN7h5iHbc6msl58oE9cfZwYkozcu7p
cm0bt7R1xYR2qNvxc8kkNjjtCF6WsgY9dvzLfCp2NU54S9VWKamdSZTgDW7iKuifDYcJ
QG4A==
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=EAs8zvB6InQ9PEOLypNoAKdj8OIC3IWMCZzAxjkxHoY=;
b=bbmCiKnTustzb3II+fNDQnaIzhCLS8XmMkej+ARHUWjanb/7d8xhYOjbi1DCq87ABc
ib46oAp7mBsF8/+qgyQgpYykdBoZ/iYD0CXtNylwoLZMF8bL8BmIqogwLfpOH1ROiUJZ
j+1+/s1yMClXTlLjQVXRvHP7zoPKKE/8Eu4+0DieW77erEmrFbTxhQt3e3PCazr6NAlO
gxkuet6T2yyMxgphFwJ+w6QETdzXN4w+8npiVrd10Ia+unhnenb7F41wpLKAIYFEKbrw
K1ClrFBCfIt2yAS4lQVT1PzZOHOmd7ThzD/pCQN4Gq0z1j8Dy3g3nhzvKUSdgiuqCQxB
nmFg==
X-Gm-Message-State: AOAM532Vq2JufXG35qhrQXvj0U6cAv9+7SHrfUy7uyIFmHTRMdYVmgPR
lP5CObG/PVTZiOdN9zfnZM11y6hQzqI=
X-Google-Smtp-Source: ABdhPJy3yKKoXXEPlQ3Cn8UwEY79ojqGtK4RNLBXP2RyZNgj3QM+7t6yJyE602SWMosqacnulLT9aA==
X-Received: by 2002:a2e:9ccd:: with SMTP id g13mr12080675ljj.29.1600430127972;
Fri, 18 Sep 2020 04:55:27 -0700 (PDT)
Date: Fri, 18 Sep 2020 14:54:54 +0300
From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" <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: <20200918115454.GA32474@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>
MIME-Version: 1.0
In-Reply-To: <20200917192250.61a407be109038d62c753807@gmail.com>
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

--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

On Thu, Sep 17, 2020 at 07:22:50PM +0200, N (nicklas DOT karlsson17 AT gmail DOT com) [via geda-user AT delorie DOT com] wrote:
> > On Wed, Sep 16, 2020 at 07:54:16PM +0200, N (nicklas DOT karlsson17 AT gmail DOT com) [via geda-user AT delorie DOT com] wrote:
> > > Anybody here know if it's possible to add attribute for nets so they end up in netlist?
> > 
> > Hi Nicklas,
> > 
> > What do you concretely mean?  Could you please elaborate on it a
> > bit, a little example would not harm.
> 
> Do not mind. Tried to figure how to add attributes for clearance or maybe more correct named creepage as it is distance on circuit board. First reading manual page, loooking for documentation but approached the time then I needed to slop so I thought maybe better to ask on geda mailing list and it all turned around back to you.
> 
> I actually got one answer there i he refere to a link http://www.delorie.com/archives/browse.cgi?p=geda-user/2015/10/14/04:07:24 "note that you can effectively attach attributes to nets using symbols. The fine primitive gnetlist:graphical-objs-in-net-with-attrib-get-attrib (the longest name in the gnetlist namespace) allows a backend to extract them. This is more versatile, as it allows the back end not only access to attributes, but allows a symbol to define relationships between nets. Consider the following, which could allow a backend to deduce that a pair of nets is a transmission line, and give it a name:"
> 
> Worked all day long and have an hour or two left today.

Nicklas,

I'm not sure I got you right.  However, I've attached a script for
'lepton-netlist' with a function which gets all names of
connections whose nets have some definite attribute attached.  It
can be easily transformed into a backend.  Please see hints on
usage at its bottom.

-- 
  Vladimir

(λ)επτόν EDA — https://github.com/lepton-eda

--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="wanted-net.scm"

(use-modules (netlist schematic)
             (netlist schematic toplevel)
             (netlist schematic-connection)
             (lepton object)
             (lepton attrib)
             (srfi srfi-1))


;;; Check if OBJECT is attribute with given NAME and VALUE.
(define (wanted-attrib? object name value)
  (and (attribute? object)
       (string= (attrib-name object) name)
       (string= (attrib-value object) value)))

;;; Check if attribute list ATTRIBS has an attribute with given
;;; NAME and VALUE.
(define (attribs-have-attrib? attribs name value)
  (define (wanted? attrib)
    (wanted-attrib? attrib name value))

  (any wanted? attribs))

;;; Check if OBJECT is net and has attribute with given NAME and
;;; VALUE attached.
(define (net-has-attrib? object name value)
  (and (net? object)
       (attribs-have-attrib? (object-attribs object)
                             name
                             value)))

;;; Check if CONN is a hierarchical schematic connection and has a
;;; net with attached attribute NAME=VALUE.
(define (connection-has-attrib? conn name value)
  (define (wanted-net? object)
    (net-has-attrib? object name value))

  (and (schematic-connection? conn)
       (any wanted-net? (schematic-connection-objects conn))))

;;; Get hierarchical connection names for toplevel schematic by
;;; given attribute NAME and VALUE.
(define (connection-names-by-attrib name value)
  (define connections
    (schematic-connections (toplevel-schematic)))

  (define (wanted-connection? conn)
    (connection-has-attrib? conn name value))

  (define wanted-connections
    (filter wanted-connection? connections))

  (define canonical-name schematic-connection-override-name)

  (map canonical-name wanted-connections))

;;; Open your schematic using:
;;;   lepton-netlist -i my-schematic.sch
;;; Usage in REPL:
;;;   (primitive-load "/path/to/this/script/wanted-net.scm")
;;;   (connection-names-by-attrib "myname" "myval")
;;;   (connection-names-by-attrib "other-name" "other-val")

--+HP7ph2BbKc20aGI--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019