src/base/main/mainFrame.c File Reference

#include "mainInt.h"
#include "abc.h"
#include "dec.h"
Include dependency graph for mainFrame.c:

Go to the source code of this file.

Functions

Vec_Ptr_tAbc_FrameReadStore ()
int Abc_FrameReadStoreSize ()
void * Abc_FrameReadLibLut ()
void * Abc_FrameReadLibGen ()
void * Abc_FrameReadLibSuper ()
void * Abc_FrameReadLibVer ()
void * Abc_FrameReadManDd ()
void * Abc_FrameReadManDec ()
char * Abc_FrameReadFlag (char *pFlag)
void Abc_FrameSetLibLut (void *pLib)
void Abc_FrameSetLibGen (void *pLib)
void Abc_FrameSetLibSuper (void *pLib)
void Abc_FrameSetLibVer (void *pLib)
void Abc_FrameSetFlag (char *pFlag, char *pValue)
bool Abc_FrameIsFlagEnabled (char *pFlag)
Abc_Frame_tAbc_FrameAllocate ()
void Abc_FrameDeallocate (Abc_Frame_t *p)
void Abc_FrameRestart (Abc_Frame_t *p)
bool Abc_FrameShowProgress (Abc_Frame_t *p)
Abc_Ntk_tAbc_FrameReadNtk (Abc_Frame_t *p)
FILE * Abc_FrameReadOut (Abc_Frame_t *p)
FILE * Abc_FrameReadErr (Abc_Frame_t *p)
int Abc_FrameReadMode (Abc_Frame_t *p)
bool Abc_FrameSetMode (Abc_Frame_t *p, bool fNameMode)
void Abc_FrameSetCurrentNetwork (Abc_Frame_t *p, Abc_Ntk_t *pNtkNew)
void Abc_FrameSwapCurrentAndBackup (Abc_Frame_t *p)
void Abc_FrameReplaceCurrentNetwork (Abc_Frame_t *p, Abc_Ntk_t *pNtk)
void Abc_FrameUnmapAllNetworks (Abc_Frame_t *p)
void Abc_FrameDeleteAllNetworks (Abc_Frame_t *p)
void Abc_FrameSetGlobalFrame (Abc_Frame_t *p)
Abc_Frame_tAbc_FrameGetGlobalFrame ()

Variables

static Abc_Frame_ts_GlobalFrame = NULL

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_FrameDeleteAllNetworks ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 444 of file mainFrame.c.

00445 {
00446     Abc_Ntk_t * pNtk, * pNtk2;
00447     // delete all the currently saved networks
00448     for ( pNtk  = p->pNtkCur, 
00449           pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL; 
00450           pNtk; 
00451           pNtk  = pNtk2, 
00452           pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL )
00453         Abc_NtkDelete( pNtk );
00454     // set the current network empty
00455     p->pNtkCur = NULL;
00456 //    fprintf( p->Out, "All networks have been deleted.\n" );
00457 }

