summaryrefslogtreecommitdiffstats
path: root/src/base/abci/abcXsim.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-11-11 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2006-11-11 08:01:00 -0800
commitda5e0785dfb98335bd49a13bf9e86e736fb931be (patch)
tree3e88084f64093c8394fddf2d96b522a4df183981 /src/base/abci/abcXsim.c
parentfaf1265bb82f934cc14b6106ccce89e37203efbd (diff)
downloadabc-da5e0785dfb98335bd49a13bf9e86e736fb931be.tar.gz
abc-da5e0785dfb98335bd49a13bf9e86e736fb931be.tar.bz2
abc-da5e0785dfb98335bd49a13bf9e86e736fb931be.zip
Version abc61111
Diffstat (limited to 'src/base/abci/abcXsim.c')
-rw-r--r--src/base/abci/abcXsim.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/base/abci/abcXsim.c b/src/base/abci/abcXsim.c
index 1d56ba36..d17ab1dd 100644
--- a/src/base/abci/abcXsim.c
+++ b/src/base/abci/abcXsim.c
@@ -24,9 +24,9 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-#define XVS0 1
-#define XVS1 2
-#define XVSX 3
+#define XVS0 ABC_INIT_ZERO
+#define XVS1 ABC_INIT_ONE
+#define XVSX ABC_INIT_DC
static inline void Abc_ObjSetXsim( Abc_Obj_t * pObj, int Value ) { pObj->pCopy = (void *)Value; }
static inline int Abc_ObjGetXsim( Abc_Obj_t * pObj ) { return (int)pObj->pCopy; }
@@ -157,6 +157,49 @@ void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fInputs, int fVer
}
}
+/**Function*************************************************************
+
+ Synopsis [Cycles the circuit to create a new initial state.]
+
+ Description [Simulates the circuit with random input for the given
+ number of timeframes to get a better initial state.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
+{
+ Abc_Obj_t * pObj;
+ int i, f;
+ assert( Abc_NtkIsStrash(pNtk) );
+ srand( 0x12341234 );
+ // initialize the values
+ Abc_ObjSetXsim( Abc_AigConst1(pNtk), XVS1 );
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_LatchIsInit1(pObj)? XVS1 : XVS0 );
+ // simulate for the given number of timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ Abc_AigForEachAnd( pNtk, pObj, i )
+ Abc_ObjSetXsim( pObj, Abc_XsimAnd(Abc_ObjGetXsimFanin0(pObj), Abc_ObjGetXsimFanin1(pObj)) );
+ Abc_NtkForEachCo( pNtk, pObj, i )
+ Abc_ObjSetXsim( pObj, Abc_ObjGetXsimFanin0(pObj) );
+ // assign input values
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ Abc_ObjSetXsim( pObj, Abc_XsimRand2() );
+ // transfer the latch values
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjSetXsim( Abc_ObjFanout0(pObj), Abc_ObjGetXsim(Abc_ObjFanin0(pObj)) );
+ }
+ // set the final values
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ pObj->pData = (void *)Abc_ObjGetXsim(Abc_ObjFanout0(pObj));
+}
+
///////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////