src/base/main/mainInt.h File Reference

#include "main.h"
Include dependency graph for mainInt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Abc_Frame_t_

Defines

#define ABC_VERSION   "UC Berkeley, ABC 1.01"
#define MAX_STR   32768

Functions

int main (int argc, char *argv[])
void Abc_FrameInit (Abc_Frame_t *pAbc)
void Abc_FrameEnd (Abc_Frame_t *pAbc)
Abc_Frame_tAbc_FrameAllocate ()
void Abc_FrameDeallocate (Abc_Frame_t *p)
char * Abc_UtilsGetVersion (Abc_Frame_t *pAbc)
char * Abc_UtilsGetUsersInput (Abc_Frame_t *pAbc)
void Abc_UtilsPrintHello (Abc_Frame_t *pAbc)
void Abc_UtilsPrintUsage (Abc_Frame_t *pAbc, char *ProgName)
void Abc_UtilsSource (Abc_Frame_t *pAbc)

Define Documentation

#define ABC_VERSION   "UC Berkeley, ABC 1.01"

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

] INCLUDES /// PARAMETERS ///

Definition at line 35 of file mainInt.h.

#define MAX_STR   32768

Definition at line 38 of file mainInt.h.


Function Documentation

Abc_Frame_t* Abc_FrameAllocate (  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file mainFrame.c.

00098 {
00099     Abc_Frame_t * p;
00100     extern void define_cube_size( int n );
00101     extern void set_espresso_flags();
00102     // allocate and clean
00103     p = ALLOC( Abc_Frame_t, 1 );
00104     memset( p, 0, sizeof(Abc_Frame_t) );
00105     // get version
00106     p->sVersion = Abc_UtilsGetVersion( p );
00107     // set streams
00108     p->Err = stderr;
00109     p->Out = stdout;
00110     p->Hst = NULL;
00111     // set the starting step
00112     p->nSteps = 1;
00113         p->fBatchMode = 0;
00114     // networks to be used by choice
00115     p->vStore = Vec_PtrAlloc( 16 );
00116     // initialize decomposition manager
00117     define_cube_size(20);
00118     set_espresso_flags();
00119     // initialize the trace manager
00120 //    Abc_HManStart();
00121     return p;
00122 }

void Abc_FrameDeallocate ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file mainFrame.c.

00137 {
00138     extern void Rwt_ManGlobalStop();
00139     extern void undefine_cube_size();
00140 //    extern void Ivy_TruthManStop();
00141 //    Abc_HManStop();
00142     undefine_cube_size();
00143     Rwt_ManGlobalStop();
00144 //    Ivy_TruthManStop();
00145     if ( p->pLibVer ) Abc_LibFree( p->pLibVer, NULL );
00146     if ( p->pManDec ) Dec_ManStop( p->pManDec );
00147     if ( p->dd )      Extra_StopManager( p->dd );
00148     if ( p->vStore )  Vec_PtrFree( p->vStore );
00149     Abc_FrameDeleteAllNetworks( p );
00150     free( p );
00151     s_GlobalFrame = NULL;
00152 }

void Abc_FrameEnd ( Abc_Frame_t pAbc  ) 

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

Synopsis [Stops all the packages.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file mainInit.c.

00084 {
00085     Abc_End( pAbc );
00086     Io_End( pAbc );
00087     Cmd_End( pAbc );
00088     Fpga_End( pAbc );
00089     Map_End( pAbc );
00090     Mio_End( pAbc );
00091     Super_End( pAbc );
00092     Libs_End( pAbc );
00093 }

void Abc_FrameInit ( Abc_Frame_t pAbc  ) 

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

Synopsis [Starts all the packages.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file mainInit.c.

00060 {
00061     Cmd_Init( pAbc );
00062     Io_Init( pAbc );
00063     Abc_Init( pAbc );
00064     Fpga_Init( pAbc );
00065     Map_Init( pAbc );
00066     Mio_Init( pAbc );
00067     Super_Init( pAbc );
00068     Libs_Init( pAbc );
00069 }

char* Abc_UtilsGetUsersInput ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file mainUtils.c.

00066 {
00067     static char Buffer[1000], Prompt[1000];
00068     sprintf( Prompt, "abc %02d> ", pAbc->nSteps );
00069 #ifdef _WIN32
00070     fprintf( pAbc->Out, "%s", Prompt );
00071     fgets( Buffer, 999, stdin );
00072     return Buffer;
00073 #else
00074     static char* line = NULL;
00075     if (line != NULL) free(line);
00076     line = readline(Prompt);  
00077     if (line == NULL){ printf("***EOF***\n"); exit(0); }
00078     add_history(line);
00079     return line;
00080 #endif
00081 }

char* Abc_UtilsGetVersion ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file mainUtils.c.

00048 {
00049     static char Version[1000];
00050     sprintf(Version, "%s (compiled %s %s)", ABC_VERSION, __DATE__, __TIME__);
00051     return Version;
00052 }

void Abc_UtilsPrintHello ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 94 of file mainUtils.c.

00095 {
00096     fprintf( pAbc->Out, "%s\n", pAbc->sVersion );
00097 }

void Abc_UtilsPrintUsage ( Abc_Frame_t pAbc,
char *  ProgName 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file mainUtils.c.

00111 {
00112     fprintf( pAbc->Err, "\n" );
00113     fprintf( pAbc->Err,
00114              "usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [file]\n", 
00115              ProgName);
00116     fprintf( pAbc->Err, "    -c cmd\texecute commands `cmd'\n");
00117     fprintf( pAbc->Err, "    -F script\texecute commands from a script file and echo commands\n");
00118     fprintf( pAbc->Err, "    -f script\texecute commands from a script file\n");
00119     fprintf( pAbc->Err, "    -h\t\tprint the command usage\n");
00120     fprintf( pAbc->Err, "    -o file\tspecify output filename to store the result\n");
00121     fprintf( pAbc->Err, "    -s\t\tdo not read any initialization file\n");
00122     fprintf( pAbc->Err, "    -t type\tspecify input type (blif_mv (default), blif_mvs, blif, or none)\n");
00123     fprintf( pAbc->Err, "    -T type\tspecify output type (blif_mv (default), blif_mvs, blif, or none)\n");
00124     fprintf( pAbc->Err, "    -x\t\tequivalent to '-t none -T none'\n");
00125     fprintf( pAbc->Err, "\n" );
00126 }

void Abc_UtilsSource ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file mainUtils.c.

00140 {  
00141 #ifdef WIN32
00142     if ( Cmd_CommandExecute(pAbc, "source abc.rc") )
00143     {
00144         if ( Cmd_CommandExecute(pAbc, "source ..\\abc.rc") == 0 )
00145             printf( "Loaded \"abc.rc\" from the parent directory.\n" );
00146         else if ( Cmd_CommandExecute(pAbc, "source ..\\..\\abc.rc") == 0 )
00147             printf( "Loaded \"abc.rc\" from the grandparent directory.\n" );
00148     }
00149 #else
00150 
00151 #if 0
00152     {
00153         char * sPath1, * sPath2;
00154 
00155          // If .rc is present in both the home and current directories, then read
00156          // it from the home directory.  Otherwise, read it from wherever it's located.
00157         sPath1 = Extra_UtilFileSearch(".rc", "~/", "r");
00158         sPath2 = Extra_UtilFileSearch(".rc", ".",  "r");
00159   
00160         if ( sPath1 && sPath2 ) {
00161             /* ~/.rc == .rc : Source the file only once */
00162             (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
00163         }
00164         else {
00165             if (sPath1) {
00166                 (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
00167             }
00168             if (sPath2) {
00169                 (void) Cmd_CommandExecute(pAbc, "source -s .rc");
00170             }
00171         }
00172         if ( sPath1 ) FREE(sPath1);
00173         if ( sPath2 ) FREE(sPath2);
00174     
00175         /* execute the abc script which can be open with the "open_path" */
00176         Cmd_CommandExecute( pAbc, "source -s abc.rc" );
00177     }
00178 #endif
00179 
00180     {
00181         char * sPath1, * sPath2;
00182         char * home;
00183 
00184          // If .rc is present in both the home and current directories, then read
00185          // it from the home directory.  Otherwise, read it from wherever it's located.
00186         home = getenv("HOME");
00187         if (home){
00188             char * sPath3 = ALLOC(char, strlen(home) + 2);
00189             (void) sprintf(sPath3, "%s/", home);
00190             sPath1 = Extra_UtilFileSearch(".abc.rc", sPath3, "r");
00191             FREE(sPath3);
00192         }else
00193             sPath1 = NULL;
00194 
00195         sPath2 = Extra_UtilFileSearch(".abc.rc", ".",  "r");
00196 
00197         if ( sPath1 && sPath2 ) {
00198             /* ~/.rc == .rc : Source the file only once */
00199             (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
00200         }
00201         else {
00202             if (sPath1) {
00203                 (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
00204             }
00205             if (sPath2) {
00206                 (void) Cmd_CommandExecute(pAbc, "source -s .abc.rc");
00207             }
00208         }
00209         if ( sPath1 ) FREE(sPath1);
00210         if ( sPath2 ) FREE(sPath2);
00211 
00212         /* execute the abc script which can be open with the "open_path" */
00213         Cmd_CommandExecute( pAbc, "source -s abc.rc" );
00214     }
00215 
00216 #endif //WIN32
00217     {
00218         // reset command history
00219         char * pName; 
00220         int i;
00221         Vec_PtrForEachEntry( pAbc->aHistory, pName, i )
00222             free( pName );
00223         pAbc->aHistory->nSize = 0;
00224     }
00225 }

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

GLOBAL VARIABLES /// MACRO DEFINITIONS /// FUNCTION DEFINITIONS ///

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 }


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