From e2dcbcad7fc1b36f301a01234bb90bf555fe5821 Mon Sep 17 00:00:00 2001 From: Clif Cox Date: Fri, 14 Jan 2011 09:50:46 -0800 Subject: [PATCH] gEDA flexable netlisting for NGspice Code Models --- gnetlist/scheme/gnet-spice-sdb.scm | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gnetlist/scheme/gnet-spice-sdb.scm b/gnetlist/scheme/gnet-spice-sdb.scm index 1babe4e..3a3e62e 100644 --- a/gnetlist/scheme/gnet-spice-sdb.scm +++ b/gnetlist/scheme/gnet-spice-sdb.scm @@ -93,6 +93,8 @@ ;; write-net-names-on-component to make it a bit more flexible. ;; Combine write-probe-item and write-net-names-on-component. Add ;; a range utility function. CC +;; 1.13.2011 -- Add four lines of code (and some comments) that allow formaitting strings +;; to be used for netlisting NGspice device models. CC ;; ;;********************************************************************************** ;; @@ -368,7 +370,8 @@ ;;---------------------------------------------------------- ;; This returns a list of all the integers from start to -;; stop. It is similar to perl's range operator '..' +;; stop, with the optional step size. +;; It is similar to perl's range operator '..' ;;---------------------------------------------------------- (define (range start stop . step) (if (null? step) @@ -533,7 +536,7 @@ ) ;; end of let* ) ;; end of if )) - + ;;********************************************************************************** ;;*************** Dealing with nets, devices, & SPICE cards. ******************* @@ -1198,7 +1201,7 @@ ;;---------------------------------------------------------------------------- -; write a voltage probe +;; write a voltage probe ;;---------------------------------------------------------------------------- (define (spice-sdb:write-probe package port) ;; fetch only one attr we care about, so far @@ -1223,7 +1226,9 @@ ;;-------------------------------------------------------------------- ;; Given a refdes and port, and optionaly a format string, this writes -;; out the nets attached to the component's pins. This is used to write +;; out the nets attached to the component's pins. If it's not called +;; with a format string it looks for one in the net-format attribute, +;; otherwise it writes out the pins unformated. This is used to write ;; out non-slotted parts. ;;-------------------------------------------------------------------- (define (spice-sdb:write-net-names-on-component refdes port . format) @@ -1258,9 +1263,12 @@ ;; First do local assignments (let ((netnames (filter-map get-net-name (range 1 (length (gnetlist:get-pins refdes))))) ) ;; let - (if (null? format) - (display (string-join netnames " " 'suffix) port) ;; write out nets. - (apply simple-format (cons port (cons (car format) netnames))) ) ;; write out nets with format string + (if (null? format) ;; Format agument take priority, otherwise use attribute + (set! format (gnetlist:get-package-attribute refdes "net-format")) + (set! format (car format)) ) + (if (string=? format "unknown") + (display (string-join netnames " " 'suffix) port) ;; write out nets. + (apply simple-format (cons port (cons format netnames))) ) ;; write out nets with format string ) ;; let ) @@ -1458,10 +1466,13 @@ ;; 1. Gets the refdes (package). ;; 2. Checks the refdes against a short list of possible values. ;; Depending upon the refdes, it does the following thing: +;; A? -- Invokes write-ic. This provides the opportunity for a code model +;; which may include a .model line. ;; D? -- Invokes write-diode ;; Q? -- Invokes write-transistor-diode. (The "type" attribute is ;; in this case so that the spice simulator will barf if the user ;; has been careless.) +;; M? -- Same as Q ;; U? -- Invokes write-ic. This provides the opportunity for a component ;; model to be instantiated. ;; X? -- Invokes write-ic. This provides the opportunity for a component @@ -1477,6 +1488,7 @@ (let ((first-char (string (string-ref package 0)) )) ;; extract first char of refdes. (cond + ((string=? first-char "A") (spice-sdb:write-ic package file-info-list port)) ((string=? first-char "D") (spice-sdb:write-diode package port)) ((string=? first-char "Q") (spice-sdb:write-transistor-diode package #f "" (list) port)) ((string=? first-char "M") (spice-sdb:write-transistor-diode package #f "" (list) port)) -- 1.5.6.5