00001
00021 #include "abc.h"
00022 #include "sim.h"
00023
00027
00028 static void Sim_SimulateSeqFrame( Vec_Ptr_t * vInfo, Abc_Ntk_t * pNtk, int iFrames, int nWords, int fTransfer );
00029
00033
00048 Vec_Ptr_t * Sim_SimulateSeqRandom( Abc_Ntk_t * pNtk, int nFrames, int nWords )
00049 {
00050 Vec_Ptr_t * vInfo;
00051 Abc_Obj_t * pNode;
00052 int i;
00053 assert( Abc_NtkIsStrash(pNtk) );
00054 vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nWords * nFrames, 0 );
00055
00056 pNode = Abc_AigConst1(pNtk);
00057 Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames, 1 );
00058
00059 Abc_NtkForEachPi( pNtk, pNode, i )
00060 Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames );
00061
00062 Abc_NtkForEachLatch( pNtk, pNode, i )
00063 if ( Abc_LatchIsInit0(pNode) )
00064 Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 0 );
00065 else if ( Abc_LatchIsInit1(pNode) )
00066 Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 1 );
00067 else
00068 Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords );
00069
00070 for ( i = 0; i < nFrames; i++ )
00071 Sim_SimulateSeqFrame( vInfo, pNtk, i, nWords, (int)(i < nFrames-1) );
00072 return vInfo;
00073 }
00074
00089 Vec_Ptr_t * Sim_SimulateSeqModel( Abc_Ntk_t * pNtk, int nFrames, int * pModel )
00090 {
00091 Vec_Ptr_t * vInfo;
00092 Abc_Obj_t * pNode;
00093 unsigned * pUnsigned;
00094 int i, k;
00095 vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nFrames, 0 );
00096
00097 pNode = Abc_AigConst1(pNtk);
00098 Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nFrames, 1 );
00099
00100 Abc_NtkForEachPi( pNtk, pNode, i )
00101 {
00102 pUnsigned = Sim_SimInfoGet(vInfo,pNode);
00103 for ( k = 0; k < nFrames; k++ )
00104 pUnsigned[k] = pModel[k * Abc_NtkPiNum(pNtk) + i] ? ~((unsigned)0) : 0;
00105 }
00106
00107 Abc_NtkForEachLatch( pNtk, pNode, i )
00108 {
00109 pUnsigned = Sim_SimInfoGet(vInfo,pNode);
00110 if ( Abc_LatchIsInit0(pNode) )
00111 pUnsigned[0] = 0;
00112 else if ( Abc_LatchIsInit1(pNode) )
00113 pUnsigned[0] = ~((unsigned)0);
00114 else
00115 pUnsigned[0] = SIM_RANDOM_UNSIGNED;
00116 }
00117
00118 for ( i = 0; i < nFrames; i++ )
00119 Sim_SimulateSeqFrame( vInfo, pNtk, i, 1, (int)(i < nFrames-1) );
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 return vInfo;
00138 }
00139
00152 void Sim_SimulateSeqFrame( Vec_Ptr_t * vInfo, Abc_Ntk_t * pNtk, int iFrames, int nWords, int fTransfer )
00153 {
00154 Abc_Obj_t * pNode;
00155 int i;
00156 Abc_NtkForEachNode( pNtk, pNode, i )
00157 Sim_UtilSimulateNodeOne( pNode, vInfo, nWords, iFrames * nWords );
00158 Abc_NtkForEachPo( pNtk, pNode, i )
00159 Sim_UtilTransferNodeOne( pNode, vInfo, nWords, iFrames * nWords, 0 );
00160 if ( !fTransfer )
00161 return;
00162 Abc_NtkForEachLatch( pNtk, pNode, i )
00163 Sim_UtilTransferNodeOne( pNode, vInfo, nWords, iFrames * nWords, 1 );
00164 }
00165
00166
00170
00171