VIS
|
00001 00049 #include "puresatInt.h" 00050 00051 /*---------------------------------------------------------------------------*/ 00052 /* Constant declarations */ 00053 /*---------------------------------------------------------------------------*/ 00054 00055 /*---------------------------------------------------------------------------*/ 00056 /* Structure declarations */ 00057 /*---------------------------------------------------------------------------*/ 00058 00059 /*---------------------------------------------------------------------------*/ 00060 /* Type declarations */ 00061 /*---------------------------------------------------------------------------*/ 00062 00063 /*---------------------------------------------------------------------------*/ 00064 /* Variable declarations */ 00065 /*---------------------------------------------------------------------------*/ 00066 00067 static jmp_buf timeOutEnv; 00068 00069 /*---------------------------------------------------------------------------*/ 00070 /* Macro declarations */ 00071 /*---------------------------------------------------------------------------*/ 00072 00075 /*---------------------------------------------------------------------------*/ 00076 /* Static function prototypes */ 00077 /*---------------------------------------------------------------------------*/ 00078 static int CommandPureSatAbRf( Hrc_Manager_t ** hmgr,int argc, char ** argv); 00079 static void TimeOutHandle(void); 00082 /*---------------------------------------------------------------------------*/ 00083 /* Definition of exported functions */ 00084 /*---------------------------------------------------------------------------*/ 00085 00101 void 00102 PureSat_Init(void) 00103 { 00104 /* 00105 * Add a command to the global command table. By using the leading 00106 * underscore, the command will be listed under "help -a" but not "help". 00107 */ 00108 Cmd_CommandAdd("_puresat_test", CommandPureSatAbRf, 0); 00109 } 00110 00111 00123 void 00124 PureSat_End(void) 00125 { 00126 00127 } 00128 00129 /*---------------------------------------------------------------------------*/ 00130 /* Definition of internal functions */ 00131 /*---------------------------------------------------------------------------*/ 00132 00133 00134 /*---------------------------------------------------------------------------*/ 00135 /* Definition of static functions */ 00136 /*---------------------------------------------------------------------------*/ 00137 00138 00152 static void 00153 TimeOutHandle() 00154 { 00155 longjmp(timeOutEnv, 1); 00156 } 00157 00171 static int 00172 CommandPureSatAbRf( 00173 Hrc_Manager_t ** hmgr, 00174 int argc, 00175 char ** argv) 00176 { 00177 Ntk_Network_t * network; 00178 00179 FILE * ltlFile; 00180 array_t * formulaArray; 00181 boolean re; 00182 int i; 00183 00184 PureSat_Manager_t *pm; 00185 int timeOutPeriod; 00186 00187 pm = PureSatManagerAlloc(); 00188 timeOutPeriod = pm->timeOutPeriod; 00189 PureSatCmdParse(argc, argv,pm); 00190 network = Ntk_HrcManagerReadCurrentNetwork(*hmgr); 00191 fprintf(vis_stdout, "Num of latches is %d\n",Ntk_NetworkReadNumLatches(network)); 00192 if (network == NIL(Ntk_Network_t)) { 00193 fprintf(vis_stderr, 00194 "No network, please read in the circuit, and init_verify\n"); 00195 return 1; 00196 } 00197 00198 ltlFile = Cmd_FileOpen(pm->ltlFileName, "r", NIL(char *), 0); 00199 if (ltlFile == NIL(FILE)) { 00200 fprintf(vis_stdout,"Cannot open LTL file %s\n", pm->ltlFileName); 00201 exit(1); 00202 } 00203 00204 formulaArray = Ctlsp_FileParseFormulaArray(ltlFile); 00205 if(!array_n(formulaArray)) 00206 {fprintf(vis_stderr,"ltlfile doesn't contain any formula \n"); 00207 exit (1);} 00208 00209 /*timeout*/ 00210 if (timeOutPeriod > 0) { 00211 (void) signal(SIGALRM, (void(*)(int))TimeOutHandle); 00212 fprintf(vis_stdout, "signal\n"); 00213 (void) alarm(timeOutPeriod); 00214 if (setjmp(timeOutEnv) > 0) { 00215 (void) fprintf(vis_stdout, 00216 "# PURESAT: timeout occurred after %d seconds.\n", timeOutPeriod); 00217 (void) fprintf(vis_stdout, "# PURESAT: data may be corrupted.\n"); 00218 alarm(0); 00219 return 1; 00220 } 00221 } 00222 00223 for (i = 0; i < array_n(formulaArray); i++) { 00224 Ctlsp_Formula_t *ltlFormula = array_fetch(Ctlsp_Formula_t *, formulaArray, i); 00225 re = PureSatCheckInv_SSS(network,ltlFormula,pm); 00226 if(re) 00227 fprintf(vis_stdout,"formula #%d is true\n",i); 00228 else 00229 fprintf(vis_stdout,"formula #%d is False\n",i); 00230 } 00231 return 0; 00232 } 00233 00234