2 This file is part of the software library CADLIB written by Conrad Ziesler
3 Copyright 2003, Conrad Ziesler, all rights reserved.
5 *************************
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* spice.h, header for spice parsing routines
25 /* note: alot of this is imported from legacy/adb
26 so it has some historic baggage still
29 #ifndef __NETLIST_SPICE_H__
30 #define __NETLIST_SPICE_H__
45 /*******************************************************/
46 /********* SPICE HASH TABLE CLIENTS ********************/
48 #define PAYLOAD_null 0
49 #define PAYLOAD_card_val 1
50 #define PAYLOAD_parent 2
51 #define PAYLOAD_gnptr 3
52 #define PAYLOAD_subckt 4
53 #define PAYLOAD_node 5
58 #define TERMPTR_BITS_DEVI 24
59 #define TERMPTR_BITS_TERMI 3
60 #define TERMPTR_BITS_DEVT 4
62 typedef struct termptr_st
64 unsigned devi
: TERMPTR_BITS_DEVI
;
66 unsigned termi
: TERMPTR_BITS_TERMI
;
67 unsigned devt
: TERMPTR_BITS_DEVT
;
75 struct subckt_st
*subckt
;
79 typedef struct hashload_st
85 typedef struct nodeclient_st
88 unsigned char str
[4]; /* alloc in place */
91 typedef struct nodeclient_st
*node_t
;
93 #define FORALL_HASH(h,i,p) hash_forall(h,i,p)
96 typedef struct paramload_st
99 struct callparam_st
*patch_call
;
104 typedef struct paramclient_st
110 typedef struct paramlookup_st
113 struct netlist_st
*nl
;
117 typedef struct callparam_st
124 /*****************************************/
125 /****** SPICE NETLIST READING *******/
127 /***** scanner stuff *****/
131 typedef enum keyword_et
133 Kother
, Kinclude
, Ksubckt
, Kends
, Kend
, Kendm
, Kmodel
, Kparam
, Kglobal
, Kmult
, Kscale
, Knull
136 #define SPICE_TOKENS { \
137 { Kinclude, ".include" }, \
138 { Ksubckt, ".subckt" }, \
139 { Kends, ".ends" }, \
140 { Kendm, ".endm" }, \
141 { Kmodel, ".model" }, \
142 { Kparam, ".param" }, \
143 { Kglobal, ".global" }, \
144 { Kmult, ".mult" }, \
145 { Kscale, ".scale" }, \
149 extern tokenmap_t spice_tokens
[];
152 /****** pass 2 ************/
159 struct subckt_st
*xp
;
161 callparam_t
**locals
;
168 #define INDEX_DRAIN 0
169 #define INDEX_SOURCE 2
175 eqn_t l
,w
,as
,ad
,ps
,pd
;
221 #define SUBCKT_MAGIC 0x43236513
223 typedef struct subckt_st
226 struct subckt_st
*parent
; /* who are we descended from */
227 hash_t
*nodes
; /* table of nodes */
228 hash_t
*params
; /* table of parameters (those defined elsewhere) */
229 hash_t
*lparams
; /* table of local parameters (those on the .subckt line) */
230 hash_t
*cktdir
; /* table of locally defined subckts */
231 hash_t
*global
; /* table of locally defined globals */
232 uchar
*name
; /* our name */
241 node_t
*defn
; /* ptrs into table of [nodes] for definitions */
242 m_t
*m
; /* array of mosfets */
243 c_t
*c
; /* array of capacitors */
244 r_t
*r
; /* array of resistors */
245 l_t
*l
; /* array of inductors */
246 x_t
*x
; /* array of subcircuit calls */
247 v_t
*v
; /* array of voltage sources */
248 i_t
*i
; /* array of current sources */
254 typedef struct stack_st
257 struct stack_st
*parent
;
260 struct stack_st
*top
;
261 struct netlist_st
*nl
;
265 typedef struct spice_st
276 #define minimum(a,b) (((a)<(b))?(a):(b))
279 subckt_t
*spice_find_subckt(subckt_t
*parent
, char *name
);
280 spice_t
*spice_new(scanner_t
*scan
);
281 void spice_release(spice_t
*sp
);
282 void spice_debug(void * dbg_fp
, spice_t
*sp
);
283 list_t
spice_list_subckt(subckt_t
*parent
);
288 #endif /* __NETLIST_SPICE_H__*/