Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / genius / genius.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : GENIUS v1.00 */
6 /* Fichier : genius.c */
7 /* */
8 /* (c) copyright 1999 Laboratoire MASI equipe CAO & VLSI */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
11 /* */
12 /* Auteur(s) : Francois DONNET le : 11/08/1999 */
13 /* */
14 /* Modifie par : le : ../../.... */
15 /* Modifie par : le : ../../.... */
16 /* Modifie par : le : ../../.... */
17 /* */
18 /****************************************************************************/
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <sys/stat.h>
22 #include MUT_H
23 #include MLO_H
24 #include MLU_H
25 #include "gen_tree_utils.h"
26 #include "gen_env.h"
27 #include "gen_tree_errors.h"
28 #include "gen_model_utils.h"
29 #include "gen_model_global.h"
30 #include "gen_verif_global.h"
31 #include "gen_execute_C.h"
32
33
34 #ifndef GENIUS_VERSION
35 #define GENIUS_VERSION "0.8"
36 #endif
37
38 #define PRIME 211 /* undivisable number */
39
40 /* LEX&YACC functions parser */
41 /* from gen_library_parser.yac */
42 extern lib_entry *Read_Library(char* library,char* path);
43 /* from gen_tree_parser.yac */
44 extern tree_list *Read_All();
45
46
47
48 extern int main(int argc,char *argv[]){
49 int err;
50 ptype_list *p,*bi_list;
51 chain_list *l,*a,*fcl=NULL,*genius=NULL;
52 ptype_list *env;
53
54 /* init environment */
55 mbkenv();
56 genius_env(NULL);
57 control_env();
58 srand(PRIME);
59
60 /* program */
61 alliancebanner("genius",GENIUS_VERSION,"GEneric Netlist Identification for User Specification","98-99","3.2");
62
63 /* ----> GENIUS_PRIORITY */
64 GENIUS_PRIORITY = Read_Library(GENIUS_LIB_NAME,GENIUS_LIB_PATH);
65 if (!GENIUS_PRIORITY) EXIT(0);
66 err = Get_Error();
67 if (err) {
68 fprintf(stderr,"\n%d error(s) detected, I can't get farther!!\n",err);
69 EXIT(err);
70 }
71
72 GENIUS_TREE = Read_All(GENIUS_PRIORITY); /* ----> GENIUS_TREE */
73 err = Get_Error();
74 if (err) {
75 fprintf(stderr,"\n%d error(s) detected, I can't get farther!!\n",err);
76 EXIT(err);
77 }
78 if (!GENIUS_TREE) EXIT(0);
79
80 /*get a ptype_list for GENIUS and FCL */
81 bi_list=Verif_All(GENIUS_TREE);
82 for (p=bi_list; p; p=p->NEXT) {
83 if (p->TYPE==FCL) fcl=(chain_list*)p->DATA;
84 if (p->TYPE==GENIUS) genius=(chain_list*)p->DATA;
85 }
86 freeptype(bi_list);
87 err = Get_Error();
88 if (err) {
89 fprintf(stderr,"\n%d error(s) detected, I can't get farther!!\n",err);
90 EXIT(err);
91 }
92 Build_All_Models(GENIUS_TREE,fcl,genius);
93
94 /*free mem */
95 Free_Tree(GENIUS_TREE);
96 GENIUS_TREE=NULL;
97
98 dumpmodel();
99
100 for (a=fcl; a; a=a->NEXT) {
101 model_list* model=getmodel((char*)a->DATA);
102 if (model->C) {
103 fprintf(GENIUS_OUTPUT,
104 "\n*************** Action of %s *****************\n",
105 model->NAME);
106 Exec_C(model->C,NULL);
107 }
108 }
109
110 for (a=genius; a; a=a->NEXT) {
111 model_list* model=getmodel((char*)a->DATA);
112 if (model->C) {
113 env=NULL;
114 for (l=model->VAR; l; l=l->NEXT) env=addptype(env,0,l->DATA);
115 env=addptype(env,(int)vectorradical(model->NAME),
116 vectorradical(model->NAME));
117 fprintf(GENIUS_OUTPUT,
118 "\n*************** Action of %s *****************\n",
119 model->NAME);
120 Exec_C(model->C,env);
121 freeptype(env);
122 }
123 }
124
125 Free_Exec_C();
126 freemodel();
127 freechain(fcl);
128 freechain(genius);
129
130 /*close file report .gen*/
131 if (GENIUS_OUTPUT!=stdout && GENIUS_OUTPUT!=stderr) fclose(GENIUS_OUTPUT);
132
133 /*file names are used for message and idetification in GENIUS*/
134 for (p=GENIUS_PRIORITY;p;p=p->NEXT) mbkfree(p->DATA);
135 freeptype(GENIUS_PRIORITY);
136 GENIUS_PRIORITY=NULL;
137
138 EXIT(0);
139 }
140
141