ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
resSim_old.c File Reference
#include "base/abc/abc.h"
#include "resInt.h"
Include dependency graph for resSim_old.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Res_Sim_tRes_SimAlloc (int nWords)
 DECLARATIONS ///.
 
void Res_SimAdjust (Res_Sim_t *p, Abc_Ntk_t *pAig)
 
void Res_SimFree (Res_Sim_t *p)
 
void Res_SimSetRandom (Res_Sim_t *p)
 
void Res_SimSetGiven (Res_Sim_t *p, Vec_Ptr_t *vInfo)
 
void Res_SimPerformOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords)
 
void Res_SimTransferOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords)
 
void Res_SimPerformRound (Res_Sim_t *p)
 
void Res_SimProcessPats (Res_Sim_t *p)
 
void Res_SimPadSimInfo (Vec_Ptr_t *vPats, int nPats, int nWords)
 
void Res_SimDeriveInfoReplicate (Res_Sim_t *p)
 
void Res_SimDeriveInfoComplement (Res_Sim_t *p)
 
void Res_SimReportOne (Res_Sim_t *p)
 
void Res_SimPrintOutPatterns (Res_Sim_t *p, Abc_Ntk_t *pAig)
 
int Res_SimPrepare (Res_Sim_t *p, Abc_Ntk_t *pAig, int nTruePis, int fVerbose)
 

Function Documentation

◆ Res_SimAdjust()

void Res_SimAdjust ( Res_Sim_t * p,
Abc_Ntk_t * pAig )

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

Synopsis [Allocate simulation engine.]

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file resSim_old.c.

78{
79 srand( 0xABC );
80
81 assert( Abc_NtkIsStrash(pAig) );
82 p->pAig = pAig;
83 if ( Vec_PtrSize(p->vPats) < Abc_NtkObjNumMax(pAig)+1 )
84 {
85 Vec_PtrFree( p->vPats );
86 p->vPats = Vec_PtrAllocSimInfo( Abc_NtkObjNumMax(pAig)+1, p->nWords );
87 }
88 if ( Vec_PtrSize(p->vPats0) < Abc_NtkPiNum(pAig) )
89 {
90 Vec_PtrFree( p->vPats0 );
91 p->vPats0 = Vec_PtrAllocSimInfo( Abc_NtkPiNum(pAig), p->nWords );
92 }
93 if ( Vec_PtrSize(p->vPats1) < Abc_NtkPiNum(pAig) )
94 {
95 Vec_PtrFree( p->vPats1 );
96 p->vPats1 = Vec_PtrAllocSimInfo( Abc_NtkPiNum(pAig), p->nWords );
97 }
98 if ( Vec_PtrSize(p->vOuts) < Abc_NtkPoNum(pAig) )
99 {
100 Vec_PtrFree( p->vOuts );
101 p->vOuts = Vec_PtrAllocSimInfo( Abc_NtkPoNum(pAig), p->nWordsOut );
102 }
103 // clean storage info for patterns
104 Abc_InfoClear( Vec_PtrEntry(p->vPats0,0), p->nWords * Abc_NtkPiNum(pAig) );
105 Abc_InfoClear( Vec_PtrEntry(p->vPats1,0), p->nWords * Abc_NtkPiNum(pAig) );
106 p->nPats0 = 0;
107 p->nPats1 = 0;
108}
Cube * p
Definition exorList.c:222
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Res_SimAlloc()

ABC_NAMESPACE_IMPL_START Res_Sim_t * Res_SimAlloc ( int nWords)

DECLARATIONS ///.

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

FileName [resSim.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Resynthesis package.]

Synopsis [Simulation engine.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 15, 2007.]

