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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Amap_Cut_t
Amap_ManSetupPis (Amap_Man_t *p)
 DECLARATIONS ///. More...
 
Amap_Cut_tAmap_ManCutStore (Amap_Man_t *p, Amap_Cut_t *pCut, int fCompl)
 
Amap_Cut_tAmap_ManCutCreate (Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, int iMat)
 
Amap_Cut_tAmap_ManCutCreate3 (Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, Amap_Cut_t *pCut2, int iMat)
 
void Amap_ManCutSaveStored (Amap_Man_t *p, Amap_Obj_t *pNode)
 
int Amap_ManMergeCountCuts (Amap_Man_t *p, Amap_Obj_t *pNode)
 
void Amap_ManPrintCuts (Amap_Obj_t *pNode)
 
void Amap_ManMergeNodeChoice (Amap_Man_t *p, Amap_Obj_t *pNode)
 
int Amap_ManFindCut (Amap_Obj_t *pNode, Amap_Obj_t *pFanin, int fComplFanin, int Val, Vec_Ptr_t *vCuts)
 
void Amap_ManMergeNodeCutsMux (Amap_Man_t *p, Amap_Obj_t *pNode)
 
void Amap_ManMergeNodeCuts (Amap_Man_t *p, Amap_Obj_t *pNode)
 
void Amap_ManMerge (Amap_Man_t *p)
 

Function Documentation

Amap_Cut_t* Amap_ManCutCreate ( Amap_Man_t p,
Amap_Cut_t pCut0,
Amap_Cut_t pCut1,
int  iMat 
)

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

