abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcFraig.c File Reference
#include "base/abc/abc.h"
#include "proof/fraig/fraig.h"
#include "base/main/main.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Abc_Ntk_t
Abc_NtkFromFraig (Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
static Abc_Ntk_tAbc_NtkFromFraig2 (Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
 
static Abc_Obj_tAbc_NodeFromFraig_rec (Abc_Ntk_t *pNtkNew, Fraig_Node_t *pNodeFraig)
 
static void Abc_NtkFromFraig2_rec (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode, Vec_Ptr_t *vNodeReprs)
 
Fraig_Node_tAbc_NtkToFraigExdc (Fraig_Man_t *pMan, Abc_Ntk_t *pNtkMain, Abc_Ntk_t *pNtkExdc)
 
static void Abc_NtkFraigRemapUsingExdc (Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
 
static int Abc_NtkFraigTrustCheck (Abc_Ntk_t *pNtk)
 
static void Abc_NtkFraigTrustOne (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
 
static Abc_Obj_tAbc_NodeFraigTrust (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
 
Abc_Ntk_tAbc_NtkFraig (Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
 FUNCTION DEFINITIONS ///. More...
 
void * Abc_NtkToFraig (Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
 
Abc_Ntk_tAbc_NtkFraigTrust (Abc_Ntk_t *pNtk)
 
int Abc_NtkFraigStore (Abc_Ntk_t *pNtkAdd)
 
Abc_Ntk_tAbc_NtkFraigRestore ()
 
void Abc_NtkFraigStoreClean ()
 
void Abc_NtkFraigStoreCheck (Abc_Ntk_t *pFraig)
 

Function Documentation

Abc_Obj_t * Abc_NodeFraigTrust ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNode 
)
static

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

Synopsis [Transforms one node into a FRAIG in the trust mode.]

Description []

SideEffects []

SeeAlso []

Definition at line 601 of file abcFraig.c.

602 {
603  Abc_Obj_t * pSum, * pFanin;
604  void ** ppTail;
605  int i, nFanins, fCompl;
606 
607  assert( Abc_ObjIsNode(pNode) );
608  // get the number of node's fanins
609  nFanins = Abc_ObjFaninNum( pNode );
610  assert( nFanins == Abc_SopGetVarNum((char *)pNode->pData) );
611  // check if it is a constant
612  if ( nFanins == 0 )
613  return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Abc_SopIsConst0((char *)pNode->pData) );
614  if ( nFanins == 1 )
615  return Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_SopIsInv((char *)pNode->pData) );
616  if ( nFanins == 2 && Abc_SopIsAndType((char *)pNode->pData) )
617  return Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc,
618  Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, !Abc_SopGetIthCareLit((char *)pNode->pData,0) ),
619  Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, !Abc_SopGetIthCareLit((char *)pNode->pData,1) ) );
620  assert( Abc_SopIsOrType((char *)pNode->pData) );
621  fCompl = Abc_SopGetIthCareLit((char *)pNode->pData,0);
622  // get the root of the choice node (the first fanin)
623  pSum = Abc_ObjFanin0(pNode)->pCopy;
624  // connect other fanins
625  ppTail = &pSum->pData;
626  Abc_ObjForEachFanin( pNode, pFanin, i )
627  {
628  if ( i == 0 )
629  continue;
630  *ppTail = pFanin->pCopy;
631  ppTail = &pFanin->pCopy->pData;
632  // set the complemented bit of this cut
633  if ( fCompl ^ Abc_SopGetIthCareLit((char *)pNode->pData, i) )
634  pFanin->pCopy->fPhase = 1;
635  }
636  assert( *ppTail == NULL );
637  return pSum;
638 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
ABC_DLL int Abc_SopIsOrType(char *pSop)
Definition: abcSop.c:772
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL int Abc_SopIsInv(char *pSop)
Definition: abcSop.c:728
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
DECLARATIONS ///.
Definition: abcAig.c:52
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL int Abc_SopIsConst0(char *pSop)
Definition: abcSop.c:676
ABC_DLL int Abc_SopGetIthCareLit(char *pSop, int i)
Definition: abcSop.c:578
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
ABC_DLL int Abc_SopIsAndType(char *pSop)
Definition: abcSop.c:748
void * pData
Definition: abc.h:145
unsigned fPhase
Definition: abc.h:137
Abc_Obj_t * Abc_NodeFromFraig_rec ( Abc_Ntk_t pNtkNew,
Fraig_Node_t pNodeFraig 
)
static

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

Synopsis [Transforms into AIG one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file abcFraig.c.

317 {
318  Abc_Obj_t * pRes, * pRes0, * pRes1, * pResMin, * pResCur;
319  Fraig_Node_t * pNodeTemp, * pNodeFraigR = Fraig_Regular(pNodeFraig);
320  void ** ppTail;
321  // check if the node was already considered
322  if ( (pRes = (Abc_Obj_t *)Fraig_NodeReadData1(pNodeFraigR)) )
323  return Abc_ObjNotCond( pRes, Fraig_IsComplement(pNodeFraig) );
324  // solve the children
325  pRes0 = Abc_NodeFromFraig_rec( pNtkNew, Fraig_NodeReadOne(pNodeFraigR) );
326  pRes1 = Abc_NodeFromFraig_rec( pNtkNew, Fraig_NodeReadTwo(pNodeFraigR) );
327  // derive the new node
328  pRes = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pRes0, pRes1 );
329  pRes->fPhase = Fraig_NodeReadSimInv( pNodeFraigR );
330  // if the node has an equivalence class, find its representative
331  if ( Fraig_NodeReadRepr(pNodeFraigR) == NULL && Fraig_NodeReadNextE(pNodeFraigR) != NULL )
332  {
333  // go through the FRAIG nodes belonging to this equivalence class
334  // and find the representative node (the node with the smallest level)
335  pResMin = pRes;
336  for ( pNodeTemp = Fraig_NodeReadNextE(pNodeFraigR); pNodeTemp; pNodeTemp = Fraig_NodeReadNextE(pNodeTemp) )
337  {
338  assert( Fraig_NodeReadData1(pNodeTemp) == NULL );
339  pResCur = Abc_NodeFromFraig_rec( pNtkNew, pNodeTemp );
340  if ( pResMin->Level > pResCur->Level )
341  pResMin = pResCur;
342  }
343  // link the nodes in such a way that representative goes first
344  ppTail = &pResMin->pData;
345  if ( pRes != pResMin )
346  {
347  *ppTail = pRes;
348  ppTail = &pRes->pData;
349  }
350  for ( pNodeTemp = Fraig_NodeReadNextE(pNodeFraigR); pNodeTemp; pNodeTemp = Fraig_NodeReadNextE(pNodeTemp) )
351  {
352  pResCur = (Abc_Obj_t *)Fraig_NodeReadData1(pNodeTemp);
353  assert( pResCur );
354  if ( pResMin == pResCur )
355  continue;
356  *ppTail = pResCur;
357  ppTail = &pResCur->pData;
358  }
359  assert( *ppTail == NULL );
360 
361  // update the phase of the node
362  pRes = Abc_ObjNotCond( pResMin, (pRes->fPhase ^ pResMin->fPhase) );
363  }
364  Fraig_NodeSetData1( pNodeFraigR, (Fraig_Node_t *)pRes );
365  return Abc_ObjNotCond( pRes, Fraig_IsComplement(pNodeFraig) );
366 }
Fraig_Node_t * Fraig_NodeReadRepr(Fraig_Node_t *p)
Definition: fraigApi.c:114
Fraig_Node_t * Fraig_NodeReadNextE(Fraig_Node_t *p)
Definition: fraigApi.c:113
DECLARATIONS ///.
Definition: abcAig.c:52
unsigned Level
Definition: abc.h:142
int Fraig_NodeReadSimInv(Fraig_Node_t *p)
Definition: fraigApi.c:117
Fraig_Node_t * Fraig_NodeReadTwo(Fraig_Node_t *p)
Definition: fraigApi.c:112
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
Fraig_Node_t * Fraig_NodeReadData1(Fraig_Node_t *p)
Definition: fraigApi.c:109
void Fraig_NodeSetData1(Fraig_Node_t *p, Fraig_Node_t *pData)
Definition: fraigApi.c:138
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: fraig.h:107
Fraig_Node_t * Fraig_NodeReadOne(Fraig_Node_t *p)
Definition: fraigApi.c:111
#define Fraig_Regular(p)
Definition: fraig.h:108
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static Abc_Obj_t * Abc_NodeFromFraig_rec(Abc_Ntk_t *pNtkNew, Fraig_Node_t *pNodeFraig)
Definition: abcFraig.c:316
unsigned fPhase
Definition: abc.h:137
Abc_Ntk_t* Abc_NtkFraig ( Abc_Ntk_t pNtk,
void *  pParams,
int  fAllNodes,
int  fExdc 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file abcFraig.c.

59 {
60  Fraig_Params_t * pPars = (Fraig_Params_t *)pParams;
61  Abc_Ntk_t * pNtkNew;
62  Fraig_Man_t * pMan;
63  // check if EXDC is present
64  if ( fExdc && pNtk->pExdc == NULL )
65  fExdc = 0, printf( "Warning: Networks has no EXDC.\n" );
66  // perform fraiging
67  pMan = (Fraig_Man_t *)Abc_NtkToFraig( pNtk, pParams, fAllNodes, fExdc );
68  // add algebraic choices
69 // if ( pPars->fChoicing )
70 // Fraig_ManAddChoices( pMan, 0, 6 );
71  // prove the miter if asked to
72  if ( pPars->fTryProve )
73  Fraig_ManProveMiter( pMan );
74  // reconstruct FRAIG in the new network
75  if ( fExdc )
76  pNtkNew = Abc_NtkFromFraig2( pMan, pNtk );
77  else
78  pNtkNew = Abc_NtkFromFraig( pMan, pNtk );
79  Fraig_ManFree( pMan );
80  if ( pNtk->pExdc )
81  pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
82  // make sure that everything is okay
83  if ( !Abc_NtkCheck( pNtkNew ) )
84  {
85  printf( "Abc_NtkFraig: The network check has failed.\n" );
86  Abc_NtkDelete( pNtkNew );
87  return NULL;
88  }
89  return pNtkNew;
90 }
typedefABC_NAMESPACE_HEADER_START struct Fraig_ManStruct_t_ Fraig_Man_t
INCLUDES ///.
Definition: fraig.h:40
Abc_Ntk_t * pExdc
Definition: abc.h:201
void Fraig_ManFree(Fraig_Man_t *pMan)
Definition: fraigMan.c:262
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkFromFraig(Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcFraig.c:279
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
void * Abc_NtkToFraig(Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
Definition: abcFraig.c:103
static Abc_Ntk_t * Abc_NtkFromFraig2(Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
Definition: abcFraig.c:379
void Fraig_ManProveMiter(Fraig_Man_t *p)
Definition: fraigSat.c:85
void Abc_NtkFraigRemapUsingExdc ( Fraig_Man_t pMan,
Abc_Ntk_t pNtk 
)
static

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

Synopsis [Changes mapping of the old nodes into FRAIG nodes using EXDC.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file abcFraig.c.

213 {
214  Fraig_Node_t * gNodeNew, * gNodeExdc;
215  stmm_table * tTable;
216  stmm_generator * gen;
217  Abc_Obj_t * pNode, * pNodeBest;
218  Abc_Obj_t * pClass, ** ppSlot;
219  Vec_Ptr_t * vNexts;
220  int i;
221 
222  // get the global don't-cares
223  assert( pNtk->pExdc );
224  gNodeExdc = Abc_NtkToFraigExdc( pMan, pNtk, pNtk->pExdc );
225 
226  // save the next pointers
227  vNexts = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
228  Abc_NtkForEachNode( pNtk, pNode, i )
229  Vec_PtrWriteEntry( vNexts, pNode->Id, pNode->pNext );
230 
231  // find the classes of AIG nodes which have FRAIG nodes assigned
232  Abc_NtkCleanNext( pNtk );
234  Abc_NtkForEachNode( pNtk, pNode, i )
235  if ( pNode->pCopy )
236  {
237  gNodeNew = Fraig_NodeAnd( pMan, (Fraig_Node_t *)pNode->pCopy, Fraig_Not(gNodeExdc) );
238  if ( !stmm_find_or_add( tTable, (char *)Fraig_Regular(gNodeNew), (char ***)&ppSlot ) )
239  *ppSlot = NULL;
240  pNode->pNext = *ppSlot;
241  *ppSlot = pNode;
242  }
243 
244  // for reach non-trival class, find the node with minimum level, and replace other nodes by it
245  Abc_AigSetNodePhases( pNtk );
246  stmm_foreach_item( tTable, gen, (char **)&gNodeNew, (char **)&pClass )
247  {
248  if ( pClass->pNext == NULL )
249  continue;
250  // find the node with minimum level
251  pNodeBest = pClass;
252  for ( pNode = pClass->pNext; pNode; pNode = pNode->pNext )
253  if ( pNodeBest->Level > pNode->Level )
254  pNodeBest = pNode;
255  // remap the class nodes
256  for ( pNode = pClass; pNode; pNode = pNode->pNext )
257  pNode->pCopy = Abc_ObjNotCond( pNodeBest->pCopy, pNode->fPhase ^ pNodeBest->fPhase );
258  }
259  stmm_free_table( tTable );
260 
261  // restore the next pointers
262  Abc_NtkCleanNext( pNtk );
263  Abc_NtkForEachNode( pNtk, pNode, i )
264  pNode->pNext = (Abc_Obj_t *)Vec_PtrEntry( vNexts, pNode->Id );
265  Vec_PtrFree( vNexts );
266 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition: stmm.c:69
Abc_Ntk_t * pExdc
Definition: abc.h:201
unsigned Level
Definition: abc.h:142
Fraig_Node_t * Abc_NtkToFraigExdc(Fraig_Man_t *pMan, Abc_Ntk_t *pNtkMain, Abc_Ntk_t *pNtkExdc)
Definition: abcFraig.c:164
#define Fraig_Not(p)
Definition: fraig.h:109
Fraig_Node_t * Fraig_NodeAnd(Fraig_Man_t *p, Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition: fraigApi.c:212
Abc_Obj_t * pCopy
Definition: abc.h:148
int stmm_ptrhash(const char *x, int size)
Definition: stmm.c:533
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_NtkCleanNext(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:636
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition: stmm.c:266
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int stmm_ptrcmp(const char *x, const char *y)
Definition: stmm.c:545
void stmm_free_table(stmm_table *table)
Definition: stmm.c:79
#define Fraig_Regular(p)
Definition: fraig.h:108
Abc_Obj_t * pNext
Definition: abc.h:131
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
#define stmm_foreach_item(table, gen, key, value)
Definition: stmm.h:121
ABC_DLL void Abc_AigSetNodePhases(Abc_Ntk_t *pNtk)
Definition: abcAig.c:1389
unsigned fPhase
Definition: abc.h:137
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Abc_NtkFraigRestore ( )

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 694 of file abcFraig.c.

695 {
696  extern Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams );
697  Fraig_Params_t Params;
698  Vec_Ptr_t * vStore;
699  Abc_Ntk_t * pNtk, * pFraig;
700  int nWords1, nWords2, nWordsMin;
701 // abctime clk = Abc_Clock();
702 
703  // get the stored network
704  vStore = Abc_FrameReadStore();
705  if ( Vec_PtrSize(vStore) == 0 )
706  {
707  printf( "There are no network currently in storage.\n" );
708  return NULL;
709  }
710 // printf( "Currently stored %d networks will be fraiged.\n", Vec_PtrSize(vStore) );
711  pNtk = (Abc_Ntk_t *)Vec_PtrEntry( vStore, 0 );
712 
713  // swap the first and last network
714  // this should lead to the primary choice being "better" because of synthesis
715  if ( Vec_PtrSize(vStore) > 1 )
716  {
717  pNtk = (Abc_Ntk_t *)Vec_PtrPop( vStore );
718  Vec_PtrPush( vStore, Vec_PtrEntry(vStore,0) );
719  Vec_PtrWriteEntry( vStore, 0, pNtk );
720  }
721 
722  // to determine the number of simulation patterns
723  // use the following strategy
724  // at least 64 words (32 words random and 32 words dynamic)
725  // no more than 256M for one circuit (128M + 128M)
726  nWords1 = 32;
727  nWords2 = (1<<27) / (Abc_NtkNodeNum(pNtk) + Abc_NtkCiNum(pNtk));
728  nWordsMin = Abc_MinInt( nWords1, nWords2 );
729 
730  // set parameters for fraiging
731  Fraig_ParamsSetDefault( &Params );
732  Params.nPatsRand = nWordsMin * 32; // the number of words of random simulation info
733  Params.nPatsDyna = nWordsMin * 32; // the number of words of dynamic simulation info
734  Params.nBTLimit = 1000; // the max number of backtracks to perform
735  Params.fFuncRed = 1; // performs only one level hashing
736  Params.fFeedBack = 1; // enables solver feedback
737  Params.fDist1Pats = 1; // enables distance-1 patterns
738  Params.fDoSparse = 1; // performs equiv tests for sparse functions
739  Params.fChoicing = 1; // enables recording structural choices
740  Params.fTryProve = 0; // tries to solve the final miter
741  Params.fInternal = 1; // does not show progress bar
742  Params.fVerbose = 0; // the verbosiness flag
743 
744  // perform partitioned computation of structural choices
745  pFraig = Abc_NtkFraigPartitioned( vStore, &Params );
747 //ABC_PRT( "Total choicing time", Abc_Clock() - clk );
748  return pFraig;
749 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
void Abc_NtkFraigStoreClean()
Definition: abcFraig.c:762
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
void Fraig_ParamsSetDefault(Fraig_Params_t *pParams)
Definition: fraigMan.c:122
Abc_Ntk_t * Abc_NtkFraigPartitioned(Vec_Ptr_t *vStore, void *pParams)
Definition: abcPart.c:1098
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
ABC_DLL Vec_Ptr_t * Abc_FrameReadStore()
FUNCTION DEFINITIONS ///.
Definition: mainFrame.c:52
int Abc_NtkFraigStore ( Abc_Ntk_t pNtkAdd)

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 654 of file abcFraig.c.

655 {
656  Vec_Ptr_t * vStore;
657  Abc_Ntk_t * pNtk;
658  // create the network to be stored
659  pNtk = Abc_NtkStrash( pNtkAdd, 0, 0, 0 );
660  if ( pNtk == NULL )
661  {
662  printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" );
663  return 0;
664  }
665  // get the network currently stored
666  vStore = Abc_FrameReadStore();
667  if ( Vec_PtrSize(vStore) > 0 )
668  {
669  // check that the networks have the same PIs
670  // reorder PIs of pNtk2 according to pNtk1
671  if ( !Abc_NtkCompareSignals( pNtk, (Abc_Ntk_t *)Vec_PtrEntry(vStore, 0), 1, 1 ) )
672  {
673  printf( "Trying to store the network with different primary inputs.\n" );
674  printf( "The previously stored networks are deleted and this one is added.\n" );
676  }
677  }
678  Vec_PtrPush( vStore, pNtk );
679 // printf( "The number of AIG nodes added to storage = %5d.\n", Abc_NtkNodeNum(pNtk) );
680  return 1;
681 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Abc_NtkFraigStoreClean()
Definition: abcFraig.c:762
ABC_DLL int Abc_NtkCompareSignals(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOnlyPis, int fComb)
Definition: abcCheck.c:741
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
ABC_DLL Vec_Ptr_t * Abc_FrameReadStore()
FUNCTION DEFINITIONS ///.
Definition: mainFrame.c:52
void Abc_NtkFraigStoreCheck ( Abc_Ntk_t pFraig)

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

Synopsis [Checks the correctness of stored networks.]

Description []

SideEffects []

SeeAlso []

Definition at line 784 of file abcFraig.c.

785 {
786  Abc_Obj_t * pNode0, * pNode1;
787  int nPoOrig, nPoFinal, nStored;
788  int i, k;
789  // check that the PO functions are correct
790  nPoFinal = Abc_NtkPoNum(pFraig);
791  nStored = Abc_FrameReadStoreSize();
792  assert( nPoFinal % nStored == 0 );
793  nPoOrig = nPoFinal / nStored;
794  for ( i = 0; i < nPoOrig; i++ )
795  {
796  pNode0 = Abc_ObjFanin0( Abc_NtkPo(pFraig, i) );
797  for ( k = 1; k < nStored; k++ )
798  {
799  pNode1 = Abc_ObjFanin0( Abc_NtkPo(pFraig, k*nPoOrig+i) );
800  if ( pNode0 != pNode1 )
801  printf( "Verification for PO #%d of network #%d has failed. The PO function is not used.\n", i+1, k+1 );
802  }
803  }
804 }
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
#define assert(ex)
Definition: util_old.h:213
ABC_DLL int Abc_FrameReadStoreSize()
Definition: mainFrame.c:53
void Abc_NtkFraigStoreClean ( )

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 762 of file abcFraig.c.

763 {
764  Vec_Ptr_t * vStore;
765  Abc_Ntk_t * pNtk;
766  int i;
767  vStore = Abc_FrameReadStore();
768  Vec_PtrForEachEntry( Abc_Ntk_t *, vStore, pNtk, i )
769  Abc_NtkDelete( pNtk );
770  Vec_PtrClear( vStore );
771 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL Vec_Ptr_t * Abc_FrameReadStore()
FUNCTION DEFINITIONS ///.
Definition: mainFrame.c:52
Abc_Ntk_t* Abc_NtkFraigTrust ( Abc_Ntk_t pNtk)

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 485 of file abcFraig.c.

486 {
487  Abc_Ntk_t * pNtkNew;
488 
489  if ( !Abc_NtkIsSopLogic(pNtk) )
490  {
491  printf( "Abc_NtkFraigTrust: Trust mode works for netlists and logic SOP networks.\n" );
492  return NULL;
493  }
494 
495  if ( !Abc_NtkFraigTrustCheck(pNtk) )
496  {
497  printf( "Abc_NtkFraigTrust: The network does not look like an AIG with choice nodes.\n" );
498  return NULL;
499  }
500 
501  // perform strashing
502  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
503  Abc_NtkFraigTrustOne( pNtk, pNtkNew );
504  Abc_NtkFinalize( pNtk, pNtkNew );
505  Abc_NtkReassignIds( pNtkNew );
506 
507  // print a warning about choice nodes
508  printf( "Warning: The resulting AIG contains %d choice nodes.\n", Abc_NtkGetChoiceNum( pNtkNew ) );
509 
510  // make sure that everything is okay
511  if ( !Abc_NtkCheck( pNtkNew ) )
512  {
513  printf( "Abc_NtkFraigTrust: The network check has failed.\n" );
514  Abc_NtkDelete( pNtkNew );
515  return NULL;
516  }
517  return pNtkNew;
518 }
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:264
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static int Abc_NtkFraigTrustCheck(Abc_Ntk_t *pNtk)
Definition: abcFraig.c:531
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1769
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
static void Abc_NtkFraigTrustOne(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcFraig.c:559
int Abc_NtkFraigTrustCheck ( Abc_Ntk_t pNtk)
static

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

Synopsis [Checks whether the node can be processed in the trust mode.]

Description []

SideEffects []

SeeAlso []

Definition at line 531 of file abcFraig.c.

532 {
533  Abc_Obj_t * pNode;
534  int i, nFanins;
535  Abc_NtkForEachNode( pNtk, pNode, i )
536  {
537  nFanins = Abc_ObjFaninNum(pNode);
538  if ( nFanins < 2 )
539  continue;
540  if ( nFanins == 2 && Abc_SopIsAndType((char *)pNode->pData) )
541  continue;
542  if ( !Abc_SopIsOrType((char *)pNode->pData) )
543  return 0;
544  }
545  return 1;
546 }
ABC_DLL int Abc_SopIsOrType(char *pSop)
Definition: abcSop.c:772
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_SopIsAndType(char *pSop)
Definition: abcSop.c:748
void * pData
Definition: abc.h:145
void Abc_NtkFraigTrustOne ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)
static

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

Synopsis [Interfaces the network with the FRAIG package.]

Description []

SideEffects []

SeeAlso []

Definition at line 559 of file abcFraig.c.

560 {
561  ProgressBar * pProgress;
562  Vec_Ptr_t * vNodes;
563  Abc_Obj_t * pNode, * pNodeNew, * pObj;
564  int i;
565 
566  // perform strashing
567  vNodes = Abc_NtkDfs( pNtk, 0 );
568  pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
569  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
570  {
571  Extra_ProgressBarUpdate( pProgress, i, NULL );
572  // get the node
573  assert( Abc_ObjIsNode(pNode) );
574  // strash the node
575  pNodeNew = Abc_NodeFraigTrust( pNtkNew, pNode );
576  // get the old object
577  if ( Abc_NtkIsNetlist(pNtk) )
578  pObj = Abc_ObjFanout0( pNode ); // the fanout net
579  else
580  pObj = pNode; // the node itself
581  // make sure the node is not yet strashed
582  assert( pObj->pCopy == NULL );
583  // mark the old object with the new AIG node
584  pObj->pCopy = pNodeNew;
585  }
586  Vec_PtrFree( vNodes );
587  Extra_ProgressBarStop( pProgress );
588 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
DECLARATIONS ///.
Abc_Obj_t * pCopy
Definition: abc.h:148
static Abc_Obj_t * Abc_NodeFraigTrust(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
Definition: abcFraig.c:601
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t * Abc_NtkFromFraig ( Fraig_Man_t pMan,
Abc_Ntk_t pNtk 
)

DECLARATIONS ///.

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

FileName [abcFraig.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures interfacing with the FRAIG package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Transforms FRAIG into strashed network with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file abcFraig.c.

280 {
281  ProgressBar * pProgress;
282  Abc_Ntk_t * pNtkNew;
283  Abc_Obj_t * pNode, * pNodeNew;
284  int i;
285  // create the new network
286  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
287  // make the mapper point to the new network
288  Abc_NtkForEachCi( pNtk, pNode, i )
289  Fraig_NodeSetData1( Fraig_ManReadIthVar(pMan, i), (Fraig_Node_t *)pNode->pCopy );
290  // set the constant node
292  // process the nodes in topological order
293  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
294  Abc_NtkForEachCo( pNtk, pNode, i )
295  {
296  Extra_ProgressBarUpdate( pProgress, i, NULL );
297  pNodeNew = Abc_NodeFromFraig_rec( pNtkNew, Fraig_ManReadOutputs(pMan)[i] );
298  Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
299  }
300  Extra_ProgressBarStop( pProgress );
301  Abc_NtkReassignIds( pNtkNew );
302  return pNtkNew;
303 }
Fraig_Node_t * Fraig_ManReadConst1(Fraig_Man_t *p)
Definition: fraigApi.c:52
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
Fraig_Node_t ** Fraig_ManReadOutputs(Fraig_Man_t *p)
Definition: fraigApi.c:47
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1769
DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Fraig_Node_t * Fraig_ManReadIthVar(Fraig_Man_t *p, int i)
Definition: fraigApi.c:168
void Fraig_NodeSetData1(Fraig_Node_t *p, Fraig_Node_t *pData)
Definition: fraigApi.c:138
void Extra_ProgressBarStop(ProgressBar *p)
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static Abc_Obj_t * Abc_NodeFromFraig_rec(Abc_Ntk_t *pNtkNew, Fraig_Node_t *pNodeFraig)
Definition: abcFraig.c:316
Abc_Ntk_t * Abc_NtkFromFraig2 ( Fraig_Man_t pMan,
Abc_Ntk_t pNtk 
)
static

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

Synopsis [Transforms FRAIG into strashed network without choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 379 of file abcFraig.c.

380 {
381  ProgressBar * pProgress;
382  stmm_table * tTable;
383  Vec_Ptr_t * vNodeReprs;
384  Abc_Ntk_t * pNtkNew;
385  Abc_Obj_t * pNode, * pRepr, ** ppSlot;
386  int i;
387 
388  // map the nodes into their lowest level representives
390  pNode = Abc_AigConst1(pNtk);
391  if ( !stmm_find_or_add( tTable, (char *)Fraig_Regular(pNode->pCopy), (char ***)&ppSlot ) )
392  *ppSlot = pNode;
393  Abc_NtkForEachCi( pNtk, pNode, i )
394  if ( !stmm_find_or_add( tTable, (char *)Fraig_Regular(pNode->pCopy), (char ***)&ppSlot ) )
395  *ppSlot = pNode;
396  Abc_NtkForEachNode( pNtk, pNode, i )
397  if ( pNode->pCopy )
398  {
399  if ( !stmm_find_or_add( tTable, (char *)Fraig_Regular(pNode->pCopy), (char ***)&ppSlot ) )
400  *ppSlot = pNode;
401  else if ( (*ppSlot)->Level > pNode->Level )
402  *ppSlot = pNode;
403  }
404  // save representatives for each node
405  vNodeReprs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
406  Abc_NtkForEachNode( pNtk, pNode, i )
407  if ( pNode->pCopy )
408  {
409  if ( !stmm_lookup( tTable, (char *)Fraig_Regular(pNode->pCopy), (char **)&pRepr ) )
410  assert( 0 );
411  if ( pNode != pRepr )
412  Vec_PtrWriteEntry( vNodeReprs, pNode->Id, pRepr );
413  }
414  stmm_free_table( tTable );
415 
416  // create the new network
417  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
418 
419  // perform strashing
420  Abc_AigSetNodePhases( pNtk );
421  Abc_NtkIncrementTravId( pNtk );
422  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
423  Abc_NtkForEachCo( pNtk, pNode, i )
424  {
425  Extra_ProgressBarUpdate( pProgress, i, NULL );
426  Abc_NtkFromFraig2_rec( pNtkNew, Abc_ObjFanin0(pNode), vNodeReprs );
427  }
428  Extra_ProgressBarStop( pProgress );
429  Vec_PtrFree( vNodeReprs );
430 
431  // finalize the network
432  Abc_NtkFinalize( pNtk, pNtkNew );
433  return pNtkNew;
434 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition: stmm.c:69
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static void Abc_NtkFromFraig2_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode, Vec_Ptr_t *vNodeReprs)
Definition: abcFraig.c:448
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
int stmm_ptrhash(const char *x, int size)
Definition: stmm.c:533
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
void Extra_ProgressBarStop(ProgressBar *p)
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition: stmm.c:266
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int stmm_ptrcmp(const char *x, const char *y)
Definition: stmm.c:545
void stmm_free_table(stmm_table *table)
Definition: stmm.c:79
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Fraig_Regular(p)
Definition: fraig.h:108
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
ABC_DLL void Abc_AigSetNodePhases(Abc_Ntk_t *pNtk)
Definition: abcAig.c:1389
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkFromFraig2_rec ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNode,
Vec_Ptr_t vNodeReprs 
)
static

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

Synopsis [Transforms into AIG one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 448 of file abcFraig.c.

449 {
450  Abc_Obj_t * pRepr;
451  // skip the PIs and constants
452  if ( Abc_ObjFaninNum(pNode) < 2 )
453  return;
454  // if this node is already visited, skip
455  if ( Abc_NodeIsTravIdCurrent( pNode ) )
456  return;
457  // mark the node as visited
458  Abc_NodeSetTravIdCurrent( pNode );
459  assert( Abc_ObjIsNode( pNode ) );
460  // get the node's representative
461  if ( (pRepr = (Abc_Obj_t *)Vec_PtrEntry(vNodeReprs, pNode->Id)) )
462  {
463  Abc_NtkFromFraig2_rec( pNtkNew, pRepr, vNodeReprs );
464  pNode->pCopy = Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pNode->fPhase );
465  return;
466  }
467  Abc_NtkFromFraig2_rec( pNtkNew, Abc_ObjFanin0(pNode), vNodeReprs );
468  Abc_NtkFromFraig2_rec( pNtkNew, Abc_ObjFanin1(pNode), vNodeReprs );
469  pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
470 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static void Abc_NtkFromFraig2_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode, Vec_Ptr_t *vNodeReprs)
Definition: abcFraig.c:448
static Abc_Obj_t * Abc_ObjChild1Copy(Abc_Obj_t *pObj)
Definition: abc.h:387
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
DECLARATIONS ///.
Definition: abcAig.c:52
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Abc_Obj_t * Abc_ObjChild0Copy(Abc_Obj_t *pObj)
Definition: abc.h:386
Abc_Obj_t * pCopy
Definition: abc.h:148
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
int Id
Definition: abc.h:132
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
unsigned fPhase
Definition: abc.h:137
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void* Abc_NtkToFraig ( Abc_Ntk_t pNtk,
void *  pParams,
int  fAllNodes,
int  fExdc 
)

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

Synopsis [Transforms the strashed network into FRAIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file abcFraig.c.

104 {
105  int fInternal = ((Fraig_Params_t *)pParams)->fInternal;
106  Fraig_Man_t * pMan;
107  ProgressBar * pProgress = NULL;
108  Vec_Ptr_t * vNodes;
109  Abc_Obj_t * pNode;
110  int i;
111 
112  assert( Abc_NtkIsStrash(pNtk) );
113 
114  // create the FRAIG manager
115  pMan = Fraig_ManCreate( (Fraig_Params_t *)pParams );
116 
117  // map the constant node
118  Abc_NtkCleanCopy( pNtk );
120  // create PIs and remember them in the old nodes
121  Abc_NtkForEachCi( pNtk, pNode, i )
122  pNode->pCopy = (Abc_Obj_t *)Fraig_ManReadIthVar(pMan, i);
123 
124  // perform strashing
125  vNodes = Abc_AigDfs( pNtk, fAllNodes, 0 );
126  if ( !fInternal )
127  pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
128  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
129  {
130  if ( Abc_ObjFaninNum(pNode) == 0 )
131  continue;
132  if ( pProgress )
133  Extra_ProgressBarUpdate( pProgress, i, NULL );
134  pNode->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan,
135  Fraig_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) ),
136  Fraig_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) ) );
137  }
138  if ( pProgress )
139  Extra_ProgressBarStop( pProgress );
140  Vec_PtrFree( vNodes );
141 
142  // use EXDC to change the mapping of nodes into FRAIG nodes
143  if ( fExdc )
144  Abc_NtkFraigRemapUsingExdc( pMan, pNtk );
145 
146  // set the primary outputs
147  Abc_NtkForEachCo( pNtk, pNode, i )
148  Fraig_ManSetPo( pMan, (Fraig_Node_t *)Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ) );
149  return pMan;
150 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
void Fraig_ManSetPo(Fraig_Man_t *p, Fraig_Node_t *pNode)
Definition: fraigApi.c:194
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
Fraig_Node_t * Fraig_ManReadConst1(Fraig_Man_t *p)
Definition: fraigApi.c:52
typedefABC_NAMESPACE_HEADER_START struct Fraig_ManStruct_t_ Fraig_Man_t
INCLUDES ///.
Definition: fraig.h:40
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
DECLARATIONS ///.
static void Abc_NtkFraigRemapUsingExdc(Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
Definition: abcFraig.c:212
Fraig_Node_t * Fraig_NodeAnd(Fraig_Man_t *p, Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition: fraigApi.c:212
Abc_Obj_t * pCopy
Definition: abc.h:148
Fraig_Node_t * Fraig_ManReadIthVar(Fraig_Man_t *p, int i)
Definition: fraigApi.c:168
if(last==0)
Definition: sparse_int.h:34
void Extra_ProgressBarStop(ProgressBar *p)
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition: abcDfs.c:1014
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Fraig_Man_t * Fraig_ManCreate(Fraig_Params_t *pParams)
Definition: fraigMan.c:184
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define Fraig_NotCond(p, c)
Definition: fraig.h:110
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Fraig_Node_t * Abc_NtkToFraigExdc ( Fraig_Man_t pMan,
Abc_Ntk_t pNtkMain,
Abc_Ntk_t pNtkExdc 
)

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

Synopsis [Derives EXDC node for the given network.]

Description [Assumes that EXDCs of all POs are the same. Returns the EXDC of the first PO.]

SideEffects []

SeeAlso []

Definition at line 164 of file abcFraig.c.

165 {
166  Abc_Ntk_t * pNtkStrash;
167  Abc_Obj_t * pObj;
168  Fraig_Node_t * gResult;
169  char ** ppNames;
170  int i, k;
171  // strash the EXDC network
172  pNtkStrash = Abc_NtkStrash( pNtkExdc, 0, 0, 0 );
173  Abc_NtkCleanCopy( pNtkStrash );
174  Abc_AigConst1(pNtkStrash)->pCopy = (Abc_Obj_t *)Fraig_ManReadConst1(pMan);
175  // set the mapping of the PI nodes
176  ppNames = Abc_NtkCollectCioNames( pNtkMain, 0 );
177  Abc_NtkForEachCi( pNtkStrash, pObj, i )
178  {
179  for ( k = 0; k < Abc_NtkCiNum(pNtkMain); k++ )
180  if ( strcmp( Abc_ObjName(pObj), ppNames[k] ) == 0 )
181  {
182  pObj->pCopy = (Abc_Obj_t *)Fraig_ManReadIthVar(pMan, k);
183  break;
184  }
185  assert( pObj->pCopy != NULL );
186  }
187  ABC_FREE( ppNames );
188  // build FRAIG for each node
189  Abc_AigForEachAnd( pNtkStrash, pObj, i )
190  pObj->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan,
191  Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, (int)Abc_ObjFaninC0(pObj) ),
192  Fraig_NotCond( Abc_ObjFanin1(pObj)->pCopy, (int)Abc_ObjFaninC1(pObj) ) );
193  // get the EXDC to be returned
194  pObj = Abc_NtkPo( pNtkStrash, 0 );
195  gResult = Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, (int)Abc_ObjFaninC0(pObj) );
196  Abc_NtkDelete( pNtkStrash );
197  return gResult;
198 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
Fraig_Node_t * Fraig_ManReadConst1(Fraig_Man_t *p)
Definition: fraigApi.c:52
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
ABC_DLL char ** Abc_NtkCollectCioNames(Abc_Ntk_t *pNtk, int fCollectCos)
Definition: abcNames.c:278
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int strcmp()
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
Fraig_Node_t * Fraig_NodeAnd(Fraig_Man_t *p, Fraig_Node_t *p1, Fraig_Node_t *p2)
Definition: fraigApi.c:212
Abc_Obj_t * pCopy
Definition: abc.h:148
Fraig_Node_t * Fraig_ManReadIthVar(Fraig_Man_t *p, int i)
Definition: fraigApi.c:168
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define ABC_FREE(obj)
Definition: abc_global.h:232
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Fraig_NotCond(p, c)
Definition: fraig.h:110
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213