[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-user: Gnetlist, spice and probes
Hello
I like to draw simulations on gschem, along with probes, without worrying about which net will be which
or naming them by hand.
I made small patch for spice-sdb backend for gnetlist that allows to list special component with attribute
device=probe generates spice alike print statements.
It's a bit imperfect, because some simulation tools allow to use something beyond V(netnumber), I even thought
about adding some attribute to probe pin to let spice-sdb:write-probe-item fetch data directly from each pin
(in case one create multipin probe). But so far I am happy with plain voltage ones.
gnet-spice-sdb.patch and probe.sym in attachment.
ps. please forgive me weak english, and even weaker scheme.
best regards
Maciej
--
Maciej Pijanka
--- /home/agaran/geda/share/gEDA/scheme/gnet-spice-sdb.scm 2009-11-14 20:59:47.000000000 +0100
+++ /home/agaran/geda/share/gEDA/scheme/gnet-spice-sdbt.scm 2010-01-15 18:56:00.000000000 +0100
@@ -1256,6 +1256,57 @@
)
)
+; most of this code is shamelessly copied from write-net-names-on-component
+; probably net-on-component could take one more argument that will be formater
+; which receives pin data those generated in let, etc
+; then this cruft might just provide own formater and reuse code
+(define spice-sdb:write-probe-item
+ (lambda (refdes number-of-pins port)
+ (if (> number-of-pins 0)
+ (begin
+ (spice-sdb:write-probe-item refdes (- number-of-pins 1) port)
+ (let* ((pin-name (number->string number-of-pins))
+ (pinnumber (gnetlist:get-attribute-by-pinseq refdes pin-name "pinnumber"))
+ (pinseq (gnetlist:get-attribute-by-pinseq refdes pin-name "pinseq"))
+ (netname (car (spice-sdb:get-net refdes pinnumber)) )
+ )
+
+;; ------- Super debug stuff --------
+ (debug-spew " In write-probe-item. . . . \n")
+ (debug-spew (string-append " pin-name = " pin-name "\n"))
+ (debug-spew (string-append " pinnumber = " pinnumber "\n"))
+ (debug-spew (string-append " pinseq = " pinseq "\n"))
+ (debug-spew (string-append " netname = " netname "\n"))
+;; ------------------------------
+
+ (if (not (string=? netname "ERROR_INVALID_PIN"))
+ (display (string-append "V(" netname ") ") port) ;; write out attached net if OK.
+ (debug-spew (string-append "For " refdes ", found pin with no pinseq attribute. Ignoring. . . .\n"))
+ )
+ ) ;; let*
+ ) ;; begin
+ ) ;; if
+ ) ;; lambda
+)
+
+(define spice-sdb:write-probe
+ (lambda (package port)
+ ;; fetch only one attr we care about, so far
+ (let ((value (gnetlist:get-package-attribute package "value"))
+ ) ;; end of local assignments
+
+ (debug-spew (string-append "Found Probe item, refdes = " package "\n"))
+
+ (if (string=? value "unknown")
+ (set! value "TRAN"))
+
+ (display (string-append ".print " value " ") port)
+ (spice-sdb:write-probe-item package (length (gnetlist:get-pins package)) port)
+ (newline port)
+ ) ;; end of let
+ ) ;; close of lambda
+) ;; close of define
+
;;--------------------------------------------------------------------
;; Given a refdes and number of pins, this writes out the nets
;; attached to the component's pins. This is used to write out
@@ -1617,6 +1668,8 @@
(spice-sdb:write-directive package port))
( (string=? device "include")
(spice-sdb:write-include package port))
+ ( (string=? device "probe")
+ (spice-sdb:write-probe package port))
( else
(spice-sdb:write-default-component package file-info-list port))
) ;; end of cond
@@ -1787,7 +1840,7 @@
;; 5. If the schematic-type is .SUBCKT: write out .ENDS, Otherwise: write out .END
;; 6. Close up the SPICE netlist file and return.
;;---------------------------------------------------------------
-(define spice-sdb
+(define spice-sdbt
(lambda (output-filename)
;;
;; First find out if this is a .SUBCKT lower level,
v 20091004 2
P 0 0 500 1000 1 0 0
{
T 0 0 5 10 0 0 0 0 1
pintype=io
T 855 495 5 10 0 1 0 0 1
pinlabel=probe (tran)
T 705 245 5 10 0 1 0 6 1
pinnumber=1
T 0 0 5 10 0 0 0 0 1
pinseq=1
}
L 500 1000 1200 1000 3 0 0 0 -1 -1
T 595 795 8 10 1 1 0 0 1
device=probe
T 595 1095 8 10 1 1 0 0 1
refdes=TP?
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user