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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Amap_LibDeriveGatePerm (Amap_Lib_t *pLib, Amap_Gat_t *pGate, Kit_DsdNtk_t *pNtk, Amap_Nod_t *pNod, char *pArray)
 DECLARATIONS ///. More...
 
Vec_Int_tAmap_CreateRulesPrime (Amap_Lib_t *p, Vec_Int_t *vNods0, Vec_Int_t *vNods1, Vec_Int_t *vNods2)
 FUNCTION DEFINITIONS ///. More...
 
void Amap_CreateRulesTwo (Amap_Lib_t *p, Vec_Int_t *vNods, Vec_Int_t *vNods0, Vec_Int_t *vNods1, int fXor)
 
int Amap_CreateCheckAllZero (Vec_Ptr_t *vVecNods)
 
Vec_Int_tAmap_CreateRulesVector_rec (Amap_Lib_t *p, Vec_Ptr_t *vVecNods, int fXor)
 
Vec_Int_tAmap_CreateRulesFromDsd_rec (Amap_Lib_t *pLib, Kit_DsdNtk_t *p, int iLit)
 
Vec_Int_tAmap_CreateRulesFromDsd (Amap_Lib_t *pLib, Kit_DsdNtk_t *p)
 
int Amap_CreateCheckEqual_rec (Kit_DsdNtk_t *p, int iLit0, int iLit1)
 
void Amap_CreateCheckAsym_rec (Kit_DsdNtk_t *p, int iLit, Vec_Int_t **pvSyms)
 
void Amap_CreateCheckAsym (Kit_DsdNtk_t *p, Vec_Int_t **pvSyms)
 
void Amap_CreateRulesForGate (Amap_Lib_t *pLib, Amap_Gat_t *pGate)
 
void Amap_LibCreateRules (Amap_Lib_t *pLib, int fVeryVerbose)
 

Function Documentation

int Amap_CreateCheckAllZero ( Vec_Ptr_t vVecNods)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file amapRule.c.

