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

Go to the source code of this file.

Data Structures

struct  Kit_ManDec_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Kit_ManDec_t_ 
Kit_ManDec_t
 DECLARATIONS ///. More...
 

Functions

static int Kit_DecOuputArrival (int nVars, Vec_Int_t *vLuts, char ATimes[])
 
Kit_ManDec_tKit_ManDecStart (int nVarsMax)
 FUNCTION DEFINITIONS ///. More...
 
void Kit_ManDecStop (Kit_ManDec_t *p)
 
int Kit_DecComputeOuputArrival (int nVars, Vec_Int_t *vSupps, int LutSize, char ATimesIn[], char ATimesOut[])
 
void Kit_DecComputeTruthOne (int LutSize, unsigned *pTruthLut, int nVars, unsigned *pTruths[], unsigned *pTemp, unsigned *pRes)
 
void Kit_DecComputeTruth (Kit_ManDec_t *p, int nVars, Vec_Int_t *vSupps, int LutSize, Vec_Int_t *vLuts, unsigned *pRes)
 
int Kit_DecComputePattern (int nVars, unsigned *pTruth, int LutSize, int Pattern[])
 
int Kit_DecComputeShared_rec (int Pattern[], int Vars[], int nVars, int Shared[], int iVarTry)
 
int Kit_DecComputeShared (int Pattern[], int LutSize, int Shared[])
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Kit_ManDec_t_ Kit_ManDec_t

DECLARATIONS ///.

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

FileName [kitDec.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Decomposition manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 18, 2009.]

Revision [

Id:
kitDec.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]

Definition at line 31 of file kitDec.c.

Function Documentation

int Kit_DecComputeOuputArrival ( int  nVars,
Vec_Int_t vSupps,
int  LutSize,
char  ATimesIn[],
char  ATimesOut[] 
)

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

