Re: gEDA-user: gnetlist backend

2011-06-10 Thread Dan White
On Thu, Jun 9, 2011 at 10:50 PM, Frank Thomson  wrote:
>> I'm not quite sure what you're asking, but perhaps
>> (gnetlist:graphical-objs-in-net-with-attrib-get-attrib) is the function you
>> seek.
>
>
> hierarchical) we have a top level schematic with instances (gates and
> modules we've designed ) with IPADS/OPADS/IOPADS to basically act as package
> pins. The netlist requires these PADS in the top level schematic be listed
> at the top of the netlist file, normally I can access pins of an instance by
> passing a uref to one of the gnetlist primitives (forget which one) and
> getting back a list of pins but I cannot do that for the very top level
> schematic, it seems to not have a uref or any way to say "give me a list of
> pins that are in the top level". Or if it could do "give me a list of
> objects that are in the top level", I could find the iopads but again I
> can't find a way to do that either. So I am asking if it is possible to tell
> gnetlist to go to the top level schematic in the hierarchy and return to me
> the IPADS/OPADS/IOPADS or something similar.


Since pins are only valid in symbols, give the xPADS component
instances an attribute to key on.  Check out the spice-sdb backend's
`spice-sdb:get-spice-IO-pins'.  The convention in that case is to only
collect "i/o pins" if there is a component with a
`device=spice-subcircuit-LL' present in the schematic.  Components
with a `device=spice-IO' attribute are collected for pin names.

On my schematics for IC work (lots of hierarchy), the pin component
attribute convention is:

device=spice-IO
port-type=foo
refdes=PIN_NAME
value=1

A patch to spice-sdb sorts these by the `value=' attribute instead of
the refdes.

That and other mostly gnetlist-related patches are in my local fork at:
http://repo.or.cz/w/geda-gaf/whiteaudio.git  (whiteaudio branch)


Dan

-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: simulation data reader

2011-04-04 Thread Dan White
Built with the help of the latest SVN of gwave's libspicefile (sp2sp)
utility, I use an in-house system to read simulation data into python
as a numpy array with attributes.  Data files are translated with
sp2sp to the numpy np.save()/load() ".npy" format and read in as
mem-mapped arrays to gracefully handle huge files.

I just added spice3 raw file support which required a 1-character
patch to libspicefile.

"spicereader.py" is the module of interest here:
http://hg.whiteaudio.com/pyspice

I have the SVN version of gwave mirrored to git:
http://repo.or.cz/w/gwave-svn.git

The "spice3" branch has the required patch.  Current SVN version
branch "guile-gnome-platform-branch" has the patch to translate
anything sp2sp can read on input to the "special" numpy disk format
wanted by spicereader.py.

The delegation of input reading to sp2sp avoided another "spice output
reader" implementation.

oscopy, announced on this list a while ago, has seen dev activity and
has integration with gschem.  I tried it out early and it looked
promising, there have been many improvements since then it looks like:
http://repo.or.cz/w/oscopy.git

Hope it helps someone else,

Dan

-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: NOR sr latch does not converge with ngspcie r22

2011-03-31 Thread Dan White
On Thu, Mar 31, 2011 at 10:30 PM, yamazakir2  wrote:
> The attached netlist does not converge. Doesn't matter what the inputs
> are, you could put a ramping voltage and it will be the same result.
> NAND latches work just fine, but nor doesn't.


.SUBCKT nor2 a b out pwr
M3 o a 0 0 n w=4u l=0.5u m=1
M4 o b 0 0 n w=4u l=0.5u m=1
M1 n0 a pwr pwr p w=8u l=0.5u m=1
M2 o b n0 pwr p w=8u l=0.5u m=1
.ENDS nor2

Don't have a _spice on hand, but the subcircuit terminal 'out' is not
used internally.  Changing the M3,4 drain terminals to 'out' instead
of 'o' should do it.

Dan

-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Time tracking

2011-02-02 Thread Dan White
On Sun, Jan 30, 2011 at 6:26 PM, Darryl Gibson  wrote:
> I'm curious what folks are using for time tracking and/or billing?


I use a periodic popup which samples my current task.  For 6min
intervals this gives resolution to 0.1 hour.  Solutions which have a
"start-task" scheme don't work because I always forget to log the
switch.

http://hg.whiteaudio.com/pubbin/

"timeSampler" is the popup and "TimeSampleHistogram" is the reporting.
 From yesterday (monospace font):


$ TimeSampleHistogram -w 70 -y
Yesterday: 2011-02-01
--
ho.dad  (21)+
lunch   ( 8)++
re.ct.paper (64)++
wa.hefc ( 4)+++
 97


The sampler popups default to the last answer and expire with 'null'
after a few hours.  I've used it for a few years by now and has worked
well enough.

Dan

-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gnucap, hspice output -> python

2011-01-20 Thread Dan White
On Thu, Jan 20, 2011 at 1:37 PM, Dan White  wrote:
> The attached numpy2ascii.py gives an example how to read the file by
> converting the data back to the gnucap ascii format.

Oops, here's the example.

Some day (tm) I'll make a gnucap plugin to output directly to this
format.  HDF5 is another more standardized option.


-- 
SDG
www.whiteaudio.com
#!/usr/bin/env python

# Dan White 

"""sp2sp -c numpy output format

Numpy array data is same as sp2sp -c nohead -s prepend.  File is in the
numpy.save('file.npy') version 1.0, documented in numpy/lib/format.py with
additional information immediately following the binary data.

Footer is a python string representation of a dict ending in a newline with
the following keys:
'sweepvars' - Tuple of strings naming the sweep variables in order,
  empty tuple if no sweeps.
  e.g. ('bias', 'foo', 'bar') or ()

'sweeprows' - Tuple of 2-element tuples indicating the start and end row
  indices of each table.  A 3-D array doesn't work because each
  sweep may have different number rows.
  e.g.((0, 20), (21, 40))

'cols' - Tuple of strings labeling the columns.  The first elements should
 match the elements of 'sweepvars'.
 e.g. ('bias', 'TIME', '0', 'v(foo', ... )

After the newline byte, the last two bytes are the footer length (including
these bytes) in uint16 little endian format.  See below for the two ways of
reading the footer while using numpy.load('spiceout.npy').
"""

import os
import sys
import struct

import numpy as np
from numpy.lib.utils import safe_eval


npfile = sys.argv[1]
npasciifile = sys.argv[2]

ndigits = 6



# 2 ways to use np.load
#   -read into memory
#   -open as mem-mapped file

# read array into memory
if 0:
fnp = open(npfile, 'rb')
npdata = np.load(fnp)
# when given an open file handle, np.load leaves the pointer just after
# the data (which is the start of the footer, conveniently).  The footer's
# newline makes this really easy:
footer = fnp.readline()

# open as a memory-mapped array on disk (preferred for large data)
else:
# At present, the memmap versions of np.load require a filename string and
# do not accept an open file-like object.  (Though
# np.lib.format.open_memmap and np.memmap look like this is not truly
# the case)
# Peek at the end of the file and use the footer len bytes to put the
# pointer at the start of the footer string
fnp = open(npfile, 'rb')
fnp.seek(-2, os.SEEK_END)
footlen = struct.unpack('>fnpa, ' '.join(header)
fmt = ' '.join(['%%%ie' % ndigits] * npdata.shape[1])
for row in npdata:
print>>fnpa, fmt % tuple(map(float, row))
fnpa.close()




___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: gnucap, hspice output -> python

2011-01-20 Thread Dan White
There have been a few python-based tools for analysis of simulation data
posted here, e.g. "oscopy" and "dataplot".  Here is another to
complement them.

To use python and numpy's arrays as the working format for signal
analysis requires conversion or import from a simulator's usual output.
Current gnucap output is an easy-to-read ascii format with
"numpy.genfromtxt()".

Converting HSPICE output is a different story...  There are several out
there but I have settled on the "sp2sp" utility from gwave as it can
output an ascii format, again read into python via "numpy.genfromtxt()".

All this is great until (#files * size-each) gets large (GB in one of my
usage cases).  Using sp2sp + numpy.genfromtxt results in files being
read twice, written once, then read entirely into RAM as a numpy.array.
This gets slow.

Solution: cache the data in a ".npy" file.  It's a binary format and,
most importantly, allows numpy to memory-map the data.  Caching the data
(for memmap read) does not allow other metadata in the file like column
headers and sweep variables/values.  This must be saved separately to
re-read the data.

Enter "pyspice.spicereader" and an extension to "sp2sp":
The gwave branch "guile-gnome-platform-branch" rev 245 patch now
includes an option to directly convert to a ".npy" file with a trick to
include metadata.

Usage is:
sp2sp -t ascii -c numpy -o out_file.npy in_file.dat
sp2sp -t hspice -c numpy -o out_file.npy in_file.tr0

The resulting ".npy" file has extra bytes appended to the normal
numpy.save() file: a string representation of a dict of column labels
and sweep info, ending in a little endian uint16 giving the length of
the appended info.

The attached numpy2ascii.py gives an example how to read the file by
converting the data back to the gnucap ascii format.

My module pyspice.spicereader presents the data as named attributes and
makes sweep handling and plotting easy.  Now I can do:

from pylab import *
from pyspice.spicereader import loadSimData

d = loadSimData('channel.tr0')
print d.siglist
plot(d.x, d.Ivsupply)

loadSimData caches the data by running sp2sp and mem-maps the file which
makes subsequent reads very fast.

The spicereader.py is part of my "pyspice" project (but not dependent
on other parts of it).  The pyspice module was written to cleanup LVS
extracted layouts for simulation, it likely does not work as-is; I
haven't used it for a few years.

Repeat: this requires the SVN branch guile-gnome-platform-branch of
gwave's utility "sp2sp".

http://hg.whiteaudio.com/pyspice


Enjoy!

Dan


-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: series of gnetlist backend patches

2011-01-02 Thread Dan White
I've pushed my local changes to the spice-sdb gnetlist backend and a new
backend out to repo.or.cz and also on the SourceForge patch tracker.
These have been part of my workflow for gschem -> {gnucap-arails,
hspice} within my analog VLSI work for some time.  The holidays
presented time to clean them up.
http://repo.or.cz/w/geda-gaf/whiteaudio.git

I use hierarchical, multi-page schematics and mostly use subcircuits for
IC devices to model parasitics and such from the foundry.

The Analog Rails tweaks to gnucap make parallel simulations with hspice
feasible from a common *.sch set.  Their repo is at
http://redmine.gnucapplus.org/

A short summary of the patches:

gnetlist: spice-sdb "no_end_card" option suppresses ".end"
SF:  3150011
A two-liner to allow a simulation netlist to .include the
topology/designn netlist.


gnetlist: spice-sdb: write provided subckt parameters from value= attr
SF:  3150016
A value= attribute on the spice-subcircuit-LL symbol is the default
subcircuit parameters.  This then outputs e.g.
.subckt name n1 n2 n3 n4 M=1 foo=43
*contents
.ends


gnetlist: spice-sdb MOS subcircuits
SF:  3150017
Makes device=SUBCKT_NMOS and PMOS behave like a spice M device but
wrapped in a subcircuit.


gnetlist: New spice-sdb:packsort, generalize to any refdes prefix.
SF:  3150018
The main one, sorts by the refdes alpha-prefix (case insensitive) order
given by 'refdes-sort-order which defaults to: ("*" "TP" "A").  Gnucap
is (more) sensitive to netlist order for parameters, probes, and
analyses.  This gives control over the sorting (with the gnetlist -s
option) by specifying the order of certain prefixes.


gnetlist: Option "sort_port_value" sorts spice-IO devs by value=.
SF:  3150019
This allows using the refdes' to indicate pinlabel and then using
value= to yield a meaningful ordering to a subckt's ports.  My symbol
generator script uses the refdes for pinlabel, order from the value
attribute, and pintype from the device attribute.


gnetlist: makedepend backend
SF:  3150021
Gnetlist backend to determine a schematic's dependencies.  Output
is in the form of:

source.sch: depend1.sch depend2.sch
source.cir: source.sch depend1.cir depend2.cir other.inc

...written to "source.d" file for inclusion into a project's
Makefile.

First line collects all source= attributes in the input pages.  Second
line lists transformed source='s/sch/cir/' and file= attributes
(.include files).

Makefile snippets for my usage of the makedepend backend and other
patches:

#
# AUTO-DEPENDENCIES
#  For the moment I don't know a way to avoid restarting make using the methods
#  described in http://mad-scientist.net/make/autodep.html
#generate schematic hierarchy dependencies for .sch and .cir
%.d: %.sch
$(GNETLIST) -g makedepend -o $@ $<

-include $(schematics:.sch=.d)
#
# bash script generator, if $1 matches, keep the element
# use as $(shell $(call keep-filter,*.sch))
#   (removes all matches, then removes these elements from orig array)
define keep-filter
  a=( $^ ); for c in $$...@]##$1}; do a=( $$...@]#$$c} ); done; echo $$...@]}
endef

%.cir: $$(wildcard %-*.sch) %.drc
gnetlist -g spice-sdb -I -s \
-O sort_port_value \
-O no_end_card \
-o $@ $(shell $(call keep-filter,*.sch))
#


At some point I'll write-up my usage of GAF, but for now: The setup
uses a naming convention including:
some_name-{1,2,..}.sch --> some_name.cir


"make tests" in gnetlist/tests and "./run_tests.sh" in
gnetlist/tests/common both pass.


Dan


--
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: help with gwave svn-REV2444

2010-10-16 Thread Dan White
On Fri, Aug 13, 2010 at 12:14 PM, Stefan Salewski  wrote:
> On Fri, 2010-08-13 at 12:19 +0100, sibu xolo wrote:
>> I have been trying to compile the program gwave (from svn )
>
> gwave is one of the most demanding tools of geda suite, for building
> from sources. In my opinion, if your goal is to compile latest versions
> from sources, then some knowledge and own work (at least google search
> for error messages) may be helpful (may be related to guile-gtk?)


Late to this party, but I've recently had the desire for the svn
version (still r244), specifically for the sim data readers and sp2sp.

I'm working on kubuntu 10.04 LTS.  Gwave requires guile-gtk, which is
no longer in ubuntu.  Compiling guile-gtk-2.1 from it's homepage
fails.  I found a gentoo patch (don't remember where) that changes the
relevant variables to something for more current gtk versions.  The
following repo has those changes I made:

http://www.whiteaudio.com/cgi-bin/fossil/guile-gtk

It also required setting LDFLAGS and GUILE_LOAD_PATH to appropriate
values even during "./configure".



The following has my changed from the current gwave svn.  Mostly it
adds an output mode to sp2sp for translating (tested with hspice) data
directly to a numpy ".npy" file to load in as a memory-mapped array.
Using numpy.genfromtxt was not an option for me as it was causing my
machine (2g ram) to swap.  The output file has a string trailing the
data as a python dict holding the sweep and column info in the array.

http://www.whiteaudio.com/cgi-bin/fossil/gwave2

Gwave itself runs after this but there is something wrong with
waveform colors so they're all black-on-black.  With the sp2sp mods
and some custom classes, using python+matplotlib has been great.

Dan


-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: sch2sym.py and Makefile example

2009-10-06 Thread Dan White
I have begun to use gaf for an audio prototyping board for a
University course I'm teaching.  The gEDA site claims no
schematic-to-symbol generator so I rolled my own and am making the
first-pass available to start to fill the gap.

I am been using the gEDA Binary Suite 0.0.2 for the moment until I get
around to moving my machines to newer releases simultaneously, so the
script is only tested on that version of gschem.  However it gives
satisfactory results on my current collection of project schematic
sheets.

Included is "usb-codec.sch" and "ingenious-A.sch" with embedded
symbols and their corresponding generated symbol.  The script puts all
input and passive ports on the left side, outputs on the right, and
power ports on the top/bottom.  The symbol box is sized according to
the minimum size to display all port label text without overlapping.

Finally, in the archive is the project Makefile as a user example for
new-comers.  The project isn't in PCB layout stage, nor have I used
simulations, so those aspects have not been vetted yet.

http://www.whiteaudio.com/proj/sch2sym.tar.gz

Comments are welcome,

Dan

-- 
SDG
www.whiteaudio.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user