abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
simSwitch.c File Reference
#include "base/abc/abc.h"
#include "sim.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Sim_NodeSimulate (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords)
 DECLARATIONS ///. More...
 
static float Sim_ComputeSwitching (unsigned *pSimInfo, int nSimWords)
 
Vec_Int_tSim_NtkComputeSwitching (Abc_Ntk_t *pNtk, int nPatterns)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

float Sim_ComputeSwitching ( unsigned *  pSimInfo,
int  nSimWords 
)
static

Function*************************************************************

Synopsis [Computes switching activity of one node.]

Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]

SideEffects []

SeeAlso []

Definition at line 98 of file simSwitch.c.

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 }
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition: simUtils.c:402
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
static ABC_NAMESPACE_IMPL_START void Sim_NodeSimulate ( Abc_Obj_t pNode,
Vec_Ptr_t vSimInfo,
int  nSimWords 
)
static

DECLARATIONS ///.

CFile****************************************************************

FileName [simSwitch.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Computes switching activity of nodes in the ABC network.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
simSwitch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Vec_Int_t* Sim_NtkComputeSwitching ( Abc_Ntk_t pNtk,
int  nPatterns 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Computes switching activity using simulation.]

Description [Computes switching activity, which is understood as the probability of switching under random simulation. Assigns the random simulation information at the CI and propagates it through the internal nodes of the AIG.]

SideEffects []

SeeAlso []

Definition at line 52 of file simSwitch.c.

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 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:447
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
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:302
static float Sim_ComputeSwitching(unsigned *pSimInfo, int nSimWords)
Definition: simSwitch.c:98
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition: abcDfs.c:1014
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
int Id
Definition: abc.h:132
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223