abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
nwkStrash.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [nwkStrash.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Logic network representation.]
8 
9  Synopsis [Performs structural hashing for the network.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: nwkStrash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "nwk.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Derives AIG from the local functions of the node.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  assert( !Hop_IsComplement(pObj) );
48  if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
49  return;
52  pObj->pData = Aig_And( p, (Aig_Obj_t *)Hop_ObjChild0Copy(pObj), (Aig_Obj_t *)Hop_ObjChild1Copy(pObj) );
53  assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
54  Hop_ObjSetMarkA( pObj );
55 }
56 
57 /**Function*************************************************************
58 
59  Synopsis [Derives AIG from the local functions of the node.]
60 
61  Description []
62 
63  SideEffects []
64 
65  SeeAlso []
66 
67 ***********************************************************************/
69 {
70  Hop_Man_t * pMan = pObj->pMan->pManHop;
71  Hop_Obj_t * pRoot = pObj->pFunc;
72  Nwk_Obj_t * pFanin;
73  int i;
74  assert( Nwk_ObjIsNode(pObj) );
75  // check the constant case
76  if ( Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
77  return Aig_NotCond( Aig_ManConst1(p), Hop_IsComplement(pRoot) );
78  // set elementary variables
79  Nwk_ObjForEachFanin( pObj, pFanin, i )
80  Hop_IthVar(pMan, i)->pData = pFanin->pCopy;
81  // strash the AIG of this node
84  // return the final node
85  return Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
86 }
87 
88 /**Function*************************************************************
89 
90  Synopsis [Derives AIG from the logic network.]
91 
92  Description [Assumes topological ordering of nodes.]
93 
94  SideEffects []
95 
96  SeeAlso []
97 
98 ***********************************************************************/
100 {
101  Vec_Ptr_t * vObjs;
102  Aig_Man_t * pMan;
103  Aig_Obj_t * pObjNew;
104  Nwk_Obj_t * pObj;
105  int i, Level;
106  pMan = Aig_ManStart( Nwk_ManGetAigNodeNum(pNtk) );
107  pMan->pName = Abc_UtilStrsav( pNtk->pName );
108  pMan->pSpec = Abc_UtilStrsav( pNtk->pSpec );
109  pMan->pManTime = Tim_ManDup( (Tim_Man_t *)pNtk->pManTime, 1 );
110  Tim_ManIncrementTravId( (Tim_Man_t *)pMan->pManTime );
111  Nwk_ManForEachObj( pNtk, pObj, i )
112  pObj->pCopy = NULL;
113 // Nwk_ManForEachObj( pNtk, pObj, i )
114  vObjs = Nwk_ManDfs( pNtk );
115  Vec_PtrForEachEntry( Nwk_Obj_t *, vObjs, pObj, i )
116  {
117  if ( Nwk_ObjIsCi(pObj) )
118  {
119  pObjNew = Aig_ObjCreateCi(pMan);
120  Level = Tim_ManGetCiArrival( (Tim_Man_t *)pMan->pManTime, pObj->PioId );
121  Aig_ObjSetLevel( pObjNew, Level );
122  }
123  else if ( Nwk_ObjIsCo(pObj) )
124  {
125  pObjNew = Aig_ObjCreateCo( pMan, Aig_NotCond((Aig_Obj_t *)Nwk_ObjFanin0(pObj)->pCopy, pObj->fInvert) );
126  Level = Aig_ObjLevel( pObjNew );
127  Tim_ManSetCoArrival( (Tim_Man_t *)pMan->pManTime, pObj->PioId, (float)Level );
128  }
129  else if ( Nwk_ObjIsNode(pObj) )
130  {
131  pObjNew = Nwk_ManStrashNode( pMan, pObj );
132  }
133  else
134  assert( 0 );
135  pObj->pCopy = pObjNew;
136  }
137  Vec_PtrFree( vObjs );
138  Aig_ManCleanup( pMan );
139  Aig_ManSetRegNum( pMan, 0 );
140  return pMan;
141 }
142 
143 ////////////////////////////////////////////////////////////////////////
144 /// END OF FILE ///
145 ////////////////////////////////////////////////////////////////////////
146 
147 
149 
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Aig_ObjSetLevel(Aig_Obj_t *pObj, int i)
Definition: aig.h:325
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
static int Hop_ObjIsMarkA(Hop_Obj_t *pObj)
Definition: hop.h:164
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Hop_ObjSetMarkA(Hop_Obj_t *pObj)
Definition: hop.h:165
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pSpec
Definition: nwk.h:65
Aig_Obj_t * Nwk_ManStrashNode(Aig_Man_t *p, Nwk_Obj_t *pObj)
Definition: nwkStrash.c:68
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
char * pName
Definition: nwk.h:64
ABC_DLL int Nwk_ManGetAigNodeNum(Nwk_Man_t *pNtk)
Definition: nwkUtil.c:155
Definition: hop.h:65
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
Definition: hopDfs.c:257
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
ABC_DLL Vec_Ptr_t * Nwk_ManDfs(Nwk_Man_t *pNtk)
Definition: nwkDfs.c:321
ABC_NAMESPACE_IMPL_START void Nwk_ManStrashNode_rec(Aig_Man_t *p, Hop_Obj_t *pObj)
DECLARATIONS ///.
Definition: nwkStrash.c:45
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
Definition: nwk.h:61
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
static Hop_Obj_t * Hop_ObjChild1Copy(Hop_Obj_t *pObj)
Definition: hop.h:187
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjChild0Copy(Hop_Obj_t *pObj)
Definition: hop.h:186
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
Definition: aig.h:69
Aig_Man_t * Nwk_ManStrash(Nwk_Man_t *pNtk)
Definition: nwkStrash.c:99
Tim_Man_t * pManTime
Definition: nwk.h:74
void * pData
Definition: hop.h:68
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
static int Aig_ObjLevel(Aig_Obj_t *pObj)
Definition: aig.h:323
static Nwk_Obj_t * Nwk_ObjFanin0(Nwk_Obj_t *p)
Definition: nwk.h:140
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223