Improving GIA interfaces for some procedures.

This commit is contained in:
Alan Mishchenko 2014-08-25 17:33:53 -07:00
parent 47dde4e478
commit 5c30eb10ef
8 changed files with 70 additions and 54 deletions

View File

@ -1183,10 +1183,10 @@ extern int Gia_ManLutLevel( Gia_Man_t * p );
extern void Gia_ManSetRefsMapped( Gia_Man_t * p ); extern void Gia_ManSetRefsMapped( Gia_Man_t * p );
extern void Gia_ManSetIfParsDefault( void * pIfPars ); extern void Gia_ManSetIfParsDefault( void * pIfPars );
extern void Gia_ManMappingVerify( Gia_Man_t * p ); extern void Gia_ManMappingVerify( Gia_Man_t * p );
extern void Gia_ManTransferMapping( Gia_Man_t * pGia, Gia_Man_t * p ); extern void Gia_ManTransferMapping( Gia_Man_t * p, Gia_Man_t * pGia );
extern void Gia_ManTransferPacking( Gia_Man_t * pGia, Gia_Man_t * p ); extern void Gia_ManTransferPacking( Gia_Man_t * p, Gia_Man_t * pGia );
extern void Gia_ManTransferTiming( Gia_Man_t * pGia, Gia_Man_t * p ); extern void Gia_ManTransferTiming( Gia_Man_t * p, Gia_Man_t * pGia );
extern Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pIfPars, int fNormalized ); extern Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pIfPars );
extern Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose ); extern Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose ); extern Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose );
/*=== giaJf.c ===========================================================*/ /*=== giaJf.c ===========================================================*/

View File

@ -559,7 +559,7 @@ Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p, int fUpdateLevel, int fVerbose )
Aig_ManStop( pTemp ); Aig_ManStop( pTemp );
pGia = Gia_ManFromAig( pNew ); pGia = Gia_ManFromAig( pNew );
Aig_ManStop( pNew ); Aig_ManStop( pNew );
Gia_ManTransferTiming( p, pGia ); Gia_ManTransferTiming( pGia, p );
return pGia; return pGia;
} }
@ -585,7 +585,7 @@ Gia_Man_t * Gia_ManPerformDch( Gia_Man_t * p, void * pPars )
// pGia = Gia_ManFromAig( pNew ); // pGia = Gia_ManFromAig( pNew );
pGia = Gia_ManFromAigChoices( pNew ); pGia = Gia_ManFromAigChoices( pNew );
Aig_ManStop( pNew ); Aig_ManStop( pNew );
Gia_ManTransferTiming( p, pGia ); Gia_ManTransferTiming( pGia, p );
return pGia; return pGia;
} }

View File

@ -1038,7 +1038,7 @@ void Gia_AigerWrite( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int
{ {
// printf( "Gia_AigerWrite(): Normalizing AIG for writing.\n" ); // printf( "Gia_AigerWrite(): Normalizing AIG for writing.\n" );
p = Gia_ManDupNormalize( pInit ); p = Gia_ManDupNormalize( pInit );
Gia_ManTransferTiming( pInit, p ); Gia_ManTransferTiming( p, pInit );
p->vNamesIn = pInit->vNamesIn; pInit->vNamesIn = NULL; p->vNamesIn = pInit->vNamesIn; pInit->vNamesIn = NULL;
p->vNamesOut = pInit->vNamesOut; pInit->vNamesOut = NULL; p->vNamesOut = pInit->vNamesOut; pInit->vNamesOut = NULL;
p->nConstrs = pInit->nConstrs; pInit->nConstrs = 0; p->nConstrs = pInit->nConstrs; pInit->nConstrs = 0;

View File

@ -976,7 +976,7 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax,
pNew2 = Gia_ManDupNormalize( pNew1 = pNew2 ); pNew2 = Gia_ManDupNormalize( pNew1 = pNew2 );
Gia_ManStop( pNew1 ); Gia_ManStop( pNew1 );
} }
Gia_ManTransferTiming( p, pNew2 ); Gia_ManTransferTiming( pNew2, p );
return pNew2; return pNew2;
} }
@ -1031,7 +1031,7 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * pInit, int fOldAlgo, int fCoarsen, int f
} }
if ( fVerbose ) Gia_ManPrintStats( pInit, NULL ); if ( fVerbose ) Gia_ManPrintStats( pInit, NULL );
p = Gia_ManDup( pInit ); p = Gia_ManDup( pInit );
Gia_ManTransferTiming( pInit, p ); Gia_ManTransferTiming( p, pInit );
if ( Gia_ManAndNum(p) == 0 ) if ( Gia_ManAndNum(p) == 0 )
return p; return p;
// delay optimization // delay optimization

View File

