49 assert( !Hop_IsComplement(pObj) );
50 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
55 assert( !Hop_ObjIsMarkA(pObj) );
56 Hop_ObjSetMarkA( pObj );
60 assert( !Hop_IsComplement(pObj) );
61 if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
65 assert( Hop_ObjIsMarkA(pObj) );
66 Hop_ObjClearMarkA( pObj );
70 assert( !Hop_IsComplement(pRoot) );
71 if ( Hop_ObjIsConst1( pRoot ) )
96 assert( Abc_NtkIsAigLogic(pNtk) );
98 Hop_ManConst1(pHopMan)->iData = 1;
102 pNode->
iTemp = Gia_ManCiLit(
p, Vec_IntEntry(vMap, i));
108 Hop_ManPi(pHopMan, k)->iData = pFanin->
iTemp;
110 assert( Abc_ObjFaninNum(pNode) <= Hop_ManPiNum(pHopMan) );
115 Vec_PtrFree( vNodes );
118 Gia_ManAppendCo(
p, Abc_ObjFanin0(pNode)->iTemp );
127 assert( Abc_NtkIsAigLogic(pNtk1) );
128 assert( Abc_NtkIsAigLogic(pNtk2) );
133 vMap1 = Vec_IntStartNatural( Abc_NtkCiNum(pNtk1) );
134 vMap2 = Vec_IntAlloc( Abc_NtkCiNum(pNtk2) );
136 pNode->
iTemp = Index++;
137 assert( Index == Abc_NtkCiNum(pNtk1) );
143 assert( Num < 0 || Abc_ObjIsCi(Abc_NtkObj(pNtk1, Num)) );
145 Vec_IntPush( vMap2, Abc_NtkObj(pNtk1, Num)->iTemp ), nCommon++;
147 Vec_IntPush( vMap2, Index++ );
150 printf(
"Matched %d vars by name.", nCommon );
151 if ( nCommon != Abc_NtkCiNum(pNtk1) )
152 printf(
" Netlist1 has %d unmatched vars.", Abc_NtkCiNum(pNtk1) - nCommon );
153 if ( nCommon != Abc_NtkCiNum(pNtk2) )
154 printf(
" Netlist2 has %d unmatched vars.", Abc_NtkCiNum(pNtk2) - nCommon );
159 vMap1 = Vec_IntStartNatural( Abc_NtkCiNum(pNtk1) );
160 vMap2 = Vec_IntStartNatural( Abc_NtkCiNum(pNtk2) );
161 Index = Abc_MaxInt( Vec_IntSize(vMap1), Vec_IntSize(vMap2) );
163 printf(
"Matched %d vars by order.", Abc_MinInt(Abc_NtkCiNum(pNtk1), Abc_NtkCiNum(pNtk2)) );
164 if ( Abc_NtkCiNum(pNtk1) < Abc_NtkCiNum(pNtk2) )
165 printf(
" The last %d vars of Netlist2 are unmatched vars.", Abc_NtkCiNum(pNtk2) - Abc_NtkCiNum(pNtk1) );
166 if ( Abc_NtkCiNum(pNtk1) > Abc_NtkCiNum(pNtk2) )
167 printf(
" The last %d vars of Netlist1 are unmatched vars.", Abc_NtkCiNum(pNtk1) - Abc_NtkCiNum(pNtk2) );
172 p->pName = Abc_UtilStrsav( Abc_NtkName(pNtk1) );
173 p->pSpec = Abc_UtilStrsav( Abc_NtkSpec(pNtk1) );
174 for ( i = 0; i < Index; i++ )
181 Vec_IntFree( vMap1 );
182 Vec_IntFree( vMap2 );
186 if ( pObj->
Value == 0 )
187 Gia_ManAppendCo(
p, Abc_Var2Lit(i, 0) );
204static inline void Abc_NtkCollectAddOne(
int iNtk,
int iObj,
int iGiaLit,
Gia_Man_t * pGia,
Vec_Int_t * vGia2Cla,
Vec_Int_t * vNexts[2] )
206 int iRepr = Gia_ObjReprSelf( pGia, Abc_Lit2Var(iGiaLit) );
207 int Compl = Abc_LitIsCompl(iGiaLit) ^ Gia_ObjPhase(Gia_ManObj(pGia, iRepr)) ^ Gia_ObjPhase(Gia_ManObj(pGia, Abc_Lit2Var(iGiaLit)));
208 int Added = Abc_Var2Lit( Abc_Var2Lit(iObj, Compl), iNtk );
209 int Entry = Vec_IntEntry( vGia2Cla, iRepr );
210 Vec_IntWriteEntry( vNexts[iNtk], iObj, Entry );
211 Vec_IntWriteEntry( vGia2Cla, iRepr, Added );
215 Vec_Int_t * vClass = Vec_IntAlloc( 100 );
216 Vec_Int_t * vClasses = Vec_IntAlloc( 1000 );
217 Vec_Int_t * vGia2Cla = Vec_IntStartFull( Gia_ManObjNum(pGia) );
218 Vec_Int_t * vNexts[2] = { Vec_IntStartFull(Abc_NtkObjNumMax(pNtks[0])), Vec_IntStartFull(Abc_NtkObjNumMax(pNtks[1])) };
220 int n, i, k, Entry, fCompl;
222 Abc_NtkCollectAddOne( 0, Abc_ObjId(pObj), pObj->
iTemp, pGia, vGia2Cla, vNexts );
223 for ( n = 0; n < 2; n++ )
225 Abc_NtkCollectAddOne( n, Abc_ObjId(pObj), pObj->
iTemp, pGia, vGia2Cla, vNexts );
228 Vec_IntClear( vClass );
229 for ( ; Entry >= 0; Entry = Vec_IntEntry(vNexts[Entry&1], Entry>>2) )
230 Vec_IntPush( vClass, Entry );
231 if ( Vec_IntSize(vClass) < 2 )
233 Vec_IntReverseOrder( vClass );
234 fCompl = 2 & Vec_IntEntry( vClass, 0 );
236 Vec_IntWriteEntry( vClass, k, Entry ^ fCompl );
237 Vec_IntPush( vClasses, Vec_IntSize(vClass) );
238 Vec_IntAppend( vClasses, vClass );
240 Vec_IntFree( vGia2Cla );
241 Vec_IntFree( vNexts[0] );
242 Vec_IntFree( vNexts[1] );
243 Vec_IntFree( vClass );
261 FILE * pFile = fopen( pFileName,
"wb" );
262 if ( pFile == NULL ) { printf(
"Cannot open file %s for writing.\n", pFileName );
return; }
263 fprintf( pFile,
"# Node equivalences computed by ABC for networks \"%s\" and \"%s\" on %s\n\n", Abc_NtkName(pNtks[0]), Abc_NtkName(pNtks[1]),
Extra_TimeStamp() );
264 for ( i = c = 0; i < Vec_IntSize(vClasses); c++, i += 1 + Vec_IntEntry(vClasses, i) )
269 char * pObjName =
Abc_ObjName( Abc_NtkObj(pNtk, Entry>>2) );
270 fprintf( pFile,
"%d:%s:%s%s\n", c+1, Abc_NtkName(pNtk), (Entry&2) ?
"NOT:":
"", pObjName );
272 fprintf( pFile,
"\n" );
297 printf(
"Computing equivalences for networks \"%s\" and \"%s\" with conflict limit %d.\n", Abc_NtkName(pNtks[0]), Abc_NtkName(pNtks[1]), nConfs );
310 Vec_IntFree( vClasses );
Gia_Man_t * Abc_NtkAigToGiaTwo(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fByName)
ABC_NAMESPACE_IMPL_START void Abc_ConvertHopToGia_rec1(Gia_Man_t *p, Hop_Obj_t *pObj)
DECLARATIONS ///.
void Abc_NtkDumpEquivFile(char *pFileName, Vec_Int_t *vClasses, Abc_Ntk_t *pNtks[2])
void Abc_ConvertHopToGia_rec2(Hop_Obj_t *pObj)
void Abc_NtkDumpEquiv(Abc_Ntk_t *pNtks[2], char *pFileName, int nConfs, int fByName, int fVerbose)
void Abc_NtkAigToGiaOne(Gia_Man_t *p, Abc_Ntk_t *pNtk, Vec_Int_t *vMap)
Vec_Int_t * Abc_NtkCollectEquivClasses(Abc_Ntk_t *pNtks[2], Gia_Man_t *pGia)
int Abc_ConvertHopToGia(Gia_Man_t *p, Hop_Obj_t *pRoot)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachAnd(p, pObj, i)
void Gia_ManCreateValueRefs(Gia_Man_t *p)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManComputeGiaEquivs(Gia_Man_t *pGia, int nConfs, int fVerbose)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManHashStop(Gia_Man_t *p)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
int Hop_DagSize(Hop_Obj_t *pObj)
struct Hop_Obj_t_ Hop_Obj_t
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.