abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lpkAbcUtil.c File Reference
#include "lpkInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Lpk_Fun_t
Lpk_FunAlloc (int nVars)
 DECLARATIONS ///. More...
 
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

ABC_NAMESPACE_IMPL_START Lpk_Fun_t* Lpk_FunAlloc ( int  nVars)

DECLARATIONS ///.

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

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

Synopsis [Allocates the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file lpkAbcUtil.c.

46 {
47  Lpk_Fun_t * p;
48  p = (Lpk_Fun_t *)ABC_ALLOC( char, sizeof(Lpk_Fun_t) + sizeof(unsigned) * Kit_TruthWordNum(nVars) * 3 );
49  memset( p, 0, sizeof(Lpk_Fun_t) );
50  return p;
51 }
char * memset()
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Lpk_FunComputeCofSupps ( Lpk_Fun_t p)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file lpkAbcUtil.c.

187 {
188  unsigned * pTruth = Lpk_FunTruth( p, 0 );
189  unsigned * pTruth0 = Lpk_FunTruth( p, 1 );
190  unsigned * pTruth1 = Lpk_FunTruth( p, 2 );
191  int Var;
192  assert( p->fSupports == 0 );
193 // Lpk_SuppForEachVar( p->uSupp, Var )
194  for ( Var = 0; Var < (int)p->nVars; Var++ )
195  {
196  Kit_TruthCofactor0New( pTruth0, pTruth, p->nVars, Var );
197  Kit_TruthCofactor1New( pTruth1, pTruth, p->nVars, Var );
198  p->puSupps[2*Var+0] = Kit_TruthSupport( pTruth0, p->nVars );
199  p->puSupps[2*Var+1] = Kit_TruthSupport( pTruth1, p->nVars );
200  }
201  p->fSupports = 1;
202 }
unsigned nVars
Definition: lpkInt.h:148
unsigned fSupports
Definition: lpkInt.h:152
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
unsigned puSupps[32]
Definition: lpkInt.h:155
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 80 of file lpkAbcUtil.c.

81 {
82  Lpk_Fun_t * p;
83  Abc_Obj_t * pNode;
84  int i;
85  p = Lpk_FunAlloc( Vec_PtrSize(vLeaves) );
86  p->Id = Vec_PtrSize(vLeaves);
87  p->vNodes = vLeaves;
88  p->nVars = Vec_PtrSize(vLeaves);
89  p->nLutK = nLutK;
90  p->nAreaLim = AreaLim;
91  p->nDelayLim = DelayLim;
92  p->uSupp = Kit_TruthSupport( pTruth, p->nVars );
93  Kit_TruthCopy( Lpk_FunTruth(p,0), pTruth, p->nVars );
94  Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
95  {
96  p->pFanins[i] = i;
97  p->pDelays[i] = pNode->Level;
98  }
99  Vec_PtrPush( p->vNodes, p );
100  return p;
101 }
unsigned nAreaLim
Definition: lpkInt.h:150
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nVars
Definition: lpkInt.h:148
unsigned nLutK
Definition: lpkInt.h:149
Vec_Ptr_t * vNodes
Definition: lpkInt.h:146
unsigned uSupp
Definition: lpkInt.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned Level
Definition: abc.h:142
unsigned Id
Definition: lpkInt.h:147
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
ABC_NAMESPACE_IMPL_START Lpk_Fun_t * Lpk_FunAlloc(int nVars)
DECLARATIONS ///.
Definition: lpkAbcUtil.c:45
char pDelays[16]
Definition: lpkInt.h:156
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
char pFanins[16]
Definition: lpkInt.h:157
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
unsigned nDelayLim
Definition: lpkInt.h:151
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 114 of file lpkAbcUtil.c.

115 {
116  Lpk_Fun_t * pNew;
117  pNew = Lpk_FunAlloc( p->nVars );
118  pNew->Id = Vec_PtrSize(p->vNodes);
119  pNew->vNodes = p->vNodes;
120  pNew->nVars = p->nVars;
121  pNew->nLutK = p->nLutK;
122  pNew->nAreaLim = p->nAreaLim;
123  pNew->nDelayLim = p->nDelayLim;
124  pNew->uSupp = Kit_TruthSupport( pTruth, p->nVars );
125  Kit_TruthCopy( Lpk_FunTruth(pNew,0), pTruth, p->nVars );
126  memcpy( pNew->pFanins, p->pFanins, 16 );
127  memcpy( pNew->pDelays, p->pDelays, 16 );
128  Vec_PtrPush( p->vNodes, pNew );
129  return pNew;
130 }
unsigned nAreaLim
Definition: lpkInt.h:150
unsigned nVars
Definition: lpkInt.h:148
unsigned nLutK
Definition: lpkInt.h:149
Vec_Ptr_t * vNodes
Definition: lpkInt.h:146
unsigned uSupp
Definition: lpkInt.h:154
char * memcpy()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned Id
Definition: lpkInt.h:147
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
ABC_NAMESPACE_IMPL_START Lpk_Fun_t * Lpk_FunAlloc(int nVars)
DECLARATIONS ///.
Definition: lpkAbcUtil.c:45
char pDelays[16]
Definition: lpkInt.h:156
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
char pFanins[16]
Definition: lpkInt.h:157
unsigned nDelayLim
Definition: lpkInt.h:151
void Lpk_FunFree ( Lpk_Fun_t p)

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

Synopsis [Deletes the function]

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file lpkAbcUtil.c.

65 {
66  ABC_FREE( p );
67 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Lpk_FunSuppMinimize ( Lpk_Fun_t p)

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

Synopsis [Minimizes support of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file lpkAbcUtil.c.

144 {
145  int i, k, nVarsNew;
146  // compress the truth table
147  if ( p->uSupp == Kit_BitMask(p->nVars) )
148  return 0;
149  // invalidate support info
150  p->fSupports = 0;
151 //Extra_PrintBinary( stdout, &p->uSupp, p->nVars ); printf( "\n" );
152  // minimize support
153  nVarsNew = Kit_WordCountOnes(p->uSupp);
154  Kit_TruthShrink( Lpk_FunTruth(p, 1), Lpk_FunTruth(p, 0), nVarsNew, p->nVars, p->uSupp, 1 );
155  k = 0;
156  Lpk_SuppForEachVar( p->uSupp, i )
157  {
158  p->pFanins[k] = p->pFanins[i];
159  p->pDelays[k] = p->pDelays[i];
160 /*
161  if ( p->fSupports )
162  {
163  p->puSupps[2*k+0] = p->puSupps[2*i+0];
164  p->puSupps[2*k+1] = p->puSupps[2*i+1];
165  }
166 */
167  k++;
168  }
169  assert( k == nVarsNew );
170  p->nVars = k;
171  p->uSupp = Kit_BitMask(p->nVars);
172  return 1;
173 }
unsigned nVars
Definition: lpkInt.h:148
unsigned uSupp
Definition: lpkInt.h:154
unsigned fSupports
Definition: lpkInt.h:152
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
void Kit_TruthShrink(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition: kitTruth.c:200
char pDelays[16]
Definition: lpkInt.h:156
char pFanins[16]
Definition: lpkInt.h:157
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
#define Lpk_SuppForEachVar(Supp, Var)
Definition: lpkInt.h:195
static unsigned Kit_BitMask(int nBits)
Definition: kit.h:225
int Lpk_SuppDelay ( unsigned  uSupp,
char *  pDelays 
)

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

Synopsis [Get the delay of the bound set.]

Description []

SideEffects []

SeeAlso []

Definition at line 215 of file lpkAbcUtil.c.

216 {
217  int Delay, Var;
218  Delay = 0;
219  Lpk_SuppForEachVar( uSupp, Var )
220  Delay = Abc_MaxInt( Delay, pDelays[Var] );
221  return Delay + 1;
222 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Var
Definition: SolverTypes.h:42
#define Lpk_SuppForEachVar(Supp, Var)
Definition: lpkInt.h:195
int Lpk_SuppToVars ( unsigned  uBoundSet,
char *  pVars 
)

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

Synopsis [Converts support into variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file lpkAbcUtil.c.

236 {
237  int i, nVars = 0;
238  Lpk_SuppForEachVar( uBoundSet, i )
239  pVars[nVars++] = i;
240  return nVars;
241 }
#define Lpk_SuppForEachVar(Supp, Var)
Definition: lpkInt.h:195