[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: gnetlist commands



> Hello,
> 
> I just write my first netlister with gentlist and it's also my first proj=
> ect=20
> with scheme.=20

Congratulations!  Scheme hacking is both easy and fun, once you wrap
your mind around its functional programming style. 

> Maybe someone can answer me the following questions:

Following from the architecture of the C <-> Scheme glue, there are
three places you need to look:

1.  Most netlist handling functions are defined in C in the file
geda-gnetlist/src/g_netlist.c. 

2.  C Functions which are exported to Scheme are registered in
geda-gnetlist/src/g_register.c.  These functions are typically the
same as those listed in 1. above.  

3.  Global functions defined and used in Scheme are defined in
geda-gnetlist/scheme/gnetlist.scm.  These are typically only wrappers
of the exported C fcns, but there are some higher-level fcns in there
also. 

> 
> When I have the refdes. How can I get:
> 
> - All properties of this package
>
If you mean "all attributes attached to this package", then this
doesn't seem to exist, at least as far as I have seen.  If I am
wrong, please correct me.  

I will need this function soon for my own "gattrib" project, so perhaps
I will write one.  But don't wait for me if you need it soon!   

>
> - All pinnames of this package
>
In geda-gnetlist/src/g_netlist.c:
SCM g_get_pins(SCM uref)

In geda-gnetlist/scheme/gnetlist.scm:
;; return all pins for a particular package 
(define pins
   (lambda (package)
      (gnetlist:get-pins package)))

(Note that this Scheme fcn just wraps the C fcn.)

>
> - All nets connectet to this package
>
In geda-gnetlist/src/g_netlist.c:
/* Given a uref and a pin number return a list of: */
/*  (netname (uref pin) (uref pin) ... ) */
SCM g_get_nets(SCM scm_uref, SCM scm_pin)

In geda-gnetlist/src/g_netlist.c:
/* Given a uref, Return a list of pairs, each pair contains the name
 * of the pin, and the name of the net connected to that pin.  
 */
SCM g_get_pins_nets(SCM scm_uref)

I didn't see a wrapper for these in
geda-gnetlist/scheme/gnetlist.scm, but you can invoke them from within
Scheme by using the name with which they are registered in
geda-gnetlist/src/g_register.c 

HTH,

Stuart