@@ -952,7 +952,114 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v
952952 SeeAlso []
953953
954954***********************************************************************/
955- int Gia_ManVerifyWithBoxes ( Gia_Man_t * pGia , int nBTLimit , int nTimeLim , int fSeq , int fDumpFiles , int fVerbose , char * pFileSpec )
955+
956+ /*
957+ › Please have a look at how name mapping is done in procedure Abc_FrameReadMiniLutNameMapping() in file "src/aig/gia/
958+ giaMini.c". The main idea is to map the object IDs in the design after synthesis (pAbc->pGiaMiniLut) into the object IDs in
959+ the design before synthesis (pAbc->pGiaMiniAig). The computation is divided into three steps: (1) computing object
960+ equivalences using Gia_ManComputeGiaEquivs(), which annotates the input AIG (pGia) containing both designs before and after
961+ synthesis with equivalence class information; this information contains equivalence classes of objects from both designs; (2)
962+ creating a map (pRes) of the resulting object IDs (in pAbc->pGiaMiniLut) into the original object IDs (in pAbc->pGiaMiniAig)
963+ using procedure Gia_ManMapMiniLut2MiniAig(); this map is enabled by having two arrays (one of them is pAbc->vCopyMiniAig
964+ mapping objects of pAbc->pGiaMiniAig in the original object IDs; the other one is pAbc->vCopyMiniLut mapping objects of
965+ pAbc->pGiaMiniLut into the IDs of pAbc->pGiaMiniLut); (3) verification procedure (commented out by default)
966+ Gia_ManNameMapVerify() which checks that the resulting mapping computed by Gia_ManMapMiniLut2MiniAig() is correct. Please
967+ let me know if this computation is clear.
968+ */
969+
970+ Vec_Int_t * Gia_ManVerifyFindNameMapping ( Gia_Man_t * p , Gia_Man_t * p1 , Gia_Man_t * p2 , Vec_Int_t * vMap1 , Vec_Int_t * vMap2 )
971+ {
972+ Vec_Int_t * vRes = Vec_IntStartFull (Vec_IntSize (vMap2 ));
973+ Vec_Int_t * vMap = Vec_IntStartFull ( Gia_ManObjNum (p ) );
974+ int i , Entry , iRepr , fCompl , iLit ;
975+ Gia_Obj_t * pObj ;
976+ Gia_ManSetPhase ( p1 );
977+ Gia_ManSetPhase ( p2 );
978+ Vec_IntForEachEntry ( vMap1 , Entry , i )
979+ {
980+ if ( Entry == -1 )
981+ continue ;
982+ pObj = Gia_ManObj ( p1 , Abc_Lit2Var (Entry ) );
983+ if ( ~pObj -> Value == 0 )
984+ continue ;
985+ fCompl = Abc_LitIsCompl (Entry ) ^ pObj -> fPhase ;
986+ iRepr = Gia_ObjReprSelf ( p , Abc_Lit2Var (pObj -> Value ) );
987+ Vec_IntWriteEntry ( vMap , iRepr , Abc_Var2Lit ( i , fCompl ) );
988+ }
989+ Vec_IntForEachEntry ( vMap2 , Entry , i )
990+ {
991+ if ( Entry == -1 )
992+ continue ;
993+ pObj = Gia_ManObj ( p2 , Abc_Lit2Var (Entry ) );
994+ if ( ~pObj -> Value == 0 )
995+ continue ;
996+ fCompl = Abc_LitIsCompl (Entry ) ^ pObj -> fPhase ;
997+ iRepr = Gia_ObjReprSelf ( p , Abc_Lit2Var (pObj -> Value ) );
998+ if ( (iLit = Vec_IntEntry (vMap , iRepr )) == -1 )
999+ continue ;
1000+ Vec_IntWriteEntry ( vRes , i , Abc_LitNotCond ( iLit , fCompl ) );
1001+ }
1002+ Vec_IntFill ( vMap , Gia_ManCoNum (p1 ), -1 );
1003+ Vec_IntForEachEntry ( vMap1 , Entry , i )
1004+ {
1005+ if ( Entry == -1 )
1006+ continue ;
1007+ pObj = Gia_ManObj ( p1 , Abc_Lit2Var (Entry ) );
1008+ if ( !Gia_ObjIsCo (pObj ) )
1009+ continue ;
1010+ Vec_IntWriteEntry ( vMap , Gia_ObjCioId (pObj ), i );
1011+ }
1012+ Vec_IntForEachEntry ( vMap2 , Entry , i )
1013+ {
1014+ if ( Entry == -1 )
1015+ continue ;
1016+ pObj = Gia_ManObj ( p2 , Abc_Lit2Var (Entry ) );
1017+ if ( !Gia_ObjIsCo (pObj ) )
1018+ continue ;
1019+
1020+ assert ( Vec_IntEntry (vRes , i ) == -1 );
1021+ Vec_IntWriteEntry ( vRes , i , Abc_Var2Lit ( Vec_IntEntry (vMap , Gia_ObjCioId (pObj )), 0 ) );
1022+ assert ( Vec_IntEntry (vRes , i ) != -1 );
1023+ }
1024+ Vec_IntFree ( vMap );
1025+ return vRes ;
1026+ }
1027+
1028+ void Gia_ManVerifyVerifyNameMapping ( Gia_Man_t * p , Gia_Man_t * p1 , Gia_Man_t * p2 , Vec_Int_t * vMap1 , Vec_Int_t * vMap2 , Vec_Int_t * vMapRes )
1029+ {
1030+ int iImpl , iReprSpec , iReprImpl , nSize = Vec_IntSize (vMap2 );
1031+ Gia_Obj_t * pObjSpec , * pObjImpl ;
1032+ if ( vMapRes == NULL || p == NULL || p -> pReprs == NULL )
1033+ return ;
1034+ assert ( Vec_IntSize (vMapRes ) == nSize );
1035+ Gia_ManSetPhase ( p1 );
1036+ Gia_ManSetPhase ( p2 );
1037+ for ( iImpl = 0 ; iImpl < nSize ; iImpl ++ )
1038+ if ( Vec_IntEntry (vMapRes , iImpl ) >= 0 )
1039+ {
1040+ int Entry = Vec_IntEntry ( vMapRes , iImpl );
1041+ int iSpec = Abc_Lit2Var ( Entry );
1042+ int fCompl = Abc_LitIsCompl ( Entry );
1043+ int iLitSpec = Vec_IntEntry ( vMap1 , iSpec );
1044+ int iLitImpl = Vec_IntEntry ( vMap2 , iImpl );
1045+ pObjSpec = Gia_ManObj ( p1 , Abc_Lit2Var (iLitSpec ) );
1046+ if ( Gia_ObjIsCo (pObjSpec ) )
1047+ continue ;
1048+ if ( ~pObjSpec -> Value == 0 )
1049+ continue ;
1050+ pObjImpl = Gia_ManObj ( p2 , Abc_Lit2Var (iLitImpl ) );
1051+ if ( ~pObjImpl -> Value == 0 )
1052+ continue ;
1053+ iReprSpec = Gia_ObjReprSelf ( p , Abc_Lit2Var (pObjSpec -> Value ) );
1054+ iReprImpl = Gia_ObjReprSelf ( p , Abc_Lit2Var (pObjImpl -> Value ) );
1055+ if ( iReprSpec != iReprImpl )
1056+ printf ( "Found functional mismatch for ImplId %d and SpecId %d.\n" , iImpl , iSpec );
1057+ if ( (pObjImpl -> fPhase ^ Abc_LitIsCompl (iLitImpl )) != (pObjSpec -> fPhase ^ Abc_LitIsCompl (iLitSpec ) ^ fCompl ) )
1058+ printf ( "Found phase mismatch for ImplId %d and SpecId %d.\n" , iImpl , iSpec );
1059+ }
1060+ }
1061+
1062+ int Gia_ManVerifyWithBoxes ( Gia_Man_t * pGia , int nBTLimit , int nTimeLim , int fSeq , int fObjIdMap , int fDumpFiles , int fVerbose , char * pFileSpec )
9561063{
9571064 int Status = -1 ;
9581065 Gia_Man_t * pSpec , * pGia0 , * pGia1 , * pMiter ;
@@ -1052,12 +1159,30 @@ int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, int nBTLimit, int nTimeLim, int fS
10521159 {
10531160 Cec_ParCec_t ParsCec , * pPars = & ParsCec ;
10541161 Cec_ManCecSetDefaultParams ( pPars );
1055- pPars -> nBTLimit = nBTLimit ;
1056- pPars -> TimeLimit = nTimeLim ;
1057- pPars -> fVerbose = fVerbose ;
1162+ pPars -> nBTLimit = nBTLimit ;
1163+ pPars -> TimeLimit = nTimeLim ;
1164+ pPars -> fUseOrigIds = fObjIdMap ;
1165+ pPars -> fVerbose = fVerbose ;
10581166 Status = Cec_ManVerify ( pMiter , pPars );
10591167 if ( pPars -> iOutFail >= 0 )
10601168 Abc_Print ( 1 , "Verification failed for at least one output (%d).\n" , pPars -> iOutFail );
1169+ if ( fObjIdMap ) {
1170+ Gia_Man_t * pReduced = Gia_ManOrigIdsReduce ( pMiter , pMiter -> vIdsEquiv );
1171+ Gia_ManStop ( pReduced );
1172+ Gia_Obj_t * pObj ; int i ;
1173+ Vec_Int_t * vCopy0 = Vec_IntAlloc (Gia_ManObjNum (pSpec ));
1174+ Gia_ManForEachObj ( pSpec , pObj , i )
1175+ Vec_IntPush ( vCopy0 , pObj -> Value );
1176+ Vec_Int_t * vCopy1 = Vec_IntAlloc (Gia_ManObjNum (pGia ));
1177+ Gia_ManForEachObj ( pGia , pObj , i )
1178+ Vec_IntPush ( vCopy1 , pObj -> Value );
1179+ Vec_IntFreeP ( & pGia -> vEquLitIds );
1180+ pGia -> vEquLitIds = Gia_ManVerifyFindNameMapping ( pMiter , pGia0 , pGia1 , vCopy0 , vCopy1 );
1181+ assert ( Vec_IntSize (pGia -> vEquLitIds ) == Gia_ManObjNum (pGia ) );
1182+ Gia_ManVerifyVerifyNameMapping ( pMiter , pGia0 , pGia1 , vCopy0 , vCopy1 , pGia -> vEquLitIds );
1183+ Vec_IntFree ( vCopy0 );
1184+ Vec_IntFree ( vCopy1 );
1185+ }
10611186 Gia_ManStop ( pMiter );
10621187 }
10631188 }
@@ -1094,4 +1219,3 @@ Vec_Int_t * Gia_ManDeriveBoxMapping( Gia_Man_t * pGia )
10941219
10951220
10961221ABC_NAMESPACE_IMPL_END
1097-
0 commit comments