src/base/main/main.c File Reference

#include "mainInt.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

static int TypeCheck (Abc_Frame_t *pAbc, char *s)
int main (int argc, char *argv[])
void Abc_Start ()
void Abc_Stop ()

Function Documentation

void Abc_Start (  ) 

Function*************************************************************

Synopsis [Initialization procedure for the library project.]

Description [Note that when Abc_Start() is run in a static library project, it does not load the resource file by default. As a result, ABC is not set up the same way, as when it is run on a command line. For example, some error messages while parsing files will not be produced, and intermediate networks will not be checked for consistancy. One possibility is to load the resource file after Abc_Start() as follows: Abc_UtilsSource( Abc_FrameGetGlobalFrame() );]

SideEffects []

SeeAlso []

Definition at line 253 of file main.c.

00254 {
00255     Abc_Frame_t * pAbc;
00256     // added to detect memory leaks:
00257 #ifdef _DEBUG
00258     _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
00259 #endif
00260     // start the glocal frame
00261     pAbc = Abc_FrameGetGlobalFrame();
00262     // source the resource file
00263 //    Abc_UtilsSource( pAbc );
00264 }

void Abc_Stop (  ) 

Function*************************************************************

Synopsis [Deallocation procedure for the library project.]

Description []

SideEffects []

SeeAlso []

Definition at line 277 of file main.c.

00278 {
00279     Abc_Frame_t * pAbc;
00280     pAbc = Abc_FrameGetGlobalFrame();
00281     // perform uninitializations
00282     Abc_FrameEnd( pAbc );
00283     // stop the framework
00284     Abc_FrameDeallocate( pAbc );
00285 }

