summaryrefslogtreecommitdiffstats
path: root/src/aig/gia
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2022-06-05 18:27:40 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2022-06-05 18:27:40 -0700
commit617eb759ae67b7fc839322639ab97cc6200e53af (patch)
treeb92fab5f7886f308ea396280425f13293e89a3e9 /src/aig/gia
parentaebf1e7b9c531c7907263cb573d8ff2d1a55cebd (diff)
downloadabc-617eb759ae67b7fc839322639ab97cc6200e53af.tar.gz
abc-617eb759ae67b7fc839322639ab97cc6200e53af.tar.bz2
abc-617eb759ae67b7fc839322639ab97cc6200e53af.zip
Enabling support for reading AIGs with XOR gates.
Diffstat (limited to 'src/aig/gia')
-rw-r--r--src/aig/gia/giaMuxes.c67
-rw-r--r--src/aig/gia/giaSimBase.c8
2 files changed, 74 insertions, 1 deletions
diff --git a/src/aig/gia/giaMuxes.c b/src/aig/gia/giaMuxes.c
index 7b3aa54c..ff542c30 100644
--- a/src/aig/gia/giaMuxes.c
+++ b/src/aig/gia/giaMuxes.c
@@ -149,6 +149,73 @@ Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p, int Limit )
/**Function*************************************************************
+ Synopsis [Creates AIG with XORs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCreateXors( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew; Gia_Obj_t * pObj, * pFan0, * pFan1;
+ Vec_Int_t * vRefs = Vec_IntStart( Gia_ManObjNum(p) );
+ int i, iLit0, iLit1, nXors = 0, nObjs = 0;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark0 = 0;
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
+ {
+ Vec_IntAddToEntry( vRefs, Gia_ObjId(p, Gia_Regular(pFan0)), 1 );
+ Vec_IntAddToEntry( vRefs, Gia_ObjId(p, Gia_Regular(pFan1)), 1 );
+ pObj->fMark0 = 1;
+ nXors++;
+ }
+ else
+ {
+ Vec_IntAddToEntry( vRefs, Gia_ObjFaninId0(pObj, i), 1 );
+ Vec_IntAddToEntry( vRefs, Gia_ObjFaninId1(pObj, i), 1 );
+ }
+ }
+ Gia_ManForEachCo( p, pObj, i )
+ Vec_IntAddToEntry( vRefs, Gia_ObjFaninId0p(p, pObj), 1 );
+ Gia_ManForEachAnd( p, pObj, i )
+ nObjs += Vec_IntEntry(vRefs, i) > 0;
+ pNew = Gia_ManStart( 1 + Gia_ManCiNum(p) + Gia_ManCoNum(p) + nObjs );
+ pNew->pName = Abc_UtilStrsav( p->pName );
+ pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ else if ( Gia_ObjIsBuf(pObj) )
+ pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+ else if ( pObj->fMark0 )
+ {
+ Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1);
+ iLit0 = Abc_LitNotCond( Gia_Regular(pFan0)->Value, Gia_IsComplement(pFan0) );
+ iLit1 = Abc_LitNotCond( Gia_Regular(pFan1)->Value, Gia_IsComplement(pFan1) );
+ pObj->Value = Gia_ManAppendXorReal( pNew, iLit0, iLit1 );
+ }
+ else if ( Vec_IntEntry(vRefs, i) > 0 )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ }
+ assert( pNew->nObjs == pNew->nObjsAlloc );
+ pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjs );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ Vec_IntFree( vRefs );
+ //printf( "Created %d XORs.\n", nXors );
+ return pNew;
+}
+
+/**Function*************************************************************
+
Synopsis [Derives GIA without MUXes.]
Description []
diff --git a/src/aig/gia/giaSimBase.c b/src/aig/gia/giaSimBase.c
index c8808532..002f6bc2 100644
--- a/src/aig/gia/giaSimBase.c
+++ b/src/aig/gia/giaSimBase.c
@@ -2485,15 +2485,21 @@ void Gia_ManSimGen( Gia_Man_t * pGia )
SeeAlso []
***********************************************************************/
-int Gia_ManSimTwo( Gia_Man_t * p0, Gia_Man_t * p1, int nWords, int nRounds, int fVerbose )
+int Gia_ManSimTwo( Gia_Man_t * p0, Gia_Man_t * p1, int nWords, int nRounds, int TimeLimit, int fVerbose )
{
Vec_Wrd_t * vSim0, * vSim1, * vSim2;
abctime clk = Abc_Clock();
int n, i, RetValue = 1;
+ int TimeStop = TimeLimit ? TimeLimit * CLOCKS_PER_SEC + Abc_Clock() : 0; // in CPU ticks
printf( "Simulating %d round with %d machine words.\n", nRounds, nWords );
Abc_RandomW(0);
for ( n = 0; RetValue && n < nRounds; n++ )
{
+ if ( TimeStop && Abc_Clock() > TimeStop )
+ {
+ printf( "Computation timed out after %d seconds and %d rounds.\n", TimeLimit, n );
+ break;
+ }
vSim0 = Vec_WrdStartRandom( Gia_ManCiNum(p0) * nWords );
p0->vSimsPi = vSim0;
p1->vSimsPi = vSim0;