ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
simSwitch.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "sim.h"
23
25
26
30
31static void Sim_NodeSimulate( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords );
32static float Sim_ComputeSwitching( unsigned * pSimInfo, int nSimWords );
33
37
53{
54 Vec_Int_t * vSwitching;
55 float * pSwitching;
56 Vec_Ptr_t * vNodes;
57 Vec_Ptr_t * vSimInfo;
58 Abc_Obj_t * pNode;
59 unsigned * pSimInfo;
60 int nSimWords, i;
61
62 // allocate space for simulation info of all nodes
63 nSimWords = SIM_NUM_WORDS(nPatterns);
64 vSimInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nSimWords, 0 );
65 // assign the random simulation to the CIs
66 vSwitching = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
67 pSwitching = (float *)vSwitching->pArray;
68 Abc_NtkForEachCi( pNtk, pNode, i )
69 {
70 pSimInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
71 Sim_UtilSetRandom( pSimInfo, nSimWords );
72 pSwitching[pNode->Id] = Sim_ComputeSwitching( pSimInfo, nSimWords );
73 }
74 // simulate the internal nodes
75 vNodes = Abc_AigDfs( pNtk, 1, 0 );
76 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
77 {
78 pSimInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
79 Sim_UtilSimulateNodeOne( pNode, vSimInfo, nSimWords, 0 );
80 pSwitching[pNode->Id] = Sim_ComputeSwitching( pSimInfo, nSimWords );
81 }
82 Vec_PtrFree( vNodes );
83 Sim_UtilInfoFree( vSimInfo );
84 return vSwitching;
85}
86
98float Sim_ComputeSwitching( unsigned * pSimInfo, int nSimWords )
99{
100 int nOnes, nTotal;
101 nTotal = 32 * nSimWords;
102 nOnes = Sim_UtilCountOnes( pSimInfo, nSimWords );
103 return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
104}
105
109
110
112
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition abcDfs.c:1198
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Vec_Int_t * Sim_NtkComputeSwitching(Abc_Ntk_t *pNtk, int nPatterns)
FUNCTION DEFINITIONS ///.
Definition simSwitch.c:52
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition simUtils.c:84
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition simUtils.c:448
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition simUtils.c:57
void Sim_UtilSimulateNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
Definition simUtils.c:303
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition simUtils.c:403
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition sim.h:148
int Id
Definition abc.h:132
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55