Synopsis [Creates new cut and adds it to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file amapMerge.c.

107 {
108  Amap_Cut_t * pCut;
109  int i, nSize = pCut0->nFans + pCut1->nFans;
110  int nBytes = sizeof(Amap_Cut_t) + sizeof(int) * nSize + sizeof(Amap_Cut_t *);
111  assert( pCut0->iMat >= pCut1->iMat );
112  pCut = (Amap_Cut_t *)Aig_MmFlexEntryFetch( p->pMemTemp, nBytes );
113  pCut->iMat = iMat;
114  pCut->fInv = 0;
115  pCut->nFans = nSize;
116  for ( i = 0; i < (int)pCut0->nFans; i++ )
117  pCut->Fans[i] = pCut0->Fans[i];
118  for ( i = 0; i < (int)pCut1->nFans; i++ )
119  pCut->Fans[pCut0->nFans+i] = pCut1->Fans[i];
120  // add it to storage
121  if ( p->ppCutsTemp[ pCut->iMat ] == NULL )
122  Vec_IntPushOrder( p->vTemp, pCut->iMat );
123  *Amap_ManCutNextP( pCut ) = p->ppCutsTemp[ pCut->iMat ];
124  p->ppCutsTemp[ pCut->iMat ] = pCut;
125  return pCut;
126 }
static void Vec_IntPushOrder(Vec_Int_t *p, int Entry)
Definition: vecInt.h:751
Vec_Int_t * vTemp
Definition: amapInt.h:99
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
Amap_Cut_t ** ppCutsTemp
Definition: amapInt.h:101
unsigned fInv
Definition: amapInt.h:186
unsigned nFans
Definition: amapInt.h:187
unsigned iMat
Definition: amapInt.h:185
struct Amap_Cut_t_ Amap_Cut_t
Definition: amapInt.h:72
#define assert(ex)
Definition: util_old.h:213
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
int Fans[0]
Definition: amapInt.h:188
static Amap_Cut_t ** Amap_ManCutNextP(Amap_Cut_t *pCut)
Definition: amapInt.h:270
Amap_Cut_t* Amap_ManCutCreate3 ( Amap_Man_t p,
Amap_Cut_t pCut0,
Amap_Cut_t pCut1,
Amap_Cut_t pCut2,
int  iMat 
)

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

Synopsis [Creates new cut and adds it to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file amapMerge.c.

141 {
142  Amap_Cut_t * pCut;
143  int i, nSize = pCut0->nFans + pCut1->nFans + pCut2->nFans;
144  int nBytes = sizeof(Amap_Cut_t) + sizeof(int) * nSize + sizeof(Amap_Cut_t *);
145  pCut = (Amap_Cut_t *)Aig_MmFlexEntryFetch( p->pMemTemp, nBytes );
146  pCut->iMat = iMat;
147  pCut->fInv = 0;
148  pCut->nFans = nSize;
149  for ( i = 0; i < (int)pCut0->nFans; i++ )
150  pCut->Fans[i] = pCut0->Fans[i];
151  for ( i = 0; i < (int)pCut1->nFans; i++ )
152  pCut->Fans[pCut0->nFans+i] = pCut1->Fans[i];
153  for ( i = 0; i < (int)pCut2->nFans; i++ )
154  pCut->Fans[pCut0->nFans+pCut1->nFans+i] = pCut2->Fans[i];
155  // add it to storage
156  if ( p->ppCutsTemp[ pCut->iMat ] == NULL )
157  Vec_IntPushOrder( p->vTemp, pCut->iMat );
158  *Amap_ManCutNextP( pCut ) = p->ppCutsTemp[ pCut->iMat ];
159  p->ppCutsTemp[ pCut->iMat ] = pCut;
160  return pCut;
161 }
static void Vec_IntPushOrder(Vec_Int_t *p, int Entry)
Definition: vecInt.h:751
Vec_Int_t * vTemp
Definition: amapInt.h:99
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
Amap_Cut_t ** ppCutsTemp
Definition: amapInt.h:101
unsigned nFans
Definition: amapInt.h:187
struct Amap_Cut_t_ Amap_Cut_t
Definition: amapInt.h:72
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
int Fans[0]
Definition: amapInt.h:188
static Amap_Cut_t ** Amap_ManCutNextP(Amap_Cut_t *pCut)
Definition: amapInt.h:270
void Amap_ManCutSaveStored ( Amap_Man_t p,
Amap_Obj_t pNode 
)

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

Synopsis [Removes cuts from the temporary storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file amapMerge.c.

175 {
176  int nMaxCuts = p->pPars->nCutsMax;
177  int * pBuffer;
178  Amap_Cut_t * pNext, * pCut;
179  int i, nWords, Entry, nCuts, nCuts2;
180  assert( pNode->pData == NULL );
181  // count memory needed
182  nCuts = 1;
183  nWords = 2;
184  Vec_IntForEachEntry( p->vTemp, Entry, i )
185  {
186  for ( pCut = p->ppCutsTemp[Entry]; pCut; pCut = *Amap_ManCutNextP(pCut) )
187  {
188  nCuts++;
189  if ( nCuts < nMaxCuts )
190  nWords += pCut->nFans + 1;
191  }
192  }
193  p->nBytesUsed += 4*nWords;
194  // allocate memory
195  pBuffer = (int *)Aig_MmFlexEntryFetch( p->pMemCuts, 4*nWords );
196  pNext = (Amap_Cut_t *)pBuffer;
197  // add the first cut
198  pNext->iMat = 0;
199  pNext->fInv = 0;
200  pNext->nFans = 1;
201  pNext->Fans[0] = Abc_Var2Lit(pNode->Id, 0);
202  pNext = (Amap_Cut_t *)(pBuffer + 2);
203  // add other cuts
204  nCuts2 = 1;
205  Vec_IntForEachEntry( p->vTemp, Entry, i )
206  {
207  for ( pCut = p->ppCutsTemp[Entry]; pCut; pCut = *Amap_ManCutNextP(pCut) )
208  {
209  nCuts2++;
210  if ( nCuts2 < nMaxCuts )
211  {
212  memcpy( pNext, pCut, sizeof(int) * (pCut->nFans + 1) );
213  pNext = (Amap_Cut_t *)((int *)pNext + pCut->nFans + 1);
214  }
215  }
216  p->ppCutsTemp[Entry] = NULL;
217  }
218  assert( nCuts == nCuts2 );
219  assert( (int *)pNext - pBuffer == nWords );
220  // restore the storage
221  Vec_IntClear( p->vTemp );
223  for ( i = 0; i < 2*p->pLib->nNodes; i++ )
224  if ( p->ppCutsTemp[i] != NULL )
225  printf( "Amap_ManCutSaveStored(): Error!\n" );
226  pNode->pData = (Amap_Cut_t *)pBuffer;
227  pNode->nCuts = Abc_MinInt( nCuts, nMaxCuts-1 );
228  assert( nCuts < (1<<20) );
229 // printf("%d ", nCuts );
230  // verify cuts
231  pCut = NULL;
232  Amap_NodeForEachCut( pNode, pNext, i )
233 // for ( i = 0, pNext = (Amap_Cut_t *)pNode->pData; i < (int)pNode->nCuts;
234 // i++, pNext = Amap_ManCutNext(pNext) )
235  {
236  if ( i == nMaxCuts )
237  break;
238  assert( pCut == NULL || pCut->iMat <= pNext->iMat );
239  pCut = pNext;
240  }
241 }
Vec_Int_t * vTemp
Definition: amapInt.h:99
void Aig_MmFlexRestart(Aig_MmFlex_t *p)
Definition: aigMem.c:411
Aig_MmFlex_t * pMemCuts
Definition: amapInt.h:90
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
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
unsigned Id
Definition: amapInt.h:201
char * memcpy()
int nWords
Definition: abcNpn.c:127
Amap_Cut_t ** ppCutsTemp
Definition: amapInt.h:101
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
void * pData
Definition: amapInt.h:212
Amap_Lib_t * pLib
Definition: amapInt.h:79
unsigned nCuts
Definition: amapInt.h:207
unsigned fInv
Definition: amapInt.h:186
int nBytesUsed
Definition: amapInt.h:110
unsigned nFans
Definition: amapInt.h:187
Amap_Par_t * pPars
Definition: amapInt.h:78
unsigned iMat
Definition: amapInt.h:185
#define assert(ex)
Definition: util_old.h:213
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
int nCutsMax
Definition: amap.h:49
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Fans[0]
Definition: amapInt.h:188
static Amap_Cut_t ** Amap_ManCutNextP(Amap_Cut_t *pCut)
Definition: amapInt.h:270
Amap_Cut_t* Amap_ManCutStore ( Amap_Man_t p,
Amap_Cut_t pCut,
int  fCompl 
)

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

Synopsis [Creates new cut and adds it to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file amapMerge.c.

77 {
78  Amap_Cut_t * pNew;
79  int iFan, nBytes = sizeof(Amap_Cut_t) + sizeof(int) * pCut->nFans + sizeof(Amap_Cut_t *);
80  pNew = (Amap_Cut_t *)Aig_MmFlexEntryFetch( p->pMemTemp, nBytes );
81  pNew->iMat = pCut->iMat;
82  pNew->fInv = pCut->fInv ^ fCompl;
83  pNew->nFans = pCut->nFans;
84  memcpy( pNew->Fans, pCut->Fans, sizeof(int) * pCut->nFans );
85  // add it to storage
86  iFan = Abc_Var2Lit( pNew->iMat, pNew->fInv );
87  if ( p->ppCutsTemp[ iFan ] == NULL )
88  Vec_IntPushOrder( p->vTemp, iFan );
89  *Amap_ManCutNextP( pNew ) = p->ppCutsTemp[ iFan ];
90  p->ppCutsTemp[ iFan ] = pNew;
91  return pNew;
92 }
static void Vec_IntPushOrder(Vec_Int_t *p, int Entry)
Definition: vecInt.h:751
Vec_Int_t * vTemp
Definition: amapInt.h:99
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()
Amap_Cut_t ** ppCutsTemp
Definition: amapInt.h:101
unsigned fInv
Definition: amapInt.h:186
unsigned nFans
Definition: amapInt.h:187
unsigned iMat
Definition: amapInt.h:185
struct Amap_Cut_t_ Amap_Cut_t
Definition: amapInt.h:72
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
int Fans[0]
Definition: amapInt.h:188
static Amap_Cut_t ** Amap_ManCutNextP(Amap_Cut_t *pCut)
Definition: amapInt.h:270
int Amap_ManFindCut ( Amap_Obj_t pNode,
Amap_Obj_t pFanin,
int  fComplFanin,
int  Val,
Vec_Ptr_t vCuts 
)

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

Synopsis [Derives cuts for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 351 of file amapMerge.c.

352 {
353  Amap_Cut_t * pCut;
354  int c, iCompl, iFan;
355  Vec_PtrClear( vCuts );
356  Amap_NodeForEachCut( pFanin, pCut, c )
357  {
358  iCompl = pCut->fInv ^ fComplFanin;
359  iFan = !pCut->iMat? 0: Abc_Var2Lit( pCut->iMat, iCompl );
360  if ( iFan == Val )
361  Vec_PtrPush( vCuts, pCut );
362  }
363  return Vec_PtrSize(vCuts) == 0;
364 }
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
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 fInv
Definition: amapInt.h:186
unsigned iMat
Definition: amapInt.h:185
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Amap_ManMerge ( Amap_Man_t p)

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

Synopsis [Derives cuts for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file amapMerge.c.

515 {
516  Amap_Obj_t * pObj;
517  int i;
518  abctime clk = Abc_Clock();
519  p->pCutsPi = Amap_ManSetupPis( p );
520  Amap_ManForEachNode( p, pObj, i )
521  Amap_ManMergeNodeCuts( p, pObj );
522  if ( p->pPars->fVerbose )
523  {
524  printf( "AIG object is %d bytes. ", (int)sizeof(Amap_Obj_t) );
525  printf( "Internal AIG = %5.2f MB. Cuts = %5.2f MB. CutsMax = %d.\n",
526  1.0*Amap_ManObjNum(p)*sizeof(Amap_Obj_t)/(1<<20), 1.0*p->nBytesUsed/(1<<20), p->pPars->nCutsMax );
527  printf( "Node =%6d. Try =%9d. Try3 =%10d. Used =%7d. R =%6.2f. ",
528  Amap_ManNodeNum(p), p->nCutsTried, p->nCutsTried3, p->nCutsUsed,
529  1.0*p->nCutsUsed/Amap_ManNodeNum(p) );
530 ABC_PRT( "Time ", Abc_Clock() - clk );
531  }
532 }
void Amap_ManMergeNodeCuts(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:443
static abctime Abc_Clock()
Definition: abc_global.h:279
#define Amap_ManForEachNode(p, pObj, i)
Definition: amapInt.h:289
if(last==0)
Definition: sparse_int.h:34
static int Amap_ManNodeNum(Amap_Man_t *p)
Definition: amapInt.h:232
static int Amap_ManObjNum(Amap_Man_t *p)
Definition: amapInt.h:231
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManSetupPis(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapMerge.c:45
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_INT64_T abctime
Definition: abc_global.h:278
Amap_Cut_t * pCutsPi
Definition: amapInt.h:102
int Amap_ManMergeCountCuts ( Amap_Man_t p,
Amap_Obj_t pNode 
)

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

Synopsis [Returns the number of possible new cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 254 of file amapMerge.c.

255 {
256  Amap_Obj_t * pFanin0 = Amap_ObjFanin0( p, pNode );
257  Amap_Obj_t * pFanin1 = Amap_ObjFanin1( p, pNode );
258  Amap_Cut_t * pCut0, * pCut1;
259  int Entry, c0, c1, iCompl0, iCompl1, iFan0, iFan1;
260  int Counter = 1;
261  Amap_NodeForEachCut( pFanin0, pCut0, c0 )
262  Amap_NodeForEachCut( pFanin1, pCut1, c1 )
263  {
264  iCompl0 = pCut0->fInv ^ Amap_ObjFaninC0(pNode);
265  iCompl1 = pCut1->fInv ^ Amap_ObjFaninC1(pNode);
266  iFan0 = !pCut0->iMat? 0: Abc_Var2Lit( pCut0->iMat, iCompl0 );
267  iFan1 = !pCut1->iMat? 0: Abc_Var2Lit( pCut1->iMat, iCompl1 );
268  Entry = Amap_LibFindNode( p->pLib, iFan0, iFan1, pNode->Type == AMAP_OBJ_XOR );
269  Counter += ( Entry >=0 );
270 // if ( Entry >=0 )
271 // printf( "Full: %d + %d = %d\n", iFan0, iFan1, Entry );
272  }
273  return Counter;
274 }
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Amap_Lib_t * pLib
Definition: amapInt.h:79
unsigned Type
Definition: amapInt.h:200
static int Counter
unsigned fInv
Definition: amapInt.h:186
static int Amap_ObjFaninC1(Amap_Obj_t *pObj)
Definition: amapInt.h:252
static Amap_Obj_t * Amap_ObjFanin1(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:249
unsigned iMat
Definition: amapInt.h:185
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
int Amap_LibFindNode(Amap_Lib_t *pLib, int iFan0, int iFan1, int fXor)
Definition: amapUniq.c:90
void Amap_ManMergeNodeChoice ( Amap_Man_t p,
Amap_Obj_t pNode 
)

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

Synopsis [Derives cuts for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file amapMerge.c.

320 {
321  Amap_Obj_t * pTemp;
322  Amap_Cut_t * pCut;
323  int c;
324  // go through the nodes of the choice node
325  for ( pTemp = pNode; pTemp; pTemp = Amap_ObjChoice(p, pTemp) )
326  {
327  Amap_NodeForEachCut( pTemp, pCut, c )
328  {
329  if (!pCut) break; // mikelee added; abort when pCut is NULL
330  if ( pCut->iMat )
331  Amap_ManCutStore( p, pCut, pNode->fPhase ^ pTemp->fPhase );
332  }
333  pTemp->pData = NULL;
334  }
335  Amap_ManCutSaveStored( p, pNode );
336 
337 // Amap_ManPrintCuts( pNode );
338 }
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
Amap_Cut_t * Amap_ManCutStore(Amap_Man_t *p, Amap_Cut_t *pCut, int fCompl)
Definition: amapMerge.c:76
void * pData
Definition: amapInt.h:212
unsigned fPhase
Definition: amapInt.h:203
static Amap_Obj_t * Amap_ObjChoice(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:258
void Amap_ManCutSaveStored(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:174
unsigned iMat
Definition: amapInt.h:185
void Amap_ManMergeNodeCuts ( Amap_Man_t p,
Amap_Obj_t pNode 
)

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

Synopsis [Derives cuts for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 443 of file amapMerge.c.

444 {
445  Amap_Obj_t * pFanin0 = Amap_ObjFanin0( p, pNode );
446  Amap_Obj_t * pFanin1 = Amap_ObjFanin1( p, pNode );
447  Amap_Cut_t * pCut0, * pCut1;
448  int ** pRules, Entry, i, k, c, iCompl0, iCompl1, iFan0, iFan1;
449  assert( pNode->pData == NULL );
450  if ( pNode->Type == AMAP_OBJ_MUX )
451  {
452  Amap_ManMergeNodeCutsMux( p, pNode );
453  return;
454  }
455  assert( pNode->Type != AMAP_OBJ_MUX );
456  pRules = (pNode->Type == AMAP_OBJ_AND)? p->pLib->pRules: p->pLib->pRulesX;
457  Amap_NodeForEachCut( pFanin0, pCut0, c )
458  {
459  iCompl0 = pCut0->fInv ^ Amap_ObjFaninC0(pNode);
460  iFan0 = !pCut0->iMat? 0: Abc_Var2Lit( pCut0->iMat, iCompl0 );
461  // complement literals
462  if ( pCut0->nFans == 1 && iCompl0 )
463  pCut0->Fans[0] = Abc_LitNot(pCut0->Fans[0]);
464  // label resulting sets
465  for ( i = 0; (Entry = pRules[iFan0][i]); i++ )
466  p->pMatsTemp[Entry & 0xffff] = (Entry >> 16);
467  // iterate through the cuts
468  Amap_NodeForEachCut( pFanin1, pCut1, k )
469  {
470  iCompl1 = pCut1->fInv ^ Amap_ObjFaninC1(pNode);
471  iFan1 = !pCut1->iMat? 0: Abc_Var2Lit( pCut1->iMat, iCompl1 );
472  if ( p->pMatsTemp[iFan1] == 0 )
473  continue;
474  // complement literals
475  if ( pCut1->nFans == 1 && iCompl1 )
476  pCut1->Fans[0] = Abc_LitNot(pCut1->Fans[0]);
477  // create new cut
478  if ( iFan0 >= iFan1 )
479  Amap_ManCutCreate( p, pCut0, pCut1, p->pMatsTemp[iFan1] );
480  else
481  Amap_ManCutCreate( p, pCut1, pCut0, p->pMatsTemp[iFan1] );
482  // uncomplement literals
483  if ( pCut1->nFans == 1 && iCompl1 )
484  pCut1->Fans[0] = Abc_LitNot(pCut1->Fans[0]);
485  }
486  // uncomplement literals
487  if ( pCut0->nFans == 1 && iCompl0 )
488  pCut0->Fans[0] = Abc_LitNot(pCut0->Fans[0]);
489  // label resulting sets
490  for ( i = 0; (Entry = pRules[iFan0][i]); i++ )
491  p->pMatsTemp[Entry & 0xffff] = 0;
492  }
493  Amap_ManCutSaveStored( p, pNode );
494  p->nCutsUsed += pNode->nCuts;
495  p->nCutsTried += pFanin0->nCuts * pFanin1->nCuts;
496 // assert( (int)pNode->nCuts == Amap_ManMergeCountCuts(p, pNode) );
497  if ( pNode->fRepr )
498  Amap_ManMergeNodeChoice( p, pNode );
499 
500 // Amap_ManPrintCuts( pNode );
501 }
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int nCutsUsed
Definition: amapInt.h:107
void * pData
Definition: amapInt.h:212
void Amap_ManMergeNodeCutsMux(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:377
Amap_Lib_t * pLib
Definition: amapInt.h:79
void Amap_ManMergeNodeChoice(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:319
unsigned nCuts
Definition: amapInt.h:207
unsigned Type
Definition: amapInt.h:200
unsigned fInv
Definition: amapInt.h:186
unsigned fRepr
Definition: amapInt.h:204
unsigned nFans
Definition: amapInt.h:187
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
void Amap_ManCutSaveStored(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:174
static int Amap_ObjFaninC1(Amap_Obj_t *pObj)
Definition: amapInt.h:252
static Amap_Obj_t * Amap_ObjFanin1(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:249
int nCutsTried
Definition: amapInt.h:108
unsigned iMat
Definition: amapInt.h:185
int * pMatsTemp
Definition: amapInt.h:100
Amap_Cut_t * Amap_ManCutCreate(Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, int iMat)
Definition: amapMerge.c:105
#define assert(ex)
Definition: util_old.h:213
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
int Fans[0]
Definition: amapInt.h:188
void Amap_ManMergeNodeCutsMux ( Amap_Man_t p,
Amap_Obj_t pNode 
)

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

Synopsis [Derives cuts for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 377 of file amapMerge.c.

378 {
379  Vec_Int_t * vRules = p->pLib->vRules3;
380  Amap_Obj_t * pFanin0 = Amap_ObjFanin0( p, pNode );
381  Amap_Obj_t * pFanin1 = Amap_ObjFanin1( p, pNode );
382  Amap_Obj_t * pFanin2 = Amap_ObjFanin2( p, pNode );
383  int fComplFanin0 = Amap_ObjFaninC0( pNode );
384  int fComplFanin1 = Amap_ObjFaninC1( pNode );
385  int fComplFanin2 = Amap_ObjFaninC2( pNode );
386  Amap_Cut_t * pCut0, * pCut1, * pCut2;
387  int x, c0, c1, c2;
388  assert( pNode->pData == NULL );
389  assert( pNode->Type == AMAP_OBJ_MUX );
390  assert( pNode->fRepr == 0 );
391  // go through the rules
392  for ( x = 0; x < Vec_IntSize(vRules); x += 4 )
393  {
394  if ( Amap_ManFindCut( pNode, pFanin0, fComplFanin0, Vec_IntEntry(vRules, x), p->vCuts0 ) )
395  continue;
396  if ( Amap_ManFindCut( pNode, pFanin1, fComplFanin1, Vec_IntEntry(vRules, x+1), p->vCuts1 ) )
397  continue;
398  if ( Amap_ManFindCut( pNode, pFanin2, fComplFanin2, Vec_IntEntry(vRules, x+2), p->vCuts2 ) )
399  continue;
400  Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts0, pCut0, c0 )
401  Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts1, pCut1, c1 )
402  Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts2, pCut2, c2 )
403  {
404  Amap_Nod_t * pNod = Amap_LibNod( p->pLib, Vec_IntEntry(vRules, x+3) );
405  if ( pNod->pSets == NULL )
406  continue;
407  // complement literals
408  if ( pCut0->nFans == 1 && (pCut0->fInv ^ fComplFanin0) )
409  pCut0->Fans[0] = Abc_LitNot(pCut0->Fans[0]);
410  if ( pCut1->nFans == 1 && (pCut1->fInv ^ fComplFanin1) )
411  pCut1->Fans[0] = Abc_LitNot(pCut1->Fans[0]);
412  if ( pCut2->nFans == 1 && (pCut2->fInv ^ fComplFanin2) )
413  pCut2->Fans[0] = Abc_LitNot(pCut2->Fans[0]);
414  // create new cut
415  Amap_ManCutCreate3( p, pCut0, pCut1, pCut2, Vec_IntEntry(vRules, x+3) );
416  // uncomplement literals
417  if ( pCut0->nFans == 1 && (pCut0->fInv ^ fComplFanin0) )
418  pCut0->Fans[0] = Abc_LitNot(pCut0->Fans[0]);
419  if ( pCut1->nFans == 1 && (pCut1->fInv ^ fComplFanin1) )
420  pCut1->Fans[0] = Abc_LitNot(pCut1->Fans[0]);
421  if ( pCut2->nFans == 1 && (pCut2->fInv ^ fComplFanin2) )
422  pCut2->Fans[0] = Abc_LitNot(pCut2->Fans[0]);
423  }
424  }
425  Amap_ManCutSaveStored( p, pNode );
426  p->nCutsUsed += pNode->nCuts;
427  p->nCutsTried3 += pFanin0->nCuts * pFanin1->nCuts * pFanin2->nCuts;
428 
429 // Amap_ManPrintCuts( pNode );
430 }
static int Amap_ObjFaninC2(Amap_Obj_t *pObj)
Definition: amapInt.h:253
Amap_Cut_t * Amap_ManCutCreate3(Amap_Man_t *p, Amap_Cut_t *pCut0, Amap_Cut_t *pCut1, Amap_Cut_t *pCut2, int iMat)
Definition: amapMerge.c:139
int nCutsTried3
Definition: amapInt.h:109
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Ptr_t * vCuts0
Definition: amapInt.h:103
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
int nCutsUsed
Definition: amapInt.h:107
void * pData
Definition: amapInt.h:212
Amap_Lib_t * pLib
Definition: amapInt.h:79
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned nCuts
Definition: amapInt.h:207
unsigned Type
Definition: amapInt.h:200
unsigned fInv
Definition: amapInt.h:186
Vec_Ptr_t * vCuts2
Definition: amapInt.h:105
unsigned fRepr
Definition: amapInt.h:204
int Amap_ManFindCut(Amap_Obj_t *pNode, Amap_Obj_t *pFanin, int fComplFanin, int Val, Vec_Ptr_t *vCuts)
Definition: amapMerge.c:351
unsigned nFans
Definition: amapInt.h:187
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
void Amap_ManCutSaveStored(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:174
static int Amap_ObjFaninC1(Amap_Obj_t *pObj)
Definition: amapInt.h:252
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Amap_Obj_t * Amap_ObjFanin1(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:249
Amap_Set_t * pSets
Definition: amapInt.h:181
static Amap_Obj_t * Amap_ObjFanin2(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:250
#define assert(ex)
Definition: util_old.h:213
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
static Amap_Nod_t * Amap_LibNod(Amap_Lib_t *p, int i)
Definition: amapInt.h:264
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t * vCuts1
Definition: amapInt.h:104
int Fans[0]
Definition: amapInt.h:188
void Amap_ManPrintCuts ( Amap_Obj_t pNode)

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

Synopsis [Print cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file amapMerge.c.

288 {
289  Amap_Cut_t * pCut;
290  int c, i;
291  printf( "NODE %5d : Type = ", pNode->Id );
292  if ( pNode->Type == AMAP_OBJ_AND )
293  printf( "AND" );
294  else if ( pNode->Type == AMAP_OBJ_XOR )
295  printf( "XOR" );
296  else if ( pNode->Type == AMAP_OBJ_MUX )
297  printf( "MUX" );
298  printf( " Cuts = %d\n", pNode->nCuts );
299  Amap_NodeForEachCut( pNode, pCut, c )
300  {
301  printf( "%3d : Mat= %3d Inv=%d ", c, pCut->iMat, pCut->fInv );
302  for ( i = 0; i < (int)pCut->nFans; i++ )
303  printf( "%d%c ", Abc_Lit2Var(pCut->Fans[i]), Abc_LitIsCompl(pCut->Fans[i])?'-':'+' );
304  printf( "\n" );
305  }
306 }
#define Amap_NodeForEachCut(pNode, pCut, i)
Definition: amapInt.h:300
unsigned Id
Definition: amapInt.h:201
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned nCuts
Definition: amapInt.h:207
unsigned Type
Definition: amapInt.h:200
unsigned fInv
Definition: amapInt.h:186
unsigned nFans
Definition: amapInt.h:187
unsigned iMat
Definition: amapInt.h:185
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Fans[0]
Definition: amapInt.h:188
ABC_NAMESPACE_IMPL_START Amap_Cut_t* Amap_ManSetupPis ( Amap_Man_t p)

DECLARATIONS ///.

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

FileName [amapMerge.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Computing cuts for the node.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Creates new cut and adds it to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapMerge.c.

46 {
47  Amap_Obj_t * pObj;
48  Amap_Cut_t * pCut;
49  int i, nBytes = sizeof(Amap_Cut_t) + sizeof(int);
50  char * pBuffer = ABC_ALLOC( char, Amap_ManPiNum(p) * nBytes );
51  Amap_ManForEachPi( p, pObj, i )
52  {
53  pCut = (Amap_Cut_t *)( pBuffer + i*nBytes );
54  pCut->iMat = 0;
55  pCut->fInv = 0;
56  pCut->nFans = 1;
57  pCut->Fans[0] = Abc_Var2Lit( pObj->Id, 0 );
58  pObj->pData = pCut;
59  pObj->nCuts = 1;
60  pObj->EstRefs = (float)1.0;
61  }
62  return (Amap_Cut_t *)pBuffer;
63 }
float EstRefs
Definition: amapInt.h:216
static int Amap_ManPiNum(Amap_Man_t *p)
Definition: amapInt.h:226
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
unsigned Id
Definition: amapInt.h:201
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Amap_ManForEachPi(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: amapInt.h:280
void * pData
Definition: amapInt.h:212
unsigned nCuts
Definition: amapInt.h:207
unsigned fInv
Definition: amapInt.h:186
unsigned nFans
Definition: amapInt.h:187
unsigned iMat
Definition: amapInt.h:185
struct Amap_Cut_t_ Amap_Cut_t
Definition: amapInt.h:72
int Fans[0]
Definition: amapInt.h:188