From 0b6af70c85cf9e4b9c26dda39ddbc194faeb9fe3 Mon Sep 17 00:00:00 2001 From: Clif Cox Date: Thu, 13 Jan 2011 19:39:31 -0800 Subject: [PATCH] Add NGspice Device Models netlisting capability to spice-sdb --- gnetlist/scheme/gnet-spice-sdb.scm | 31 ++++++++++++++++++++----------- 1 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gnetlist/scheme/gnet-spice-sdb.scm b/gnetlist/scheme/gnet-spice-sdb.scm index bc1e751..3a3e62e 100644 --- a/gnetlist/scheme/gnet-spice-sdb.scm +++ b/gnetlist/scheme/gnet-spice-sdb.scm @@ -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))