summaryrefslogtreecommitdiffstats
path: root/src/aig/nwk
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2008-04-20 20:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2008-04-20 20:01:00 -0700
commit7ec48bc20de6209f311715f4b1479cb2e0a4d906 (patch)
tree00ee497c28001a646f98407115f5541fb49adf83 /src/aig/nwk
parent7ff4c2b2719a78ba7d1ddcfdf9356affa291e876 (diff)
downloadabc-7ec48bc20de6209f311715f4b1479cb2e0a4d906.tar.gz
abc-7ec48bc20de6209f311715f4b1479cb2e0a4d906.tar.bz2
abc-7ec48bc20de6209f311715f4b1479cb2e0a4d906.zip
Version abc80420_2
Diffstat (limited to 'src/aig/nwk')
-rw-r--r--src/aig/nwk/nwk.h2
-rw-r--r--src/aig/nwk/nwkFanio.c53
-rw-r--r--src/aig/nwk/nwkFlow.c2
-rw-r--r--src/aig/nwk/nwkMan.c131
-rw-r--r--src/aig/nwk/nwkMap.c3
-rw-r--r--src/aig/nwk/nwkTiming.c2
6 files changed, 121 insertions, 72 deletions
diff --git a/src/aig/nwk/nwk.h b/src/aig/nwk/nwk.h
index d0a871cf..c36f3498 100644
--- a/src/aig/nwk/nwk.h
+++ b/src/aig/nwk/nwk.h
@@ -250,7 +250,7 @@ extern Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches,
/*=== nwkMan.c ============================================================*/
extern Nwk_Man_t * Nwk_ManAlloc();
extern void Nwk_ManFree( Nwk_Man_t * p );
-extern void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib );
+extern void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, void * pNtl );
/*=== nwkMap.c ============================================================*/
extern Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars );
/*=== nwkObj.c ============================================================*/
diff --git a/src/aig/nwk/nwkFanio.c b/src/aig/nwk/nwkFanio.c
index 1b701e9e..89bf60ee 100644
--- a/src/aig/nwk/nwkFanio.c
+++ b/src/aig/nwk/nwkFanio.c
@@ -125,58 +125,6 @@ static inline int Nwk_ObjReallocIsNeeded( Nwk_Obj_t * pObj )
{
return pObj->nFanins + pObj->nFanouts == pObj->nFanioAlloc;
}
-
-/**Function*************************************************************
-
- Synopsis [Reallocates the object.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static Nwk_Obj_t * Nwk_ManReallocNode_old( Nwk_Obj_t * pObj )
-{
- Nwk_Obj_t * pObjNew, * pTemp;
- int i, iNum;
- assert( Nwk_ObjReallocIsNeeded(pObj) );
- pObjNew = (Nwk_Obj_t *)Aig_MmFlexEntryFetch( pObj->pMan->pMemObjs, sizeof(Nwk_Obj_t) + 2 * pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
- memmove( pObjNew, pObj, sizeof(Nwk_Obj_t) + pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
- pObjNew->nFanioAlloc = 2 * pObj->nFanioAlloc;
- // update the fanouts' fanins
- Nwk_ObjForEachFanout( pObj, pTemp, i )
- {
- iNum = Nwk_ObjFindFanin( pTemp, pObj );
- if ( iNum == -1 )
- printf( "Nwk_ManReallocNode(): Error! Fanin cannot be found.\n" );
- pTemp->pFanio[iNum] = pObjNew;
- }
- // update the fanins' fanouts
- Nwk_ObjForEachFanin( pObj, pTemp, i )
- {
- iNum = Nwk_ObjFindFanout( pTemp, pObj );
- if ( iNum == -1 )
- printf( "Nwk_ManReallocNode(): Error! Fanout cannot be found.\n" );
- pTemp->pFanio[pTemp->nFanins+iNum] = pObjNew;
- }
- memset( pObj, 0, sizeof(Nwk_Obj_t) + pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
- assert( Nwk_ManObj(pObjNew->pMan, pObjNew->Id) == pObj );
- Vec_PtrWriteEntry( pObjNew->pMan->vObjs, pObjNew->Id, pObjNew );
- if ( Nwk_ObjIsCi(pObjNew) )
- {
- assert( Nwk_ManCi(pObjNew->pMan, pObjNew->PioId) == pObj );
- Vec_PtrWriteEntry( pObjNew->pMan->vCis, pObjNew->PioId, pObjNew );
- }
- if ( Nwk_ObjIsCo(pObjNew) )
- {
- assert( Nwk_ManCo(pObjNew->pMan, pObjNew->PioId) == pObj );
- Vec_PtrWriteEntry( pObjNew->pMan->vCos, pObjNew->PioId, pObjNew );
- }
- pObjNew->pMan->nRealloced++;
- return pObjNew;
-}
/**Function*************************************************************
@@ -200,7 +148,6 @@ static Nwk_Obj_t * Nwk_ManReallocNode( Nwk_Obj_t * pObj )
return NULL;
}
-
/**Function*************************************************************
Synopsis [Creates fanout/fanin relationship between the nodes.]
diff --git a/src/aig/nwk/nwkFlow.c b/src/aig/nwk/nwkFlow.c
index b245628a..3a7e6df6 100644
--- a/src/aig/nwk/nwkFlow.c
+++ b/src/aig/nwk/nwkFlow.c
@@ -524,7 +524,7 @@ Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches, int fVerbo
pObj->MarkA = 1;
Nwk_ManForEachPoSeq( pMan, pObj, i )
Nwk_ManMarkTfiCone_rec( pObj );
- Nwk_ManForEachObj( pMan, pObj, i )
+ Nwk_ManForEachNode( pMan, pObj, i )
if ( Nwk_ObjFaninNum(pObj) == 0 )
pObj->MarkA = 1;
// start flow computation from each LI driver
diff --git a/src/aig/nwk/nwkMan.c b/src/aig/nwk/nwkMan.c
index a1f20a8e..aeebac3f 100644
--- a/src/aig/nwk/nwkMan.c
+++ b/src/aig/nwk/nwkMan.c
@@ -104,6 +104,92 @@ void Nwk_ManPrintLutSizes( Nwk_Man_t * p, If_Lib_t * pLutLib )
/**Function*************************************************************
+ Synopsis [If the network is best, saves it in "best.blif" and returns 1.]
+
+ Description [If the networks are incomparable, saves the new network,
+ returns its parameters in the internal parameter structure, and returns 1.
+ If the new network is not a logic network, quits without saving and returns 0.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
+{
+ extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
+ static struct ParStruct {
+ char * pName; // name of the best saved network
+ int Depth; // depth of the best saved network
+ int Flops; // flops in the best saved network
+ int Nodes; // nodes in the best saved network
+ int nPis; // the number of primary inputs
+ int nPos; // the number of primary outputs
+ } ParsNew, ParsBest = { 0 };
+ // free storage for the name
+ if ( pNtk == NULL )
+ {
+ FREE( ParsBest.pName );
+ return 0;
+ }
+ // get the parameters
+ ParsNew.Depth = Nwk_ManLevel( pNtk );
+ ParsNew.Flops = Nwk_ManLatchNum( pNtk );
+ ParsNew.Nodes = Nwk_ManNodeNum( pNtk );
+ ParsNew.nPis = Nwk_ManPiNum( pNtk );
+ ParsNew.nPos = Nwk_ManPoNum( pNtk );
+ // reset the parameters if the network has the same name
+ if ( ParsBest.pName == NULL ||
+ strcmp(ParsBest.pName, pNtk->pName) ||
+ ParsBest.Depth > ParsNew.Depth ||
+ ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops ||
+ ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes )
+ {
+ FREE( ParsBest.pName );
+ ParsBest.pName = Aig_UtilStrsav( pNtk->pName );
+ ParsBest.Depth = ParsNew.Depth;
+ ParsBest.Flops = ParsNew.Flops;
+ ParsBest.Nodes = ParsNew.Nodes;
+ ParsBest.nPis = ParsNew.nPis;
+ ParsBest.nPos = ParsNew.nPos;
+ // writ the network
+ Ioa_WriteBlifLogic( pNtk, pNtl, "best.blif" );
+ return 1;
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Nwk_FileNameGeneric( char * FileName )
+{
+ char * pDot;
+ char * pUnd;
+ char * pRes;
+ // find the generic name of the file
+ pRes = Aig_UtilStrsav( FileName );
+ // find the pointer to the "." symbol in the file name
+// pUnd = strstr( FileName, "_" );
+ pUnd = NULL;
+ pDot = strstr( FileName, "." );
+ if ( pUnd )
+ pRes[pUnd - FileName] = 0;
+ else if ( pDot )
+ pRes[pDot - FileName] = 0;
+ return pRes;
+}
+
+/**Function*************************************************************
+
Synopsis [Prints stats of the manager.]
Description []
@@ -113,24 +199,37 @@ void Nwk_ManPrintLutSizes( Nwk_Man_t * p, If_Lib_t * pLutLib )
SeeAlso []
***********************************************************************/
-void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib )
+void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, void * pNtl )
{
- p->pLutLib = pLutLib;
- printf( "%-15s : ", p->pName );
- printf( "pi = %5d ", Nwk_ManPiNum(p) );
- printf( "po = %5d ", Nwk_ManPoNum(p) );
- printf( "ci = %5d ", Nwk_ManCiNum(p) );
- printf( "co = %5d ", Nwk_ManCoNum(p) );
- printf( "lat = %5d ", Nwk_ManLatchNum(p) );
- printf( "node = %5d ", Nwk_ManNodeNum(p) );
- printf( "edge = %5d ", Nwk_ManGetTotalFanins(p) );
- printf( "aig = %6d ", Nwk_ManGetAigNodeNum(p) );
- printf( "lev = %3d ", Nwk_ManLevel(p) );
-// printf( "lev2 = %3d ", Nwk_ManLevelBackup(p) );
- printf( "delay = %5.2f ", Nwk_ManDelayTraceLut(p) );
- Nwk_ManPrintLutSizes( p, pLutLib );
+ extern int Ntl_ManLatchNum( void * p );
+ extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
+ if ( fSaveBest )
+ Nwk_ManCompareAndSaveBest( pNtk, pNtl );
+ if ( fDumpResult )
+ {
+ char Buffer[1000] = {0};
+ char * pNameGen = pNtk->pSpec? Nwk_FileNameGeneric( pNtk->pSpec ) : "nameless_";
+ sprintf( Buffer, "%s_dump.blif", pNameGen );
+ Ioa_WriteBlifLogic( pNtk, pNtl, Buffer );
+ if ( pNtk->pSpec ) free( pNameGen );
+ }
+
+ pNtk->pLutLib = pLutLib;
+ printf( "%-15s : ", pNtk->pName );
+ printf( "pi = %5d ", Nwk_ManPiNum(pNtk) );
+ printf( "po = %5d ", Nwk_ManPoNum(pNtk) );
+ printf( "ci = %5d ", Nwk_ManCiNum(pNtk) );
+ printf( "co = %5d ", Nwk_ManCoNum(pNtk) );
+ printf( "lat = %5d ", Ntl_ManLatchNum(pNtl) );
+ printf( "node = %5d ", Nwk_ManNodeNum(pNtk) );
+ printf( "edge = %5d ", Nwk_ManGetTotalFanins(pNtk) );
+ printf( "aig = %6d ", Nwk_ManGetAigNodeNum(pNtk) );
+ printf( "lev = %3d ", Nwk_ManLevel(pNtk) );
+// printf( "lev2 = %3d ", Nwk_ManLevelBackup(pNtk) );
+ printf( "delay = %5.2f ", Nwk_ManDelayTraceLut(pNtk) );
+ Nwk_ManPrintLutSizes( pNtk, pLutLib );
printf( "\n" );
-// Nwk_ManDelayTracePrint( p, pLutLib );
+// Nwk_ManDelayTracePrint( pNtk, pLutLib );
fflush( stdout );
}
diff --git a/src/aig/nwk/nwkMap.c b/src/aig/nwk/nwkMap.c
index effffcf7..45d56eb5 100644
--- a/src/aig/nwk/nwkMap.c
+++ b/src/aig/nwk/nwkMap.c
@@ -267,6 +267,9 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
pNtk = Nwk_ManAlloc();
pNtk->pName = Aig_UtilStrsav( p->pName );
pNtk->pSpec = Aig_UtilStrsav( p->pSpec );
+// pNtk->nLatches = Aig_ManRegNum(p);
+// pNtk->nTruePis = Nwk_ManCiNum(pNtk) - pNtk->nLatches;
+// pNtk->nTruePos = Nwk_ManCoNum(pNtk) - pNtk->nLatches;
Aig_ManForEachObj( p, pObj, i )
{
pIfObj = Vec_PtrEntry( vAigToIf, i );
diff --git a/src/aig/nwk/nwkTiming.c b/src/aig/nwk/nwkTiming.c
index 9ab24467..e8123dae 100644
--- a/src/aig/nwk/nwkTiming.c
+++ b/src/aig/nwk/nwkTiming.c
@@ -427,7 +427,7 @@ int Nwk_ManVerifyTiming( Nwk_Man_t * pNtk )
int i;
Nwk_ManForEachObj( pNtk, pObj, i )
{
- if ( Nwk_ObjIsPi(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
+ if ( Nwk_ObjIsCi(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
continue;
tArrival = Nwk_NodeComputeArrival( pObj, 1 );
tRequired = Nwk_NodeComputeRequired( pObj, 1 );