From 0c6505a26a537dc911b6566f82d759521e527c08 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 30 Jan 2008 20:01:00 -0800 Subject: Version abc80130_2 --- src/base/main/main.c | 107 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 25 deletions(-) (limited to 'src/base/main/main.c') diff --git a/src/base/main/main.c b/src/base/main/main.c index 0622a3bd..8f43c605 100644 --- a/src/base/main/main.c +++ b/src/base/main/main.c @@ -20,6 +20,9 @@ #include "mainInt.h" +// this line should be included in the library project +//#define _LIB + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -27,9 +30,11 @@ static int TypeCheck( Abc_Frame_t * pAbc, char * s); //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFITIONS /// +/// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +#ifndef _LIB + /**Function************************************************************* Synopsis [The main() procedure.] @@ -48,11 +53,14 @@ int main( int argc, char * argv[] ) char * sCommand, * sOutFile, * sInFile; int fStatus = 0; bool fBatch, fInitSource, fInitRead, fFinalWrite; - + // added to detect memory leaks: #ifdef _DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif + +// Npn_Experiment(); +// Npn_Generate(); // get global frame (singleton pattern) // will be initialized on first call @@ -64,24 +72,24 @@ int main( int argc, char * argv[] ) fInitRead = 0; fFinalWrite = 0; sInFile = sOutFile = NULL; - sprintf( sReadCmd, "read_blif_mv" ); - sprintf( sWriteCmd, "write_blif_mv" ); + sprintf( sReadCmd, "read" ); + sprintf( sWriteCmd, "write" ); - util_getopt_reset(); - while ((c = util_getopt(argc, argv, "c:hf:F:o:st:T:x")) != EOF) { + Extra_UtilGetoptReset(); + while ((c = Extra_UtilGetopt(argc, argv, "c:hf:F:o:st:T:x")) != EOF) { switch(c) { case 'c': - strcpy( sCommandUsr, util_optarg ); + strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 1; break; case 'f': - sprintf(sCommandUsr, "source %s", util_optarg); + sprintf(sCommandUsr, "source %s", globalUtilOptarg); fBatch = 1; break; case 'F': - sprintf(sCommandUsr, "source -x %s", util_optarg); + sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); fBatch = 1; break; @@ -90,7 +98,7 @@ int main( int argc, char * argv[] ) break; case 'o': - sOutFile = util_optarg; + sOutFile = globalUtilOptarg; fFinalWrite = 1; break; @@ -99,12 +107,12 @@ int main( int argc, char * argv[] ) break; case 't': - if ( TypeCheck( pAbc, util_optarg ) ) + if ( TypeCheck( pAbc, globalUtilOptarg ) ) { - if ( !strcmp(util_optarg, "none") == 0 ) + if ( !strcmp(globalUtilOptarg, "none") == 0 ) { fInitRead = 1; - sprintf( sReadCmd, "read_%s", util_optarg ); + sprintf( sReadCmd, "read_%s", globalUtilOptarg ); } } else { @@ -114,12 +122,12 @@ int main( int argc, char * argv[] ) break; case 'T': - if ( TypeCheck( pAbc, util_optarg ) ) + if ( TypeCheck( pAbc, globalUtilOptarg ) ) { - if (!strcmp(util_optarg, "none") == 0) + if (!strcmp(globalUtilOptarg, "none") == 0) { fFinalWrite = 1; - sprintf( sWriteCmd, "write_%s", util_optarg); + sprintf( sWriteCmd, "write_%s", globalUtilOptarg); } } else { @@ -143,14 +151,14 @@ int main( int argc, char * argv[] ) { pAbc->fBatchMode = 1; - if (argc - util_optind == 0) + if (argc - globalUtilOptind == 0) { sInFile = NULL; } - else if (argc - util_optind == 1) + else if (argc - globalUtilOptind == 1) { fInitRead = 1; - sInFile = argv[util_optind]; + sInFile = argv[globalUtilOptind]; } else { @@ -209,14 +217,11 @@ int main( int argc, char * argv[] ) break; } } - + // if the memory should be freed, quit packages - if ( fStatus == -2 ) + if ( fStatus < 0 ) { - // perform uninitializations - Abc_FrameEnd( pAbc ); - // stop the framework - Abc_FrameDeallocate( pAbc ); + Abc_Stop(); } return 0; @@ -226,6 +231,58 @@ usage: return 1; } +#endif + +/**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 [] + +***********************************************************************/ +void Abc_Start() +{ + Abc_Frame_t * pAbc; + // added to detect memory leaks: +#ifdef _DEBUG + _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); +#endif + // start the glocal frame + pAbc = Abc_FrameGetGlobalFrame(); + // source the resource file +// Abc_UtilsSource( pAbc ); +} + +/**Function************************************************************* + + Synopsis [Deallocation procedure for the library project.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_Stop() +{ + Abc_Frame_t * pAbc; + pAbc = Abc_FrameGetGlobalFrame(); + // perform uninitializations + Abc_FrameEnd( pAbc ); + // stop the framework + Abc_FrameDeallocate( pAbc ); +} /**Function******************************************************************** -- cgit v1.2.3