summaryrefslogtreecommitdiffstats
path: root/src/base/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/main')
-rw-r--r--src/base/main/main.c57
-rw-r--r--src/base/main/main.h9
-rw-r--r--src/base/main/mainFrame.c19
-rw-r--r--src/base/main/mainUtils.c4
4 files changed, 36 insertions, 53 deletions
diff --git a/src/base/main/main.c b/src/base/main/main.c
index a9f27bf8..1c6cbcb0 100644
--- a/src/base/main/main.c
+++ b/src/base/main/main.c
@@ -75,21 +75,21 @@ int main( int argc, char * argv[] )
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;
@@ -98,7 +98,7 @@ int main( int argc, char * argv[] )
break;
case 'o':
- sOutFile = util_optarg;
+ sOutFile = globalUtilOptarg;
fFinalWrite = 1;
break;
@@ -107,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 {
@@ -122,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 {
@@ -151,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
{
@@ -221,10 +221,7 @@ int main( int argc, char * argv[] )
// if the memory should be freed, quit packages
if ( fStatus < 0 )
{
- // perform uninitializations
- Abc_FrameEnd( pAbc );
- // stop the framework
- Abc_FrameDeallocate( pAbc );
+ Abc_Stop();
}
return 0;
@@ -250,16 +247,12 @@ usage:
void Abc_Start()
{
Abc_Frame_t * pAbc;
-
// added to detect memory leaks:
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
-
- // get global frame (singleton pattern)
- // will be initialized on first call
+ // start the glocal frame
pAbc = Abc_FrameGetGlobalFrame();
-
// source the resource file
// Abc_UtilsSource( pAbc );
}
@@ -278,17 +271,11 @@ void Abc_Start()
void Abc_Stop()
{
Abc_Frame_t * pAbc;
- int fStatus = 0;
-
- // if the memory should be freed, quit packages
- if ( fStatus == -2 )
- {
- pAbc = Abc_FrameGetGlobalFrame();
- // perform uninitializations
- Abc_FrameEnd( pAbc );
- // stop the framework
- Abc_FrameDeallocate( pAbc );
- }
+ pAbc = Abc_FrameGetGlobalFrame();
+ // perform uninitializations
+ Abc_FrameEnd( pAbc );
+ // stop the framework
+ Abc_FrameDeallocate( pAbc );
}
/**Function********************************************************************
diff --git a/src/base/main/main.h b/src/base/main/main.h
index c5f311aa..d5a463f5 100644
--- a/src/base/main/main.h
+++ b/src/base/main/main.h
@@ -40,17 +40,10 @@ typedef struct Abc_Frame_t_ Abc_Frame_t;
// it is used to catch memory leaks on Windows
#include "leaks.h"
-// standard includes
-#include <stdio.h>
-#include <string.h>
-
-// includes from GLU
-#include "util.h"
-#include "st.h"
-
// data structure packages
#include "extra.h"
#include "vec.h"
+#include "st.h"
// core packages
#include "abc.h"
diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c
index e9e243af..b3208740 100644
--- a/src/base/main/mainFrame.c
+++ b/src/base/main/mainFrame.c
@@ -48,8 +48,8 @@ int Abc_FrameReadNtkStoreSize() { return s_GlobalFrame->nSt
void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; }
void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; }
void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; }
-void * Abc_FrameReadManDd() { return s_GlobalFrame->dd; }
-void * Abc_FrameReadManDec() { return s_GlobalFrame->pManDec; }
+void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; }
+void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; }
char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
void Abc_FrameSetNtkStore( Abc_Ntk_t * pNtk ) { s_GlobalFrame->pStored = pNtk; }
@@ -97,7 +97,8 @@ bool Abc_FrameIsFlagEnabled( char * pFlag )
Abc_Frame_t * Abc_FrameAllocate()
{
Abc_Frame_t * p;
-
+ extern void define_cube_size( int n );
+ extern void set_espresso_flags();
// allocate and clean
p = ALLOC( Abc_Frame_t, 1 );
memset( p, 0, sizeof(Abc_Frame_t) );
@@ -111,8 +112,8 @@ Abc_Frame_t * Abc_FrameAllocate()
p->nSteps = 1;
p->fBatchMode = 0;
// initialize decomposition manager
- p->pManDec = Dec_ManStart();
- p->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ define_cube_size(20);
+ set_espresso_flags();
return p;
}
@@ -130,11 +131,13 @@ Abc_Frame_t * Abc_FrameAllocate()
***********************************************************************/
void Abc_FrameDeallocate( Abc_Frame_t * p )
{
- Dec_ManStop( p->pManDec );
- Extra_StopManager( p->dd );
+ extern void undefine_cube_size();
+ undefine_cube_size();
+ if ( p->pManDec ) Dec_ManStop( p->pManDec );
+ if ( p->dd ) Extra_StopManager( p->dd );
Abc_FrameDeleteAllNetworks( p );
free( p );
- p = NULL;
+ s_GlobalFrame = NULL;
}
/**Function*************************************************************
diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c
index aa8b63d0..3d0bdc33 100644
--- a/src/base/main/mainUtils.c
+++ b/src/base/main/mainUtils.c
@@ -139,8 +139,8 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc )
// If .rc is present in both the home and current directories, then read
// it from the home directory. Otherwise, read it from wherever it's located.
- sPath1 = util_file_search(".rc", "~/", "r");
- sPath2 = util_file_search(".rc", ".", "r");
+ sPath1 = Extra_UtilFileSearch(".rc", "~/", "r");
+ sPath2 = Extra_UtilFileSearch(".rc", ".", "r");
if ( sPath1 && sPath2 ) {
/* ~/.rc == .rc : Source the file only once */