int main ( int  argc,
char *  argv[] 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [The main() procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file main.c.

00050 {
00051     Abc_Frame_t * pAbc;
00052     char sCommandUsr[500], sCommandTmp[100], sReadCmd[20], sWriteCmd[20], c;
00053     char * sCommand, * sOutFile, * sInFile;
00054     int  fStatus = 0;
00055     bool fBatch, fInitSource, fInitRead, fFinalWrite;
00056 
00057     // added to detect memory leaks:
00058 #ifdef _DEBUG
00059     _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
00060 #endif
00061     
00062 //    Npn_Experiment();
00063 //    Npn_Generate();
00064 
00065         // get global frame (singleton pattern)
00066         // will be initialized on first call
00067         pAbc = Abc_FrameGetGlobalFrame();
00068 
00069     // default options
00070     fBatch = 0;
00071     fInitSource = 1;
00072     fInitRead   = 0;
00073     fFinalWrite = 0;
00074     sInFile = sOutFile = NULL;
00075     sprintf( sReadCmd,  "read"  );
00076     sprintf( sWriteCmd, "write" );
00077     
00078     Extra_UtilGetoptReset();
00079     while ((c = Extra_UtilGetopt(argc, argv, "c:hf:F:o:st:T:x")) != EOF) {
00080         switch(c) {
00081             case 'c':
00082                 strcpy( sCommandUsr, globalUtilOptarg );
00083                 fBatch = 1;
00084                 break;
00085                 
00086             case 'f':
00087                 sprintf(sCommandUsr, "source %s", globalUtilOptarg);
00088                 fBatch = 1;
00089                 break;
00090 
00091             case 'F':
00092                 sprintf(sCommandUsr, "source -x %s", globalUtilOptarg);
00093                 fBatch = 1;
00094                 break;
00095                 
00096             case 'h':
00097                 goto usage;
00098                 break;
00099                 
00100             case 'o':
00101                 sOutFile = globalUtilOptarg;
00102                 fFinalWrite = 1;
00103                 break;
00104                 
00105             case 's':
00106                 fInitSource = 0;
00107                 break;
00108                 
00109             case 't':
00110                 if ( TypeCheck( pAbc, globalUtilOptarg ) )
00111                 {
00112                     if ( !strcmp(globalUtilOptarg, "none") == 0 )
00113                     {
00114                         fInitRead = 1;
00115                         sprintf( sReadCmd, "read_%s", globalUtilOptarg );
00116                     }
00117                 }
00118                 else {
00119                     goto usage;
00120                 }
00121                 fBatch = 1;
00122                 break;
00123                 
00124             case 'T':
00125                 if ( TypeCheck( pAbc, globalUtilOptarg ) )
00126                 {
00127                     if (!strcmp(globalUtilOptarg, "none") == 0)
00128                     {
00129                         fFinalWrite = 1;
00130                         sprintf( sWriteCmd, "write_%s", globalUtilOptarg);
00131                     }
00132                 }
00133                 else {
00134                     goto usage;
00135                 }
00136                 fBatch = 1;
00137                 break;
00138                 
00139             case 'x':
00140                 fFinalWrite = 0;
00141                 fInitRead   = 0;
00142                 fBatch = 1;
00143                 break;
00144                 
00145             default:
00146                 goto usage;
00147         }
00148     }
00149     
00150     if ( fBatch )
00151     {
00152                 pAbc->fBatchMode = 1;
00153 
00154         if (argc - globalUtilOptind == 0)
00155         {
00156             sInFile = NULL;
00157         }
00158         else if (argc - globalUtilOptind == 1)
00159         {
00160             fInitRead = 1;
00161             sInFile = argv[globalUtilOptind];
00162         }
00163         else
00164         {
00165             Abc_UtilsPrintUsage( pAbc, argv[0] );
00166         }
00167         
00168         // source the resource file
00169         if ( fInitSource )
00170         {
00171             Abc_UtilsSource( pAbc );
00172         }
00173         
00174         fStatus = 0;
00175         if ( fInitRead && sInFile )
00176         {
00177             sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile );
00178             fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
00179         }
00180         
00181         if ( fStatus == 0 )
00182         {
00183             /* cmd line contains `source <file>' */
00184             fStatus = Cmd_CommandExecute( pAbc, sCommandUsr );
00185             if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile )
00186             {
00187                 sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile );
00188                 fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
00189             }
00190         }
00191         
00192     }
00193     else
00194     {
00195         // start interactive mode
00196         // print the hello line
00197         Abc_UtilsPrintHello( pAbc );
00198         
00199         // source the resource file
00200         if ( fInitSource )
00201         {
00202             Abc_UtilsSource( pAbc );
00203         }
00204                         
00205         // execute commands given by the user
00206         while ( !feof(stdin) )
00207         {
00208             // print command line prompt and
00209             // get the command from the user
00210             sCommand = Abc_UtilsGetUsersInput( pAbc );
00211             
00212             // execute the user's command
00213             fStatus = Cmd_CommandExecute( pAbc, sCommand );
00214             
00215             // stop if the user quitted or an error occurred
00216             if ( fStatus == -1 || fStatus == -2 )
00217                 break;
00218         }
00219     }
00220       
00221     // if the memory should be freed, quit packages
00222     if ( fStatus < 0 ) 
00223     {
00224         Abc_Stop();
00225     }
00226     return 0;
00227 
00228 usage:
00229     Abc_UtilsPrintHello( pAbc );
00230     Abc_UtilsPrintUsage( pAbc, argv[0] );
00231     return 1;
00232 }

static int TypeCheck ( Abc_Frame_t pAbc,
char *  s 
) [static]

CFile****************************************************************

FileName [main.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The main package.]

Synopsis [Here everything starts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
main.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS ///

Function********************************************************************

Synopsis [Returns 1 if s is a file type recognized, else returns 0.]

Description [Returns 1 if s is a file type recognized by ABC, else returns 0. Recognized types are "blif", "bench", "pla", and "none".]

SideEffects []

Definition at line 297 of file main.c.

00298 {
00299     if (strcmp(s, "blif") == 0)
00300         return 1;
00301     else if (strcmp(s, "bench") == 0)
00302         return 1;
00303     else if (strcmp(s, "pla") == 0)
00304         return 1;
00305     else if (strcmp(s, "none") == 0)
00306         return 1;
00307     else {
00308         fprintf( pAbc->Err, "unknown type %s\n", s );
00309         return 0;
00310     }
00311 }


Generated on Tue Jan 5 12:18:48 2010 for abc70930 by  doxygen 1.6.1