Abc_Frame_t* Abc_FrameGetGlobalFrame (  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 486 of file mainFrame.c.

00487 {
00488         if ( s_GlobalFrame == 0 )
00489         {
00490                 // start the framework
00491                 s_GlobalFrame = Abc_FrameAllocate();
00492                 // perform initializations
00493                 Abc_FrameInit( s_GlobalFrame );
00494         }
00495         return s_GlobalFrame;
00496 }

bool Abc_FrameIsFlagEnabled ( char *  pFlag  ) 

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

Synopsis [Returns 1 if the flag is enabled without value or with value 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file mainFrame.c.

00074 {
00075     char * pValue;
00076     // if flag is not defined, it is not enabled
00077     pValue = Abc_FrameReadFlag( pFlag );
00078     if ( pValue == NULL )
00079         return 0;
00080     // if flag is defined but value is not empty (no parameter) or "1", it is not enabled
00081     if ( strcmp(pValue, "") && strcmp(pValue, "1") )
00082         return 0;
00083     return 1;
00084 }

FILE* Abc_FrameReadErr ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file mainFrame.c.

00230 {
00231     return p->Err;
00232 }

char* Abc_FrameReadFlag ( char *  pFlag  ) 

Definition at line 54 of file mainFrame.c.

00054 { return Cmd_FlagReadByName( s_GlobalFrame, pFlag );  } 

void* Abc_FrameReadLibGen (  ) 

Definition at line 49 of file mainFrame.c.

00049 { return s_GlobalFrame->pLibGen;      } 

void* Abc_FrameReadLibLut (  ) 

Definition at line 48 of file mainFrame.c.

00048 { return s_GlobalFrame->pLibLut;      } 

void* Abc_FrameReadLibSuper (  ) 

Definition at line 50 of file mainFrame.c.

00050 { return s_GlobalFrame->pLibSuper;    } 

void* Abc_FrameReadLibVer (  ) 

Definition at line 51 of file mainFrame.c.

00051 { return s_GlobalFrame->pLibVer;      } 

void* Abc_FrameReadManDd (  ) 

Definition at line 52 of file mainFrame.c.

void* Abc_FrameReadManDec (  ) 

Definition at line 53 of file mainFrame.c.

int Abc_FrameReadMode ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file mainFrame.c.

00246 {
00247     int fShortNames;
00248     char * pValue;
00249     pValue = Cmd_FlagReadByName( p, "namemode" );
00250     if ( pValue == NULL )
00251         fShortNames = 0;
00252     else 
00253         fShortNames = atoi(pValue);
00254     return fShortNames;
00255 }

Abc_Ntk_t* Abc_FrameReadNtk ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file mainFrame.c.

00198 {
00199     return p->pNtkCur;
00200 }

FILE* Abc_FrameReadOut ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file mainFrame.c.

00214 {
00215     return p->Out;
00216 }

Vec_Ptr_t* Abc_FrameReadStore (  ) 

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

Synopsis [APIs to access parameters in the flobal frame.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file mainFrame.c.

00046 { return s_GlobalFrame->vStore;       } 

int Abc_FrameReadStoreSize (  ) 

Definition at line 47 of file mainFrame.c.

00047 { return Vec_PtrSize(s_GlobalFrame->vStore); }

void Abc_FrameReplaceCurrentNetwork ( Abc_Frame_t p,
Abc_Ntk_t pNtk 
)

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

Synopsis [Replaces the current network by the given one.]

Description [This procedure does not modify the stack of saved networks.]

SideEffects []

SeeAlso []

Definition at line 389 of file mainFrame.c.

00390 {
00391     if ( pNtk == NULL )
00392         return;
00393 
00394     // transfer the parameters to the new network
00395     if ( p->pNtkCur && Abc_FrameIsFlagEnabled( "backup" ) )
00396     {
00397         Abc_NtkSetBackup( pNtk, Abc_NtkBackup(p->pNtkCur) );
00398         Abc_NtkSetStep( pNtk, Abc_NtkStep(p->pNtkCur) );
00399         // delete the current network
00400         Abc_NtkDelete( p->pNtkCur );
00401     }
00402     else
00403     {
00404         Abc_NtkSetBackup( pNtk, NULL );
00405         Abc_NtkSetStep( pNtk, ++p->nSteps );
00406         // delete the current network if present but backup is disabled
00407         if ( p->pNtkCur )
00408             Abc_NtkDelete( p->pNtkCur );
00409     }
00410     // set the new current network
00411     p->pNtkCur = pNtk;
00412 }

void Abc_FrameRestart ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file mainFrame.c.

00166 {
00167 }

void Abc_FrameSetCurrentNetwork ( Abc_Frame_t p,
Abc_Ntk_t pNtkNew 
)

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 []

Definition at line 295 of file mainFrame.c.

00296 {
00297     Abc_Ntk_t * pNtk, * pNtk2, * pNtk3;
00298     int nNetsPresent;
00299     int nNetsToSave;
00300     char * pValue;
00301 
00302     // link it to the previous network
00303     Abc_NtkSetBackup( pNtkNew, p->pNtkCur );
00304     // set the step of this network
00305     Abc_NtkSetStep( pNtkNew, ++p->nSteps );
00306     // set this network to be the current network
00307     p->pNtkCur = pNtkNew;
00308 
00309     // remove any extra network that may happen to be in the stack
00310     pValue = Cmd_FlagReadByName( p, "savesteps" );
00311     // if the value of steps to save is not set, assume 1-level undo
00312     if ( pValue == NULL )
00313         nNetsToSave = 1;
00314     else 
00315         nNetsToSave = atoi(pValue);
00316     
00317     // count the network, remember the last one, and the one before the last one
00318     nNetsPresent = 0;
00319     pNtk2 = pNtk3 = NULL;
00320     for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk2) )
00321     {
00322         nNetsPresent++;
00323         pNtk3 = pNtk2;
00324         pNtk2 = pNtk;
00325     }
00326 
00327     // remove the earliest backup network if it is more steps away than we store
00328     if ( nNetsPresent - 1 > nNetsToSave )
00329     { // delete the last network
00330         Abc_NtkDelete( pNtk2 );
00331         // clean the pointer of the network before the last one
00332         Abc_NtkSetBackup( pNtk3, NULL );
00333     }
00334 }

void Abc_FrameSetFlag ( char *  pFlag,
char *  pValue 
)

Definition at line 60 of file mainFrame.c.

00060 { Cmd_FlagUpdateValue( s_GlobalFrame, pFlag, pValue );  } 

void Abc_FrameSetGlobalFrame ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file mainFrame.c.

00471 {
00472         s_GlobalFrame = p;
00473 }

void Abc_FrameSetLibGen ( void *  pLib  ) 

Definition at line 57 of file mainFrame.c.

00057 { s_GlobalFrame->pLibGen   = pLib;    } 

void Abc_FrameSetLibLut ( void *  pLib  ) 

Definition at line 56 of file mainFrame.c.

00056 { s_GlobalFrame->pLibLut   = pLib;    } 

void Abc_FrameSetLibSuper ( void *  pLib  ) 

Definition at line 58 of file mainFrame.c.

00058 { s_GlobalFrame->pLibSuper = pLib;    } 

void Abc_FrameSetLibVer ( void *  pLib  ) 

Definition at line 59 of file mainFrame.c.

00059 { s_GlobalFrame->pLibVer   = pLib;    } 

bool Abc_FrameSetMode ( Abc_Frame_t p,
bool  fNameMode 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 268 of file mainFrame.c.

00269 {
00270     char Buffer[2];
00271     bool fNameModeOld;
00272     fNameModeOld = Abc_FrameReadMode( p );
00273     Buffer[0] = '0' + fNameMode;
00274     Buffer[1] = 0;
00275     Cmd_FlagUpdateValue( p, "namemode", (char *)Buffer );
00276     return fNameModeOld;
00277 }

bool Abc_FrameShowProgress ( Abc_Frame_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 180 of file mainFrame.c.

00181 {
00182     return Abc_FrameIsFlagEnabled( "progressbar" );
00183 }

void Abc_FrameSwapCurrentAndBackup ( Abc_Frame_t p  ) 

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

Synopsis [This procedure swaps the current and the backup network.]

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file mainFrame.c.

00348 {
00349     Abc_Ntk_t * pNtkCur, * pNtkBack, * pNtkBack2;
00350     int iStepCur, iStepBack;
00351 
00352     pNtkCur  = p->pNtkCur;
00353     pNtkBack = Abc_NtkBackup( pNtkCur );
00354     iStepCur = Abc_NtkStep  ( pNtkCur );
00355 
00356     // if there is no backup nothing to reset
00357     if ( pNtkBack == NULL )
00358         return;
00359 
00360     // remember the backup of the backup
00361     pNtkBack2 = Abc_NtkBackup( pNtkBack );
00362     iStepBack = Abc_NtkStep  ( pNtkBack );
00363 
00364     // set pNtkCur to be the next after the backup's backup
00365     Abc_NtkSetBackup( pNtkCur, pNtkBack2 );
00366     Abc_NtkSetStep  ( pNtkCur, iStepBack );
00367 
00368     // set pNtkCur to be the next after the backup
00369     Abc_NtkSetBackup( pNtkBack, pNtkCur );
00370     Abc_NtkSetStep  ( pNtkBack, iStepCur );
00371 
00372     // set the current network
00373     p->pNtkCur = pNtkBack;
00374 }

void Abc_FrameUnmapAllNetworks ( Abc_Frame_t p  ) 

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

Synopsis [Removes library binding of all currently stored networks.]

Description [This procedure is called when the library is freed.]

SideEffects []

SeeAlso []

Definition at line 425 of file mainFrame.c.

00426 {
00427     Abc_Ntk_t * pNtk;
00428     for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) )
00429         if ( Abc_NtkHasMapping(pNtk) )
00430             Abc_NtkMapToSop( pNtk );
00431 }


Variable Documentation

Abc_Frame_t* s_GlobalFrame = NULL [static]

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

] DECLARATIONS ///

Definition at line 29 of file mainFrame.c.


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