#include "bdcInt.h"
Go to the source code of this file.
Functions | |
Bdc_Man_t * | Bdc_ManAlloc (Bdc_Par_t *pPars) |
void | Bdc_ManFree (Bdc_Man_t *p) |
void | Bdc_ManPrepare (Bdc_Man_t *p, Vec_Ptr_t *vDivs) |
int | Bdc_ManDecompose (Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax) |
CFile****************************************************************
FileName [bdcCore.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Truth-table-based bi-decomposition engine.]
Synopsis [The gateway to bi-decomposition.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - January 30, 2007.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Allocate resynthesis manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 42 of file bdcCore.c.
00043 { 00044 Bdc_Man_t * p; 00045 unsigned * pData; 00046 int i, k, nBits; 00047 p = ALLOC( Bdc_Man_t, 1 ); 00048 memset( p, 0, sizeof(Bdc_Man_t) ); 00049 assert( pPars->nVarsMax > 3 && pPars->nVarsMax < 16 ); 00050 p->pPars = pPars; 00051 p->nWords = Kit_TruthWordNum( pPars->nVarsMax ); 00052 p->nDivsLimit = 200; 00053 p->nNodesLimit = 0; // will be set later 00054 // memory 00055 p->vMemory = Vec_IntStart( 1 << 16 ); 00056 // internal nodes 00057 p->nNodesAlloc = 512; 00058 p->pNodes = ALLOC( Bdc_Fun_t, p->nNodesAlloc ); 00059 // set up hash table 00060 p->nTableSize = (1 << p->pPars->nVarsMax); 00061 p->pTable = ALLOC( Bdc_Fun_t *, p->nTableSize ); 00062 memset( p->pTable, 0, sizeof(Bdc_Fun_t *) * p->nTableSize ); 00063 p->vSpots = Vec_IntAlloc( 256 ); 00064 // truth tables 00065 p->vTruths = Vec_PtrAllocSimInfo( pPars->nVarsMax + 5, p->nWords ); 00066 // set elementary truth tables 00067 nBits = (1 << pPars->nVarsMax); 00068 Kit_TruthFill( Vec_PtrEntry(p->vTruths, 0), p->nVars ); 00069 for ( k = 0; k < pPars->nVarsMax; k++ ) 00070 { 00071 pData = Vec_PtrEntry( p->vTruths, k+1 ); 00072 Kit_TruthClear( pData, p->nVars ); 00073 for ( i = 0; i < nBits; i++ ) 00074 if ( i & (1 << k) ) 00075 pData[i>>5] |= (1 << (i&31)); 00076 } 00077 p->puTemp1 = Vec_PtrEntry( p->vTruths, pPars->nVarsMax + 1 ); 00078 p->puTemp2 = Vec_PtrEntry( p->vTruths, pPars->nVarsMax + 2 ); 00079 p->puTemp3 = Vec_PtrEntry( p->vTruths, pPars->nVarsMax + 3 ); 00080 p->puTemp4 = Vec_PtrEntry( p->vTruths, pPars->nVarsMax + 4 ); 00081 // start the internal ISFs 00082 p->pIsfOL = &p->IsfOL; Bdc_IsfStart( p, p->pIsfOL ); 00083 p->pIsfOR = &p->IsfOR; Bdc_IsfStart( p, p->pIsfOR ); 00084 p->pIsfAL = &p->IsfAL; Bdc_IsfStart( p, p->pIsfAL ); 00085 p->pIsfAR = &p->IsfAR; Bdc_IsfStart( p, p->pIsfAR ); 00086 return p; 00087 }
int Bdc_ManDecompose | ( | Bdc_Man_t * | p, | |
unsigned * | puFunc, | |||
unsigned * | puCare, | |||
int | nVars, | |||
Vec_Ptr_t * | vDivs, | |||
int | nNodesMax | |||
) |
Function*************************************************************
Synopsis [Performs decomposition of one function.]
Description []
SideEffects []
SeeAlso []
Definition at line 162 of file bdcCore.c.
00163 { 00164 Bdc_Isf_t Isf, * pIsf = &Isf; 00165 // set current manager parameters 00166 p->nVars = nVars; 00167 p->nWords = Kit_TruthWordNum( nVars ); 00168 Bdc_ManPrepare( p, vDivs ); 00169 p->nNodesLimit = (p->nNodes + nNodesMax < p->nNodesAlloc)? p->nNodes + nNodesMax : p->nNodesAlloc; 00170 // copy the function 00171 Bdc_IsfStart( p, pIsf ); 00172 Bdc_IsfClean( pIsf ); 00173 pIsf->uSupp = Kit_TruthSupport( puFunc, p->nVars ) | Kit_TruthSupport( puCare, p->nVars ); 00174 Kit_TruthAnd( pIsf->puOn, puCare, puFunc, p->nVars ); 00175 Kit_TruthSharp( pIsf->puOff, puCare, puFunc, p->nVars ); 00176 // call decomposition 00177 Bdc_SuppMinimize( p, pIsf ); 00178 p->pRoot = Bdc_ManDecompose_rec( p, pIsf ); 00179 if ( p->pRoot == NULL ) 00180 return -1; 00181 return p->nNodesNew; 00182 }
void Bdc_ManFree | ( | Bdc_Man_t * | p | ) |
Function*************************************************************
Synopsis [Deallocate resynthesis manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 100 of file bdcCore.c.
00101 { 00102 Vec_IntFree( p->vMemory ); 00103 Vec_IntFree( p->vSpots ); 00104 Vec_PtrFree( p->vTruths ); 00105 free( p->pNodes ); 00106 free( p->pTable ); 00107 free( p ); 00108 }
Function*************************************************************
Synopsis [Clears the manager.]
Description []
SideEffects []
SeeAlso []
Definition at line 121 of file bdcCore.c.
00122 { 00123 unsigned * puTruth; 00124 Bdc_Fun_t * pNode; 00125 int i; 00126 Bdc_TableClear( p ); 00127 Vec_IntClear( p->vMemory ); 00128 // add constant 1 and elementary vars 00129 p->nNodes = p->nNodesNew = 0; 00130 for ( i = 0; i <= p->pPars->nVarsMax; i++ ) 00131 { 00132 pNode = Bdc_FunNew( p ); 00133 pNode->Type = BDC_TYPE_PI; 00134 pNode->puFunc = Vec_PtrEntry( p->vTruths, i ); 00135 pNode->uSupp = i? (1 << (i-1)) : 0; 00136 Bdc_TableAdd( p, pNode ); 00137 } 00138 // add the divisors 00139 Vec_PtrForEachEntry( vDivs, puTruth, i ) 00140 { 00141 pNode = Bdc_FunNew( p ); 00142 pNode->Type = BDC_TYPE_PI; 00143 pNode->puFunc = puTruth; 00144 pNode->uSupp = Kit_TruthSupport( puTruth, p->nVars ); 00145 Bdc_TableAdd( p, pNode ); 00146 if ( i == p->nDivsLimit ) 00147 break; 00148 } 00149 }