abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
simMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [simMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Simulation manager.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: simMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "sim.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Starts the simulation manager.]
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
46 Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose )
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 }
86 
87 /**Function*************************************************************
88 
89  Synopsis [Stops the simulation manager.]
90 
91  Description []
92 
93  SideEffects []
94 
95  SeeAlso []
96 
97 ***********************************************************************/
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 }
123 
124 /**Function*************************************************************
125 
126  Synopsis [Prints the manager statisticis.]
127 
128  Description []
129 
130  SideEffects []
131 
132  SeeAlso []
133 
134 ***********************************************************************/
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 }
153 
154 
155 /**Function*************************************************************
156 
157  Synopsis [Starts the simulation manager.]
158 
159  Description []
160 
161  SideEffects []
162 
163  SeeAlso []
164 
165 ***********************************************************************/
166 Sim_Man_t * Sim_ManStart( Abc_Ntk_t * pNtk, int fLightweight )
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 }
196 
197 /**Function*************************************************************
198 
199  Synopsis [Stops the simulation manager.]
200 
201  Description []
202 
203  SideEffects []
204 
205  SeeAlso []
206 
207 ***********************************************************************/
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 }
221 
222 /**Function*************************************************************
223 
224  Synopsis [Prints the manager statisticis.]
225 
226  Description []
227 
228  SideEffects []
229 
230  SeeAlso []
231 
232 ***********************************************************************/
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 }
247 
248 
249 
250 /**Function*************************************************************
251 
252  Synopsis [Returns one simulation pattern.]
253 
254  Description []
255 
256  SideEffects []
257 
258  SeeAlso []
259 
260 ***********************************************************************/
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 }
270 
271 /**Function*************************************************************
272 
273  Synopsis [Returns one simulation pattern.]
274 
275  Description []
276 
277  SideEffects []
278 
279  SeeAlso []
280 
281 ***********************************************************************/
283 {
284  Extra_MmFixedEntryRecycle( p->pMmPat, (char *)pPat );
285 }
286 
287 ////////////////////////////////////////////////////////////////////////
288 /// END OF FILE ///
289 ////////////////////////////////////////////////////////////////////////
290 
291 
293 
char * memset()
Vec_Ptr_t * vFifo
Definition: sim.h:123
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
int nSuppWords
Definition: sim.h:115
void Sym_ManStop(Sym_Man_t *p)
Definition: simMan.c:98
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
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
int Sim_UtilCountSuppSizes(Sim_Man_t *p, int fStruct)
Definition: simUtils.c:371
static Llb_Mgr_t * p
Definition: llb3Image.c:950
abctime timeSat
Definition: sim.h:132
int nSimWords
Definition: sim.h:110
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Vec_Int_t * vDiffs
Definition: sim.h:124
int nSatRunsUnsat
Definition: sim.h:127
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
abctime timeTrav
Definition: sim.h:130
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
struct Sim_Pat_t_ Sim_Pat_t
Definition: sim.h:136
abctime timeTotal
Definition: sim.h:133
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
unsigned * pData
Definition: sim.h:141
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
int Output
Definition: sim.h:140
Vec_Ptr_t * Sim_ComputeStrSupp(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: simSupp.c:57
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
abctime timeSim
Definition: sim.h:129
Vec_Ptr_t * vSuppStr
Definition: sim.h:116
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
abctime timeFraig
Definition: sim.h:131
void Sim_ManPatFree(Sim_Man_t *p, Sim_Pat_t *pPat)
Definition: simMan.c:282
void Extra_BitMatrixStop(Extra_BitMat_t *p)
void Sim_ManStop(Sim_Man_t *p)
Definition: simMan.c:208
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
Sim_Pat_t * Sim_ManPatAlloc(Sim_Man_t *p)
Definition: simMan.c:261
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void Sim_ManPrintStats(Sim_Man_t *p)
Definition: simMan.c:233
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
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Extra_BitMat_t * Extra_BitMatrixStart(int nSize)
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
int nSatRunsSat
Definition: sim.h:126
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
Vec_Ptr_t * Sim_ComputeFunSupp(Abc_Ntk_t *pNtk, int fVerbose)
Definition: simSupp.c:103
Abc_Ntk_t * pNtk
Definition: sim.h:104
Sim_Man_t * Sim_ManStart(Abc_Ntk_t *pNtk, int fLightweight)
Definition: simMan.c:166
ABC_NAMESPACE_IMPL_START Sym_Man_t * Sym_ManStart(Abc_Ntk_t *pNtk, int fVerbose)
DECLARATIONS ///.
Definition: simMan.c:46
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
int nOutputs
Definition: sim.h:106
int nInputs
Definition: sim.h:105
#define Sim_SuppFunHasVar(vSupps, Output, v)
Definition: sim.h:169
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Sym_ManPrintStats(Sym_Man_t *p)
Definition: simMan.c:135