6 chain_list
*ALL_HIERARCHY_LOTRS
;
8 lofig_list
*current_lofig
;
9 ptype_list
*ALL_ENV
, *GEN_USER
;
10 lofig_list
*CUR_HIER_LOFIG
;
11 corresp_t
*CUR_CORRESP_TABLE
;
12 ALL_FOR_GNS
*LATEST_GNS_RUN
;
13 lofig_list
*GENIUS_GLOBAL_LOFIG
;
15 lofig_list
*GEN_HEAD_LOFIG
= NULL
;
16 ht
*GEN_HT_LOFIG
= NULL
;
18 chain_list
*reject_list
;
20 static mbkContext
*EXTERNAL_LOFIGS
;
22 lofig_list
*(*external_getlofig
)(char *name
);
24 mbkContext
*genius_external_getcontext()
26 return EXTERNAL_LOFIGS
;
29 void genius_external_setcontext(mbkContext
*ctx
)
34 lofig_list
*genius_external_getlofig(char *name
)
37 mbkSwitchContext(EXTERNAL_LOFIGS
);
38 lf
=getlofig(name
, 'A');
39 mbkSwitchContext(EXTERNAL_LOFIGS
);
52 mbkContext newcontext
;
53 lofig_list
*(*tmpfunc
)(char *name
);
57 static chain_list
*__ctx_chain
=NULL
;
60 lofig_list
*gen_getlofig (char *name
)
62 lofig_list
*head_lofig
, *fig
;
65 // Contextualize HEAD_LOFIG ___________________________
67 head_lofig
= HEAD_LOFIG
;
68 HEAD_LOFIG
= GEN_HEAD_LOFIG
;
71 HT_LOFIG
= GEN_HT_LOFIG
;
73 fig
= getloadedlofig (name
);
75 // Release HEAD_LOFIG _________________________________
77 GEN_HEAD_LOFIG
= HEAD_LOFIG
;
78 HEAD_LOFIG
= head_lofig
;
80 GEN_HT_LOFIG
= HT_LOFIG
;
86 void in_genius_context_of(ALL_FOR_GNS
*all
, subinst_t
*sins
)
94 tmp
=(__ctx
*)mbkalloc(sizeof(__ctx
));
95 tmp
->oHT
=GEN_HT_LOFIG
; tmp
->oHL
=GEN_HEAD_LOFIG
;
96 tmp
->oCHL
=CUR_HIER_LOFIG
; tmp
->oCT
=CUR_CORRESP_TABLE
;
97 tmp
->oMAINLF
=GENIUS_GLOBAL_LOFIG
; tmp
->var
=ALL_ENV
;
98 tmp
->oldctx
=genius_external_getcontext();
99 tmp
->newcontext
.HT_LOFIG
=HT_LOFIG
;
100 tmp
->newcontext
.HEAD_LOFIG
=HEAD_LOFIG
;
101 tmp
->tmpfunc
=external_getlofig
;
102 tmp
->templateht
=GNS_TEMPLATE_HT
;
104 external_getlofig
=genius_external_getlofig
;
105 genius_external_setcontext(&all
->external_ctx
);
107 __ctx_chain
=addchain(__ctx_chain
, tmp
);
111 var
=addptype(var
, (long)table
->GENIUS_FIGNAME
, namealloc("model"));
112 var
=addptype(var
, (long)table
->GENIUS_INSNAME
, namealloc("instance"));
114 if (table
->ARCHISTART
==0)
115 var
=addptype(var
, (long)table
->FIGNAME
, namealloc("archi"));
118 strncpy(temp
, &table
->GENIUS_FIGNAME
[(int)table
->ARCHISTART
], table
->ARCHILENGTH
);
119 temp
[(int)table
->ARCHILENGTH
]='\0';
120 var
=addptype(var
, (long)namealloc(temp
), namealloc("archi"));
123 GENIUS_GLOBAL_LOFIG
=all
->GLOBAL_LOFIG
;
124 GEN_HEAD_LOFIG
= all
->HIER_HEAD_LOFIG
;
125 GEN_HT_LOFIG
= all
->HIER_HT_LOFIG
;
126 CUR_HIER_LOFIG
=gen_getlofig(table
->GENIUS_FIGNAME
);
127 CUR_CORRESP_TABLE
=table
;
130 GNS_TEMPLATE_HT
=all
->TEMPLATE_HT
;
134 void out_genius_context_of()
138 if (__ctx_chain
==NULL
) return;
140 tmp
=(__ctx
*)__ctx_chain
->DATA
;
141 ALL_ENV
->NEXT
->NEXT
->NEXT
=NULL
;
143 external_getlofig
=tmp
->tmpfunc
;
144 genius_external_setcontext(tmp
->oldctx
);
145 GEN_HT_LOFIG
=tmp
->oHT
; GEN_HEAD_LOFIG
=tmp
->oHL
;
146 CUR_HIER_LOFIG
=tmp
->oCHL
; CUR_CORRESP_TABLE
=tmp
->oCT
;
147 GENIUS_GLOBAL_LOFIG
=tmp
->oMAINLF
; ALL_ENV
=tmp
->var
;
148 GNS_TEMPLATE_HT
=tmp
->templateht
;
150 cl
=__ctx_chain
; __ctx_chain
=__ctx_chain
->NEXT
;
155 char *gen_makeinstancename (char *s
)
158 static char temp
[200];
160 for (i
= 0, j
= 0; s
[i
] != '\0'; i
++) {
161 if (s
[i
] != ' ' && s
[i
] != ')' && s
[i
] != ']')
166 for (i
= 0; i
< j
; i
++)
167 if (temp
[i
] == '[' || temp
[i
] == '(')
173 chain_list
*gen_hierarchical_split (char *name
)
175 char *s
, *start
= name
;
176 chain_list
*cl
= NULL
;
178 s
= strchr (start
, '.');
182 cl
= addchain (cl
, namealloc (start
));
185 s
= strchr (start
, '.');
187 cl
= addchain (cl
, namealloc (start
));
191 chain_list
*gen_goto (chain_list
* arbo
, corresp_t
** crt
, int tag
)
193 corresp_t
*crt0
, *level
;
196 while (arbo
->NEXT
!= NULL
) {
197 for (cl
= level
->SUBINSTS
; cl
!= NULL
; cl
= cl
->NEXT
) {
199 if (cl
->INSNAME
== arbo
->DATA
)
202 if (cl
== NULL
|| (cl
->FLAGS
& LOINS_IS_BLACKBOX
)!=0)
215 static char *repack(chain_list
*lst
, char *buf
)
220 strcat(buf
, lst
->DATA
);
228 lotrs_list
*_gen_GetCorrespondingTransistor(char *name
, corresp_t
* level
, int mode
)
230 chain_list
*arbo
, *mainarbo
;
235 mainarbo
= arbo
= gen_hierarchical_split (gen_makeinstancename (name
));
237 arbo
= gen_goto (arbo
, &level
, 1);
239 freechain (mainarbo
);
240 if (!mode
) avt_errmsg(GNS_ERRMSG
, "036", AVT_ERROR
, gen_info (), name
);
241 //fprintf (stderr, "%s: gns_GetCorrespondingTransistor() can't go thru '%s'\n", gen_info (), name);
245 if (level
->TRANSISTORS
!=NULL
)
247 if (arbo
->NEXT
==NULL
) trname
=arbo
->DATA
;
248 else trname
=namealloc(repack(arbo
, buf
));
250 entry
=gethtitem(level
->TRANSISTORS
, trname
);
252 freechain (mainarbo
);
253 if (entry
!=EMPTYHT
) return (lotrs_list
*)entry
;
255 if (!mode
) avt_errmsg(GNS_ERRMSG
, "006", AVT_ERROR
, gen_info (), name
);
256 //fprintf (stderr, "%s: gns_GetCorrespondingTransistor() can't find transistor '%s' in model\n", gen_info (), name);
260 lotrs_list
*gen_GetCorrespondingTransistor(char *name
, corresp_t
* level
)
262 return _gen_GetCorrespondingTransistor(name
, level
, 0); // display errors
265 subinst_t
*gen_GetCorrespondingInstance (char *name
, corresp_t
* level
)
269 chain_list
*arbo
, *mainarbo
;
273 mainarbo
= arbo
= gen_hierarchical_split (gen_makeinstancename (name
));
275 arbo
= gen_goto (arbo
, &level
, 1);
277 freechain (mainarbo
);
278 avt_errmsg(GNS_ERRMSG
, "036", AVT_FATAL
, gen_info (), name
);
279 //fprintf (stderr, "%s: gns_GetCorrespondingInstance() can't go thru '%s'\n", gen_info (), name);
283 if (arbo
->NEXT
==NULL
) insname
=arbo
->DATA
;
284 else insname
=namealloc(repack(arbo
, buf
));
286 for (cl
= level
->SUBINSTS
; cl
!= NULL
; cl
= cl
->NEXT
) {
288 if (cl
->INSNAME
== insname
) {
289 freechain (mainarbo
);
293 freechain (mainarbo
);
294 avt_errmsg(GNS_ERRMSG
, "037", AVT_ERROR
, gen_info (), name
);
295 //fprintf (stderr, "%s: gns_GetCorrespondingInstance() can't find instance '%s' in model\n", gen_info (), name);
299 subinst_t
*gen_get_hier_instance(ALL_FOR_GNS
*all
, char *hiername
)
301 char temp
[1024], *c
, *nm
;
303 strcpy(temp
, hiername
);
310 for (sins
=all
->TOP_LEVEL_SUBINST
; sins
!=NULL
&& sins
->INSNAME
!=nm
; sins
=sins
->NEXT
) ;
311 if (c
==NULL
|| sins
==NULL
) return sins
;
312 return gen_GetCorrespondingInstance(&c
[1], sins
->CRT
);
315 int is_genius_instance(lofig_list
*lf
, char *name
)
317 if (LATEST_GNS_RUN
==NULL
) return 0;
318 if (LATEST_GNS_RUN
->GLOBAL_LOFIG
!=lf
) return 0;
319 if (gen_get_hier_instance(LATEST_GNS_RUN
, name
)!=NULL
) return 1;
323 HierLofigInfo
*gethierlofiginfo(lofig_list
*lf
)
328 if ((p
=getptype(lf
->USER
, HIER_LOFIG_INFO_PTYPE
))!=NULL
)
329 return (HierLofigInfo
*)p
->DATA
;
331 hli
=(HierLofigInfo
*)mbkalloc(sizeof(HierLofigInfo
));
335 lf
->USER
=addptype(lf
->USER
, HIER_LOFIG_INFO_PTYPE
, hli
);
339 ArcInfo
*getarcinfo(HierLofigInfo
*hli
, char *name
)
343 if ((l
=gethtitem(hli
->ARCS
, name
))!=EMPTYHT
)
346 ai
=(ArcInfo
*)mbkalloc(sizeof(ArcInfo
));
352 addhtitem(hli
->ARCS
, name
, (long)ai
);
356 ht
*gen_get_losig_ht(lofig_list
*lf
)
362 if ((pt
=getptype(lf
->USER
, GEN_HIERLOFIG_LOSIG_HT
))!=NULL
)
363 return (ht
*)pt
->DATA
;
367 for (ls
=lf
->LOSIG
; ls
!=NULL
; ls
=ls
->NEXT
)
368 addhtitem(sight
, ls
->NAMECHAIN
->DATA
, (long)ls
);
370 lf
->USER
=addptype(lf
->USER
, GEN_HIERLOFIG_LOSIG_HT
, sight
);
375 void destroy_genius_context(ALL_FOR_GNS
*all
)
383 tmp=(__ctx *)mbkalloc(sizeof(__ctx));
384 tmp->oHT=GEN_HT_LOFIG; tmp->oHL=GEN_HEAD_LOFIG;
385 tmp->oCHL=CUR_HIER_LOFIG; tmp->oCT=CUR_CORRESP_TABLE;
386 tmp->oMAINLF=GENIUS_GLOBAL_LOFIG; tmp->var=ALL_ENV;
387 tmp->oldctx=genius_external_getcontext();
388 tmp->newcontext.HT_LOFIG=HT_LOFIG;
389 tmp->newcontext.HEAD_LOFIG=HEAD_LOFIG;
390 tmp->tmpfunc=external_getlofig;
391 tmp->templateht=GNS_TEMPLATE_HT;
393 external_getlofig=genius_external_getlofig;
394 genius_external_setcontext(&tmp->newcontext);
396 __ctx_chain=addchain(__ctx_chain, tmp);
400 var=addptype(var, (long)table->GENIUS_FIGNAME, namealloc("model"));
401 var=addptype(var, (long)table->GENIUS_INSNAME, namealloc("instance"));
403 if (table->ARCHISTART==0)
404 var=addptype(var, (long)table->FIGNAME, namealloc("archi"));
407 strncpy(temp, &table->GENIUS_FIGNAME[(int)table->ARCHISTART], table->ARCHILENGTH);
408 temp[(int)table->ARCHILENGTH]='\0';
409 var=addptype(var, (long)namealloc(temp), namealloc("archi"));
412 GENIUS_GLOBAL_LOFIG=all->GLOBAL_LOFIG;
413 GEN_HEAD_LOFIG = all->HIER_HEAD_LOFIG;
414 GEN_HT_LOFIG = all->HIER_HT_LOFIG;
415 CUR_HIER_LOFIG=gen_getlofig(table->GENIUS_FIGNAME);
416 CUR_CORRESP_TABLE=table;
419 GNS_TEMPLATE_HT=all->TEMPLATE_HT;