src/opt/lpk/lpkMap.c File Reference

#include "lpkInt.h"
Include dependency graph for lpkMap.c:

Go to the source code of this file.

Functions

If_Obj_tLpk_MapPrimeInternal (If_Man_t *pIfMan, Kit_Graph_t *pGraph)
If_Obj_tLpk_MapPrime (Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
If_Obj_tLpk_MapTree_rec (Lpk_Man_t *p, Kit_DsdNtk_t *pNtk, If_Obj_t **ppLeaves, int iLit, If_Obj_t *pResult)

Function Documentation

If_Obj_t* Lpk_MapPrime ( Lpk_Man_t p,
unsigned *  pTruth,
int  nVars,
If_Obj_t **  ppLeaves 
)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file lpkMap.c.

00077 {
00078     Kit_Graph_t * pGraph;
00079     Kit_Node_t * pNode;
00080     If_Obj_t * pRes;
00081     int i;
00082     // derive the factored form
00083     pGraph = Kit_TruthToGraph( pTruth, nVars, p->vCover );
00084     if ( pGraph == NULL )
00085         return NULL;
00086     // collect the fanins
00087     Kit_GraphForEachLeaf( pGraph, pNode, i )
00088         pNode->pFunc = ppLeaves[i];
00089     // perform strashing
00090     pRes = Lpk_MapPrimeInternal( p->pIfMan, pGraph );
00091     pRes = If_NotCond( pRes, Kit_GraphIsComplement(pGraph) );
00092     Kit_GraphFree( pGraph );
00093     return pRes;
00094 }

If_Obj_t* Lpk_MapPrimeInternal ( If_Man_t pIfMan,
Kit_Graph_t pGraph 
)

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

FileName [lpkMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Fast Boolean matching for LUT structures.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file lpkMap.c.

00043 {
00044     Kit_Node_t * pNode;
00045     If_Obj_t * pAnd0, * pAnd1;
00046     int i;
00047     // check for constant function
00048     if ( Kit_GraphIsConst(pGraph) )
00049         return If_ManConst1(pIfMan);
00050     // check for a literal
00051     if ( Kit_GraphIsVar(pGraph) )
00052         return Kit_GraphVar(pGraph)->pFunc;
00053     // build the AIG nodes corresponding to the AND gates of the graph
00054     Kit_GraphForEachNode( pGraph, pNode, i )
00055     {
00056         pAnd0 = Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc; 
00057         pAnd1 = Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc; 
00058         pNode->pFunc = If_ManCreateAnd( pIfMan, 
00059             If_NotCond( If_Regular(pAnd0), If_IsComplement(pAnd0) ^ pNode->eEdge0.fCompl ), 
00060             If_NotCond( If_Regular(pAnd1), If_IsComplement(pAnd1) ^ pNode->eEdge1.fCompl ) );
00061     }
00062     return pNode->pFunc;
00063 }

If_Obj_t* Lpk_MapTree_rec ( Lpk_Man_t p,
Kit_DsdNtk_t pNtk,
If_Obj_t **  ppLeaves,
int  iLit,
If_Obj_t pResult 
)

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

Synopsis [Prepares the mapping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file lpkMap.c.

00108 {
00109     Kit_DsdObj_t * pObj;
00110     If_Obj_t * pObjNew = NULL, * pObjNew2 = NULL, * pFansNew[16];
00111     unsigned i, iLitFanin;
00112 
00113     assert( iLit >= 0 );
00114 
00115     // consider the case of a gate
00116     pObj = Kit_DsdNtkObj( pNtk, Kit_DsdLit2Var(iLit) );
00117     if ( pObj == NULL )
00118     {
00119         pObjNew = ppLeaves[Kit_DsdLit2Var(iLit)];
00120         return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
00121     }
00122     if ( pObj->Type == KIT_DSD_CONST1 )
00123     {
00124         return If_NotCond( If_ManConst1(p->pIfMan), Kit_DsdLitIsCompl(iLit) );
00125     }
00126     if ( pObj->Type == KIT_DSD_VAR )
00127     {
00128         pObjNew = ppLeaves[Kit_DsdLit2Var(pObj->pFans[0])];
00129         return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) ^ Kit_DsdLitIsCompl(pObj->pFans[0]) );
00130     }
00131     if ( pObj->Type == KIT_DSD_AND )
00132     {
00133         assert( pObj->nFans == 2 );
00134         pFansNew[0] = Lpk_MapTree_rec( p, pNtk, ppLeaves, pObj->pFans[0], NULL );
00135         pFansNew[1] = pResult? pResult : Lpk_MapTree_rec( p, pNtk, ppLeaves, pObj->pFans[1], NULL );
00136         if ( pFansNew[0] == NULL || pFansNew[1] == NULL )
00137             return NULL;
00138         pObjNew = If_ManCreateAnd( p->pIfMan, pFansNew[0], pFansNew[1] ); 
00139         return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
00140     }
00141     if ( pObj->Type == KIT_DSD_XOR )
00142     {
00143         int fCompl = Kit_DsdLitIsCompl(iLit);
00144         assert( pObj->nFans == 2 );
00145         pFansNew[0] = Lpk_MapTree_rec( p, pNtk, ppLeaves, pObj->pFans[0], NULL );
00146         pFansNew[1] = pResult? pResult : Lpk_MapTree_rec( p, pNtk, ppLeaves, pObj->pFans[1], NULL );
00147         if ( pFansNew[0] == NULL || pFansNew[1] == NULL )
00148             return NULL;
00149         fCompl ^= If_IsComplement(pFansNew[0]) ^ If_IsComplement(pFansNew[1]);
00150         pObjNew = If_ManCreateXor( p->pIfMan, If_Regular(pFansNew[0]), If_Regular(pFansNew[1]) );
00151         return If_NotCond( pObjNew, fCompl );
00152     }
00153     assert( pObj->Type == KIT_DSD_PRIME );
00154     p->nBlocks[pObj->nFans]++;
00155 
00156     // solve for the inputs
00157     Kit_DsdObjForEachFanin( pNtk, pObj, iLitFanin, i )
00158     {
00159         if ( i == 0 )
00160             pFansNew[i] = pResult? pResult : Lpk_MapTree_rec( p, pNtk, ppLeaves, iLitFanin, NULL );
00161         else
00162             pFansNew[i] = Lpk_MapTree_rec( p, pNtk, ppLeaves, iLitFanin, NULL );
00163         if ( pFansNew[i] == NULL )
00164             return NULL;
00165     }
00166 /* 
00167     if ( !p->fCofactoring && p->pPars->nVarsShared > 0 && (int)pObj->nFans > p->pPars->nLutSize )
00168     {
00169         pObjNew = Lpk_MapTreeMulti( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
00170         return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
00171     }
00172 */
00173 /*
00174     if ( (int)pObj->nFans > p->pPars->nLutSize )
00175     {
00176         pObjNew2 = Lpk_MapTreeMux_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
00177 //        if ( pObjNew2 )
00178 //            return If_NotCond( pObjNew2, Kit_DsdLitIsCompl(iLit) );
00179     }
00180 */
00181 
00182     // find best cofactoring variable
00183     if ( p->pPars->nVarsShared > 0 && (int)pObj->nFans > p->pPars->nLutSize )
00184     {
00185         pObjNew2 = Lpk_MapSuppRedDec_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
00186         if ( pObjNew2 )
00187             return If_NotCond( pObjNew2, Kit_DsdLitIsCompl(iLit) );
00188     }
00189 
00190     pObjNew = Lpk_MapPrime( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
00191 
00192     // add choice
00193     if ( pObjNew && pObjNew2 )
00194     {
00195         If_ObjSetChoice( If_Regular(pObjNew), If_Regular(pObjNew2) );
00196         If_ManCreateChoice( p->pIfMan, If_Regular(pObjNew) );
00197     }
00198     return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
00199 }


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