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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Sym_Man_t
Sym_ManStart (Abc_Ntk_t *pNtk, int fVerbose)
 DECLARATIONS ///. More...
 
void Sym_ManStop (Sym_Man_t *p)
 
void Sym_ManPrintStats (Sym_Man_t *p)
 
Sim_Man_tSim_ManStart (Abc_Ntk_t *pNtk, int fLightweight)
 
void Sim_ManStop (Sim_Man_t *p)
 
void Sim_ManPrintStats (Sim_Man_t *p)
 
Sim_Pat_tSim_ManPatAlloc (Sim_Man_t *p)
 
void Sim_ManPatFree (Sim_Man_t *p, Sim_Pat_t *pPat)
 

Function Documentation

Sim_Pat_t* Sim_ManPatAlloc ( Sim_Man_t p)

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

Synopsis [Returns one simulation pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file simMan.c.

262 {
263  Sim_Pat_t * pPat;
264  pPat = (Sim_Pat_t *)Extra_MmFixedEntryFetch( p->pMmPat );
265  pPat->Output = -1;
266  pPat->pData = (unsigned *)((char *)pPat + sizeof(Sim_Pat_t));
267  memset( pPat->pData, 0, p->nSuppWords * sizeof(unsigned) );
268  return pPat;
269 }
char * memset()
int nSuppWords
Definition: sim.h:115
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
struct Sim_Pat_t_ Sim_Pat_t
Definition: sim.h:136
unsigned * pData
Definition: sim.h:141
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
int Output
Definition: sim.h:140
void Sim_ManPatFree ( Sim_Man_t p,
Sim_Pat_t pPat 
)

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

Synopsis [Returns one simulation pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file simMan.c.

283 {
284  Extra_MmFixedEntryRecycle( p->pMmPat, (char *)pPat );
285 }
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
void Sim_ManPrintStats ( Sim_Man_t p)

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

Synopsis [Prints the manager statisticis.]

Description []

SideEffects []

SeeAlso []

Definition at line 233 of file simMan.c.

234 {
235 // printf( "Inputs = %5d. Outputs = %5d. Sim words = %5d.\n",
236 // Abc_NtkCiNum(p->pNtk), Abc_NtkCoNum(p->pNtk), p->nSimWords );
237  printf( "Total func supps = %8d.\n", Sim_UtilCountSuppSizes(p, 0) );
238  printf( "Total struct supps = %8d.\n", Sim_UtilCountSuppSizes(p, 1) );
239  printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat );
240  printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat );
241  ABC_PRT( "Simulation ", p->timeSim );
242  ABC_PRT( "Traversal ", p->timeTrav );
243  ABC_PRT( "Fraiging ", p->timeFraig );
244  ABC_PRT( "SAT ", p->timeSat );
245  ABC_PRT( "TOTAL ", p->timeTotal );
246 }
int Sim_UtilCountSuppSizes(Sim_Man_t *p, int fStruct)
Definition: simUtils.c:371
abctime timeSat
Definition: sim.h:132
int nSatRunsUnsat
Definition: sim.h:127
abctime timeTrav
Definition: sim.h:130
abctime timeTotal
Definition: sim.h:133
abctime timeSim
Definition: sim.h:129
abctime timeFraig
Definition: sim.h:131
int nSatRunsSat
Definition: sim.h:126
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Sim_Man_t* Sim_ManStart ( Abc_Ntk_t pNtk,
int  fLightweight 
)

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