Revision [

Id
resSim.c,v 1.00 2007/01/15 00:00:00 alanmi Exp

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

Synopsis [Allocate simulation engine.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file resSim_old.c.

47{
48 Res_Sim_t * p;
49 p = ALLOC( Res_Sim_t, 1 );
50 memset( p, 0, sizeof(Res_Sim_t) );
51 // simulation parameters
52 p->nWords = nWords;
53 p->nPats = 8 * sizeof(unsigned) * p->nWords;
54 p->nWordsOut = p->nPats * p->nWords;
55 p->nPatsOut = p->nPats * p->nPats;
56 // simulation info
57 p->vPats = Vec_PtrAllocSimInfo( 1024, p->nWords );
58 p->vPats0 = Vec_PtrAllocSimInfo( 128, p->nWords );
59 p->vPats1 = Vec_PtrAllocSimInfo( 128, p->nWords );
60 p->vOuts = Vec_PtrAllocSimInfo( 128, p->nWordsOut );
61 // resub candidates
62 p->vCands = Vec_VecStart( 16 );
63 return p;
64}
int nWords
Definition abcNpn.c:127
#define ALLOC(type, num)
Definition avl.h:27
struct Res_Sim_t_ Res_Sim_t
Definition resInt.h:69
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_SimDeriveInfoComplement()

void Res_SimDeriveInfoComplement ( Res_Sim_t * p)

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

Synopsis [Complement the simulation info if necessary.]

Description []

SideEffects []

SeeAlso []

Definition at line 384 of file resSim_old.c.

385{
386 unsigned * pInfo, * pInfo2;
387 Abc_Obj_t * pObj;
388 int i, j, w;
389 Abc_NtkForEachPo( p->pAig, pObj, i )
390 {
391 pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
392 pInfo2 = Vec_PtrEntry( p->vOuts, i );
393 for ( j = 0; j < p->nPats; j++, pInfo2 += p->nWords )
394 if ( Abc_InfoHasBit( pInfo, j ) )
395 for ( w = 0; w < p->nWords; w++ )
396 pInfo2[w] = ~pInfo2[w];
397 }
398}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
int Id
Definition abc.h:132
Here is the caller graph for this function:

◆ Res_SimDeriveInfoReplicate()

void Res_SimDeriveInfoReplicate ( Res_Sim_t * p)

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

Synopsis [Duplicates the simulation info to fill the space.]

Description []

SideEffects []

SeeAlso []

Definition at line 358 of file resSim_old.c.

359{
360 unsigned * pInfo, * pInfo2;
361 Abc_Obj_t * pObj;
362 int i, j, w;
363 Abc_NtkForEachPo( p->pAig, pObj, i )
364 {
365 pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
366 pInfo2 = Vec_PtrEntry( p->vOuts, i );
367 for ( j = 0; j < p->nPats; j++ )
368 for ( w = 0; w < p->nWords; w++ )
369 *pInfo2++ = pInfo[w];
370 }
371}
Here is the caller graph for this function:

◆ Res_SimFree()

void Res_SimFree ( Res_Sim_t * p)

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

Synopsis [Free simulation engine.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file resSim_old.c.

122{
123 Vec_PtrFree( p->vPats );
124 Vec_PtrFree( p->vPats0 );
125 Vec_PtrFree( p->vPats1 );
126 Vec_PtrFree( p->vOuts );
127 Vec_VecFree( p->vCands );
128 free( p );
129}
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_SimPadSimInfo()

void Res_SimPadSimInfo ( Vec_Ptr_t * vPats,
int nPats,
int nWords )

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

Synopsis [Pads the extra space with duplicated simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 325 of file resSim_old.c.

326{
327 unsigned * pInfo;
328 int i, w, iWords;
329 assert( nPats > 0 && nPats < nWords * 8 * (int) sizeof(unsigned) );
330 // pad the first word
331 if ( nPats < 8 * sizeof(unsigned) )
332 {
333 Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
334 if ( pInfo[0] & 1 )
335 pInfo[0] |= ((~0) << nPats);
336 nPats = 8 * sizeof(unsigned);
337 }
338 // pad the empty words
339 iWords = nPats / (8 * sizeof(unsigned));
340 Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
341 {
342 for ( w = iWords; w < nWords; w++ )
343 pInfo[w] = pInfo[0];
344 }
345}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Res_SimPerformOne()

void Res_SimPerformOne ( Abc_Obj_t * pNode,
Vec_Ptr_t * vSimInfo,
int nSimWords )

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file resSim_old.c.

192{
193 unsigned * pInfo, * pInfo1, * pInfo2;
194 int k, fComp1, fComp2;
195 // simulate the internal nodes
196 assert( Abc_ObjIsNode(pNode) );
197 pInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
198 pInfo1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
199 pInfo2 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
200 fComp1 = Abc_ObjFaninC0(pNode);
201 fComp2 = Abc_ObjFaninC1(pNode);
202 if ( fComp1 && fComp2 )
203 for ( k = 0; k < nSimWords; k++ )
204 pInfo[k] = ~pInfo1[k] & ~pInfo2[k];
205 else if ( fComp1 && !fComp2 )
206 for ( k = 0; k < nSimWords; k++ )
207 pInfo[k] = ~pInfo1[k] & pInfo2[k];
208 else if ( !fComp1 && fComp2 )
209 for ( k = 0; k < nSimWords; k++ )
210 pInfo[k] = pInfo1[k] & ~pInfo2[k];
211 else // if ( fComp1 && fComp2 )
212 for ( k = 0; k < nSimWords; k++ )
213 pInfo[k] = pInfo1[k] & pInfo2[k];
214}
Here is the caller graph for this function:

◆ Res_SimPerformRound()

void Res_SimPerformRound ( Res_Sim_t * p)

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

Synopsis [Performs one round of simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file resSim_old.c.

256{
257 Abc_Obj_t * pObj;
258 int i;
259 Abc_InfoFill( Vec_PtrEntry(p->vPats,0), p->nWords );
260 Abc_AigForEachAnd( p->pAig, pObj, i )
261 Res_SimPerformOne( pObj, p->vPats, p->nWords );
262 Abc_NtkForEachPo( p->pAig, pObj, i )
263 Res_SimTransferOne( pObj, p->vPats, p->nWords );
264}
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
void Res_SimTransferOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords)
Definition resSim_old.c:227
void Res_SimPerformOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords)
Definition resSim_old.c:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_SimPrepare()

int Res_SimPrepare ( Res_Sim_t * p,
Abc_Ntk_t * pAig,
int nTruePis,
int fVerbose )

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

Synopsis [Prepares simulation info for candidate filtering.]

Description []

SideEffects []

SeeAlso []

Definition at line 477 of file resSim_old.c.

478{
479 int Limit;
480 // prepare the manager
481 Res_SimAdjust( p, pAig );
482 // collect 0/1 simulation info
483 for ( Limit = 0; Limit < 10; Limit++ )
484 {
488 if ( !(p->nPats0 < p->nPats || p->nPats1 < p->nPats) )
489 break;
490 }
491// printf( "%d ", Limit );
492 // report the last set of patterns
493// Res_SimReportOne( p );
494// printf( "\n" );
495 // quit if there is not enough
496// if ( p->nPats0 < 4 || p->nPats1 < 4 )
497 if ( p->nPats0 < 4 || p->nPats1 < 4 )
498 {
499// Res_SimReportOne( p );
500 return 0;
501 }
502 // create bit-matrix info
503 if ( p->nPats0 < p->nPats )
504 Res_SimPadSimInfo( p->vPats0, p->nPats0, p->nWords );
505 if ( p->nPats1 < p->nPats )
506 Res_SimPadSimInfo( p->vPats1, p->nPats1, p->nWords );
507 // resimulate 0-patterns
508 Res_SimSetGiven( p, p->vPats0 );
511 // resimulate 1-patterns
512 Res_SimSetGiven( p, p->vPats1 );
515 // print output patterns
516// Res_SimPrintOutPatterns( p, pAig );
517 return 1;
518}
void Res_SimSetGiven(Res_Sim_t *p, Vec_Ptr_t *vInfo)
Definition resSim_old.c:166
void Res_SimPadSimInfo(Vec_Ptr_t *vPats, int nPats, int nWords)
Definition resSim_old.c:325
void Res_SimAdjust(Res_Sim_t *p, Abc_Ntk_t *pAig)
Definition resSim_old.c:77
void Res_SimSetRandom(Res_Sim_t *p)
Definition resSim_old.c:143
void Res_SimProcessPats(Res_Sim_t *p)
Definition resSim_old.c:277
void Res_SimDeriveInfoComplement(Res_Sim_t *p)
Definition resSim_old.c:384
void Res_SimPerformRound(Res_Sim_t *p)
Definition resSim_old.c:255
void Res_SimDeriveInfoReplicate(Res_Sim_t *p)
Definition resSim_old.c:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_SimPrintOutPatterns()

void Res_SimPrintOutPatterns ( Res_Sim_t * p,
Abc_Ntk_t * pAig )

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

Synopsis [Prints output patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file resSim_old.c.

454{
455 Abc_Obj_t * pObj;
456 unsigned * pInfo2;
457 int i;
458 Abc_NtkForEachPo( pAig, pObj, i )
459 {
460 pInfo2 = Vec_PtrEntry( p->vOuts, i );
461 Extra_PrintBinary( stdout, pInfo2, p->nPatsOut );
462 printf( "\n" );
463 }
464}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
Here is the call graph for this function:

◆ Res_SimProcessPats()

void Res_SimProcessPats ( Res_Sim_t * p)

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

Synopsis [Processes simulation patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 277 of file resSim_old.c.

278{
279 Abc_Obj_t * pObj;
280 unsigned * pInfoCare, * pInfoNode;
281 int i, j, nDcs = 0;
282 pInfoCare = Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 0)->Id );
283 pInfoNode = Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 1)->Id );
284 for ( i = 0; i < p->nPats; i++ )
285 {
286 // skip don't-care patterns
287 if ( !Abc_InfoHasBit(pInfoCare, i) )
288 {
289 nDcs++;
290 continue;
291 }
292 // separate offset and onset patterns
293 if ( !Abc_InfoHasBit(pInfoNode, i) )
294 {
295 if ( p->nPats0 >= p->nPats )
296 continue;
297 Abc_NtkForEachPi( p->pAig, pObj, j )
298 if ( Abc_InfoHasBit( Vec_PtrEntry(p->vPats, pObj->Id), i ) )
299 Abc_InfoSetBit( Vec_PtrEntry(p->vPats0, j), p->nPats0 );
300 p->nPats0++;
301 }
302 else
303 {
304 if ( p->nPats1 >= p->nPats )
305 continue;
306 Abc_NtkForEachPi( p->pAig, pObj, j )
307 if ( Abc_InfoHasBit( Vec_PtrEntry(p->vPats, pObj->Id), i ) )
308 Abc_InfoSetBit( Vec_PtrEntry(p->vPats1, j), p->nPats1 );
309 p->nPats1++;
310 }
311 }
312}
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
Here is the caller graph for this function:

◆ Res_SimReportOne()

void Res_SimReportOne ( Res_Sim_t * p)

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

Synopsis [Free simulation engine.]

Description []

SideEffects []

SeeAlso []

Definition at line 411 of file resSim_old.c.

412{
413 unsigned * pInfoCare, * pInfoNode;
414 int i, nDcs, nOnes, nZeros;
415 pInfoCare = Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 0)->Id );
416 pInfoNode = Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 1)->Id );
417 nDcs = nOnes = nZeros = 0;
418 for ( i = 0; i < p->nPats; i++ )
419 {
420 // skip don't-care patterns
421 if ( !Abc_InfoHasBit(pInfoCare, i) )
422 {
423 nDcs++;
424 continue;
425 }
426 // separate offset and onset patterns
427 if ( !Abc_InfoHasBit(pInfoNode, i) )
428 nZeros++;
429 else
430 nOnes++;
431 }
432 printf( "On = %3d (%7.2f %%) ", nOnes, 100.0*nOnes/p->nPats );
433 printf( "Off = %3d (%7.2f %%) ", nZeros, 100.0*nZeros/p->nPats );
434 printf( "Dc = %3d (%7.2f %%) ", nDcs, 100.0*nDcs/p->nPats );
435 printf( "P0 = %3d ", p->nPats0 );
436 printf( "P1 = %3d ", p->nPats1 );
437 if ( p->nPats0 < 4 || p->nPats1 < 4 )
438 printf( "*" );
439 printf( "\n" );
440}

