abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
resStrash.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [resStrash.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Resynthesis package.]
8 
9  Synopsis [Structural hashing of the nodes in the window.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - January 15, 2007.]
16 
17  Revision [$Id: resStrash.c,v 1.00 2007/01/15 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "resInt.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 extern Abc_Obj_t * Abc_ConvertAigToAig( Abc_Ntk_t * pAig, Abc_Obj_t * pObjOld );
32 
33 ////////////////////////////////////////////////////////////////////////
34 /// FUNCTION DEFINITIONS ///
35 ////////////////////////////////////////////////////////////////////////
36 
37 /**Function*************************************************************
38 
39  Synopsis [Structurally hashes the given window.]
40 
41  Description [The first PO is the observability condition. The second
42  is the node's function. The remaining POs are the candidate divisors.]
43 
44  SideEffects []
45 
46  SeeAlso []
47 
48 ***********************************************************************/
50 {
51  Vec_Ptr_t * vPairs;
52  Abc_Ntk_t * pAig;
53  Abc_Obj_t * pObj, * pMiter;
54  int i;
55  assert( Abc_NtkHasAig(p->pNode->pNtk) );
56 // Abc_NtkCleanCopy( p->pNode->pNtk );
57  // create the network
59  pAig->pName = Extra_UtilStrsav( "window" );
60  // create the inputs
61  Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
62  pObj->pCopy = Abc_NtkCreatePi( pAig );
63  Vec_PtrForEachEntry( Abc_Obj_t *, p->vBranches, pObj, i )
64  pObj->pCopy = Abc_NtkCreatePi( pAig );
65  // go through the nodes in the topological order
66  Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
67  {
68  pObj->pCopy = Abc_ConvertAigToAig( pAig, pObj );
69  if ( pObj == p->pNode )
70  pObj->pCopy = Abc_ObjNot( pObj->pCopy );
71  }
72  // collect the POs
73  vPairs = Vec_PtrAlloc( 2 * Vec_PtrSize(p->vRoots) );
74  Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
75  {
76  Vec_PtrPush( vPairs, pObj->pCopy );
77  Vec_PtrPush( vPairs, NULL );
78  }
79  // mark the TFO of the node
80  Abc_NtkIncrementTravId( p->pNode->pNtk );
81  Res_WinSweepLeafTfo_rec( p->pNode, (int)p->pNode->Level + p->nWinTfoMax );
82  // update strashing of the node
83  p->pNode->pCopy = Abc_ObjNot( p->pNode->pCopy );
84  Abc_NodeSetTravIdPrevious( p->pNode );
85  // redo strashing in the TFO
86  Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
87  {
88  if ( Abc_NodeIsTravIdCurrent(pObj) )
89  pObj->pCopy = Abc_ConvertAigToAig( pAig, pObj );
90  }
91  // collect the POs
92  Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
93  Vec_PtrWriteEntry( vPairs, 2 * i + 1, pObj->pCopy );
94  // add the miter
95  pMiter = Abc_AigMiter( (Abc_Aig_t *)pAig->pManFunc, vPairs, 0 );
96  Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pMiter );
97  Vec_PtrFree( vPairs );
98  // add the node
99  Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), p->pNode->pCopy );
100  // add the fanins
101  Abc_ObjForEachFanin( p->pNode, pObj, i )
102  Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pObj->pCopy );
103  // add the divisors
104  Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pObj, i )
105  Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pObj->pCopy );
106  // add the names
107  Abc_NtkAddDummyPiNames( pAig );
108  Abc_NtkAddDummyPoNames( pAig );
109  // check the resulting network
110  if ( !Abc_NtkCheck( pAig ) )
111  fprintf( stdout, "Res_WndStrash(): Network check has failed.\n" );
112  return pAig;
113 }
114 
115 
116 ////////////////////////////////////////////////////////////////////////
117 /// END OF FILE ///
118 ////////////////////////////////////////////////////////////////////////
119 
120 
122 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Abc_NodeSetTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:410
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
typedefABC_NAMESPACE_HEADER_START struct Res_Win_t_ Res_Win_t
INCLUDES ///.
Definition: resInt.h:44
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
DECLARATIONS ///.
Definition: abcAig.c:52
char * Extra_UtilStrsav(const char *s)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
void * pManFunc
Definition: abc.h:191
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:398
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL Abc_Obj_t * Abc_AigMiter(Abc_Aig_t *pMan, Vec_Ptr_t *vPairs, int fImplic)
Definition: abcAig.c:789
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Abc_Ntk_t * Res_WndStrash(Res_Win_t *p)
FUNCTION DEFINITIONS ///.
Definition: resStrash.c:49
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
void Res_WinSweepLeafTfo_rec(Abc_Obj_t *pObj, int nLevelLimit)
Definition: resDivs.c:196
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkHasAig(Abc_Ntk_t *pNtk)
Definition: abc.h:255
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_ConvertAigToAig(Abc_Ntk_t *pAig, Abc_Obj_t *pObjOld)
DECLARATIONS ///.
Definition: abcFunc.c:1036
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223