Synopsis [Starts the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file simMan.c.

167 {
168  Sim_Man_t * p;
169  // start the manager
170  p = ABC_ALLOC( Sim_Man_t, 1 );
171  memset( p, 0, sizeof(Sim_Man_t) );
172  p->pNtk = pNtk;
173  p->nInputs = Abc_NtkCiNum(p->pNtk);
174  p->nOutputs = Abc_NtkCoNum(p->pNtk);
175  // internal simulation information
176  p->nSimBits = 2048;
178  p->vSim0 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
179  p->fLightweight = fLightweight;
180  if (!p->fLightweight) {
181  p->vSim1 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
182  // support information
183  p->nSuppBits = Abc_NtkCiNum(pNtk);
185  p->vSuppStr = Sim_ComputeStrSupp( pNtk );
187  // other data
188  p->pMmPat = Extra_MmFixedStart( sizeof(Sim_Pat_t) + p->nSuppWords * sizeof(unsigned) );
189  p->vFifo = Vec_PtrAlloc( 100 );
190  p->vDiffs = Vec_IntAlloc( 100 );
191  // allocate support targets (array of unresolved outputs for each input)
192  p->vSuppTargs = Vec_VecStart( p->nInputs );
193  }
194  return p;
195 }
char * memset()
Vec_Ptr_t * vFifo
Definition: sim.h:123
int nSuppWords
Definition: sim.h:115
Vec_Ptr_t * vSuppFun
Definition: sim.h:117
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nSimWords
Definition: sim.h:110
Vec_Int_t * vDiffs
Definition: sim.h:124
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
Vec_Ptr_t * Sim_ComputeStrSupp(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: simSupp.c:57
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
Vec_Ptr_t * vSuppStr
Definition: sim.h:116
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
Vec_Ptr_t * vSim1
Definition: sim.h:112
int fLightweight
Definition: sim.h:107
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
int nSuppBits
Definition: sim.h:114
int nSimBits
Definition: sim.h:109
Vec_Ptr_t * vSim0
Definition: sim.h:111
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
Abc_Ntk_t * pNtk
Definition: sim.h:104
int nOutputs
Definition: sim.h:106
int nInputs
Definition: sim.h:105
void Sim_ManStop ( Sim_Man_t p)

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

Synopsis [Stops the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file simMan.c.

209 {
210  Sim_ManPrintStats( p );
211  if ( p->vSim0 ) Sim_UtilInfoFree( p->vSim0 );
212  if ( p->vSim1 ) Sim_UtilInfoFree( p->vSim1 );
213  if ( p->vSuppStr ) Sim_UtilInfoFree( p->vSuppStr );
214 // if ( p->vSuppFun ) Sim_UtilInfoFree( p->vSuppFun );
215  if ( p->vSuppTargs ) Vec_VecFree( p->vSuppTargs );
216  if ( p->pMmPat ) Extra_MmFixedStop( p->pMmPat );
217  if ( p->vFifo ) Vec_PtrFree( p->vFifo );
218  if ( p->vDiffs ) Vec_IntFree( p->vDiffs );
219  ABC_FREE( p );
220 }
Vec_Ptr_t * vFifo
Definition: sim.h:123
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Vec_Int_t * vDiffs
Definition: sim.h:124
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
Vec_Ptr_t * vSuppStr
Definition: sim.h:116
void Sim_ManPrintStats(Sim_Man_t *p)
Definition: simMan.c:233
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Sym_ManPrintStats ( Sym_Man_t p)

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

Synopsis [Prints the manager statisticis.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file simMan.c.

136 {
137 // printf( "Inputs = %5d. Outputs = %5d. Sim words = %5d.\n",
138 // Abc_NtkCiNum(p->pNtk), Abc_NtkCoNum(p->pNtk), p->nSimWords );
139  printf( "Total symm = %8d.\n", p->nPairsSymm );
140  printf( "Structural symm = %8d.\n", p->nPairsSymmStr );
141  printf( "Total non-sym = %8d.\n", p->nPairsNonSymm );
142  printf( "Total var pairs = %8d.\n", p->nPairsTotal );
143  printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat );
144  printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat );
145  ABC_PRT( "Structural ", p->timeStruct );
146  ABC_PRT( "Simulation ", p->timeSim );
147  ABC_PRT( "Matrix ", p->timeMatr );
148  ABC_PRT( "Counting ", p->timeCount );
149  ABC_PRT( "Fraiging ", p->timeFraig );
150  ABC_PRT( "SAT ", p->timeSat );
151  ABC_PRT( "TOTAL ", p->timeTotal );
152 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_NAMESPACE_IMPL_START Sym_Man_t* Sym_ManStart ( Abc_Ntk_t pNtk,
int  fVerbose 
)

DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

FileName [simMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Simulation manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Starts the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file simMan.c.

47 {
48  Sym_Man_t * p;
49  int i, v;
50  // start the manager
51  p = ABC_ALLOC( Sym_Man_t, 1 );
52  memset( p, 0, sizeof(Sym_Man_t) );
53  p->pNtk = pNtk;
54  p->vNodes = Abc_NtkDfs( pNtk, 0 );
55  p->nInputs = Abc_NtkCiNum(p->pNtk);
56  p->nOutputs = Abc_NtkCoNum(p->pNtk);
57  // internal simulation information
58  p->nSimWords = SIM_NUM_WORDS(p->nInputs);
59  p->vSim = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
60  // symmetry info for each output
61  p->vMatrSymms = Vec_PtrStart( p->nOutputs );
62  p->vMatrNonSymms = Vec_PtrStart( p->nOutputs );
63  p->vPairsTotal = Vec_IntStart( p->nOutputs );
64  p->vPairsSym = Vec_IntStart( p->nOutputs );
65  p->vPairsNonSym = Vec_IntStart( p->nOutputs );
66  for ( i = 0; i < p->nOutputs; i++ )
67  {
68  p->vMatrSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs );
69  p->vMatrNonSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs );
70  }
71  // temporary patterns
72  p->uPatRand = ABC_ALLOC( unsigned, p->nSimWords );
73  p->uPatCol = ABC_ALLOC( unsigned, p->nSimWords );
74  p->uPatRow = ABC_ALLOC( unsigned, p->nSimWords );
75  p->vVarsU = Vec_IntStart( 100 );
76  p->vVarsV = Vec_IntStart( 100 );
77  // compute supports
78  p->vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
79  p->vSupports = Vec_VecStart( p->nOutputs );
80  for ( i = 0; i < p->nOutputs; i++ )
81  for ( v = 0; v < p->nInputs; v++ )
82  if ( Sim_SuppFunHasVar( p->vSuppFun, i, v ) )
83  Vec_VecPush( p->vSupports, i, (void *)(ABC_PTRUINT_T)v );
84  return p;
85 }
char * memset()
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
typedefABC_NAMESPACE_HEADER_START struct Sym_Man_t_ Sym_Man_t
INCLUDES ///.
Definition: sim.h:48
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
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
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
Extra_BitMat_t * Extra_BitMatrixStart(int nSize)
Vec_Ptr_t * Sim_ComputeFunSupp(Abc_Ntk_t *pNtk, int fVerbose)
Definition: simSupp.c:103
#define Sim_SuppFunHasVar(vSupps, Output, v)
Definition: sim.h:169
void Sym_ManStop ( Sym_Man_t p)

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

Synopsis [Stops the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file simMan.c.

99 {
100  int i;
101  Sym_ManPrintStats( p );
102  if ( p->vSuppFun ) Sim_UtilInfoFree( p->vSuppFun );
103  if ( p->vSim ) Sim_UtilInfoFree( p->vSim );
104  if ( p->vNodes ) Vec_PtrFree( p->vNodes );
105  if ( p->vSupports ) Vec_VecFree( p->vSupports );
106  for ( i = 0; i < p->nOutputs; i++ )
107  {
108  Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrSymms->pArray[i] );
109  Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrNonSymms->pArray[i] );
110  }
111  Vec_IntFree( p->vVarsU );
112  Vec_IntFree( p->vVarsV );
113  Vec_PtrFree( p->vMatrSymms );
114  Vec_PtrFree( p->vMatrNonSymms );
115  Vec_IntFree( p->vPairsTotal );
116  Vec_IntFree( p->vPairsSym );
117  Vec_IntFree( p->vPairsNonSym );
118  ABC_FREE( p->uPatRand );
119  ABC_FREE( p->uPatCol );
120  ABC_FREE( p->uPatRow );
121  ABC_FREE( p );
122 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
void Extra_BitMatrixStop(Extra_BitMat_t *p)
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Sym_ManPrintStats(Sym_Man_t *p)
Definition: simMan.c:135