103 {
104  Vec_Int_t * vNods;
105  int i;
106  Vec_PtrForEachEntryReverse( Vec_Int_t *, vVecNods, vNods, i )
107  if ( Vec_IntSize(vNods) != 1 || Vec_IntEntry(vNods,0) != 0 )
108  return 0;
109  return 1;
110 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition: vecPtr.h:63
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Amap_CreateCheckAsym ( Kit_DsdNtk_t p,
Vec_Int_t **  pvSyms 
)

Definition at line 314 of file amapRule.c.

315 {
316  Amap_CreateCheckAsym_rec( p, Abc_LitRegular(p->Root), pvSyms );
317 }
unsigned short Root
Definition: kit.h:127
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
void Amap_CreateCheckAsym_rec(Kit_DsdNtk_t *p, int iLit, Vec_Int_t **pvSyms)
Definition: amapRule.c:288
void Amap_CreateCheckAsym_rec ( Kit_DsdNtk_t p,
int  iLit,
Vec_Int_t **  pvSyms 
)

Definition at line 288 of file amapRule.c.

289 {
290  Kit_DsdObj_t * pObj;
291  int i, k, iFanin;
292  assert( !Abc_LitIsCompl(iLit) );
293  pObj = Kit_DsdNtkObj( p, Abc_Lit2Var(iLit) );
294  if ( pObj == NULL )
295  return;
296  Kit_DsdObjForEachFanin( p, pObj, iFanin, i )
297  Amap_CreateCheckAsym_rec( p, Abc_LitRegular(iFanin), pvSyms );
298  if ( pObj->Type == KIT_DSD_PRIME )
299  return;
300  assert( pObj->Type == KIT_DSD_AND || pObj->Type == KIT_DSD_XOR );
301  for ( i = 0; i < (int)pObj->nFans; i++ )
302  for ( k = i+1; k < (int)pObj->nFans; k++ )
303  {
304  if ( Abc_LitIsCompl(pObj->pFans[i]) != Abc_LitIsCompl(pObj->pFans[k]) &&
305  Kit_DsdNtkObj(p, Abc_Lit2Var(pObj->pFans[i])) == NULL &&
306  Kit_DsdNtkObj(p, Abc_Lit2Var(pObj->pFans[k])) == NULL )
307  {
308  if ( *pvSyms == NULL )
309  *pvSyms = Vec_IntAlloc( 16 );
310  Vec_IntPush( *pvSyms, (Abc_Lit2Var(pObj->pFans[i]) << 8) | Abc_Lit2Var(pObj->pFans[k]) );
311  }
312  }
313 }
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
Definition: kit.h:150
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
Definition: kit.h:157
for(p=first;p->value< newval;p=p->next)
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned short pFans[0]
Definition: kit.h:117
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
void Amap_CreateCheckAsym_rec(Kit_DsdNtk_t *p, int iLit, Vec_Int_t **pvSyms)
Definition: amapRule.c:288
int Amap_CreateCheckEqual_rec ( Kit_DsdNtk_t p,
int  iLit0,
int  iLit1 
)

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

Synopsis [Returns 1 if DSD network contains asymentry due to complements.]

Description []

SideEffects []

SeeAlso []

Definition at line 260 of file amapRule.c.

261 {
262  Kit_DsdObj_t * pObj0, * pObj1;
263  int i;
264  assert( !Abc_LitIsCompl(iLit0) );
265  assert( !Abc_LitIsCompl(iLit1) );
266  pObj0 = Kit_DsdNtkObj( p, Abc_Lit2Var(iLit0) );
267  pObj1 = Kit_DsdNtkObj( p, Abc_Lit2Var(iLit1) );
268  if ( pObj0 == NULL && pObj1 == NULL )
269  return 1;
270  if ( pObj0 == NULL || pObj1 == NULL )
271  return 0;
272  if ( pObj0->Type != pObj1->Type )
273  return 0;
274  if ( pObj0->nFans != pObj1->nFans )
275  return 0;
276  if ( pObj0->Type == KIT_DSD_PRIME )
277  return 0;
278  assert( pObj0->Type == KIT_DSD_AND || pObj0->Type == KIT_DSD_XOR );
279  for ( i = 0; i < (int)pObj0->nFans; i++ )
280  {
281  if ( Abc_LitIsCompl(pObj0->pFans[i]) != Abc_LitIsCompl(pObj1->pFans[i]) )
282  return 0;
283  if ( !Amap_CreateCheckEqual_rec( p, Abc_LitRegular(pObj0->pFans[i]), Abc_LitRegular(pObj1->pFans[i]) ) )
284  return 0;
285  }
286  return 1;
287 }
unsigned Type
Definition: kit.h:112
unsigned nFans
Definition: kit.h:116
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
Definition: kit.h:150
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned short pFans[0]
Definition: kit.h:117
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
int Amap_CreateCheckEqual_rec(Kit_DsdNtk_t *p, int iLit0, int iLit1)
Definition: amapRule.c:260
void Amap_CreateRulesForGate ( Amap_Lib_t pLib,
Amap_Gat_t pGate 
)

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

Synopsis [Creates rules for the given gate]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file amapRule.c.

331 {
332  Kit_DsdNtk_t * pNtk, * pTemp;
333  Vec_Int_t * vSyms = NULL;
334  Vec_Int_t * vNods;
335  Amap_Nod_t * pNod;
336  Amap_Set_t * pSet, * pSet2;
337  int iNod, i, k, Entry;
338 // if ( pGate->nPins > 4 )
339 // return;
340  pNtk = Kit_DsdDecomposeMux( pGate->pFunc, pGate->nPins, 2 );
341  if ( pGate->nPins == 2 && (pGate->pFunc[0] == 0x66666666 || pGate->pFunc[0] == ~0x66666666) )
342  pLib->fHasXor = 1;
343  if ( Kit_DsdNonDsdSizeMax(pNtk) == 3 )
344  pLib->fHasMux = pGate->fMux = 1;
345  pNtk = Kit_DsdExpand( pTemp = pNtk );
346  Kit_DsdNtkFree( pTemp );
347  Kit_DsdVerify( pNtk, pGate->pFunc, pGate->nPins );
348  // check symmetries
349  Amap_CreateCheckAsym( pNtk, &vSyms );
350 // if ( vSyms )
351 // Kit_DsdPrint( stdout, pNtk ), printf( "\n" );
352 
353 if ( pLib->fVerbose )
354 //if ( pGate->fMux )
355 {
356 printf( "\nProcessing library gate %4d: %10s ", pGate->Id, pGate->pName );
357 Kit_DsdPrint( stdout, pNtk );
358 }
359  vNods = Amap_CreateRulesFromDsd( pLib, pNtk );
360  if ( vNods )
361  {
362  Vec_IntForEachEntry( vNods, iNod, i )
363  {
364  assert( iNod > 1 );
365  pNod = Amap_LibNod( pLib, Abc_Lit2Var(iNod) );
366 // assert( pNod->Type == AMAP_OBJ_MUX || pNod->nSuppSize == pGate->nPins );
367  pSet = (Amap_Set_t *)Aig_MmFlexEntryFetch( pLib->pMemSet, sizeof(Amap_Set_t) );
368  memset( pSet, 0, sizeof(Amap_Set_t) );
369  pSet->iGate = pGate->Id;
370  pSet->fInv = Abc_LitIsCompl(iNod);
371  pSet->nIns = pGate->nPins;
372  if ( Amap_LibDeriveGatePerm( pLib, pGate, pNtk, pNod, pSet->Ins ) == 0 )
373  {
374 if ( pLib->fVerbose )
375 {
376  printf( "Cound not prepare gate \"%s\": ", pGate->pName );
377  Kit_DsdPrint( stdout, pNtk );
378 }
379  continue;
380  }
381  pSet->pNext = pNod->pSets;
382  pNod->pSets = pSet;
383  pLib->nSets++;
384  if ( vSyms == NULL )
385  continue;
386 // continue;
387  // add sets equivalent due to symmetry
388  Vec_IntForEachEntry( vSyms, Entry, k )
389  {
390  int iThis = Entry & 0xff;
391  int iThat = Entry >> 8;
392 // printf( "%d %d\n", iThis, iThat );
393  // create new set
394  pSet2 = (Amap_Set_t *)Aig_MmFlexEntryFetch( pLib->pMemSet, sizeof(Amap_Set_t) );
395  memset( pSet2, 0, sizeof(Amap_Set_t) );
396  pSet2->iGate = pGate->Id;
397  pSet2->fInv = Abc_LitIsCompl(iNod);
398  pSet2->nIns = pGate->nPins;
399  memcpy( pSet2->Ins, pSet->Ins, pGate->nPins );
400  // update inputs
401  pSet2->Ins[iThis] = Abc_Var2Lit( Abc_Lit2Var(pSet->Ins[iThat]), Abc_LitIsCompl(pSet->Ins[iThis]) );
402  pSet2->Ins[iThat] = Abc_Var2Lit( Abc_Lit2Var(pSet->Ins[iThis]), Abc_LitIsCompl(pSet->Ins[iThat]) );
403  // add set to collection
404  pSet2->pNext = pNod->pSets;
405  pNod->pSets = pSet2;
406  pLib->nSets++;
407  }
408  }
409  Vec_IntFree( vNods );
410  }
411  Kit_DsdNtkFree( pNtk );
412  Vec_IntFreeP( &vSyms );
413 }
char * memset()
unsigned fMux
Definition: amapInt.h:160
int Kit_DsdNonDsdSizeMax(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1211
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Amap_Set_t * pNext
Definition: amapInt.h:166
unsigned fInv
Definition: amapInt.h:168
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * memcpy()
Vec_Int_t * Amap_CreateRulesFromDsd(Amap_Lib_t *pLib, Kit_DsdNtk_t *p)
Definition: amapRule.c:233
void Amap_CreateCheckAsym(Kit_DsdNtk_t *p, Vec_Int_t **pvSyms)
Definition: amapRule.c:314
ABC_NAMESPACE_IMPL_START int Amap_LibDeriveGatePerm(Amap_Lib_t *pLib, Amap_Gat_t *pGate, Kit_DsdNtk_t *pNtk, Amap_Nod_t *pNod, char *pArray)
DECLARATIONS ///.
Definition: amapPerm.c:331
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
char Ins[AMAP_MAXINS]
Definition: amapInt.h:170
unsigned * pFunc
Definition: amapInt.h:158
unsigned nPins
Definition: amapInt.h:161
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
Amap_Set_t * pSets
Definition: amapInt.h:181
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned iGate
Definition: amapInt.h:167
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
#define assert(ex)
Definition: util_old.h:213
unsigned nIns
Definition: amapInt.h:169
char * pName
Definition: amapInt.h:154
static Amap_Nod_t * Amap_LibNod(Amap_Lib_t *p, int i)
Definition: amapInt.h:264
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
unsigned Id
Definition: amapInt.h:159
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
Vec_Int_t* Amap_CreateRulesFromDsd ( Amap_Lib_t pLib,
Kit_DsdNtk_t p 
)

Definition at line 233 of file amapRule.c.

234 {
235  Vec_Int_t * vNods;
236  int iNod, i;
237  assert( p->nVars >= 2 );
238  vNods = Amap_CreateRulesFromDsd_rec( pLib, p, Abc_LitRegular(p->Root) );
239  if ( vNods == NULL )
240  return NULL;
241  if ( Abc_LitIsCompl(p->Root) )
242  {
243  Vec_IntForEachEntry( vNods, iNod, i )
244  Vec_IntWriteEntry( vNods, i, Abc_LitNot(iNod) );
245  }
246  return vNods;
247 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
unsigned short Root
Definition: kit.h:127
Vec_Int_t * Amap_CreateRulesFromDsd_rec(Amap_Lib_t *pLib, Kit_DsdNtk_t *p, int iLit)
Definition: amapRule.c:191
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
unsigned short nVars
Definition: kit.h:124
Vec_Int_t* Amap_CreateRulesFromDsd_rec ( Amap_Lib_t pLib,
Kit_DsdNtk_t p,
int  iLit 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file amapRule.c.

192 {
193  Vec_Int_t * vRes;
194  Vec_Ptr_t * vVecNods;
195  Vec_Int_t * vNodsFanin;
196  Kit_DsdObj_t * pObj;
197  unsigned i;
198  int iFanin, iNod, k;
199  assert( !Abc_LitIsCompl(iLit) );
200  pObj = Kit_DsdNtkObj( p, Abc_Lit2Var(iLit) );
201  if ( pObj == NULL )
202  return Vec_IntStartNatural( 1 );
203  // solve for the inputs
204  vVecNods = Vec_PtrAlloc( pObj->nFans );
205  Kit_DsdObjForEachFanin( p, pObj, iFanin, i )
206  {
207  vNodsFanin = Amap_CreateRulesFromDsd_rec( pLib, p, Abc_LitRegular(iFanin) );
208  if ( Abc_LitIsCompl(iFanin) )
209  {
210  Vec_IntForEachEntry( vNodsFanin, iNod, k )
211  if ( iNod > 0 )
212  Vec_IntWriteEntry( vNodsFanin, k, Abc_LitNot(iNod) );
213  }
214  Vec_PtrPush( vVecNods, vNodsFanin );
215  }
216  if ( pObj->Type == KIT_DSD_AND )
217  vRes = Amap_CreateRulesVector_rec( pLib, vVecNods, 0 );
218  else if ( pObj->Type == KIT_DSD_XOR )
219  vRes = Amap_CreateRulesVector_rec( pLib, vVecNods, 1 );
220  else if ( pObj->Type == KIT_DSD_PRIME )
221  {
222  assert( pObj->nFans == 3 );
223  assert( Kit_DsdObjTruth(pObj)[0] == 0xCACACACA );
224  vRes = Amap_CreateRulesPrime( pLib, (Vec_Int_t *)Vec_PtrEntry(vVecNods, 0),
225  (Vec_Int_t *)Vec_PtrEntry(vVecNods, 1), (Vec_Int_t *)Vec_PtrEntry(vVecNods, 2) );
226  }
227  else assert( 0 );
228  Vec_PtrForEachEntry( Vec_Int_t *, vVecNods, vNodsFanin, k )
229  Vec_IntFree( vNodsFanin );
230  Vec_PtrFree( vVecNods );
231  return vRes;
232 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
unsigned nFans
Definition: kit.h:116
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
Definition: kit.h:150
Vec_Int_t * Amap_CreateRulesFromDsd_rec(Amap_Lib_t *pLib, Kit_DsdNtk_t *p, int iLit)
Definition: amapRule.c:191
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
Definition: kit.h:157
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static unsigned * Kit_DsdObjTruth(Kit_DsdObj_t *pObj)
Definition: kit.h:148
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Vec_Int_t * Amap_CreateRulesPrime(Amap_Lib_t *p, Vec_Int_t *vNods0, Vec_Int_t *vNods1, Vec_Int_t *vNods2)
FUNCTION DEFINITIONS ///.
Definition: amapRule.c:48
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
Vec_Int_t * Amap_CreateRulesVector_rec(Amap_Lib_t *p, Vec_Ptr_t *vVecNods, int fXor)
Definition: amapRule.c:123
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Int_t* Amap_CreateRulesPrime ( Amap_Lib_t p,
Vec_Int_t vNods0,
Vec_Int_t vNods1,
Vec_Int_t vNods2 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Checks if the three-argument rule exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file amapRule.c.

49 {
50  Vec_Int_t * vRes;
51  int i, k, j, iNod, iNod0, iNod1, iNod2;
52  if ( p->vRules3 == NULL )
53  p->vRules3 = Vec_IntAlloc( 100 );
54  vRes = Vec_IntAlloc( 10 );
55  Vec_IntForEachEntry( vNods0, iNod0, i )
56  Vec_IntForEachEntry( vNods1, iNod1, k )
57  Vec_IntForEachEntry( vNods2, iNod2, j )
58  {
59  iNod = Amap_LibFindMux( p, iNod0, iNod1, iNod2 );
60  if ( iNod == -1 )
61  iNod = Amap_LibCreateMux( p, iNod0, iNod1, iNod2 );
62  Vec_IntPush( vRes, Abc_Var2Lit(iNod, 0) );
63  }
64  return vRes;
65 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int Amap_LibFindMux(Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
Definition: amapUniq.c:109
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int Amap_LibCreateMux(Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
Definition: amapUniq.c:244
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Amap_CreateRulesTwo ( Amap_Lib_t p,
Vec_Int_t vNods,
Vec_Int_t vNods0,
Vec_Int_t vNods1,
int  fXor 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file amapRule.c.

79 {
80  int i, k, iNod, iNod0, iNod1;
81  Vec_IntForEachEntry( vNods0, iNod0, i )
82  Vec_IntForEachEntry( vNods1, iNod1, k )
83  {
84  iNod = Amap_LibFindNode( p, iNod0, iNod1, fXor );
85  if ( iNod == -1 )
86  iNod = Amap_LibCreateNode( p, iNod0, iNod1, fXor );
87  Vec_IntPushUnique( vNods, Abc_Var2Lit(iNod, 0) );
88  }
89 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int Amap_LibCreateNode(Amap_Lib_t *p, int iFan0, int iFan1, int fXor)
Definition: amapUniq.c:189
int Amap_LibFindNode(Amap_Lib_t *pLib, int iFan0, int iFan1, int fXor)
Definition: amapUniq.c:90
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Vec_Int_t* Amap_CreateRulesVector_rec ( Amap_Lib_t p,
Vec_Ptr_t vVecNods,
int  fXor 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file amapRule.c.

124 {
125  Vec_Ptr_t * vVecNods0, * vVecNods1;
126  Vec_Int_t * vRes, * vNods, * vNods0, * vNods1;
127  int i, k;
128  if ( Vec_PtrSize(vVecNods) == 1 )
129  return Vec_IntDup( (Vec_Int_t *)Vec_PtrEntry(vVecNods, 0) );
130  vRes = Vec_IntAlloc( 10 );
131  vVecNods0 = Vec_PtrAlloc( Vec_PtrSize(vVecNods) );
132  vVecNods1 = Vec_PtrAlloc( Vec_PtrSize(vVecNods) );
133  if ( Amap_CreateCheckAllZero(vVecNods) )
134  {
135  for ( i = Vec_PtrSize(vVecNods)-1; i > 0; i-- )
136  {
137  Vec_PtrClear( vVecNods0 );
138  Vec_PtrClear( vVecNods1 );
139  Vec_PtrForEachEntryStop( Vec_Int_t *, vVecNods, vNods, k, i )
140  Vec_PtrPush( vVecNods0, vNods );
141  Vec_PtrForEachEntryStart( Vec_Int_t *, vVecNods, vNods, k, i )
142  Vec_PtrPush( vVecNods1, vNods );
143  vNods0 = Amap_CreateRulesVector_rec( p, vVecNods0, fXor );
144  vNods1 = Amap_CreateRulesVector_rec( p, vVecNods1, fXor );
145  Amap_CreateRulesTwo( p, vRes, vNods0, vNods1, fXor );
146  Vec_IntFree( vNods0 );
147  Vec_IntFree( vNods1 );
148  }
149  }
150  else
151  {
152  int Limit = (1 << Vec_PtrSize(vVecNods))-2;
153  for ( i = 1; i < Limit; i++ )
154  {
155  Vec_PtrClear( vVecNods0 );
156  Vec_PtrClear( vVecNods1 );
157  Vec_PtrForEachEntryReverse( Vec_Int_t *, vVecNods, vNods, k )
158  {
159  if ( i & (1 << k) )
160  Vec_PtrPush( vVecNods1, vNods );
161  else
162  Vec_PtrPush( vVecNods0, vNods );
163  }
164  assert( Vec_PtrSize(vVecNods0) > 0 );
165  assert( Vec_PtrSize(vVecNods1) > 0 );
166  assert( Vec_PtrSize(vVecNods0) < Vec_PtrSize(vVecNods) );
167  assert( Vec_PtrSize(vVecNods1) < Vec_PtrSize(vVecNods) );
168  vNods0 = Amap_CreateRulesVector_rec( p, vVecNods0, fXor );
169  vNods1 = Amap_CreateRulesVector_rec( p, vVecNods1, fXor );
170  Amap_CreateRulesTwo( p, vRes, vNods0, vNods1, fXor );
171  Vec_IntFree( vNods0 );
172  Vec_IntFree( vNods1 );
173  }
174  }
175  Vec_PtrFree( vVecNods0 );
176  Vec_PtrFree( vVecNods1 );
177  return vRes;
178 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Amap_CreateCheckAllZero(Vec_Ptr_t *vVecNods)
Definition: amapRule.c:102
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition: vecPtr.h:63
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
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
else
Definition: sparse_int.h:55
void Amap_CreateRulesTwo(Amap_Lib_t *p, Vec_Int_t *vNods, Vec_Int_t *vNods0, Vec_Int_t *vNods1, int fXor)
Definition: amapRule.c:78
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Int_t * Amap_CreateRulesVector_rec(Amap_Lib_t *p, Vec_Ptr_t *vVecNods, int fXor)
Definition: amapRule.c:123
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Amap_LibCreateRules ( Amap_Lib_t pLib,
int  fVeryVerbose 
)

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

Synopsis [Creates rules for the given gate]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file amapRule.c.

427 {
428  Amap_Gat_t * pGate;
429  int i, nGates = 0;
430 // abctime clk = Abc_Clock();
431  pLib->fVerbose = fVeryVerbose;
432  pLib->vRules = Vec_PtrAlloc( 100 );
433  pLib->vRulesX = Vec_PtrAlloc( 100 );
434  pLib->vRules3 = Vec_IntAlloc( 100 );
435  Amap_LibCreateVar( pLib );
436  Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vSelect, pGate, i )
437  {
438  if ( pGate->nPins < 2 )
439  continue;
440  if ( pGate->pFunc == NULL )
441  {
442  printf( "Amap_LibCreateRules(): Skipping gate %s (%s).\n", pGate->pName, pGate->pForm );
443  continue;
444  }
445  Amap_CreateRulesForGate( pLib, pGate );
446  nGates++;
447  }
448  assert( Vec_PtrSize(pLib->vRules) == 2*pLib->nNodes );
449  assert( Vec_PtrSize(pLib->vRulesX) == 2*pLib->nNodes );
450  pLib->pRules = Amap_LibLookupTableAlloc( pLib->vRules, 0 );
451  pLib->pRulesX = Amap_LibLookupTableAlloc( pLib->vRulesX, 0 );
452  Vec_VecFree( (Vec_Vec_t *)pLib->vRules ); pLib->vRules = NULL;
453  Vec_VecFree( (Vec_Vec_t *)pLib->vRulesX ); pLib->vRulesX = NULL;
454 }
char * pForm
Definition: amapInt.h:157
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Amap_CreateRulesForGate(Amap_Lib_t *pLib, Amap_Gat_t *pGate)
Definition: amapRule.c:330
int Amap_LibCreateVar(Amap_Lib_t *p)
Definition: amapUniq.c:164
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int ** Amap_LibLookupTableAlloc(Vec_Ptr_t *vVec, int fVerbose)
Definition: amapUniq.c:278
unsigned * pFunc
Definition: amapInt.h:158
unsigned nPins
Definition: amapInt.h:161
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: amapInt.h:154
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_NAMESPACE_IMPL_START int Amap_LibDeriveGatePerm ( Amap_Lib_t pLib,
Amap_Gat_t pGate,
Kit_DsdNtk_t pNtk,
Amap_Nod_t pNod,
char *  pArray 
)

DECLARATIONS ///.

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

FileName [amapRule.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Matching rules.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
amapRule.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

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

Synopsis [Matches the node with the DSD of a gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 331 of file amapPerm.c.

332 {
333  int fVerbose = 0;
334  Vec_Int_t * vPerm;
335  int Entry, Entry2, i, k;
336 // Kit_DsdPrint( stdout, pNtk );
337 
338  vPerm = Amap_LibDeriveGatePerm_rec( pLib, pNtk, Abc_LitRegular(pNtk->Root), pNod );
339  if ( vPerm == NULL )
340  return 0;
341  // check that the permutation is valid
342  assert( Vec_IntSize(vPerm) == (int)pNod->nSuppSize );
343  Vec_IntForEachEntry( vPerm, Entry, i )
344  Vec_IntForEachEntryStart( vPerm, Entry2, k, i+1 )
345  if ( Abc_Lit2Var(Entry) == Abc_Lit2Var(Entry2) )
346  {
347  Vec_IntFree( vPerm );
348  return 0;
349  }
350 
351  // reverse the permutation
352  Vec_IntForEachEntry( vPerm, Entry, i )
353  {
354  assert( Entry < 2 * (int)pNod->nSuppSize );
355  pArray[Abc_Lit2Var(Entry)] = Abc_Var2Lit( i, Abc_LitIsCompl(Entry) );
356 // pArray[i] = Entry;
357 //printf( "%d=%d%c ", Abc_Lit2Var(Entry), i, Abc_LitIsCompl(Entry)?'-':'+' );
358  }
359 //printf( "\n" );
360 // if ( Kit_DsdNonDsdSizeMax(pNtk) < 3 )
361 // Amap_LibVerifyPerm( pLib, pGate, pNtk, pNod, Vec_IntArray(vPerm) );
362  Vec_IntFree( vPerm );
363  // print the result
364  if ( fVerbose )
365  {
366  printf( "node %4d : ", pNod->Id );
367  for ( i = 0; i < (int)pNod->nSuppSize; i++ )
368  printf( "%d=%d%c ", i, Abc_Lit2Var(pArray[i]), Abc_LitIsCompl(pArray[i])?'-':'+' );
369  printf( "\n" );
370  }
371  return 1;
372 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
unsigned short Root
Definition: kit.h:127
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
if(last==0)
Definition: sparse_int.h:34
unsigned nSuppSize
Definition: amapInt.h:175
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
Vec_Int_t * Amap_LibDeriveGatePerm_rec(Amap_Lib_t *pLib, Kit_DsdNtk_t *pNtk, int iLit, Amap_Nod_t *pNod)
Definition: amapPerm.c:95
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Id
Definition: amapInt.h:174
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54