summaryrefslogtreecommitdiffstats
path: root/src/aig/gia/giaSim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/aig/gia/giaSim.c')
-rw-r--r--src/aig/gia/giaSim.c166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/aig/gia/giaSim.c b/src/aig/gia/giaSim.c
index 001bd8ac..ecad182f 100644
--- a/src/aig/gia/giaSim.c
+++ b/src/aig/gia/giaSim.c
@@ -1222,6 +1222,172 @@ int Gia_ManIncrSimCheckEqual( Gia_Man_t * p, int iLit0, int iLit1 )
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSimOneBit( Gia_Man_t * p, Vec_Int_t * vValues )
+{
+ Gia_Obj_t * pObj; int k;
+ assert( Vec_IntSize(vValues) == Gia_ManCiNum(p) );
+
+ Gia_ManConst0(p)->fMark0 = 0;
+ Gia_ManForEachCi( p, pObj, k )
+ pObj->fMark0 = Vec_IntEntry(vValues, k);
+ Gia_ManForEachAnd( p, pObj, k )
+ pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
+ Gia_ManForEachCo( p, pObj, k )
+ pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
+
+ Gia_ManForEachCi( p, pObj, k )
+ printf( "%d", k % 10 );
+ printf( "\n" );
+ Gia_ManForEachCi( p, pObj, k )
+ printf( "%d", Vec_IntEntry(vValues, k) );
+ printf( "\n" );
+
+ Gia_ManForEachCo( p, pObj, k )
+ printf( "%d", k % 10 );
+ printf( "\n" );
+ Gia_ManForEachCo( p, pObj, k )
+ printf( "%d", pObj->fMark0 );
+ printf( "\n" );
+ printf( "\n" );
+}
+void Gia_ManSimOneBitTest2( Gia_Man_t * p )
+{
+ Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Vec_IntWriteEntry( vValues, 1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2+2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Vec_IntWriteEntry( vValues, 1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntFill( vValues, Vec_IntSize(vValues)/2, 1 );
+ Vec_IntFillExtra( vValues, Gia_ManCiNum(p), 0 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
+
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
+
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
+ Vec_IntWriteEntry( vValues, 127, 1 );
+ Vec_IntWriteEntry( vValues, 255, 0 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
+
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
+ Vec_IntWriteEntry( vValues, 127, 0 );
+ Vec_IntWriteEntry( vValues, 255, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
+
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
+ Vec_IntWriteEntry( vValues, 127, 0 );
+ Vec_IntWriteEntry( vValues, 255, 0 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
+
+ Vec_IntFree( vValues );
+}
+void Gia_ManSimOneBitTest3( Gia_Man_t * p )
+{
+ Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, 0, 1 );
+ Vec_IntWriteEntry( vValues, 1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2+2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-3, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -3, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-3, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
+ Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -3, 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 1 );
+ Gia_ManSimOneBit( p, vValues );
+ Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
+
+ Vec_IntFree( vValues );
+}
+
+
+void Gia_ManSimOneBitTest( Gia_Man_t * p )
+{
+ Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
+ int i, k;
+ for ( i = 0; i < 10; i++ )
+ {
+ for ( k = 0; k < Vec_IntSize(vValues); k++ )
+ Vec_IntWriteEntry( vValues, k, Vec_IntEntry(vValues, k) ^ (rand()&1) );
+
+ printf( "Values = %d ", Vec_IntSum(vValues) );
+ Gia_ManSimOneBit( p, vValues );
+ }
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///