◆ Res_SimSetGiven()

void Res_SimSetGiven ( Res_Sim_t * p,
Vec_Ptr_t * vInfo )

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

Synopsis [Sets given PI simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file resSim_old.c.

167{
168 Abc_Obj_t * pObj;
169 unsigned * pInfo, * pInfo2;
170 int i, w;
171 Abc_NtkForEachPi( p->pAig, pObj, i )
172 {
173 pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
174 pInfo2 = Vec_PtrEntry( vInfo, i );
175 for ( w = 0; w < p->nWords; w++ )
176 pInfo[w] = pInfo2[w];
177 }
178}
Here is the caller graph for this function:

◆ Res_SimSetRandom()

void Res_SimSetRandom ( Res_Sim_t * p)

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

Synopsis [Sets random PI simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file resSim_old.c.

144{
145 Abc_Obj_t * pObj;
146 unsigned * pInfo;
147 int i;
148 Abc_NtkForEachPi( p->pAig, pObj, i )
149 {
150 pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
151 Abc_InfoRandom( pInfo, p->nWords );
152 }
153}
Here is the caller graph for this function:

◆ Res_SimTransferOne()

void Res_SimTransferOne ( Abc_Obj_t * pNode,
Vec_Ptr_t * vSimInfo,
int nSimWords )

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

Synopsis [Simulates one CO node.]

Description []

SideEffects []

SeeAlso []

Definition at line 227 of file resSim_old.c.

228{
229 unsigned * pInfo, * pInfo1;
230 int k, fComp1;
231 // simulate the internal nodes
232 assert( Abc_ObjIsCo(pNode) );
233 pInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
234 pInfo1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
235 fComp1 = Abc_ObjFaninC0(pNode);
236 if ( fComp1 )
237 for ( k = 0; k < nSimWords; k++ )
238 pInfo[k] = ~pInfo1[k];
239 else
240 for ( k = 0; k < nSimWords; k++ )
241 pInfo[k] = pInfo1[k];
242}
Here is the caller graph for this function: