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 /* netlist_lib.h, definitions for netlist library routines
37 #define NLIBIO_MAXNODES 4
39 /* convenience structures */
40 typedef struct nlibiodef_st
49 /* input definition */
50 typedef struct nlibio_st
55 int nodes
[NLIBIO_MAXNODES
];
58 typedef struct nlibiol_st
61 int qtokens
; /* product (iol[k].tokens) */
65 typedef struct nlibpm_st
67 int index
; /* index into netlist parameter list */
72 typedef struct nlibfunc_st
74 int p_delay
; /* phases of delay before we begin computations */
75 int p_cycle
; /* phases per cycle (compute each n phases) */
76 int p_offset
; /* phases between inputs sampled and outputs valid */
79 int map
[2]; /* alloc in place, size = qin*sizeof(int) */
82 /* function reference */
83 typedef struct nlibfref_st
90 /* reference nodes and associated skew parameters */
91 typedef enum nlibreftype_en
99 #define MAXSKEW_PARAMS 3
100 typedef struct nlibrefnode_st
102 eqn_t skew
[MAXSKEW_PARAMS
]; /* RTxxx indices */
103 int vrefi
; /* index into vref structure */
104 int devnodei
; /* node index in netlist */
107 /* database object */
108 typedef struct nlibdb_st
112 nlibfref_t map
; /* mapping between input and output tokens */
119 typedef struct nlibflatdb_st
121 int lib_index
; /* index from process */
122 int db_index
; /* index into db list */
123 int qvals
; /* cache db->params.q */
124 float *pvals
; /* copy db pvals to here */
125 list_t uservals
; /* array of user gate physical parameters */
128 /* container of database objects */
129 typedef struct nlib_st
132 list_t db
; /* our database of nlibdb objects */
133 names_t
*dbref
; /* database gate reference names */
134 names_t
*vref
; /* voltage reference node names */
136 list_t funcs
; /* ptrs */
138 eqnlist_t eqnl
; /* top level parameters we can use anywhere in eqns */
139 bitlist_t
*flags
; /* user can select set of elements to use */
140 list_t flatdb
; /* database of flat info */
144 #define NLIB_MAXPHASES 4
146 typedef struct nlib_icall_st
150 float *in
[NLIBIO_MAXNODES
];
151 float *out
[NLIBIO_MAXNODES
];
152 int itokens
[NLIB_MAXPHASES
], otokens
[NLIB_MAXPHASES
], ctoken
;
155 int idigitize
, odigitize
;
159 #define NLIB_MAXFREF 64
160 typedef struct nlib_ifref_st
163 float vals
[NLIB_MAXPHASES
];
164 char name
[NLIB_MAXFREF
];
167 typedef enum nlib_refid_en
169 NLIBref_vss
, /* the vdd/vss values are used by cmos digitalize */
171 NLIBref_clk
, /* clk is generic refering to some clock signal */
172 NLIBref_firstunused
, /* user can allocate any ref ids after this point */
176 typedef struct nlib_iface_st
181 int ref_map
[NLIBref_max
];
183 float * (*lookup_node_f
)(void *user
, char *name
);
187 typedef enum nlib_tokens_en
189 Knlib_start
=1024, Knlib_nlib
,Knlib_input
, Knlib_output
,
190 Knlib_param
, Knlib_netlist
, Knlib_spice
,
191 Knlib_encoding
, Knlib_wires
,
192 Knlib_tokens
, Knlib_digitize
, Knlib_digital
, Knlib_qtyin
, Knlib_qtyout
,
193 Knlib_end_digital
, Knlib_min
, Knlib_max
, Knlib_qty
,
194 Knlib_function
, Knlib_end_netlist
, Knlib_define
,
195 Knlib_reference
, Knlib_name
, Knlib_rseries
, Knlib_cshunt
, Knlib_delay
,
196 Knlib_p_delay
, Knlib_p_offset
, Knlib_p_cycle
,
200 #define NLIB_TOKENS { \
201 { Knlib_nlib, ".nlib" }, \
202 { Knlib_input, ".input" }, \
203 { Knlib_output, ".output" }, \
204 { Knlib_define, ".define" }, \
205 { Knlib_param, ".param" }, \
206 { Knlib_netlist, ".netlist" }, \
207 { Knlib_end_netlist, ".end_netlist" }, \
208 { Knlib_spice, ".spice" }, \
209 { Knlib_encoding, ".encoding" }, \
210 { Knlib_digital, ".digital" }, \
211 { Knlib_end_digital, ".end_digital" }, \
212 { Knlib_qtyout, ".qtyout" }, \
213 { Knlib_qtyin, ".qtyin" }, \
214 { Knlib_digitize, ".digitize" }, \
215 { Knlib_min, ".min" }, \
216 { Knlib_max, ".max" }, \
217 { Knlib_qty, ".qtysteps" }, \
218 { Knlib_function, ".function" }, \
219 { Knlib_tokens, ".tokens" }, \
220 { Knlib_wires, ".wires" }, \
221 { Knlib_name, ".name" }, \
222 { Knlib_rseries, ".rseries" }, \
223 { Knlib_cshunt, ".cshunt" }, \
224 { Knlib_delay, ".delay" }, \
225 { Knlib_reference, ".reference" }, \
226 { Knlib_p_delay, ".p_delay" }, \
227 { Knlib_p_offset, ".p_offset" }, \
228 { Knlib_p_cycle, ".p_cycle" }, \
229 { Knlib_end, NULL } }
232 typedef struct nlib_process_st
234 /* filled in by user */
235 void (*process
)(struct nlib_process_st
*proc
);
239 /* filled in by nlib_process before user->process() is called */
246 int nlib_parse(nlib_t
*nlib
, scanner_t
*scan
);
247 int nlib_add_io(nlib_t
*nlib
, int dbindex
, nlibiol_t
*io
, int tokens
, int nodes
, int dig
, char **names
);
248 int nlib_init(nlib_t
*nlib
);
249 int nlib_add_pm(nlib_t
*nlib
, int dbi
, char *str
, float min
, float max
, int qty
);
250 int nlib_new_db(nlib_t
*nlib
, char *str
);
251 int nlib_db_netlist(nlib_t
*nlib
, int index
, netlist_t
*nl
);
252 int nlib_db_func(nlib_t
*nlib
, int index
, char *str
);
253 void nlib_process(nlib_process_t
*user
, int screened
);
254 void nlib_fixup(nlib_t
*nlib
);
255 void nlib_disable(nlib_t
*nlib
, int index
);
256 int nlib_isdisabled(nlib_t
*nlib
, int index
);
258 void nlib_release(nlib_t
*nlib
);
260 void *nlib_flat(nlib_process_t
*user
, int s_uservals
, int q_uservals
);
261 void nlib_o_spice_subckts(nlib_t
*nlib
, void * of_fp
);
262 void nlib_o_spice_call(nlib_t
*nlib
, int index
, int i_node
, int o_node
, int *skt
, void * of
);
263 void nlib_o_spice_refs(nlib_t
*nlib
, void * of_fp
);
264 int nlib_flatdb_write(nlib_t
*nlib
, void * file_fp
);
265 int nlib_flatdb_read(nlib_t
*nlib
, void * file_fp
);
267 /* interface routines */
269 nlib_ifref_t
*nlib_iface_getref(nlib_iface_t
*iface
, int id
);
270 void nlib_iface_phase(nlib_iface_t
*iface
);
271 int nlib_i_spice_calls(nlib_iface_t
*iface
, void * cktf_fp
);
272 void nlib_iface_init(nlib_iface_t
*iface
, nlib_t
*nlib
);
273 void nlib_iface_release(nlib_iface_t
*iface
);