@ -464,7 +464,7 @@ Gia_Man_t * Gia_ManPerformFx( Gia_Man_t * p, int nNewNodesMax, int LitCountMax,
// Abc_PrintTime( 1, "Fx runtime", Abc_Clock() - clk ); // Abc_PrintTime( 1, "Fx runtime", Abc_Clock() - clk );
// insert information // insert information
pNew = Gia_ManFxInsert( p, vCubes, vCompl ); pNew = Gia_ManFxInsert( p, vCubes, vCompl );
Gia_ManTransferTiming( p, pNew ); Gia_ManTransferTiming( pNew, p );
// cleanup // cleanup
Vec_WecFree( vCubes ); Vec_WecFree( vCubes );
Vec_StrFree( vCompl ); Vec_StrFree( vCompl );

View File

@ -1561,7 +1561,7 @@ void Gia_ManMappingVerify( Gia_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Gia_ManTransferMapping( Gia_Man_t * pGia, Gia_Man_t * p ) void Gia_ManTransferMapping( Gia_Man_t * p, Gia_Man_t * pGia )
{ {
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
int i, k, iFan; int i, k, iFan;
@ -1583,7 +1583,7 @@ void Gia_ManTransferMapping( Gia_Man_t * pGia, Gia_Man_t * p )
} }
Gia_ManMappingVerify( p ); Gia_ManMappingVerify( p );
} }
void Gia_ManTransferPacking( Gia_Man_t * pGia, Gia_Man_t * p ) void Gia_ManTransferPacking( Gia_Man_t * p, Gia_Man_t * pGia )
{ {
Vec_Int_t * vPackingNew; Vec_Int_t * vPackingNew;
Gia_Obj_t * pObj, * pObjNew; Gia_Obj_t * pObj, * pObjNew;
@ -1617,7 +1617,7 @@ void Gia_ManTransferPacking( Gia_Man_t * pGia, Gia_Man_t * p )
assert( p->vPacking == NULL ); assert( p->vPacking == NULL );
p->vPacking = vPackingNew; p->vPacking = vPackingNew;
} }
void Gia_ManTransferTiming( Gia_Man_t * pGia, Gia_Man_t * p ) void Gia_ManTransferTiming( Gia_Man_t * p, Gia_Man_t * pGia )
{ {
if ( pGia->pManTime == NULL ) if ( pGia->pManTime == NULL )
return; return;
@ -1637,44 +1637,20 @@ void Gia_ManTransferTiming( Gia_Man_t * pGia, Gia_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp, int fNormalized ) Gia_Man_t * Gia_ManPerformMappingInt( Gia_Man_t * p, If_Par_t * pPars )
{ {
extern void Gia_ManIffTest( Gia_Man_t * pGia, If_LibLut_t * pLib, int fVerbose ); extern void Gia_ManIffTest( Gia_Man_t * pGia, If_LibLut_t * pLib, int fVerbose );
Gia_Man_t * pNew; Gia_Man_t * pNew;
If_Man_t * pIfMan; If_Man_t * pIfMan;
If_Par_t * pPars = (If_Par_t *)pp; assert( pPars->pTimesArr == NULL );
assert( pPars->pTimesReq == NULL );
// disable cut minimization when GIA strucure is needed // disable cut minimization when GIA strucure is needed
if ( !pPars->fDelayOpt && !pPars->fDelayOptLut && !pPars->fDsdBalance && !pPars->fUserRecLib && !pPars->fDeriveLuts && !pPars->fUseDsd && !pPars->fUseTtPerm ) if ( !pPars->fDelayOpt && !pPars->fDelayOptLut && !pPars->fDsdBalance && !pPars->fUserRecLib && !pPars->fDeriveLuts && !pPars->fUseDsd && !pPars->fUseTtPerm )
pPars->fCutMin = 0; pPars->fCutMin = 0;
// reconstruct GIA according to the hierarchy manager
assert( pPars->pTimesArr == NULL );
assert( pPars->pTimesReq == NULL );
if ( p->pManTime )
{
if ( fNormalized )
{
pNew = Gia_ManDupUnnormalize( p );
if ( pNew == NULL )
return NULL;
pNew->pManTime = p->pManTime; p->pManTime = NULL;
pNew->pAigExtra = p->pAigExtra; p->pAigExtra = NULL;
pNew->nAnd2Delay = p->nAnd2Delay; p->nAnd2Delay = 0;
p = pNew;
// set arrival and required times
pPars->pTimesArr = Tim_ManGetArrTimes( (Tim_Man_t *)p->pManTime );
pPars->pTimesReq = Tim_ManGetReqTimes( (Tim_Man_t *)p->pManTime );
}
}
else
p = Gia_ManDup( p );
// translate into the mapper // translate into the mapper
pIfMan = Gia_ManToIf( p, pPars ); pIfMan = Gia_ManToIf( p, pPars );
if ( pIfMan == NULL ) if ( pIfMan == NULL )
{
Gia_ManStop( p );
return NULL; return NULL;
}
// create DSD manager // create DSD manager
if ( pPars->fUseDsd ) if ( pPars->fUseDsd )
{ {
@ -1698,7 +1674,6 @@ Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp, int fNormalized )
if ( !If_ManPerformMapping( pIfMan ) ) if ( !If_ManPerformMapping( pIfMan ) )
{ {
If_ManStop( pIfMan ); If_ManStop( pIfMan );
Gia_ManStop( p );
return NULL; return NULL;
} }
// transform the result of mapping into the new network // transform the result of mapping into the new network
@ -1712,17 +1687,58 @@ Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp, int fNormalized )
pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec ); pNew->pSpec = Abc_UtilStrsav( p->pSpec );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
// return the original (unmodified by the mapper) timing manager
Gia_ManTransferTiming( p, pNew );
Gia_ManStop( p );
// normalize and transfer mapping
pNew = Gia_ManDupNormalize( p = pNew );
Gia_ManTransferMapping( p, pNew );
Gia_ManTransferPacking( p, pNew );
Gia_ManTransferTiming( p, pNew );
Gia_ManStop( p );
return pNew; return pNew;
} }
Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp )
{
Gia_Man_t * pNew;
if ( p->pManTime && Tim_ManBoxNum(p->pManTime) && Gia_ManIsNormalized(p) )
{
Tim_Man_t * pTimOld = (Tim_Man_t *)p->pManTime;
p->pManTime = Tim_ManDup( pTimOld, 1 );
pNew = Gia_ManDupUnnormalize( p );
if ( pNew == NULL )
return NULL;
Gia_ManTransferTiming( pNew, p );
p = pNew;
// mapping
pNew = Gia_ManPerformMappingInt( p, (If_Par_t *)pp );
if ( pNew != p )
{
Gia_ManTransferTiming( pNew, p );
Gia_ManStop( p );
}
// normalize
pNew = Gia_ManDupNormalize( p = pNew );
Gia_ManTransferMapping( pNew, p );
Gia_ManTransferPacking( pNew, p );
Gia_ManTransferTiming( pNew, p );
Gia_ManStop( p );
// cleanup
Tim_ManStop( (Tim_Man_t *)pNew->pManTime );
pNew->pManTime = pTimOld;
assert( Gia_ManIsNormalized(pNew) );
}
else
{
// mapping
pNew = Gia_ManPerformMappingInt( p, (If_Par_t *)pp );
Gia_ManTransferTiming( pNew, p );
}
return pNew;
}
/**Function*************************************************************
Synopsis [Interface of other mapping-based procedures.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose ) Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose )
{ {
Gia_Man_t * pNew; Gia_Man_t * pNew;
@ -1742,7 +1758,7 @@ Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
If_ManPerformMapping( pIfMan ); If_ManPerformMapping( pIfMan );
pNew = Gia_ManFromIfAig( pIfMan ); pNew = Gia_ManFromIfAig( pIfMan );
If_ManStop( pIfMan ); If_ManStop( pIfMan );
Gia_ManTransferTiming( p, pNew ); Gia_ManTransferTiming( pNew, p );
// transfer name // transfer name
assert( pNew->pName == NULL ); assert( pNew->pName == NULL );
pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pName = Abc_UtilStrsav( p->pName );
@ -1775,7 +1791,7 @@ Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum,
If_ManPerformMapping( pIfMan ); If_ManPerformMapping( pIfMan );
pNew = Gia_ManFromIfAig( pIfMan ); pNew = Gia_ManFromIfAig( pIfMan );
If_ManStop( pIfMan ); If_ManStop( pIfMan );
Gia_ManTransferTiming( p, pNew ); Gia_ManTransferTiming( pNew, p );
// transfer name // transfer name
assert( pNew->pName == NULL ); assert( pNew->pName == NULL );
pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pName = Abc_UtilStrsav( p->pName );

View File

@ -328,7 +328,7 @@ Gia_Man_t * Gia_ManFraigSweep( Gia_Man_t * p, void * pPars )
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
// normalize the result // normalize the result
pNew = Gia_ManDupNormalize( pTemp = pNew ); pNew = Gia_ManDupNormalize( pTemp = pNew );
Gia_ManTransferTiming( pTemp, pNew ); Gia_ManTransferTiming( pNew, pTemp );
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
// return the result // return the result
assert( pNew->pManTime != NULL ); assert( pNew->pManTime != NULL );

View File

@ -30851,7 +30851,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// perform mapping // perform mapping
pNew = Gia_ManPerformMapping( pAbc->pGia, pPars, 1 ); pNew = Gia_ManPerformMapping( pAbc->pGia, pPars );
if ( pNew == NULL ) if ( pNew == NULL )
{ {
Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of GIA has failed.\n" ); Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of GIA has failed.\n" );