src/aig/cnf/cnfPost.c File Reference

#include "cnf.h"
Include dependency graph for cnfPost.c:

Go to the source code of this file.

Functions

void Cnf_ManPostprocess_old (Cnf_Man_t *p)
void Cnf_ManTransferCuts (Cnf_Man_t *p)
void Cnf_ManFreeCuts (Cnf_Man_t *p)
void Cnf_ManPostprocess (Cnf_Man_t *p)

Function Documentation

void Cnf_ManFreeCuts ( Cnf_Man_t p  ) 

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

Synopsis [Transfers cuts of the mapped nodes into internal representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file cnfPost.c.

00140 {
00141     Aig_Obj_t * pObj;
00142     int i;
00143     Aig_ManForEachObj( p->pManAig, pObj, i )
00144         if ( pObj->pData )
00145         {
00146             Cnf_CutFree( pObj->pData );
00147             pObj->pData = NULL;
00148         }
00149 }

void Cnf_ManPostprocess ( Cnf_Man_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file cnfPost.c.

00163 {
00164     Cnf_Cut_t * pCut, * pCutFan, * pCutRes;
00165     Aig_Obj_t * pObj, * pFan;
00166     int Order[16], Costs[16];
00167     int i, k, fChanges;
00168     Aig_ManForEachNode( p->pManAig, pObj, i )
00169     {
00170         if ( pObj->nRefs == 0 )
00171             continue;
00172         pCut = Cnf_ObjBestCut(pObj);
00173 
00174         // sort fanins according to their size
00175         Cnf_CutForEachLeaf( p->pManAig, pCut, pFan, k )
00176         {
00177             Order[k] = k;
00178             Costs[k] = Aig_ObjIsNode(pFan)? Cnf_ObjBestCut(pFan)->Cost : 0;
00179         }
00180         // sort the cuts by Weight
00181         do {
00182             int Temp;
00183             fChanges = 0;
00184             for ( k = 0; k < pCut->nFanins - 1; k++ )
00185             {
00186                 if ( Costs[Order[k]] <= Costs[Order[k+1]] )
00187                     continue;
00188                 Temp = Order[k];
00189                 Order[k] = Order[k+1];
00190                 Order[k+1] = Temp;
00191                 fChanges = 1;
00192             }
00193         } while ( fChanges );
00194 
00195 
00196 //        Cnf_CutForEachLeaf( p->pManAig, pCut, pFan, k )
00197         for ( k = 0; (k < (int)(pCut)->nFanins) && ((pFan) = Aig_ManObj(p->pManAig, (pCut)->pFanins[Order[k]])); k++ )
00198         {
00199             if ( !Aig_ObjIsNode(pFan) )
00200                 continue;
00201             assert( pFan->nRefs != 0 );
00202             if ( pFan->nRefs != 1 )
00203                 continue;
00204             pCutFan = Cnf_ObjBestCut(pFan);
00205             // try composing these two cuts
00206 //            Cnf_CutPrint( pCut );
00207             pCutRes = Cnf_CutCompose( p, pCut, pCutFan, pFan->Id );
00208 //            Cnf_CutPrint( pCut );
00209 //            printf( "\n" );
00210             // check if the cost if reduced
00211             if ( pCutRes == NULL || pCutRes->Cost == 127 || pCutRes->Cost > pCut->Cost + pCutFan->Cost )
00212             {
00213                 if ( pCutRes )
00214                     Cnf_CutFree( pCutRes );
00215                 continue;
00216             }
00217             // update the cut
00218             Cnf_ObjSetBestCut( pObj, pCutRes );
00219             Cnf_ObjSetBestCut( pFan, NULL );
00220             Cnf_CutUpdateRefs( p, pCut, pCutFan, pCutRes );
00221             assert( pFan->nRefs == 0 );
00222             Cnf_CutFree( pCut );
00223             Cnf_CutFree( pCutFan );
00224             break;
00225         }
00226     }
00227 }

void Cnf_ManPostprocess_old ( Cnf_Man_t p  ) 

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

FileName [cnfPost.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG-to-CNF conversion.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
cnfPost.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file cnfPost.c.

00043 {
00044 //    extern int Aig_ManLargeCutEval( Aig_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCutR, Dar_Cut_t * pCutL, int Leaf );
00045     int nNew, Gain, nGain = 0, nVars = 0;
00046 
00047     Aig_Obj_t * pObj, * pFan;
00048     Dar_Cut_t * pCutBest, * pCut;
00049     int i, k;//, a, b, Counter;
00050     Aig_ManForEachObj( p->pManAig, pObj, i )
00051     {
00052         if ( !Aig_ObjIsNode(pObj) )
00053             continue;
00054         if ( pObj->nRefs == 0 )
00055             continue;
00056 //        pCutBest = Aig_ObjBestCut(pObj);
00057         pCutBest = NULL;
00058 
00059         Dar_CutForEachLeaf( p->pManAig, pCutBest, pFan, k )
00060         {
00061             if ( !Aig_ObjIsNode(pFan) )
00062                 continue;
00063             assert( pFan->nRefs != 0 );
00064             if ( pFan->nRefs != 1 )
00065                 continue;
00066 //            pCut = Aig_ObjBestCut(pFan);
00067             pCut = NULL;
00068 /*
00069             // find how many common variable they have
00070             Counter = 0;
00071             for ( a = 0; a < (int)pCut->nLeaves; a++ )
00072             {
00073                 for ( b = 0; b < (int)pCutBest->nLeaves; b++ )
00074                     if ( pCut->pLeaves[a] == pCutBest->pLeaves[b] )
00075                         break;
00076                 if ( b == (int)pCutBest->nLeaves )
00077                     continue;
00078                 Counter++;
00079             }
00080             printf( "%d ", Counter );
00081 */
00082             // find the new truth table after collapsing these two cuts
00083 
00084 
00085 //            nNew = Aig_ManLargeCutEval( p->pManAig, pObj, pCutBest, pCut, pFan->Id );
00086             nNew = 0;
00087 
00088 
00089 //            printf( "%d+%d=%d:%d(%d) ", pCutBest->Cost, pCut->Cost, 
00090 //                pCutBest->Cost+pCut->Cost, nNew, pCutBest->Cost+pCut->Cost-nNew );
00091 
00092             Gain = pCutBest->Value + pCut->Value - nNew;
00093             if ( Gain > 0 )
00094             {
00095                 nGain += Gain;
00096                 nVars++;
00097             }
00098         }
00099     }
00100     printf( "Total gain = %d.  Vars = %d.\n", nGain, nVars );
00101 }

void Cnf_ManTransferCuts ( Cnf_Man_t p  ) 

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

Synopsis [Transfers cuts of the mapped nodes into internal representation.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file cnfPost.c.

00115 {
00116     Aig_Obj_t * pObj;
00117     int i;
00118     Aig_MmFlexRestart( p->pMemCuts );
00119     Aig_ManForEachObj( p->pManAig, pObj, i )
00120     {
00121         if ( Aig_ObjIsNode(pObj) && pObj->nRefs > 0 )
00122             pObj->pData = Cnf_CutCreate( p, pObj );
00123         else
00124             pObj->pData = NULL;
00125     }
00126 }


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