src/opt/lpk/lpkAbcUtil.c File Reference

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

Go to the source code of this file.

Functions

Lpk_Fun_tLpk_FunAlloc (int nVars)
void Lpk_FunFree (Lpk_Fun_t *p)
Lpk_Fun_tLpk_FunCreate (Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, int nLutK, int AreaLim, int DelayLim)
Lpk_Fun_tLpk_FunDup (Lpk_Fun_t *p, unsigned *pTruth)
int Lpk_FunSuppMinimize (Lpk_Fun_t *p)
void Lpk_FunComputeCofSupps (Lpk_Fun_t *p)
int Lpk_SuppDelay (unsigned uSupp, char *pDelays)
int Lpk_SuppToVars (unsigned uBoundSet, char *pVars)

Function Documentation

Lpk_Fun_t* Lpk_FunAlloc ( int  nVars  ) 

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

FileName [lpkAbcUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Fast Boolean matching for LUT structures.]

Synopsis [Procedures working on decomposed functions.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Allocates the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file lpkAbcUtil.c.

00043 {
00044     Lpk_Fun_t * p;
00045     p = (Lpk_Fun_t *)malloc( sizeof(Lpk_Fun_t) + sizeof(unsigned) * Kit_TruthWordNum(nVars) * 3 );
00046     memset( p, 0, sizeof(Lpk_Fun_t) );
00047     return p;
00048 }

void Lpk_FunComputeCofSupps ( Lpk_Fun_t p  ) 

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

Synopsis [Computes cofactors w.r.t. each variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file lpkAbcUtil.c.

00184 {
00185     unsigned * pTruth  = Lpk_FunTruth( p, 0 );
00186     unsigned * pTruth0 = Lpk_FunTruth( p, 1 );
00187     unsigned * pTruth1 = Lpk_FunTruth( p, 2 );
00188     int Var;
00189     assert( p->fSupports == 0 );
00190 //    Lpk_SuppForEachVar( p->uSupp, Var )
00191     for ( Var = 0; Var < (int)p->nVars; Var++ )
00192     {
00193         Kit_TruthCofactor0New( pTruth0, pTruth, p->nVars, Var );
00194         Kit_TruthCofactor1New( pTruth1, pTruth, p->nVars, Var );
00195         p->puSupps[2*Var+0] = Kit_TruthSupport( pTruth0, p->nVars );
00196         p->puSupps[2*Var+1] = Kit_TruthSupport( pTruth1, p->nVars );
00197     }
00198     p->fSupports = 1;
00199 }

Lpk_Fun_t* Lpk_FunCreate ( Abc_Ntk_t pNtk,
Vec_Ptr_t vLeaves,
unsigned *  pTruth,
int  nLutK,
int  AreaLim,
int  DelayLim 
)

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

Synopsis [Creates the starting function.]

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file lpkAbcUtil.c.

00078 {
00079     Lpk_Fun_t * p;
00080     Abc_Obj_t * pNode;
00081     int i;
00082     p = Lpk_FunAlloc( Vec_PtrSize(vLeaves) );
00083     p->Id = Vec_PtrSize(vLeaves);
00084     p->vNodes = vLeaves;
00085     p->nVars = Vec_PtrSize(vLeaves);
00086     p->nLutK = nLutK;
00087     p->nAreaLim = AreaLim;
00088     p->nDelayLim = DelayLim;
00089     p->uSupp = Kit_TruthSupport( pTruth, p->nVars );
00090     Kit_TruthCopy( Lpk_FunTruth(p,0), pTruth, p->nVars );
00091     Vec_PtrForEachEntry( vLeaves, pNode, i )
00092     {
00093         p->pFanins[i] = i;
00094         p->pDelays[i] = pNode->Level;
00095     }
00096     Vec_PtrPush( p->vNodes, p );
00097     return p;
00098 }

Lpk_Fun_t* Lpk_FunDup ( Lpk_Fun_t p,
unsigned *  pTruth 
)

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

Synopsis [Creates the new function with the given truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file lpkAbcUtil.c.

00112 {
00113     Lpk_Fun_t * pNew;
00114     pNew = Lpk_FunAlloc( p->nVars );
00115     pNew->Id = Vec_PtrSize(p->vNodes);
00116     pNew->vNodes = p->vNodes;
00117     pNew->nVars = p->nVars;
00118     pNew->nLutK = p->nLutK;
00119     pNew->nAreaLim = p->nAreaLim;
00120     pNew->nDelayLim = p->nDelayLim;
00121     pNew->uSupp = Kit_TruthSupport( pTruth, p->nVars );
00122     Kit_TruthCopy( Lpk_FunTruth(pNew,0), pTruth, p->nVars );
00123     memcpy( pNew->pFanins, p->pFanins, 16 );
00124     memcpy( pNew->pDelays, p->pDelays, 16 );
00125     Vec_PtrPush( p->vNodes, pNew );
00126     return pNew;
00127 }

void Lpk_FunFree ( Lpk_Fun_t p  ) 

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

Synopsis [Deletes the function]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file lpkAbcUtil.c.

00062 {
00063     free( p );
00064 }

int Lpk_FunSuppMinimize ( Lpk_Fun_t p  ) 

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

Synopsis [Minimizes support of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 140 of file lpkAbcUtil.c.

00141 {
00142     int i, k, nVarsNew;
00143     // compress the truth table
00144     if ( p->uSupp == Kit_BitMask(p->nVars) )
00145         return 0;
00146     // invalidate support info
00147     p->fSupports = 0;
00148 //Extra_PrintBinary( stdout, &p->uSupp, p->nVars ); printf( "\n" );
00149     // minimize support
00150     nVarsNew = Kit_WordCountOnes(p->uSupp);
00151     Kit_TruthShrink( Lpk_FunTruth(p, 1), Lpk_FunTruth(p, 0), nVarsNew, p->nVars, p->uSupp, 1 );
00152     k = 0;
00153     Lpk_SuppForEachVar( p->uSupp, i )
00154     {
00155         p->pFanins[k] = p->pFanins[i];
00156         p->pDelays[k] = p->pDelays[i];
00157 /*
00158         if ( p->fSupports )
00159         {
00160             p->puSupps[2*k+0] = p->puSupps[2*i+0];
00161             p->puSupps[2*k+1] = p->puSupps[2*i+1];
00162         }
00163 */
00164         k++;
00165     }
00166     assert( k == nVarsNew );
00167     p->nVars = k;
00168     p->uSupp = Kit_BitMask(p->nVars);
00169     return 1;
00170 }

int Lpk_SuppDelay ( unsigned  uSupp,
char *  pDelays 
)

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

Synopsis [Get the delay of the bound set.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file lpkAbcUtil.c.

00213 {
00214     int Delay, Var;
00215     Delay = 0;
00216     Lpk_SuppForEachVar( uSupp, Var )
00217         Delay = ABC_MAX( Delay, pDelays[Var] );
00218     return Delay + 1;
00219 }

int Lpk_SuppToVars ( unsigned  uBoundSet,
char *  pVars 
)

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

Synopsis [Converts support into variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file lpkAbcUtil.c.

00233 {
00234     int i, nVars = 0;
00235     Lpk_SuppForEachVar( uBoundSet, i )
00236         pVars[nVars++] = i;
00237     return nVars;
00238 }


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