30#define PROPAGATE_NAMES
59 for( i=0; i< Vec_PtrSize( vec ); i++ )
61 printf(
"vec[%d] = %s\n", i, (
char *)Vec_PtrEntry(vec, i) );
84 assert( Saig_ObjIsPi( pAigNew, pObjPivot ) );
86 if( pObj == pObjPivot )
88 assert( index < Aig_ManCiNum( pAigNew ) - Aig_ManRegNum( pAigNew ) );
89 if( index == Saig_ManPiNum( pAigNew ) - 1 )
93 pObjOld = Aig_ManCi( pAigOld, index );
94 pNode = Abc_NtkPi( pNtkOld, index );
104 int index, oldIndex, originalLatchNum = Saig_ManRegNum(pAigOld), strMatch, i;
105 char *dummyStr = (
char *)
malloc(
sizeof(
char) * 50 );
107 assert( Saig_ObjIsLo( pAigNew, pObjPivot ) );
109 if( pObj == pObjPivot )
111 if( index < originalLatchNum )
113 oldIndex = Saig_ManPiNum( pAigOld ) + index;
114 pObjOld = Aig_ManCi( pAigOld, oldIndex );
115 pNode = Abc_NtkCi( pNtkOld, oldIndex );
119 else if( index == originalLatchNum )
121 else if( index > originalLatchNum && index < 2 * originalLatchNum + 1 )
123 oldIndex = Saig_ManPiNum( pAigOld ) + index - originalLatchNum - 1;
124 pObjOld = Aig_ManCi( pAigOld, oldIndex );
125 pNode = Abc_NtkCi( pNtkOld, oldIndex );
129 else if( index >= 2 * originalLatchNum + 1 && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) )
131 oldIndex = index - 2 * originalLatchNum - 1;
135 pNode = Abc_NtkPo( pNtkOld, i );
138 if( strMatch == oldIndex )
148 else if( index >= 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) )
150 oldIndex = index - 2 * originalLatchNum - 1 - Vec_PtrSize( vLive );
154 pNode = Abc_NtkPo( pNtkOld, i );
157 if( strMatch == oldIndex )
178 int nPisOld = Aig_ManCiNum(
p);
181 if ( Aig_ManRegNum(
p) )
182 p->nTruePis = Aig_ManCiNum(
p) - Aig_ManRegNum(
p);
184 return nPisOld - Aig_ManCiNum(
p);
190 int nPosOld = Aig_ManCoNum(
p);
193 if ( Aig_ManRegNum(
p) )
194 p->nTruePos = Aig_ManCoNum(
p) - Aig_ManRegNum(
p);
195 return nPosOld - Aig_ManCoNum(
p);
205 Aig_Obj_t *pObjSaveOrSaved, *pObjSavedLoAndEquality;
206 Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
207 Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
208 Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
212 int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, liveLatch = 0, fairLatch = 0;
214 vecPis = Vec_PtrAlloc( Saig_ManPiNum(
p ) + 1);
215 vecPiNames = Vec_PtrAlloc( Saig_ManPiNum(
p ) + 1);
217 vecLos = Vec_PtrAlloc( Saig_ManRegNum(
p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
218 vecLoNames = Vec_PtrAlloc( Saig_ManRegNum(
p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
220#ifdef DUPLICATE_CKT_DEBUG
221 printf(
"\nCode is compiled in DEBUG mode, the input-output behavior will be the same as the original circuit\n");
222 printf(
"Press any key to continue...");
232 pNew->pName = Abc_UtilStrsav(
"live2safe" );
238 pObj = Aig_ManConst1(
p );
239 pObj->
pData = Aig_ManConst1( pNew );
249 nodeName = Abc_UtilStrsav(
Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
256#ifndef DUPLICATE_CKT_DEBUG
258 nodeName = Abc_UtilStrsav(
"SAVE_BIERE"),
270 nodeName = Abc_UtilStrsav(
Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
277#ifndef DUPLICATE_CKT_DEBUG
280 Vec_PtrPush(
vecLos, pObjSavedLo );
281 nodeName = Abc_UtilStrsav(
"SAVED_LO");
288#ifndef DUPLICATE_CKT_DEBUG
289 pObjSaveOrSaved =
Aig_Or( pNew, pObjSavePi, pObjSavedLo );
298 pObj->
pData =
Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
306#ifndef DUPLICATE_CKT_DEBUG
314#ifdef DUPLICATE_CKT_DEBUG
326 pMatch = Saig_ObjLoToLi(
p, pObj );
334#ifndef DUPLICATE_CKT_DEBUG
346#ifdef PROPAGATE_NAMES
347 Vec_PtrPush(
vecLos, pObjShadowLo );
349 sprintf( nodeName,
"%s__%s",
Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ),
"SHADOW" );
356 loCreated++; liCreated++;
359 pObjXnor = Aig_Not( pObjXor );
360 if( pObjAndAcc == NULL )
361 pObjAndAcc = pObjXnor;
364 pObjAndAccDummy = pObjAndAcc;
365 pObjAndAcc =
Aig_And( pNew, pObjXnor, pObjAndAccDummy );
370 pObjSavedLoAndEquality =
Aig_And( pNew, pObjSavedLo, pObjAndAcc );
374 if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
375 printf(
"\nCircuit without any liveness property\n");
383 pDriverImage = Aig_NotCond((
Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
386#ifdef PROPAGATE_NAMES
387 Vec_PtrPush(
vecLos, pObjShadowLo );
393 pObjShadowLiDriver =
Aig_Or( pNew,
Aig_Mux(pNew, pObjSavePi, Aig_Not(Aig_ManConst1(pNew)), pObjShadowLo),
394 Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
397 loCreated++; liCreated++;
399 if( pObjAndAcc == NULL )
400 pObjAndAcc = pObjShadowLo;
403 pObjAndAccDummy = pObjAndAcc;
404 pObjAndAcc =
Aig_And( pNew, pObjShadowLo, pObjAndAccDummy );
409 if( pObjAndAcc != NULL )
410 pObjLive = pObjAndAcc;
412 pObjLive = Aig_ManConst1( pNew );
416 if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
417 printf(
"\nCircuit without any fairness property\n");
424 pDriverImage = Aig_NotCond((
Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
427#ifdef PROPAGATE_NAMES
428 Vec_PtrPush(
vecLos, pObjShadowLo );
434 pObjShadowLiDriver =
Aig_Or( pNew,
Aig_Mux(pNew, pObjSavePi, Aig_Not(Aig_ManConst1(pNew)), pObjShadowLo),
435 Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
438 loCreated++; liCreated++;
440 if( pObjAndAcc == NULL )
441 pObjAndAcc = pObjShadowLo;
444 pObjAndAccDummy = pObjAndAcc;
445 pObjAndAcc =
Aig_And( pNew, pObjShadowLo, pObjAndAccDummy );
450 if( pObjAndAcc != NULL )
451 pObjFair = pObjAndAcc;
453 pObjFair = Aig_ManConst1( pNew );
456 pObjSafetyGate =
Aig_And( pNew, pObjSavedLoAndEquality,
Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
469#ifndef DUPLICATE_CKT_DEBUG
470 assert((
Aig_Obj_t *)Vec_PtrEntry(pNew->vCos, Saig_ManPoNum(pNew)+Aig_ObjCioId(pObjSavedLo)-Saig_ManPiNum(
p)-1) == pObjSavedLi);
471 assert( Saig_ManPoNum( pNew ) == 1 );
472 assert( Saig_ManPiNum(
p ) + 1 == Saig_ManPiNum( pNew ) );
473 assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum(
p ) * 2 + 1 + liveLatch + fairLatch );
487 Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
488 Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
495 int piCopied = 0, liCopied = 0, loCopied = 0;
497 vecPis = Vec_PtrAlloc( Saig_ManPiNum(
p ) + 1);
498 vecPiNames = Vec_PtrAlloc( Saig_ManPiNum(
p ) + 1);
500 vecLos = Vec_PtrAlloc( Saig_ManRegNum(
p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
501 vecLoNames = Vec_PtrAlloc( Saig_ManRegNum(
p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
509 pNew->pName = Abc_UtilStrsav(
"live2safe" );
515 pObj = Aig_ManConst1(
p );
516 pObj->
pData = Aig_ManConst1( pNew );
526 nodeName = Abc_UtilStrsav(
Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
534 nodeName =
"SAVE_BIERE",
545 nodeName = Abc_UtilStrsav(
Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
556 Vec_PtrPush(
vecLos, pObjSavedLo );
557 nodeName =
"SAVED_LO";
565 pObjSaveOrSaved =
Aig_Or( pNew, pObjSavePi, pObjSavedLo );
566 pObjSaveAndNotSaved =
Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
574 pObj->
pData =
Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
590 pMatch = Saig_ObjLoToLi(
p, pObj );
613 pObjCorrespondingLi = Saig_ObjLoToLi(
p, pObj );
615 pObjXor =
Aig_Exor( pNew, (
Aig_Obj_t *)pObj->
pData, Aig_NotCond( (
Aig_Obj_t *)Aig_ObjFanin0( pObjCorrespondingLi )->pData, Aig_ObjFaninC0( pObjCorrespondingLi ) ) );
616 pObjXnor = Aig_Not( pObjXor );
618 if( pObjAndAcc == NULL )
619 pObjAndAcc = pObjXnor;
622 pObjAndAccDummy = pObjAndAcc;
623 pObjAndAcc =
Aig_And( pNew, pObjXnor, pObjAndAccDummy );
628 pObjSavedLoAndEquality =
Aig_And( pNew, pObjSavePi, pObjAndAcc );
632 if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
633 printf(
"\nCircuit without any liveness property\n");
638 pDriverImage = Aig_NotCond((
Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
639 if( pObjAndAcc == NULL )
640 pObjAndAcc = pDriverImage;
643 pObjAndAccDummy = pObjAndAcc;
644 pObjAndAcc =
Aig_And( pNew, pDriverImage, pObjAndAccDummy );
649 if( pObjAndAcc != NULL )
650 pObjLive = pObjAndAcc;
652 pObjLive = Aig_ManConst1( pNew );
656 if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
657 printf(
"\nCircuit without any fairness property\n");
662 pDriverImage = Aig_NotCond((
Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
663 if( pObjAndAcc == NULL )
664 pObjAndAcc = pDriverImage;
667 pObjAndAccDummy = pObjAndAcc;
668 pObjAndAcc =
Aig_And( pNew, pDriverImage, pObjAndAccDummy );
673 if( pObjAndAcc != NULL )
674 pObjFair = pObjAndAcc;
676 pObjFair = Aig_ManConst1( pNew );
678 pObjSafetyGate =
Aig_And( pNew, pObjSavedLoAndEquality,
Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
684 printf(
"\nSaig_ManPiNum = %d, Reg Num = %d, before everything, before Pi cleanup\n", Vec_PtrSize( pNew->vCis ), pNew->nRegs );
701 int i, liveCounter = 0;
704 vLive = Vec_PtrAlloc( 100 );
708 Vec_PtrPush( vLive, Aig_ManCo( pAig, i ) );
711 printf(
"\nNumber of liveness property found = %d\n", liveCounter);
718 int i, fairCounter = 0;
721 vFair = Vec_PtrAlloc( 100 );
725 Vec_PtrPush( vFair, Aig_ManCo( pAig, i ) );
728 printf(
"\nNumber of fairness property found = %d\n", fairCounter);
741 ntkObjId = Abc_NtkCi( pNtk, i )->Id;
747 ntkObjId = Abc_NtkCi( pNtk, Saig_ManPiNum( pAig ) + i )->Id;
757 Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
768 fprintf( pErr,
"Empty network.\n" );
772 if( !Abc_NtkIsStrash( pNtk ) )
774 printf(
"\nThe input network was not strashed, strashing....\n");
791 printf(
"\nDetail statistics*************************************\n");
792 printf(
"Number of true primary inputs = %d\n", Saig_ManPiNum( pAig ));
793 printf(
"Number of true primary outputs = %d\n", Saig_ManPoNum( pAig ));
794 printf(
"Number of true latch outputs = %d\n", Saig_ManCiNum( pAig ) - Saig_ManPiNum( pAig ));
795 printf(
"Number of true latch inputs = %d\n", Saig_ManCoNum( pAig ) - Saig_ManPoNum( pAig ));
796 printf(
"Numer of registers = %d\n", Saig_ManRegNum( pAig ) );
797 printf(
"\n*******************************************************\n");
802 pAigNew = LivenessToSafetyTransformationOneStepLoopSim( pNtk, pAig, vLive, vFair );
804 pAigNew = LivenessToSafetyTransformationSim( pNtk, pAig, vLive, vFair );
808 printf(
"\nDetail statistics*************************************\n");
809 printf(
"Number of true primary inputs = %d\n", Saig_ManPiNum( pAigNew ));
810 printf(
"Number of true primary outputs = %d\n", Saig_ManPoNum( pAigNew ));
811 printf(
"Number of true latch outputs = %d\n", Saig_ManCiNum( pAigNew ) - Saig_ManPiNum( pAigNew ));
812 printf(
"Number of true latch inputs = %d\n", Saig_ManCoNum( pAigNew ) - Saig_ManPoNum( pAigNew ));
813 printf(
"Numer of registers = %d\n", Saig_ManRegNum( pAigNew ) );
814 printf(
"\n*******************************************************\n");
820 fprintf( stdout,
"Abc_NtkCreateCone(): Network check has failed.\n" );
835#ifndef DUPLICATE_CKT_DEBUG
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachPo(pNtk, pPo, i)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Aig_Obj_t * Aig_Mux(Aig_Man_t *p, Aig_Obj_t *pC, Aig_Obj_t *p1, Aig_Obj_t *p0)
struct Aig_Obj_t_ Aig_Obj_t
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
void Aig_ManPrintStats(Aig_Man_t *p)
#define Aig_ManForEachNode(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
int Aig_ManCleanup(Aig_Man_t *p)
void Aig_ObjPatchFanin0(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFaninNew)
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
void printVecPtrOfString(Vec_Ptr_t *vec)
Vec_Ptr_t * populateFairnessVector(Abc_Ntk_t *pNtk, Aig_Man_t *pAig)
int Aig_ManCoCleanupBiere(Aig_Man_t *p)
char * retrieveTruePiName(Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot)
char * retrieveLOName(Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot, Vec_Ptr_t *vLive, Vec_Ptr_t *vFair)
void updateNewNetworkNameManager(Abc_Ntk_t *pNtk, Aig_Man_t *pAig, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vLoNames)
int Aig_ManCiCleanupBiere(Aig_Man_t *p)
int getPoIndex(Aig_Man_t *pAig, Aig_Obj_t *pPivot)
Vec_Ptr_t * populateLivenessVector(Abc_Ntk_t *pNtk, Aig_Man_t *pAig)
int Abc_CommandAbcLivenessToSafetySim(Abc_Frame_t *pAbc, int argc, char **argv)
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
DECLARATIONS ///.
Abc_Ntk_t * Abc_NtkFromAigPhase(Aig_Man_t *pMan)
DECLARATIONS ///.
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
char * Nm_ManStoreIdName(Nm_Man_t *p, int ObjId, int Type, char *pName, char *pSuffix)
#define Saig_ManForEachPo(p, pObj, i)
#define Saig_ManForEachLo(p, pObj, i)
#define Saig_ManForEachPi(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.