Synopsis [Deriving timing information for the decomposed structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file kitDec.c.

127 {
128  int i, v, iVar, nLuts, Delay;
129  nLuts = Vec_IntSize(vSupps) / LutSize;
130  assert( nLuts > 0 );
131  assert( Vec_IntSize(vSupps) % LutSize == 0 );
132  for ( v = 0; v < nVars; v++ )
133  ATimesOut[v] = ATimesIn[v];
134  for ( v = 0; v < nLuts; v++ )
135  {
136  Delay = 0;
137  for ( i = 0; i < LutSize; i++ )
138  {
139  iVar = Vec_IntEntry( vSupps, v * LutSize + i );
140  assert( iVar < nVars + v );
141  Delay = Abc_MaxInt( Delay, ATimesOut[iVar] );
142  }
143  ATimesOut[nVars + v] = Delay + 1;
144  }
145  return ATimesOut[nVars + nLuts - 1];
146 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int Kit_DecComputePattern ( int  nVars,
unsigned *  pTruth,
int  LutSize,
int  Pattern[] 
)

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

Synopsis [Derives the truth table]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file kitDec.c.

224 {
225  int nCofs = (1 << LutSize);
226  int i, k, nMyu = 0;
227  assert( LutSize <= 6 );
228  assert( LutSize < nVars );
229  if ( nVars - LutSize <= 5 )
230  {
231  unsigned uCofs[64];
232  int nBits = (1 << (nVars - LutSize));
233  for ( i = 0; i < nCofs; i++ )
234  uCofs[i] = (pTruth[(i*nBits)/32] >> ((i*nBits)%32)) & ((1<<nBits)-1);
235  for ( i = 0; i < nCofs; i++ )
236  {
237  for ( k = 0; k < nMyu; k++ )
238  if ( uCofs[i] == uCofs[k] )
239  {
240  Pattern[i] = k;
241  break;
242  }
243  if ( k == i )
244  Pattern[nMyu++] = i;
245  }
246  }
247  else
248  {
249  unsigned * puCofs[64];
250  int nWords = (1 << (nVars - LutSize - 5));
251  for ( i = 0; i < nCofs; i++ )
252  puCofs[i] = pTruth + nWords;
253  for ( i = 0; i < nCofs; i++ )
254  {
255  for ( k = 0; k < nMyu; k++ )
256  if ( Kit_TruthIsEqual( puCofs[i], puCofs[k], nVars - LutSize - 5 ) )
257  {
258  Pattern[i] = k;
259  break;
260  }
261  if ( k == i )
262  Pattern[nMyu++] = i;
263  }
264  }
265  return nMyu;
266 }
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
int Kit_DecComputeShared ( int  Pattern[],
int  LutSize,
int  Shared[] 
)

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

Synopsis [Returns the number of shared variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 328 of file kitDec.c.

329 {
330  int i, Vars[6];
331  assert( LutSize <= 6 );
332  for ( i = 0; i < LutSize; i++ )
333  Vars[i] = i;
334  return Kit_DecComputeShared_rec( Pattern, Vars, LutSize, Shared, 0 );
335 }
int Kit_DecComputeShared_rec(int Pattern[], int Vars[], int nVars, int Shared[], int iVarTry)
Definition: kitDec.c:279
#define assert(ex)
Definition: util_old.h:213
int Kit_DecComputeShared_rec ( int  Pattern[],
int  Vars[],
int  nVars,
int  Shared[],
int  iVarTry 
)

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

Synopsis [Returns the number of shared variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file kitDec.c.

280 {
281  int Pat0[32], Pat1[32], Shared0[5], Shared1[5], VarsNext[5];
282  int v, u, iVarsNext, iPat0, iPat1, m, nMints = (1 << nVars);
283  int nShared0, nShared1, nShared = 0;
284  for ( v = iVarTry; v < nVars; v++ )
285  {
286  iVarsNext = 0;
287  for ( u = 0; u < nVars; u++ )
288  if ( u == v )
289  VarsNext[iVarsNext++] = Vars[u];
290  iPat0 = iPat1 = 0;
291  for ( m = 0; m < nMints; m++ )
292  if ( m & (1 << v) )
293  Pat1[iPat1++] = m;
294  else
295  Pat0[iPat0++] = m;
296  assert( iPat0 == nMints / 2 );
297  assert( iPat1 == nMints / 2 );
298  nShared0 = Kit_DecComputeShared_rec( Pat0, VarsNext, nVars-1, Shared0, v + 1 );
299  if ( nShared0 == 0 )
300  continue;
301  nShared1 = Kit_DecComputeShared_rec( Pat1, VarsNext, nVars-1, Shared1, v + 1 );
302  if ( nShared1 == 0 )
303  continue;
304  Shared[nShared++] = v;
305  for ( u = 0; u < nShared0; u++ )
306  for ( m = 0; m < nShared1; m++ )
307  if ( Shared0[u] >= 0 && Shared1[m] >= 0 && Shared0[u] == Shared1[m] )
308  {
309  Shared[nShared++] = Shared0[u];
310  Shared0[u] = Shared1[m] = -1;
311  }
312  return nShared;
313  }
314  return 0;
315 }
int Kit_DecComputeShared_rec(int Pattern[], int Vars[], int nVars, int Shared[], int iVarTry)
Definition: kitDec.c:279
#define assert(ex)
Definition: util_old.h:213
void Kit_DecComputeTruth ( Kit_ManDec_t p,
int  nVars,
Vec_Int_t vSupps,
int  LutSize,
Vec_Int_t vLuts,
unsigned *  pRes 
)

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

Synopsis [Derives the truth table]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file kitDec.c.

189 {
190  unsigned * pResult, * pTruthLuts, * pTruths[17];
191  int nTruthLutWords, i, v, iVar, nLuts;
192  nLuts = Vec_IntSize(vSupps) / LutSize;
193  pTruthLuts = (unsigned *)Vec_IntArray( vLuts );
194  nTruthLutWords = Kit_TruthWordNum( LutSize );
195  assert( nLuts > 0 );
196  assert( Vec_IntSize(vSupps) % LutSize == 0 );
197  assert( nLuts * nTruthLutWords == Vec_IntSize(vLuts) );
198  for ( v = 0; v < nLuts; v++ )
199  {
200  for ( i = 0; i < LutSize; i++ )
201  {
202  iVar = Vec_IntEntry( vSupps, v * LutSize + i );
203  assert( iVar < nVars + v );
204  pTruths[i] = (iVar < nVars)? (unsigned *)Vec_PtrEntry(p->vTruthVars, iVar) : (unsigned *)Vec_PtrEntry(p->vTruthNodes, iVar-nVars);
205  }
206  pResult = (v == nLuts - 1) ? pRes : (unsigned *)Vec_PtrEntry(p->vTruthNodes, v);
207  Kit_DecComputeTruthOne( LutSize, pTruthLuts, nVars, pTruths, (unsigned *)Vec_PtrEntry(p->vTruthNodes, v+1), pResult );
208  pTruthLuts += nTruthLutWords;
209  }
210 }
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Kit_DecComputeTruthOne(int LutSize, unsigned *pTruthLut, int nVars, unsigned *pTruths[], unsigned *pTemp, unsigned *pRes)
Definition: kitDec.c:159
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
void Kit_DecComputeTruthOne ( int  LutSize,
unsigned *  pTruthLut,
int  nVars,
unsigned *  pTruths[],
unsigned *  pTemp,
unsigned *  pRes 
)

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

Synopsis [Derives the truth table]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file kitDec.c.

160 {
161  int i, v;
162  Kit_TruthClear( pRes, nVars );
163  for ( i = 0; i < (1<<LutSize); i++ )
164  {
165  if ( !Kit_TruthHasBit( pTruthLut, i ) )
166  continue;
167  Kit_TruthFill( pTemp, nVars );
168  for ( v = 0; v < LutSize; v++ )
169  if ( i & (1<<v) )
170  Kit_TruthAnd( pTemp, pTemp, pTruths[v], nVars );
171  else
172  Kit_TruthSharp( pTemp, pTemp, pTruths[v], nVars );
173  Kit_TruthOr( pRes, pRes, pTemp, nVars );
174  }
175 }
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
static void Kit_TruthFill(unsigned *pOut, int nVars)
Definition: kit.h:367
static int Kit_TruthHasBit(unsigned *p, int Bit)
Definition: kit.h:229
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
static void Kit_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:397
static void Kit_TruthClear(unsigned *pOut, int nVars)
Definition: kit.h:361
static void Kit_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:385
static int Kit_DecOuputArrival ( int  nVars,
Vec_Int_t vLuts,
char  ATimes[] 
)
inlinestatic

Definition at line 55 of file kitDec.c.

55 { return ATimes[nVars + Vec_IntSize(vLuts) - 1]; }
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Kit_ManDec_t* Kit_ManDecStart ( int  nVarsMax)

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts Decmetry manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file kitDec.c.

73 {
74  Kit_ManDec_t * p;
75  assert( nVarsMax <= 20 );
76  p = ABC_CALLOC( Kit_ManDec_t, 1 );
77  p->nVarsMax = nVarsMax;
78  p->nWordsMax = Kit_TruthWordNum( p->nVarsMax );
79  p->vTruthVars = Vec_PtrAllocTruthTables( p->nVarsMax );
80  p->vTruthNodes = Vec_PtrAllocSimInfo( 64, p->nWordsMax );
81  p->vLutsIn = Vec_IntAlloc( 50 );
82  p->vSuppIn = Vec_IntAlloc( 50 );
83  p->vLutsOut = Vec_IntAlloc( 50 );
84  p->vSuppOut = Vec_IntAlloc( 50 );
85  p->pTruthIn = ABC_ALLOC( unsigned, p->nWordsMax );
86  p->pTruthOut = ABC_ALLOC( unsigned, p->nWordsMax );
87  return p;
88 }
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
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
typedefABC_NAMESPACE_IMPL_START struct Kit_ManDec_t_ Kit_ManDec_t
DECLARATIONS ///.
Definition: kitDec.c:31
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
Definition: vecPtr.h:929
void Kit_ManDecStop ( Kit_ManDec_t p)

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

Synopsis [Stops Decmetry manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file kitDec.c.

102 {
103  ABC_FREE( p->pTruthIn );
104  ABC_FREE( p->pTruthOut );
105  Vec_IntFreeP( &p->vLutsIn );
106  Vec_IntFreeP( &p->vSuppIn );
107  Vec_IntFreeP( &p->vLutsOut );
108  Vec_IntFreeP( &p->vSuppOut );
109  Vec_PtrFreeP( &p->vTruthVars );
110  Vec_PtrFreeP( &p->vTruthNodes );
111  ABC_FREE( p );
112 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240