src/opt/res/res.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Res_Par_t_

Typedefs

typedef struct Res_Par_t_ Res_Par_t

Functions

int Abc_NtkResynthesize (Abc_Ntk_t *pNtk, Res_Par_t *pPars)

Typedef Documentation

typedef struct Res_Par_t_ Res_Par_t

CFile****************************************************************

FileName [res.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Resynthesis package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 15, 2007.]

Revision [

Id
res.h,v 1.00 2007/01/15 00:00:00 alanmi Exp

] INCLUDES /// PARAMETERS /// BASIC TYPES ///

Definition at line 40 of file res.h.


Function Documentation

int Abc_NtkResynthesize ( Abc_Ntk_t pNtk,
Res_Par_t pPars 
)

MACRO DEFINITIONS /// FUNCTION DECLARATIONS ///

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

Synopsis [Entrace into the resynthesis package.]

Description []

SideEffects []

SeeAlso []

Definition at line 207 of file resCore.c.

00208 {
00209     ProgressBar * pProgress;
00210     Res_Man_t * p;
00211     Abc_Obj_t * pObj;
00212     Hop_Obj_t * pFunc;
00213     Kit_Graph_t * pGraph;
00214     Vec_Ptr_t * vFanins;
00215     unsigned * puTruth;
00216     int i, k, RetValue, nNodesOld, nFanins, nFaninsMax;
00217     int clk, clkTotal = clock();
00218 
00219     // start the manager
00220     p = Res_ManAlloc( pPars );
00221     p->nTotalNets = Abc_NtkGetTotalFanins(pNtk);
00222     p->nTotalNodes = Abc_NtkNodeNum(pNtk);
00223     nFaninsMax = Abc_NtkGetFaninMax(pNtk);
00224 
00225     // perform the network sweep
00226     Abc_NtkSweep( pNtk, 0 );
00227 
00228     // convert into the AIG
00229     if ( !Abc_NtkToAig(pNtk) )
00230     {
00231         fprintf( stdout, "Converting to BDD has failed.\n" );
00232         Res_ManFree( p );
00233         return 0;
00234     }
00235     assert( Abc_NtkHasAig(pNtk) );
00236 
00237     // set the number of levels
00238     Abc_NtkLevel( pNtk );
00239     Abc_NtkStartReverseLevels( pNtk, pPars->nGrowthLevel );
00240 
00241     // try resynthesizing nodes in the topological order
00242     nNodesOld = Abc_NtkObjNumMax(pNtk);
00243     pProgress = Extra_ProgressBarStart( stdout, nNodesOld );
00244     Abc_NtkForEachObj( pNtk, pObj, i )
00245     {
00246         Extra_ProgressBarUpdate( pProgress, i, NULL );
00247         if ( !Abc_ObjIsNode(pObj) )
00248             continue;
00249         if ( pObj->Id > nNodesOld )
00250             break;
00251 
00252         // create the window for this node
00253 clk = clock();
00254         RetValue = Res_WinCompute( pObj, p->pPars->nWindow/10, p->pPars->nWindow%10, p->pWin );
00255 p->timeWin += clock() - clk;
00256         if ( !RetValue )
00257             continue;
00258         p->nWinsTriv += Res_WinIsTrivial( p->pWin );
00259 
00260         if ( p->pPars->fVeryVerbose )
00261         {
00262             printf( "%5d (lev=%2d) : ", pObj->Id, pObj->Level );
00263             printf( "Win = %3d/%3d/%4d/%3d   ", 
00264                 Vec_PtrSize(p->pWin->vLeaves), 
00265                 Vec_PtrSize(p->pWin->vBranches),
00266                 Vec_PtrSize(p->pWin->vNodes), 
00267                 Vec_PtrSize(p->pWin->vRoots) );
00268         }
00269 
00270         // collect the divisors
00271 clk = clock();
00272         Res_WinDivisors( p->pWin, Abc_ObjRequiredLevel(pObj) - 1 );
00273 p->timeDiv += clock() - clk;
00274 
00275         p->nWins++;
00276         p->nWinNodes += Vec_PtrSize(p->pWin->vNodes);
00277         p->nDivNodes += Vec_PtrSize( p->pWin->vDivs);
00278 
00279         if ( p->pPars->fVeryVerbose )
00280         {
00281             printf( "D = %3d ", Vec_PtrSize(p->pWin->vDivs) );
00282             printf( "D+ = %3d ", p->pWin->nDivsPlus );
00283         }
00284 
00285         // create the AIG for the window
00286 clk = clock();
00287         if ( p->pAig ) Abc_NtkDelete( p->pAig );
00288         p->pAig = Res_WndStrash( p->pWin );
00289 p->timeAig += clock() - clk;
00290 
00291         if ( p->pPars->fVeryVerbose )
00292         {
00293             printf( "AIG = %4d ", Abc_NtkNodeNum(p->pAig) );
00294             printf( "\n" );
00295         }
00296  
00297         // prepare simulation info
00298 clk = clock();
00299         RetValue = Res_SimPrepare( p->pSim, p->pAig, Vec_PtrSize(p->pWin->vLeaves), 0 ); //p->pPars->fVerbose );
00300 p->timeSim += clock() - clk;
00301         if ( !RetValue )
00302         {
00303             p->nSimEmpty++;
00304             continue;
00305         }
00306 
00307         // consider the case of constant node
00308         if ( p->pSim->fConst0 || p->pSim->fConst1 )
00309         {
00310             p->nConstsUsed++;
00311 
00312             pFunc = p->pSim->fConst1? Hop_ManConst1(pNtk->pManFunc) : Hop_ManConst0(pNtk->pManFunc);
00313             vFanins = Vec_VecEntry( p->vResubsW, 0 );
00314             Vec_PtrClear( vFanins );
00315             Res_UpdateNetwork( pObj, vFanins, pFunc, p->vLevels );
00316             continue;
00317         }
00318 
00319 //        printf( " " );
00320 
00321         // find resub candidates for the node
00322 clk = clock();
00323         if ( p->pPars->fArea )
00324             RetValue = Res_FilterCandidates( p->pWin, p->pAig, p->pSim, p->vResubs, p->vResubsW, nFaninsMax, 1 );
00325         else
00326             RetValue = Res_FilterCandidates( p->pWin, p->pAig, p->pSim, p->vResubs, p->vResubsW, nFaninsMax, 0 );
00327 p->timeCand += clock() - clk;
00328         p->nCandSets += RetValue;
00329         if ( RetValue == 0 )
00330             continue;
00331 
00332 //        printf( "%d(%d) ", Vec_PtrSize(p->pWin->vDivs), RetValue );
00333 
00334         p->nWinsUsed++;
00335 
00336         // iterate through candidate resubstitutions
00337         Vec_VecForEachLevel( p->vResubs, vFanins, k )
00338         {
00339             if ( Vec_PtrSize(vFanins) == 0 )
00340                 break;
00341 
00342             // solve the SAT problem and get clauses
00343 clk = clock();
00344             if ( p->pCnf ) Sto_ManFree( p->pCnf );
00345             p->pCnf = Res_SatProveUnsat( p->pAig, vFanins );
00346             if ( p->pCnf == NULL )
00347             {
00348 p->timeSatSat += clock() - clk;
00349 //                printf( " Sat\n" );
00350 //                printf( "-" );
00351                 continue;
00352             }
00353 p->timeSatUnsat += clock() - clk;
00354 //            printf( "+" );
00355 
00356             p->nProvedSets++;
00357 //            printf( " Unsat\n" );
00358 //            continue;
00359 //            printf( "Proved %d.\n", k );
00360 
00361             // write it into a file
00362 //            Sto_ManDumpClauses( p->pCnf, "trace.cnf" );
00363 
00364             // interpolate the problem if it was UNSAT
00365 clk = clock();
00366             nFanins = Int_ManInterpolate( p->pMan, p->pCnf, 0, &puTruth );
00367 p->timeInt += clock() - clk;
00368             if ( nFanins != Vec_PtrSize(vFanins) - 2 )
00369                 continue;
00370             assert( puTruth );
00371 //            Extra_PrintBinary( stdout, puTruth, 1 << nFanins );  printf( "\n" );
00372 
00373             // transform interpolant into the AIG
00374             pGraph = Kit_TruthToGraph( puTruth, nFanins, p->vMem );
00375 
00376             // derive the AIG for the decomposition tree
00377             pFunc = Kit_GraphToHop( pNtk->pManFunc, pGraph );
00378             Kit_GraphFree( pGraph );
00379 
00380             // update the network
00381 clk = clock();
00382             Res_UpdateNetwork( pObj, Vec_VecEntry(p->vResubsW, k), pFunc, p->vLevels );
00383 p->timeUpd += clock() - clk;
00384             break;
00385         }
00386 //        printf( "\n" );
00387     }
00388     Extra_ProgressBarStop( pProgress );
00389     Abc_NtkStopReverseLevels( pNtk );
00390 
00391 p->timeSatSim += p->pSim->timeSat;
00392 p->timeSatTotal = p->timeSatSat + p->timeSatUnsat + p->timeSatSim;
00393 
00394     p->nTotalNets2 = Abc_NtkGetTotalFanins(pNtk);
00395     p->nTotalNodes2 = Abc_NtkNodeNum(pNtk);
00396 
00397     // quit resubstitution manager
00398 p->timeTotal = clock() - clkTotal;
00399     Res_ManFree( p );
00400 
00401 s_ResynTime += clock() - clkTotal;
00402     // check the resulting network
00403     if ( !Abc_NtkCheck( pNtk ) )
00404     {
00405         fprintf( stdout, "Abc_NtkResynthesize(): Network check has failed.\n" );
00406         return 0;
00407     }
00408     return 1;
00409 }


Generated on Tue Jan 5 12:19:30 2010 for abc70930 by  doxygen 1.6.1