diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2007-09-30 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2007-09-30 08:01:00 -0700 |
commit | e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7 (patch) | |
tree | de3ffe87c3e17950351e3b7d97fa18318bd5ea9a /src/base/main | |
parent | 7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2 (diff) | |
download | abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.tar.gz abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.tar.bz2 abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.zip |
Version abc70930
Diffstat (limited to 'src/base/main')
-rw-r--r-- | src/base/main/libSupport.c | 193 | ||||
-rw-r--r-- | src/base/main/main.c | 317 | ||||
-rw-r--r-- | src/base/main/main.h | 122 | ||||
-rw-r--r-- | src/base/main/mainFrame.c | 503 | ||||
-rw-r--r-- | src/base/main/mainInit.c | 100 | ||||
-rw-r--r-- | src/base/main/mainInt.h | 109 | ||||
-rw-r--r-- | src/base/main/mainUtils.c | 237 | ||||
-rw-r--r-- | src/base/main/module.make | 5 |
8 files changed, 0 insertions, 1586 deletions
diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c deleted file mode 100644 index 471ea09e..00000000 --- a/src/base/main/libSupport.c +++ /dev/null @@ -1,193 +0,0 @@ -/**CFile**************************************************************** - - FileName [libSupport.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [Support for external libaries.] - - Author [Mike Case] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: libSupport.c,v 1.1 2005/09/06 19:59:51 casem Exp $] - -***********************************************************************/ - -#include "mainInt.h" -#include <stdio.h> -#include <string.h> - -#ifndef WIN32 -# include <sys/types.h> -# include <dirent.h> -# include <dlfcn.h> -#endif - -#define MAX_LIBS 256 -static void* libHandles[MAX_LIBS+1]; // will be null terminated - -typedef void (*lib_init_end_func) (Abc_Frame_t * pAbc); - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// This will find all the ABC library extensions in the current directory and load them all. -//////////////////////////////////////////////////////////////////////////////////////////////////// -void open_libs() { - int curr_lib = 0; - -#ifdef WIN32 -// printf("Warning: open_libs WIN32 not implemented.\n"); -#else - DIR* dirp; - struct dirent* dp; - char *env, *init_p, *p; - int done; - - env = getenv ("ABC_LIB_PATH"); - if (env == NULL) { -// printf("Warning: ABC_LIB_PATH not defined. Looking into the current directory.\n"); - init_p = malloc (2*sizeof(char)); - init_p[0]='.'; init_p[1] = 0; - } else { - init_p = malloc ((strlen(env)+1)*sizeof(char)); - strcpy (init_p, env); - } - - // Extract directories and read libraries - done = 0; - p = init_p; - while (!done) { - char *endp = strchr (p,':'); - if (endp == NULL) done = 1; // last directory in the list - else *endp = 0; // end of string - - dirp = opendir(p); - if (dirp == NULL) { -// printf("Warning: directory in ABC_LIB_PATH does not exist (%s).\n", p); - continue; - } - - while ((dp = readdir(dirp)) != NULL) { - if ((strncmp("libabc_", dp->d_name, 7) == 0) && - (strcmp(".so", dp->d_name + strlen(dp->d_name) - 3) == 0)) { - - // make sure we don't overflow the handle array - if (curr_lib >= MAX_LIBS) { - printf("Warning: maximum number of ABC libraries (%d) exceeded. Not loading %s.\n", - MAX_LIBS, - dp->d_name); - } - - // attempt to load it - else { - char* szPrefixed = malloc((strlen(dp->d_name) + strlen(p) + 2) * - sizeof(char)); - sprintf(szPrefixed, "%s/", p); - strcat(szPrefixed, dp->d_name); - libHandles[curr_lib] = dlopen(szPrefixed, RTLD_NOW | RTLD_LOCAL); - - // did the load succeed? - if (libHandles[curr_lib] != 0) { - printf("Loaded ABC library: %s (Abc library extension #%d)\n", szPrefixed, curr_lib); - curr_lib++; - } else { - printf("Warning: failed to load ABC library %s:\n\t%s\n", szPrefixed, dlerror()); - } - - free(szPrefixed); - } - } - } - closedir(dirp); - p = endp+1; - } - - free(init_p); -#endif - - // null terminate the list of handles - libHandles[curr_lib] = 0; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// This will close all open ABC library extensions -//////////////////////////////////////////////////////////////////////////////////////////////////// -void close_libs() { -#ifdef WIN32 - printf("Warning: close_libs WIN32 not implemented.\n"); -#else - int i; - for (i = 0; libHandles[i] != 0; i++) { - if (dlclose(libHandles[i]) != 0) { - printf("Warning: failed to close library %d\n", i); - } - libHandles[i] = 0; - } -#endif -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// This will get a pointer to a function inside of an open library -//////////////////////////////////////////////////////////////////////////////////////////////////// -void* get_fnct_ptr(int lib_num, char* sym_name) { -#ifdef WIN32 - printf("Warning: get_fnct_ptr WIN32 not implemented.\n"); - return 0; -#else - return dlsym(libHandles[lib_num], sym_name); -#endif -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// This will call an initialization function in every open library. -//////////////////////////////////////////////////////////////////////////////////////////////////// -void call_inits(Abc_Frame_t* pAbc) { - int i; - lib_init_end_func init_func; - for (i = 0; libHandles[i] != 0; i++) { - init_func = (lib_init_end_func) get_fnct_ptr(i, "abc_init"); - if (init_func == 0) { - printf("Warning: Failed to initialize library %d.\n", i); - } else { - (*init_func)(pAbc); - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// This will call a shutdown function in every open library. -//////////////////////////////////////////////////////////////////////////////////////////////////// -void call_ends(Abc_Frame_t* pAbc) { - int i; - lib_init_end_func end_func; - for (i = 0; libHandles[i] != 0; i++) { - end_func = (lib_init_end_func) get_fnct_ptr(i, "abc_end"); - if (end_func == 0) { - printf("Warning: Failed to end library %d.\n", i); - } else { - (*end_func)(pAbc); - } - } -} - -void Libs_Init(Abc_Frame_t * pAbc) -{ - open_libs(); - call_inits(pAbc); -} - -void Libs_End(Abc_Frame_t * pAbc) -{ - call_ends(pAbc); - - // It's good practice to close our libraries at this point, but this can mess up any backtrace printed by Valgind. - // close_libs(); -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// diff --git a/src/base/main/main.c b/src/base/main/main.c deleted file mode 100644 index 8f43c605..00000000 --- a/src/base/main/main.c +++ /dev/null @@ -1,317 +0,0 @@ -/**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 $] - -***********************************************************************/ - -#include "mainInt.h" - -// this line should be included in the library project -//#define _LIB - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -static int TypeCheck( Abc_Frame_t * pAbc, char * s); - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -#ifndef _LIB - -/**Function************************************************************* - - Synopsis [The main() procedure.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int main( int argc, char * argv[] ) -{ - Abc_Frame_t * pAbc; - char sCommandUsr[500], sCommandTmp[100], sReadCmd[20], sWriteCmd[20], c; - 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 - pAbc = Abc_FrameGetGlobalFrame(); - - // default options - fBatch = 0; - fInitSource = 1; - fInitRead = 0; - fFinalWrite = 0; - sInFile = sOutFile = NULL; - sprintf( sReadCmd, "read" ); - sprintf( sWriteCmd, "write" ); - - Extra_UtilGetoptReset(); - while ((c = Extra_UtilGetopt(argc, argv, "c:hf:F:o:st:T:x")) != EOF) { - switch(c) { - case 'c': - strcpy( sCommandUsr, globalUtilOptarg ); - fBatch = 1; - break; - - case 'f': - sprintf(sCommandUsr, "source %s", globalUtilOptarg); - fBatch = 1; - break; - - case 'F': - sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); - fBatch = 1; - break; - - case 'h': - goto usage; - break; - - case 'o': - sOutFile = globalUtilOptarg; - fFinalWrite = 1; - break; - - case 's': - fInitSource = 0; - break; - - case 't': - if ( TypeCheck( pAbc, globalUtilOptarg ) ) - { - if ( !strcmp(globalUtilOptarg, "none") == 0 ) - { - fInitRead = 1; - sprintf( sReadCmd, "read_%s", globalUtilOptarg ); - } - } - else { - goto usage; - } - fBatch = 1; - break; - - case 'T': - if ( TypeCheck( pAbc, globalUtilOptarg ) ) - { - if (!strcmp(globalUtilOptarg, "none") == 0) - { - fFinalWrite = 1; - sprintf( sWriteCmd, "write_%s", globalUtilOptarg); - } - } - else { - goto usage; - } - fBatch = 1; - break; - - case 'x': - fFinalWrite = 0; - fInitRead = 0; - fBatch = 1; - break; - - default: - goto usage; - } - } - - if ( fBatch ) - { - pAbc->fBatchMode = 1; - - if (argc - globalUtilOptind == 0) - { - sInFile = NULL; - } - else if (argc - globalUtilOptind == 1) - { - fInitRead = 1; - sInFile = argv[globalUtilOptind]; - } - else - { - Abc_UtilsPrintUsage( pAbc, argv[0] ); - } - - // source the resource file - if ( fInitSource ) - { - Abc_UtilsSource( pAbc ); - } - - fStatus = 0; - if ( fInitRead && sInFile ) - { - sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile ); - fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); - } - - if ( fStatus == 0 ) - { - /* cmd line contains `source <file>' */ - fStatus = Cmd_CommandExecute( pAbc, sCommandUsr ); - if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile ) - { - sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile ); - fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); - } - } - - } - else - { - // start interactive mode - // print the hello line - Abc_UtilsPrintHello( pAbc ); - - // source the resource file - if ( fInitSource ) - { - Abc_UtilsSource( pAbc ); - } - - // execute commands given by the user - while ( !feof(stdin) ) - { - // print command line prompt and - // get the command from the user - sCommand = Abc_UtilsGetUsersInput( pAbc ); - - // execute the user's command - fStatus = Cmd_CommandExecute( pAbc, sCommand ); - - // stop if the user quitted or an error occurred - if ( fStatus == -1 || fStatus == -2 ) - break; - } - } - - // if the memory should be freed, quit packages - if ( fStatus < 0 ) - { - Abc_Stop(); - } - return 0; - -usage: - Abc_UtilsPrintHello( pAbc ); - Abc_UtilsPrintUsage( pAbc, argv[0] ); - 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******************************************************************** - - 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 [] - -******************************************************************************/ -static int TypeCheck( Abc_Frame_t * pAbc, char * s ) -{ - if (strcmp(s, "blif") == 0) - return 1; - else if (strcmp(s, "bench") == 0) - return 1; - else if (strcmp(s, "pla") == 0) - return 1; - else if (strcmp(s, "none") == 0) - return 1; - else { - fprintf( pAbc->Err, "unknown type %s\n", s ); - return 0; - } -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/base/main/main.h b/src/base/main/main.h deleted file mode 100644 index 4433a8b4..00000000 --- a/src/base/main/main.h +++ /dev/null @@ -1,122 +0,0 @@ -/**CFile**************************************************************** - - FileName [main.h] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [External declarations of the main package.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: main.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////// -/// TYPEDEFS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// STRUCTURE DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -// the framework containing all data -typedef struct Abc_Frame_t_ Abc_Frame_t; - -//////////////////////////////////////////////////////////////////////// -/// INCLUDES /// -//////////////////////////////////////////////////////////////////////// - -// this include should be the first one in the list -// it is used to catch memory leaks on Windows -#include "leaks.h" - -// data structure packages -#include "extra.h" -#include "vec.h" -#include "st.h" - -// core packages -#include "abc.h" -#include "cmd.h" -#include "io.h" - -//////////////////////////////////////////////////////////////////////// -/// PARAMETERS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// GLOBAL VARIABLES /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// MACRO DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/*=== main.c ===========================================================*/ -extern void Abc_Start(); -extern void Abc_Stop(); - -/*=== mainFrame.c ===========================================================*/ -extern Abc_Ntk_t * Abc_FrameReadNtk( Abc_Frame_t * p ); -extern FILE * Abc_FrameReadOut( Abc_Frame_t * p ); -extern FILE * Abc_FrameReadErr( Abc_Frame_t * p ); -extern bool Abc_FrameReadMode( Abc_Frame_t * p ); -extern bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode ); -extern void Abc_FrameRestart( Abc_Frame_t * p ); -extern bool Abc_FrameShowProgress( Abc_Frame_t * p ); - -extern void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ); -extern void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p ); -extern void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ); -extern void Abc_FrameUnmapAllNetworks( Abc_Frame_t * p ); -extern void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p ); - -extern void Abc_FrameSetGlobalFrame( Abc_Frame_t * p ); -extern Abc_Frame_t * Abc_FrameGetGlobalFrame(); - -extern Vec_Ptr_t * Abc_FrameReadStore(); -extern int Abc_FrameReadStoreSize(); -extern void * Abc_FrameReadLibLut(); -extern void * Abc_FrameReadLibGen(); -extern void * Abc_FrameReadLibSuper(); -extern void * Abc_FrameReadLibVer(); -extern void * Abc_FrameReadManDd(); -extern void * Abc_FrameReadManDec(); -extern char * Abc_FrameReadFlag( char * pFlag ); -extern bool Abc_FrameIsFlagEnabled( char * pFlag ); - -extern void Abc_FrameSetNtkStore( Abc_Ntk_t * pNtk ); -extern void Abc_FrameSetNtkStoreSize( int nStored ); -extern void Abc_FrameSetLibLut( void * pLib ); -extern void Abc_FrameSetLibGen( void * pLib ); -extern void Abc_FrameSetLibSuper( void * pLib ); -extern void Abc_FrameSetLibVer( void * pLib ); -extern void Abc_FrameSetFlag( char * pFlag, char * pValue ); - -#ifdef __cplusplus -} -#endif - -#endif - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c deleted file mode 100644 index eae8b7a6..00000000 --- a/src/base/main/mainFrame.c +++ /dev/null @@ -1,503 +0,0 @@ -/**CFile**************************************************************** - - FileName [mainFrame.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [The global framework resides in this file.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: mainFrame.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "mainInt.h" -#include "abc.h" -#include "dec.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -static Abc_Frame_t * s_GlobalFrame = NULL; - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [APIs to access parameters in the flobal frame.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Ptr_t * Abc_FrameReadStore() { return s_GlobalFrame->vStore; } -int Abc_FrameReadStoreSize() { return Vec_PtrSize(s_GlobalFrame->vStore); } -void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; } -void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; } -void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; } -void * Abc_FrameReadLibVer() { return s_GlobalFrame->pLibVer; } -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_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut = pLib; } -void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; } -void Abc_FrameSetLibSuper( void * pLib ) { s_GlobalFrame->pLibSuper = pLib; } -void Abc_FrameSetLibVer( void * pLib ) { s_GlobalFrame->pLibVer = pLib; } -void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateValue( s_GlobalFrame, pFlag, pValue ); } - -/**Function************************************************************* - - Synopsis [Returns 1 if the flag is enabled without value or with value 1.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -bool Abc_FrameIsFlagEnabled( char * pFlag ) -{ - char * pValue; - // if flag is not defined, it is not enabled - pValue = Abc_FrameReadFlag( pFlag ); - if ( pValue == NULL ) - return 0; - // if flag is defined but value is not empty (no parameter) or "1", it is not enabled - if ( strcmp(pValue, "") && strcmp(pValue, "1") ) - return 0; - return 1; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -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) ); - // get version - p->sVersion = Abc_UtilsGetVersion( p ); - // set streams - p->Err = stderr; - p->Out = stdout; - p->Hst = NULL; - // set the starting step - p->nSteps = 1; - p->fBatchMode = 0; - // networks to be used by choice - p->vStore = Vec_PtrAlloc( 16 ); - // initialize decomposition manager - define_cube_size(20); - set_espresso_flags(); - // initialize the trace manager -// Abc_HManStart(); - return p; -} - - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameDeallocate( Abc_Frame_t * p ) -{ - extern void Rwt_ManGlobalStop(); - extern void undefine_cube_size(); -// extern void Ivy_TruthManStop(); -// Abc_HManStop(); - undefine_cube_size(); - Rwt_ManGlobalStop(); -// Ivy_TruthManStop(); - if ( p->pLibVer ) Abc_LibFree( p->pLibVer, NULL ); - if ( p->pManDec ) Dec_ManStop( p->pManDec ); - if ( p->dd ) Extra_StopManager( p->dd ); - if ( p->vStore ) Vec_PtrFree( p->vStore ); - Abc_FrameDeleteAllNetworks( p ); - free( p ); - s_GlobalFrame = NULL; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameRestart( Abc_Frame_t * p ) -{ -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -bool Abc_FrameShowProgress( Abc_Frame_t * p ) -{ - return Abc_FrameIsFlagEnabled( "progressbar" ); -} - - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Abc_Ntk_t * Abc_FrameReadNtk( Abc_Frame_t * p ) -{ - return p->pNtkCur; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -FILE * Abc_FrameReadOut( Abc_Frame_t * p ) -{ - return p->Out; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -FILE * Abc_FrameReadErr( Abc_Frame_t * p ) -{ - return p->Err; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Abc_FrameReadMode( Abc_Frame_t * p ) -{ - int fShortNames; - char * pValue; - pValue = Cmd_FlagReadByName( p, "namemode" ); - if ( pValue == NULL ) - fShortNames = 0; - else - fShortNames = atoi(pValue); - return fShortNames; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode ) -{ - char Buffer[2]; - bool fNameModeOld; - fNameModeOld = Abc_FrameReadMode( p ); - Buffer[0] = '0' + fNameMode; - Buffer[1] = 0; - Cmd_FlagUpdateValue( p, "namemode", (char *)Buffer ); - return fNameModeOld; -} - - -/**Function************************************************************* - - Synopsis [Sets the given network to be the current one.] - - Description [Takes the network and makes it the current network. - The previous current network is attached to the given network as - a backup copy. In the stack of backup networks contains too many - networks (defined by the paramater "savesteps"), the bottom - most network is deleted.] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNtkNew ) -{ - Abc_Ntk_t * pNtk, * pNtk2, * pNtk3; - int nNetsPresent; - int nNetsToSave; - char * pValue; - - // link it to the previous network - Abc_NtkSetBackup( pNtkNew, p->pNtkCur ); - // set the step of this network - Abc_NtkSetStep( pNtkNew, ++p->nSteps ); - // set this network to be the current network - p->pNtkCur = pNtkNew; - - // remove any extra network that may happen to be in the stack - pValue = Cmd_FlagReadByName( p, "savesteps" ); - // if the value of steps to save is not set, assume 1-level undo - if ( pValue == NULL ) - nNetsToSave = 1; - else - nNetsToSave = atoi(pValue); - - // count the network, remember the last one, and the one before the last one - nNetsPresent = 0; - pNtk2 = pNtk3 = NULL; - for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk2) ) - { - nNetsPresent++; - pNtk3 = pNtk2; - pNtk2 = pNtk; - } - - // remove the earliest backup network if it is more steps away than we store - if ( nNetsPresent - 1 > nNetsToSave ) - { // delete the last network - Abc_NtkDelete( pNtk2 ); - // clean the pointer of the network before the last one - Abc_NtkSetBackup( pNtk3, NULL ); - } -} - -/**Function************************************************************* - - Synopsis [This procedure swaps the current and the backup network.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p ) -{ - Abc_Ntk_t * pNtkCur, * pNtkBack, * pNtkBack2; - int iStepCur, iStepBack; - - pNtkCur = p->pNtkCur; - pNtkBack = Abc_NtkBackup( pNtkCur ); - iStepCur = Abc_NtkStep ( pNtkCur ); - - // if there is no backup nothing to reset - if ( pNtkBack == NULL ) - return; - - // remember the backup of the backup - pNtkBack2 = Abc_NtkBackup( pNtkBack ); - iStepBack = Abc_NtkStep ( pNtkBack ); - - // set pNtkCur to be the next after the backup's backup - Abc_NtkSetBackup( pNtkCur, pNtkBack2 ); - Abc_NtkSetStep ( pNtkCur, iStepBack ); - - // set pNtkCur to be the next after the backup - Abc_NtkSetBackup( pNtkBack, pNtkCur ); - Abc_NtkSetStep ( pNtkBack, iStepCur ); - - // set the current network - p->pNtkCur = pNtkBack; -} - - -/**Function************************************************************* - - Synopsis [Replaces the current network by the given one.] - - Description [This procedure does not modify the stack of saved - networks.] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNtk ) -{ - if ( pNtk == NULL ) - return; - - // transfer the parameters to the new network - if ( p->pNtkCur && Abc_FrameIsFlagEnabled( "backup" ) ) - { - Abc_NtkSetBackup( pNtk, Abc_NtkBackup(p->pNtkCur) ); - Abc_NtkSetStep( pNtk, Abc_NtkStep(p->pNtkCur) ); - // delete the current network - Abc_NtkDelete( p->pNtkCur ); - } - else - { - Abc_NtkSetBackup( pNtk, NULL ); - Abc_NtkSetStep( pNtk, ++p->nSteps ); - // delete the current network if present but backup is disabled - if ( p->pNtkCur ) - Abc_NtkDelete( p->pNtkCur ); - } - // set the new current network - p->pNtkCur = pNtk; -} - -/**Function************************************************************* - - Synopsis [Removes library binding of all currently stored networks.] - - Description [This procedure is called when the library is freed.] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameUnmapAllNetworks( Abc_Frame_t * p ) -{ - Abc_Ntk_t * pNtk; - for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) ) - if ( Abc_NtkHasMapping(pNtk) ) - Abc_NtkMapToSop( pNtk ); -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p ) -{ - Abc_Ntk_t * pNtk, * pNtk2; - // delete all the currently saved networks - for ( pNtk = p->pNtkCur, - pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL; - pNtk; - pNtk = pNtk2, - pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL ) - Abc_NtkDelete( pNtk ); - // set the current network empty - p->pNtkCur = NULL; -// fprintf( p->Out, "All networks have been deleted.\n" ); -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameSetGlobalFrame( Abc_Frame_t * p ) -{ - s_GlobalFrame = p; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Abc_Frame_t * Abc_FrameGetGlobalFrame() -{ - if ( s_GlobalFrame == 0 ) - { - // start the framework - s_GlobalFrame = Abc_FrameAllocate(); - // perform initializations - Abc_FrameInit( s_GlobalFrame ); - } - return s_GlobalFrame; -} - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c deleted file mode 100644 index 03953e5b..00000000 --- a/src/base/main/mainInit.c +++ /dev/null @@ -1,100 +0,0 @@ -/**CFile**************************************************************** - - FileName [mainInit.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [Initialization procedures.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: mainInit.c,v 1.3 2005/09/14 22:53:37 casem Exp $] - -***********************************************************************/ - -#include "mainInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -extern void Abc_Init( Abc_Frame_t * pAbc ); -extern void Abc_End ( Abc_Frame_t * pAbc ); -extern void Io_Init( Abc_Frame_t * pAbc ); -extern void Io_End ( Abc_Frame_t * pAbc ); -extern void Cmd_Init( Abc_Frame_t * pAbc ); -extern void Cmd_End ( Abc_Frame_t * pAbc ); -extern void Fpga_Init( Abc_Frame_t * pAbc ); -extern void Fpga_End ( Abc_Frame_t * pAbc ); -extern void Map_Init( Abc_Frame_t * pAbc ); -extern void Map_End ( Abc_Frame_t * pAbc ); -extern void Mio_Init( Abc_Frame_t * pAbc ); -extern void Mio_End ( Abc_Frame_t * pAbc ); -extern void Super_Init( Abc_Frame_t * pAbc ); -extern void Super_End ( Abc_Frame_t * pAbc ); -extern void Libs_Init(Abc_Frame_t * pAbc); -extern void Libs_End(Abc_Frame_t * pAbc); - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Starts all the packages.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameInit( Abc_Frame_t * pAbc ) -{ - Cmd_Init( pAbc ); - Io_Init( pAbc ); - Abc_Init( pAbc ); - Fpga_Init( pAbc ); - Map_Init( pAbc ); - Mio_Init( pAbc ); - Super_Init( pAbc ); - Libs_Init( pAbc ); -} - - -/**Function************************************************************* - - Synopsis [Stops all the packages.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_FrameEnd( Abc_Frame_t * pAbc ) -{ - Abc_End( pAbc ); - Io_End( pAbc ); - Cmd_End( pAbc ); - Fpga_End( pAbc ); - Map_End( pAbc ); - Mio_End( pAbc ); - Super_End( pAbc ); - Libs_End( pAbc ); -} - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h deleted file mode 100644 index 09ad96f3..00000000 --- a/src/base/main/mainInt.h +++ /dev/null @@ -1,109 +0,0 @@ -/**CFile**************************************************************** - - FileName [mainInt.h] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [Internal declarations of the main package.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: mainInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#ifndef __MAIN_INT_H__ -#define __MAIN_INT_H__ - -//////////////////////////////////////////////////////////////////////// -/// INCLUDES /// -//////////////////////////////////////////////////////////////////////// - -#include "main.h" - -//////////////////////////////////////////////////////////////////////// -/// PARAMETERS /// -//////////////////////////////////////////////////////////////////////// - -// the current version -#define ABC_VERSION "UC Berkeley, ABC 1.01" - -// the maximum length of an input line -#define MAX_STR 32768 - -//////////////////////////////////////////////////////////////////////// -/// STRUCTURE DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -struct Abc_Frame_t_ -{ - // general info - char * sVersion; // the name of the current version - // commands, aliases, etc - st_table * tCommands; // the command table - st_table * tAliases; // the alias table - st_table * tFlags; // the flag table - Vec_Ptr_t * aHistory; // the command history - // the functionality - Abc_Ntk_t * pNtkCur; // the current network - int nSteps; // the counter of different network processed - int fAutoexac; // marks the autoexec mode - int fBatchMode; // are we invoked in batch mode? - // output streams - FILE * Out; - FILE * Err; - FILE * Hst; - // used for runtime measurement - int TimeCommand; // the runtime of the last command - int TimeTotal; // the total runtime of all commands - // temporary storage for structural choices - Vec_Ptr_t * vStore; // networks to be used by choice - // decomposition package - void * pManDec; // decomposition manager - DdManager * dd; // temporary BDD package - // libraries for mapping - void * pLibLut; // the current LUT library - void * pLibGen; // the current genlib - void * pLibSuper; // the current supergate library - void * pLibVer; // the current Verilog library -}; - -//////////////////////////////////////////////////////////////////////// -/// GLOBAL VARIABLES /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// MACRO DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/*=== mvMain.c ===========================================================*/ -extern int main( int argc, char * argv[] ); -/*=== mvInit.c ===================================================*/ -extern void Abc_FrameInit( Abc_Frame_t * pAbc ); -extern void Abc_FrameEnd( Abc_Frame_t * pAbc ); -/*=== mvFrame.c =====================================================*/ -extern Abc_Frame_t * Abc_FrameAllocate(); -extern void Abc_FrameDeallocate( Abc_Frame_t * p ); -/*=== mvUtils.c =====================================================*/ -extern char * Abc_UtilsGetVersion( Abc_Frame_t * pAbc ); -extern char * Abc_UtilsGetUsersInput( Abc_Frame_t * pAbc ); -extern void Abc_UtilsPrintHello( Abc_Frame_t * pAbc ); -extern void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName ); -extern void Abc_UtilsSource( Abc_Frame_t * pAbc ); - -#endif - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c deleted file mode 100644 index 2cd4e337..00000000 --- a/src/base/main/mainUtils.c +++ /dev/null @@ -1,237 +0,0 @@ -/**CFile**************************************************************** - - FileName [mainUtils.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [The main package.] - - Synopsis [Miscellaneous utilities.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: mainUtils.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "mainInt.h" - -#ifndef _WIN32 -#include "readline/readline.h" -#endif - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// -static char * DateReadFromDateString(char * datestr); - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -char * Abc_UtilsGetVersion( Abc_Frame_t * pAbc ) -{ - static char Version[1000]; - sprintf(Version, "%s (compiled %s %s)", ABC_VERSION, __DATE__, __TIME__); - return Version; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -char * Abc_UtilsGetUsersInput( Abc_Frame_t * pAbc ) -{ - static char Buffer[1000], Prompt[1000]; - sprintf( Prompt, "abc %02d> ", pAbc->nSteps ); -#ifdef _WIN32 - fprintf( pAbc->Out, "%s", Prompt ); - fgets( Buffer, 999, stdin ); - return Buffer; -#else - static char* line = NULL; - if (line != NULL) free(line); - line = readline(Prompt); - if (line == NULL){ printf("***EOF***\n"); exit(0); } - add_history(line); - return line; -#endif -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_UtilsPrintHello( Abc_Frame_t * pAbc ) -{ - fprintf( pAbc->Out, "%s\n", pAbc->sVersion ); -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName ) -{ - fprintf( pAbc->Err, "\n" ); - fprintf( pAbc->Err, - "usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [file]\n", - ProgName); - fprintf( pAbc->Err, " -c cmd\texecute commands `cmd'\n"); - fprintf( pAbc->Err, " -F script\texecute commands from a script file and echo commands\n"); - fprintf( pAbc->Err, " -f script\texecute commands from a script file\n"); - fprintf( pAbc->Err, " -h\t\tprint the command usage\n"); - fprintf( pAbc->Err, " -o file\tspecify output filename to store the result\n"); - fprintf( pAbc->Err, " -s\t\tdo not read any initialization file\n"); - fprintf( pAbc->Err, " -t type\tspecify input type (blif_mv (default), blif_mvs, blif, or none)\n"); - fprintf( pAbc->Err, " -T type\tspecify output type (blif_mv (default), blif_mvs, blif, or none)\n"); - fprintf( pAbc->Err, " -x\t\tequivalent to '-t none -T none'\n"); - fprintf( pAbc->Err, "\n" ); -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Abc_UtilsSource( Abc_Frame_t * pAbc ) -{ -#ifdef WIN32 - if ( Cmd_CommandExecute(pAbc, "source abc.rc") ) - { - if ( Cmd_CommandExecute(pAbc, "source ..\\abc.rc") == 0 ) - printf( "Loaded \"abc.rc\" from the parent directory.\n" ); - else if ( Cmd_CommandExecute(pAbc, "source ..\\..\\abc.rc") == 0 ) - printf( "Loaded \"abc.rc\" from the grandparent directory.\n" ); - } -#else - { - char * sPath1, * sPath2; - - // 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 = Extra_UtilFileSearch(".rc", "~/", "r"); - sPath2 = Extra_UtilFileSearch(".rc", ".", "r"); - - if ( sPath1 && sPath2 ) { - /* ~/.rc == .rc : Source the file only once */ - (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc"); - } - else { - if (sPath1) { - (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc"); - } - if (sPath2) { - (void) Cmd_CommandExecute(pAbc, "source -s .rc"); - } - } - if ( sPath1 ) FREE(sPath1); - if ( sPath2 ) FREE(sPath2); - - /* execute the abc script which can be open with the "open_path" */ - Cmd_CommandExecute( pAbc, "source -s abc.rc" ); - } -#endif //WIN32 - { - // reset command history - char * pName; - int i; - Vec_PtrForEachEntry( pAbc->aHistory, pName, i ) - free( pName ); - pAbc->aHistory->nSize = 0; - } -} - -/**Function******************************************************************** - - Synopsis [Returns the date in a brief format assuming its coming from - the program `date'.] - - Description [optional] - - SideEffects [] - -******************************************************************************/ -char * -DateReadFromDateString( - char * datestr) -{ - static char result[25]; - char day[10]; - char month[10]; - char zone[10]; - char *at; - int date; - int hour; - int minute; - int second; - int year; - - if (sscanf(datestr, "%s %s %2d %2d:%2d:%2d %s %4d", - day, month, &date, &hour, &minute, &second, zone, &year) == 8) { - if (hour >= 12) { - if (hour >= 13) hour -= 12; - at = "PM"; - } - else { - if (hour == 0) hour = 12; - at = "AM"; - } - (void) sprintf(result, "%d-%3s-%02d at %d:%02d %s", - date, month, year % 100, hour, minute, at); - return result; - } - else { - return datestr; - } -} - - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/base/main/module.make b/src/base/main/module.make deleted file mode 100644 index 367f89f6..00000000 --- a/src/base/main/module.make +++ /dev/null @@ -1,5 +0,0 @@ -SRC += src/base/main/main.c \ - src/base/main/mainFrame.c \ - src/base/main/mainInit.c \ - src/base/main/libSupport.c \ - src/base/main/mainUtils.c |