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

gEDA-user: How I'd write a netlister in Scheme... Was: Introduction and some questions/thoughts on gEDA/gaf...



Hello again, everyone!

Well, I've been studying gEDA/gnetlist codebas for a while now and
I do have a feeling that there ought to be a better way to do netlisting,
espcially since it is conceptually a rather simple operation. Well, the hard
part is maintaining net connectivity, which is done now on libgeda level,
in C, right? Nothing prevents us from storing a list of nets to which
individual pins of a component are connected as an instance attribute
(alternatively, can we attach attributes to instance pins? -- this is what
Cadence DFII is doing during "Check and Save", but having a single list
attached to an instance in pinseq order is just fine too).

After that the job of a netlister is to loop through all components on a
schematic page and call special-purpose element-writing functions.
The most natural way to pass component attributes to those functions
is to (eval (let ((model "modelName")
                        (refdes "U25")
                        (netnames (list "net1" "net15" "GND"))
                         <all other attributes on the component>)
                       (processElement) ; special-purpose function
                       ;; update attributes -- see below
                      ))
-- of course the (let) block is  constructed on the fly with macros.
Now, (processElement) sees all relevant attributes as just scheme
variables, moreover, if, say, (model) is not defined for a given element
scheme itself can search up the scope for an appropriate default.

Now, for netlister we need read-only access to schematic, but an iterator
over all elements can be made even more useful by, after (processElement)
is called, chacking if attributes (scheme variables) were changed  by
(processElement)
and, if yes, saving chages back to schematic (backannotation, scaling, etc.)

To handle hierarchy it would be up to (processElement) function to decide
if we want flat netlist, then call (netlist source) recursively if
source is defined
or, if we want to preserve hierarchy in the netlist, to add 'source'
to the set of
things to netlist later.

Is there anything else that generic netlister has to do besides this? If no,
I'll try to prototype it as soon as I get some kind of scheme command line
working...

> Whatever I end up doing will have to take this into account (read: I will
> probably stick with scheme but use a different portable interpreter).
>
>                                                                 -Ales

Any thoughts on what could that be? I can see that guile is not the most
active project (well, kind of competes with Hurd ;-) ), even Gimp now
uses another smaller scheme interpreter. PLT scheme seems to be
quite popular in the crowd, and they do have leight-weighted embeddable
MzScheme (http://www.plt-scheme.org/software/mzscheme/) package,
as well as nice development environment
http://www.plt-scheme.org/software/drscheme/,
seems to be pretty active too.

Paul B.