ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
saigStrSim.c File Reference
#include "saig.h"
#include "proof/ssw/ssw.h"
Include dependency graph for saigStrSim.c:

Go to the source code of this file.

Macros

#define SAIG_WORDS   16
 DECLARATIONS ///.
 

Functions

unsigned Saig_StrSimHash (Aig_Obj_t *pObj)
 FUNCTION DEFINITIONS ///.
 
int Saig_StrSimIsEqual (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 
int Saig_StrSimIsZero (Aig_Obj_t *pObj)
 
int Saig_StrSimIsOne (Aig_Obj_t *pObj)
 
void Saig_StrSimAssignRandom (Aig_Obj_t *pObj)
 
void Saig_StrSimAssignOne (Aig_Obj_t *pObj)
 
void Saig_StrSimAssignZeroInit (Aig_Obj_t *pObj)
 
void Saig_StrSimulateNode (Aig_Obj_t *pObj, int i)
 
void Saig_StrSimSaveOutput (Aig_Obj_t *pObj, int i)
 
void Saig_StrSimTransfer (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 
void Saig_StrSimTransferNext (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1, int i)
 
void Saig_StrSimulateRound (Aig_Man_t *p0, Aig_Man_t *p1)
 
Aig_Obj_tSaig_StrSimTableLookup (Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
 
void Saig_StrSimTableInsert (Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
 
int Saig_StrSimDetectUnique (Aig_Man_t *p0, Aig_Man_t *p1)
 
int Saig_StrSimCountMatchedFlops (Aig_Man_t *p)
 
int Saig_StrSimCountMatchedNodes (Aig_Man_t *p)
 
void Saig_StrSimPrepareAig (Aig_Man_t *p)
 
void Saig_StrSimSetInitMatching (Aig_Man_t *p0, Aig_Man_t *p1)
 
void Saig_StrSimSetFinalMatching (Aig_Man_t *p0, Aig_Man_t *p1)
 
void Saig_StrSimSetContiguousMatching_rec (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Saig_StrSimSetContiguousMatching (Aig_Man_t *p0, Aig_Man_t *p1)
 
void Ssw_StrSimMatchingExtendOne (Aig_Man_t *p, Vec_Ptr_t *vNodes)
 
int Ssw_StrSimMatchingCountUnmached (Aig_Man_t *p)
 
void Ssw_StrSimMatchingExtend (Aig_Man_t *p0, Aig_Man_t *p1, int nDist, int fVerbose)
 
Vec_Int_tSaig_StrSimPerformMatching (Aig_Man_t *p0, Aig_Man_t *p1, int nDist, int fVerbose, Aig_Man_t **ppMiter)
 

Macro Definition Documentation

◆ SAIG_WORDS

#define SAIG_WORDS   16

DECLARATIONS ///.

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

FileName [saigStrSim.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Sequential AIG package.]

Synopsis [Structural matching using simulation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file saigStrSim.c.

Function Documentation

◆ Saig_StrSimAssignOne()

void Saig_StrSimAssignOne ( Aig_Obj_t * pObj)

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

Synopsis [Assigns constant 0 simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file saigStrSim.c.

173{
174 unsigned * pSims = (unsigned *)pObj->pData;
175 int i;
176 for ( i = 0; i < SAIG_WORDS; i++ )
177 pSims[i] = ~0;
178}
#define SAIG_WORDS
DECLARATIONS ///.
Definition saigStrSim.c:31
void * pData
Definition aig.h:87
Here is the caller graph for this function:

◆ Saig_StrSimAssignRandom()

void Saig_StrSimAssignRandom ( Aig_Obj_t * pObj)

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

Synopsis [Assigns random simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file saigStrSim.c.

154{
155 unsigned * pSims = (unsigned *)pObj->pData;
156 int i;
157 for ( i = 0; i < SAIG_WORDS; i++ )
158 pSims[i] = Aig_ManRandom(0);
159}
unsigned Aig_ManRandom(int fReset)
Definition aigUtil.c:1170
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimAssignZeroInit()

void Saig_StrSimAssignZeroInit ( Aig_Obj_t * pObj)

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

Synopsis [Assigns constant 0 simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file saigStrSim.c.

192{
193 unsigned * pSims = (unsigned *)pObj->pData;
194 pSims[0] = 0;
195}
Here is the caller graph for this function:

◆ Saig_StrSimCountMatchedFlops()

int Saig_StrSimCountMatchedFlops ( Aig_Man_t * p)

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

Synopsis [Counts the number of matched flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 476 of file saigStrSim.c.

477{
478 Aig_Obj_t * pObj;
479 int i, Counter = 0;
480 Saig_ManForEachLo( p, pObj, i )
481 if ( Aig_ObjRepr(p, pObj) )
482 Counter++;
483 return Counter;
484}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Cube * p
Definition exorList.c:222
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
Here is the caller graph for this function:

◆ Saig_StrSimCountMatchedNodes()

int Saig_StrSimCountMatchedNodes ( Aig_Man_t * p)

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

Synopsis [Counts the number of matched nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 497 of file saigStrSim.c.

498{
499 Aig_Obj_t * pObj;
500 int i, Counter = 0;
501 Aig_ManForEachNode( p, pObj, i )
502 if ( Aig_ObjRepr(p, pObj) )
503 Counter++;
504 return Counter;
505}
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
Here is the caller graph for this function:

◆ Saig_StrSimDetectUnique()

int Saig_StrSimDetectUnique ( Aig_Man_t * p0,
Aig_Man_t * p1 )

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

Synopsis [Perform one round of matching.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file saigStrSim.c.

395{
396 Aig_Obj_t ** ppTable, ** ppNexts, ** ppCands;
397 Aig_Obj_t * pObj, * pEntry;
398 int i, nTableSize, Counter;
399
400 // allocate the hash table hashing simulation info into nodes
401 nTableSize = Abc_PrimeCudd( Aig_ManObjNum(p0)/2 );
402 ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
403 ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
404 ppCands = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
405
406 // hash nodes of the first AIG
407 Aig_ManForEachObj( p0, pObj, i )
408 {
409 if ( !Aig_ObjIsCi(pObj) && !Aig_ObjIsNode(pObj) )
410 continue;
411 if ( Aig_ObjRepr(p0, pObj) )
412 continue;
413 if ( Saig_StrSimIsZero(pObj) || Saig_StrSimIsOne(pObj) )
414 continue;
415 // check if the entry exists
416 pEntry = Saig_StrSimTableLookup( ppTable, ppNexts, nTableSize, pObj );
417 if ( pEntry == NULL ) // insert
418 Saig_StrSimTableInsert( ppTable, ppNexts, nTableSize, pObj );
419 else // mark the entry as not unique
420 pEntry->fMarkA = 1;
421 }
422
423 // hash nodes from the second AIG
424 Aig_ManForEachObj( p1, pObj, i )
425 {
426 if ( !Aig_ObjIsCi(pObj) && !Aig_ObjIsNode(pObj) )
427 continue;
428 if ( Aig_ObjRepr(p1, pObj) )
429 continue;
430 if ( Saig_StrSimIsZero(pObj) || Saig_StrSimIsOne(pObj) )
431 continue;
432 // check if the entry exists
433 pEntry = Saig_StrSimTableLookup( ppTable, ppNexts, nTableSize, pObj );
434 if ( pEntry == NULL ) // skip
435 continue;
436 // if there is no candidate, label it
437 if ( Saig_ObjNext( ppCands, pEntry ) == NULL )
438 Saig_ObjSetNext( ppCands, pEntry, pObj );
439 else // mark the entry as not unique
440 pEntry->fMarkA = 1;
441 }
442
443 // create representatives for the unique entries
444 Counter = 0;
445 for ( i = 0; i < nTableSize; i++ )
446 for ( pEntry = ppTable[i]; pEntry; pEntry = Saig_ObjNext(ppNexts,pEntry) )
447 if ( !pEntry->fMarkA && (pObj = Saig_ObjNext( ppCands, pEntry )) )
448 {
449// assert( Aig_ObjIsNode(pEntry) == Aig_ObjIsNode(pObj) );
450 if ( Aig_ObjType(pEntry) != Aig_ObjType(pObj) )
451 continue;
452 Aig_ObjSetRepr( p0, pEntry, pObj );
453 Aig_ObjSetRepr( p1, pObj, pEntry );
454 Counter++;
455 }
456
457 // cleanup
458 Aig_ManCleanMarkA( p0 );
459 ABC_FREE( ppTable );
460 ABC_FREE( ppNexts );
461 ABC_FREE( ppCands );
462 return Counter;
463}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition aigUtil.c:148
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
void Saig_StrSimTableInsert(Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
Definition saigStrSim.c:369
int Saig_StrSimIsOne(Aig_Obj_t *pObj)
Definition saigStrSim.c:132
Aig_Obj_t * Saig_StrSimTableLookup(Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
Definition saigStrSim.c:345
int Saig_StrSimIsZero(Aig_Obj_t *pObj)
Definition saigStrSim.c:111
unsigned int fMarkA
Definition aig.h:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimHash()

unsigned Saig_StrSimHash ( Aig_Obj_t * pObj)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes hash value of the node using its simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file saigStrSim.c.

52{
53 static int s_SPrimes[128] = {
54 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
55 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
56 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
57 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
58 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
59 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
60 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
61 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
62 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
63 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
64 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
65 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
66 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
67 };
68 unsigned * pSims;
69 unsigned uHash = 0;
70 int i;
71 assert( SAIG_WORDS <= 128 );
72 pSims = (unsigned *)pObj->pData;
73 for ( i = 0; i < SAIG_WORDS; i++ )
74 uHash ^= pSims[i] * s_SPrimes[i & 0x7F];
75 return uHash;
76}
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Saig_StrSimIsEqual()

int Saig_StrSimIsEqual ( Aig_Obj_t * pObj0,
Aig_Obj_t * pObj1 )

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

Synopsis [Computes hash value of the node using its simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file saigStrSim.c.

90{
91 unsigned * pSims0 = (unsigned *)pObj0->pData;
92 unsigned * pSims1 = (unsigned *)pObj1->pData;
93 int i;
94 for ( i = 0; i < SAIG_WORDS; i++ )
95 if ( pSims0[i] != pSims1[i] )
96 return 0;
97 return 1;
98}
Here is the caller graph for this function:

◆ Saig_StrSimIsOne()

int Saig_StrSimIsOne ( Aig_Obj_t * pObj)

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

Synopsis [Returns 1 if simulation info is one.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file saigStrSim.c.

133{
134 unsigned * pSims = (unsigned *)pObj->pData;
135 int i;
136 for ( i = 0; i < SAIG_WORDS; i++ )
137 if ( pSims[i] != ~0 )
138 return 0;
139 return 1;
140}
Here is the caller graph for this function:

◆ Saig_StrSimIsZero()

int Saig_StrSimIsZero ( Aig_Obj_t * pObj)

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

Synopsis [Returns 1 if simulation info is zero.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file saigStrSim.c.

112{
113 unsigned * pSims = (unsigned *)pObj->pData;
114 int i;
115 for ( i = 0; i < SAIG_WORDS; i++ )
116 if ( pSims[i] != 0 )
117 return 0;
118 return 1;
119}
Here is the caller graph for this function:

◆ Saig_StrSimPerformMatching()

Vec_Int_t * Saig_StrSimPerformMatching ( Aig_Man_t * p0,
Aig_Man_t * p1,
int nDist,
int fVerbose,
Aig_Man_t ** ppMiter )

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

Synopsis [Performs structural matching of two AIGs using simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 873 of file saigStrSim.c.

874{
876
877 Vec_Int_t * vPairs;
878 Aig_Man_t * pPart0, * pPart1;
879 Aig_Obj_t * pObj0, * pObj1;
880 int i, nMatches;
881 abctime clk, clkTotal = Abc_Clock();
882 Aig_ManRandom( 1 );
883 // consider the case when a miter is given
884 if ( p1 == NULL )
885 {
886 if ( fVerbose )
887 {
888 Aig_ManPrintStats( p0 );
889 }
890 // demiter the miter
891 if ( !Saig_ManDemiterSimpleDiff( p0, &pPart0, &pPart1 ) )
892 {
893 Abc_Print( 1, "Demitering has failed.\n" );
894 return NULL;
895 }
896 }
897 else
898 {
899 pPart0 = Aig_ManDupSimple( p0 );
900 pPart1 = Aig_ManDupSimple( p1 );
901 }
902 if ( fVerbose )
903 {
904 Aig_ManPrintStats( pPart0 );
905 Aig_ManPrintStats( pPart1 );
906 }
907 // start simulation
908 Saig_StrSimPrepareAig( pPart0 );
909 Saig_StrSimPrepareAig( pPart1 );
910 Saig_StrSimSetInitMatching( pPart0, pPart1 );
911 if ( fVerbose )
912 {
913 Abc_Print( 1, "Allocated %6.2f MB to simulate the first AIG.\n",
914 1.0 * Aig_ManObjNumMax(pPart0) * SAIG_WORDS * sizeof(unsigned) / (1<<20) );
915 Abc_Print( 1, "Allocated %6.2f MB to simulate the second AIG.\n",
916 1.0 * Aig_ManObjNumMax(pPart1) * SAIG_WORDS * sizeof(unsigned) / (1<<20) );
917 }
918 // iterate matching
919 nMatches = 1;
920 for ( i = 0; nMatches > 0; i++ )
921 {
922 clk = Abc_Clock();
923 Saig_StrSimulateRound( pPart0, pPart1 );
924 nMatches = Saig_StrSimDetectUnique( pPart0, pPart1 );
925 if ( fVerbose )
926 {
927 int nFlops = Saig_StrSimCountMatchedFlops(pPart0);
928 int nNodes = Saig_StrSimCountMatchedNodes(pPart0);
929 Abc_Print( 1, "%3d : Match =%6d. FF =%6d. (%6.2f %%) Node =%6d. (%6.2f %%) ",
930 i, nMatches,
931 nFlops, 100.0*nFlops/Aig_ManRegNum(pPart0),
932 nNodes, 100.0*nNodes/Aig_ManNodeNum(pPart0) );
933 ABC_PRT( "Time", Abc_Clock() - clk );
934 }
935 if ( i == 20 )
936 break;
937 }
938 // cleanup
939 Vec_PtrFree( (Vec_Ptr_t *)pPart0->pData2 ); pPart0->pData2 = NULL;
940 Vec_PtrFree( (Vec_Ptr_t *)pPart1->pData2 ); pPart1->pData2 = NULL;
941 // extend the islands
942 Aig_ManFanoutStart( pPart0 );
943 Aig_ManFanoutStart( pPart1 );
944 if ( nDist )
945 Ssw_StrSimMatchingExtend( pPart0, pPart1, nDist, fVerbose );
946 Saig_StrSimSetFinalMatching( pPart0, pPart1 );
947// Saig_StrSimSetContiguousMatching( pPart0, pPart1 );
948 // copy the results into array
949 vPairs = Vec_IntAlloc( 2*Aig_ManObjNumMax(pPart0) );
950 Aig_ManForEachObj( pPart0, pObj0, i )
951 {
952 pObj1 = Aig_ObjRepr(pPart0, pObj0);
953 if ( pObj1 == NULL )
954 continue;
955 assert( pObj0 == Aig_ObjRepr(pPart1, pObj1) );
956 Vec_IntPush( vPairs, pObj0->Id );
957 Vec_IntPush( vPairs, pObj1->Id );
958 }
959 // this procedure adds matching of PO and LI
960 if ( ppMiter )
961 *ppMiter = Saig_ManWindowExtractMiter( pPart0, pPart1 );
962 Aig_ManFanoutStop( pPart0 );
963 Aig_ManFanoutStop( pPart1 );
964 Aig_ManStop( pPart0 );
965 Aig_ManStop( pPart1 );
966 ABC_PRT( "Total runtime", Abc_Clock() - clkTotal );
967 return vPairs;
968}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigFanout.c:56
Aig_Man_t * Aig_ManDupSimple(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigDup.c:46
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition aigFanout.c:89
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
void Aig_ManPrintStats(Aig_Man_t *p)
Definition aigMan.c:379
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Ssw_StrSimMatchingExtend(Aig_Man_t *p0, Aig_Man_t *p1, int nDist, int fVerbose)
Definition saigStrSim.c:808
void Saig_StrSimPrepareAig(Aig_Man_t *p)
Definition saigStrSim.c:518
void Saig_StrSimulateRound(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:294
int Saig_StrSimDetectUnique(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:394
void Saig_StrSimSetInitMatching(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:544
int Saig_StrSimCountMatchedNodes(Aig_Man_t *p)
Definition saigStrSim.c:497
void Saig_StrSimSetFinalMatching(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:571
int Saig_StrSimCountMatchedFlops(Aig_Man_t *p)
Definition saigStrSim.c:476
Aig_Man_t * Saig_ManWindowExtractMiter(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigWnd.c:716
int Saig_ManDemiterSimpleDiff(Aig_Man_t *p, Aig_Man_t **ppAig0, Aig_Man_t **ppAig1)
Definition saigMiter.c:660
int Id
Definition aig.h:85
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimPrepareAig()

void Saig_StrSimPrepareAig ( Aig_Man_t * p)

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

Synopsis [Performs structural matching of two AIGs using simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 518 of file saigStrSim.c.

519{
520 Aig_Obj_t * pObj;
521 int i;
522 Aig_ManReprStart( p, Aig_ManObjNumMax(p) );
523 // allocate simulation info
524 p->pData2 = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p), SAIG_WORDS );
525 Aig_ManForEachObj( p, pObj, i )
526 pObj->pData = Vec_PtrEntry( (Vec_Ptr_t *)p->pData2, i );
527 // set simulation info for constant1 and register outputs
528 Saig_StrSimAssignOne( Aig_ManConst1(p) );
529 Saig_ManForEachLo( p, pObj, i )
531}
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition aigRepr.c:45
void Saig_StrSimAssignOne(Aig_Obj_t *pObj)
Definition saigStrSim.c:172
void Saig_StrSimAssignZeroInit(Aig_Obj_t *pObj)
Definition saigStrSim.c:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimSaveOutput()

void Saig_StrSimSaveOutput ( Aig_Obj_t * pObj,
int i )

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

Synopsis [Saves output of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file saigStrSim.c.

235{
236 unsigned * pSims = (unsigned *)pObj->pData;
237 unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
238 if ( Aig_ObjFaninC0(pObj) )
239 pSims[i] = ~pSims0[i];
240 else
241 pSims[i] = pSims0[i];
242}
Here is the caller graph for this function:

◆ Saig_StrSimSetContiguousMatching()

void Saig_StrSimSetContiguousMatching ( Aig_Man_t * p0,
Aig_Man_t * p1 )

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

Synopsis [Performs structural matching of two AIGs using simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 678 of file saigStrSim.c.

679{
680 Aig_Obj_t * pObj0, * pObj1;
681 int i, CountAll = 0, CountNot = 0;
682 // mark nodes reachable through the PIs
684 Aig_ObjSetTravIdCurrent( p0, Aig_ManConst1(p0) );
685 Saig_ManForEachPi( p0, pObj0, i )
687 // remove irrelevant matches
688 Aig_ManForEachObj( p0, pObj0, i )
689 {
690 pObj1 = Aig_ObjRepr( p0, pObj0 );
691 if ( pObj1 == NULL )
692 continue;
693 CountAll++;
694 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
695 if ( !Aig_ObjIsTravIdCurrent( p0, pObj0 ) )
696 {
697 Aig_ObjSetRepr( p0, pObj0, NULL );
698 Aig_ObjSetRepr( p1, pObj1, NULL );
699 CountNot++;
700 }
701 }
702 Abc_Print( 1, "Total matches = %6d. Wrong matches = %6d. Ratio = %5.2f %%\n",
703 CountAll, CountNot, 100.0*CountNot/CountAll );
704}
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigUtil.c:44
void Saig_StrSimSetContiguousMatching_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition saigStrSim.c:639
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
Here is the call graph for this function:

◆ Saig_StrSimSetContiguousMatching_rec()

void Saig_StrSimSetContiguousMatching_rec ( Aig_Man_t * p,
Aig_Obj_t * pObj )

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

Synopsis [Returns the number of dangling nodes removed.]

Description []

SideEffects []

SeeAlso []

Definition at line 639 of file saigStrSim.c.

640{
641 Aig_Obj_t * pFanout;
642 int i, iFanout = -1;
643 if ( Aig_ObjIsTravIdCurrent(p, pObj) )
644 return;
645 Aig_ObjSetTravIdCurrent(p, pObj);
646 if ( Saig_ObjIsPo( p, pObj ) )
647 return;
648 if ( Saig_ObjIsLi( p, pObj ) )
649 {
650 Saig_StrSimSetContiguousMatching_rec( p, Saig_ObjLiToLo(p, pObj) );
651 return;
652 }
653 assert( Aig_ObjIsCi(pObj) || Aig_ObjIsNode(pObj) );
654 if ( Aig_ObjRepr(p, pObj) == NULL )
655 return;
656 // go through the fanouts
657 Aig_ObjForEachFanout( p, pObj, pFanout, iFanout, i )
659 // go through the fanins
660 if ( !Aig_ObjIsCi( pObj ) )
661 {
662 Saig_StrSimSetContiguousMatching_rec( p, Aig_ObjFanin0(pObj) );
663 Saig_StrSimSetContiguousMatching_rec( p, Aig_ObjFanin1(pObj) );
664 }
665}
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition aig.h:427
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimSetFinalMatching()

void Saig_StrSimSetFinalMatching ( Aig_Man_t * p0,
Aig_Man_t * p1 )

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

Synopsis [Performs structural matching of two AIGs using simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 571 of file saigStrSim.c.

572{
573 Aig_Obj_t * pObj0, * pObj1;
574 Aig_Obj_t * pFanin00, * pFanin01;
575 Aig_Obj_t * pFanin10, * pFanin11;
576 int i, CountAll = 0, CountNot = 0;
578 Aig_ManForEachObj( p0, pObj0, i )
579 {
580 pObj1 = Aig_ObjRepr( p0, pObj0 );
581 if ( pObj1 == NULL )
582 continue;
583 CountAll++;
584 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
585 if ( Aig_ObjIsNode(pObj0) )
586 {
587 assert( Aig_ObjIsNode(pObj1) );
588 pFanin00 = Aig_ObjFanin0(pObj0);
589 pFanin01 = Aig_ObjFanin1(pObj0);
590 pFanin10 = Aig_ObjFanin0(pObj1);
591 pFanin11 = Aig_ObjFanin1(pObj1);
592 if ( Aig_ObjRepr(p0, pFanin00) != pFanin10 ||
593 Aig_ObjRepr(p0, pFanin01) != pFanin11 )
594 {
595 Aig_ObjSetTravIdCurrent(p0, pObj0);
596 CountNot++;
597 }
598 }
599 else if ( Saig_ObjIsLo(p0, pObj0) )
600 {
601 assert( Saig_ObjIsLo(p1, pObj1) );
602 pFanin00 = Aig_ObjFanin0( Saig_ObjLoToLi(p0, pObj0) );
603 pFanin10 = Aig_ObjFanin0( Saig_ObjLoToLi(p1, pObj1) );
604 if ( Aig_ObjRepr(p0, pFanin00) != pFanin10 )
605 {
606 Aig_ObjSetTravIdCurrent(p0, pObj0);
607 CountNot++;
608 }
609 }
610 }
611 // remove irrelevant matches
612 Aig_ManForEachObj( p0, pObj0, i )
613 {
614 pObj1 = Aig_ObjRepr( p0, pObj0 );
615 if ( pObj1 == NULL )
616 continue;
617 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
618 if ( Aig_ObjIsTravIdCurrent( p0, pObj0 ) )
619 {
620 Aig_ObjSetRepr( p0, pObj0, NULL );
621 Aig_ObjSetRepr( p1, pObj1, NULL );
622 }
623 }
624 Abc_Print( 1, "Total matches = %6d. Wrong matches = %6d. Ratio = %5.2f %%\n",
625 CountAll, CountNot, 100.0*CountNot/CountAll );
626}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimSetInitMatching()

void Saig_StrSimSetInitMatching ( Aig_Man_t * p0,
Aig_Man_t * p1 )

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

Synopsis [Performs structural matching of two AIGs using simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 544 of file saigStrSim.c.

545{
546 Aig_Obj_t * pObj0, * pObj1;
547 int i;
548 pObj0 = Aig_ManConst1( p0 );
549 pObj1 = Aig_ManConst1( p1 );
550 Aig_ObjSetRepr( p0, pObj0, pObj1 );
551 Aig_ObjSetRepr( p1, pObj1, pObj0 );
552 Saig_ManForEachPi( p0, pObj0, i )
553 {
554 pObj1 = Aig_ManCi( p1, i );
555 Aig_ObjSetRepr( p0, pObj0, pObj1 );
556 Aig_ObjSetRepr( p1, pObj1, pObj0 );
557 }
558}
Here is the caller graph for this function:

◆ Saig_StrSimTableInsert()

void Saig_StrSimTableInsert ( Aig_Obj_t ** ppTable,
Aig_Obj_t ** ppNexts,
int nTableSize,
Aig_Obj_t * pObj )

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

Synopsis [Inserts the entry into the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 369 of file saigStrSim.c.

370{
371 // find the hash entry
372 int iEntry = Saig_StrSimHash( pObj ) % nTableSize;
373 // check if there are nodes with this signatures
374 if ( ppTable[iEntry] == NULL )
375 ppTable[iEntry] = pObj;
376 else
377 {
378 Saig_ObjSetNext( ppNexts, pObj, Saig_ObjNext(ppNexts, ppTable[iEntry]) );
379 Saig_ObjSetNext( ppNexts, ppTable[iEntry], pObj );
380 }
381}
unsigned Saig_StrSimHash(Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition saigStrSim.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimTableLookup()

Aig_Obj_t * Saig_StrSimTableLookup ( Aig_Obj_t ** ppTable,
Aig_Obj_t ** ppNexts,
int nTableSize,
Aig_Obj_t * pObj )

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

Synopsis [Checks if the entry exists in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 345 of file saigStrSim.c.

346{
347 Aig_Obj_t * pEntry;
348 int iEntry;
349 // find the hash entry
350 iEntry = Saig_StrSimHash( pObj ) % nTableSize;
351 // check if there are nodes with this signatures
352 for ( pEntry = ppTable[iEntry]; pEntry; pEntry = Saig_ObjNext(ppNexts,pEntry) )
353 if ( Saig_StrSimIsEqual( pEntry, pObj ) )
354 return pEntry;
355 return NULL;
356}
int Saig_StrSimIsEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition saigStrSim.c:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_StrSimTransfer()

void Saig_StrSimTransfer ( Aig_Obj_t * pObj0,
Aig_Obj_t * pObj1 )

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

Synopsis [Transfers simulation output to another node.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file saigStrSim.c.

256{
257 unsigned * pSims0 = (unsigned *)pObj0->pData;
258 unsigned * pSims1 = (unsigned *)pObj1->pData;
259 int i;
260 for ( i = 0; i < SAIG_WORDS; i++ )
261 pSims1[i] = pSims0[i];
262}
Here is the caller graph for this function:

◆ Saig_StrSimTransferNext()

void Saig_StrSimTransferNext ( Aig_Obj_t * pObj0,
Aig_Obj_t * pObj1,
int i )

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

Synopsis [Transfers simulation output to another node.]

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file saigStrSim.c.

276{
277 unsigned * pSims0 = (unsigned *)pObj0->pData;
278 unsigned * pSims1 = (unsigned *)pObj1->pData;
279 assert( i < SAIG_WORDS - 1 );
280 pSims1[i+1] = pSims0[i];
281}
Here is the caller graph for this function:

◆ Saig_StrSimulateNode()

void Saig_StrSimulateNode ( Aig_Obj_t * pObj,
int i )

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

Synopsis [Simulated one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file saigStrSim.c.

209{
210 unsigned * pSims = (unsigned *)pObj->pData;
211 unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
212 unsigned * pSims1 = (unsigned *)Aig_ObjFanin1(pObj)->pData;
213 if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
214 pSims[i] = ~(pSims0[i] | pSims1[i]);
215 else if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
216 pSims[i] = (~pSims0[i] & pSims1[i]);
217 else if ( !Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
218 pSims[i] = (pSims0[i] & ~pSims1[i]);
219 else // if ( !Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
220 pSims[i] = (pSims0[i] & pSims1[i]);
221}
Here is the caller graph for this function:

◆ Saig_StrSimulateRound()

void Saig_StrSimulateRound ( Aig_Man_t * p0,
Aig_Man_t * p1 )

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

Synopsis [Perform one round of simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 294 of file saigStrSim.c.

295{
296 Aig_Obj_t * pObj0, * pObj1;
297 int f, i;
298 // simulate the nodes
299 Aig_ManForEachObj( p0, pObj0, i )
300 {
301 if ( !Aig_ObjIsCi(pObj0) && !Aig_ObjIsNode(pObj0) )
302 continue;
303 pObj1 = Aig_ObjRepr(p0, pObj0);
304 if ( pObj1 == NULL )
305 continue;
306 assert( Aig_ObjRepr(p1, pObj1) == pObj0 );
308 Saig_StrSimTransfer( pObj0, pObj1 );
309 }
310 // simulate the timeframes
311 for ( f = 0; f < SAIG_WORDS; f++ )
312 {
313 // simulate the first AIG
314 Aig_ManForEachNode( p0, pObj0, i )
315 if ( Aig_ObjRepr(p0, pObj0) == NULL )
316 Saig_StrSimulateNode( pObj0, f );
317 Saig_ManForEachLi( p0, pObj0, i )
318 Saig_StrSimSaveOutput( pObj0, f );
319 if ( f < SAIG_WORDS - 1 )
320 Saig_ManForEachLiLo( p0, pObj0, pObj1, i )
321 Saig_StrSimTransferNext( pObj0, pObj1, f );
322 // simulate the second AIG
323 Aig_ManForEachNode( p1, pObj1, i )
324 if ( Aig_ObjRepr(p1, pObj1) == NULL )
325 Saig_StrSimulateNode( pObj1, f );
326 Saig_ManForEachLi( p1, pObj1, i )
327 Saig_StrSimSaveOutput( pObj1, f );
328 if ( f < SAIG_WORDS - 1 )
329 Saig_ManForEachLiLo( p1, pObj1, pObj0, i )
330 Saig_StrSimTransferNext( pObj1, pObj0, f );
331 }
332}
void Saig_StrSimulateNode(Aig_Obj_t *pObj, int i)
Definition saigStrSim.c:208
void Saig_StrSimTransfer(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition saigStrSim.c:255
void Saig_StrSimTransferNext(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1, int i)
Definition saigStrSim.c:275
void Saig_StrSimAssignRandom(Aig_Obj_t *pObj)
Definition saigStrSim.c:153
void Saig_StrSimSaveOutput(Aig_Obj_t *pObj, int i)
Definition saigStrSim.c:234
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLi(p, pObj, i)
Definition saig.h:98
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_StrSimMatchingCountUnmached()

int Ssw_StrSimMatchingCountUnmached ( Aig_Man_t * p)

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

Synopsis [Establishes relationship between nodes using pairing.]

Description []

SideEffects []

SeeAlso []

Definition at line 782 of file saigStrSim.c.

783{
784 Aig_Obj_t * pObj;
785 int i, Counter = 0;
786 Aig_ManForEachObj( p, pObj, i )
787 {
788 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
789 continue;
790 if ( Aig_ObjRepr( p, pObj ) != NULL )
791 continue;
792 Counter++;
793 }
794 return Counter;
795}
Here is the caller graph for this function:

◆ Ssw_StrSimMatchingExtend()

void Ssw_StrSimMatchingExtend ( Aig_Man_t * p0,
Aig_Man_t * p1,
int nDist,
int fVerbose )

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

Synopsis [Establishes relationship between nodes using pairing.]

Description []

SideEffects []

SeeAlso []

Definition at line 808 of file saigStrSim.c.

809{
810 Vec_Ptr_t * vNodes0, * vNodes1;
811 Aig_Obj_t * pNext0, * pNext1;
812 int d, k;
813 vNodes0 = Vec_PtrAlloc( 1000 );
814 vNodes1 = Vec_PtrAlloc( 1000 );
815 if ( fVerbose )
816 {
817 int nUnmached = Ssw_StrSimMatchingCountUnmached(p0);
818 Abc_Print( 1, "Extending islands by %d steps:\n", nDist );
819 Abc_Print( 1, "%2d : Total = %6d. Unmatched = %6d. Ratio = %6.2f %%\n",
820 0, Aig_ManCiNum(p0) + Aig_ManNodeNum(p0),
821 nUnmached, 100.0 * nUnmached/(Aig_ManCiNum(p0) + Aig_ManNodeNum(p0)) );
822 }
823 for ( d = 0; d < nDist; d++ )
824 {
825 Ssw_StrSimMatchingExtendOne( p0, vNodes0 );
826 Ssw_StrSimMatchingExtendOne( p1, vNodes1 );
827 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pNext0, k )
828 {
829 pNext1 = Aig_ObjRepr( p0, pNext0 );
830 if ( pNext1 == NULL )
831 continue;
832 assert( pNext0 == Aig_ObjRepr( p1, pNext1 ) );
833 if ( Saig_ObjIsPi(p1, pNext1) )
834 continue;
835 Aig_ObjSetRepr( p0, pNext0, NULL );
836 Aig_ObjSetRepr( p1, pNext1, NULL );
837 }
838 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pNext1, k )
839 {
840 pNext0 = Aig_ObjRepr( p1, pNext1 );
841 if ( pNext0 == NULL )
842 continue;
843 assert( pNext1 == Aig_ObjRepr( p0, pNext0 ) );
844 if ( Saig_ObjIsPi(p0, pNext0) )
845 continue;
846 Aig_ObjSetRepr( p0, pNext0, NULL );
847 Aig_ObjSetRepr( p1, pNext1, NULL );
848 }
849 if ( fVerbose )
850 {
851 int nUnmached = Ssw_StrSimMatchingCountUnmached(p0);
852 Abc_Print( 1, "%2d : Total = %6d. Unmatched = %6d. Ratio = %6.2f %%\n",
853 d+1, Aig_ManCiNum(p0) + Aig_ManNodeNum(p0),
854 nUnmached, 100.0 * nUnmached/(Aig_ManCiNum(p0) + Aig_ManNodeNum(p0)) );
855 }
856 }
857 Vec_PtrFree( vNodes0 );
858 Vec_PtrFree( vNodes1 );
859}
void Ssw_StrSimMatchingExtendOne(Aig_Man_t *p, Vec_Ptr_t *vNodes)
Definition saigStrSim.c:719
int Ssw_StrSimMatchingCountUnmached(Aig_Man_t *p)
Definition saigStrSim.c:782
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_StrSimMatchingExtendOne()

void Ssw_StrSimMatchingExtendOne ( Aig_Man_t * p,
Vec_Ptr_t * vNodes )

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

Synopsis [Establishes relationship between nodes using pairing.]

Description []

SideEffects []

SeeAlso []

Definition at line 719 of file saigStrSim.c.

720{
721 Aig_Obj_t * pNext, * pObj;
722 int i, k, iFan = -1;
723 Vec_PtrClear( vNodes );
725 Aig_ManForEachObj( p, pObj, i )
726 {
727 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
728 continue;
729 if ( Aig_ObjRepr( p, pObj ) != NULL )
730 continue;
731 if ( Saig_ObjIsLo(p, pObj) )
732 {
733 pNext = Saig_ObjLoToLi(p, pObj);
734 pNext = Aig_ObjFanin0(pNext);
735 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) && !Aig_ObjIsConst1(pNext) )
736 {
737 Aig_ObjSetTravIdCurrent(p, pNext);
738 Vec_PtrPush( vNodes, pNext );
739 }
740 }
741 if ( Aig_ObjIsNode(pObj) )
742 {
743 pNext = Aig_ObjFanin0(pObj);
744 if ( Aig_ObjRepr( p, pNext )&& !Aig_ObjIsTravIdCurrent(p, pNext) )
745 {
746 Aig_ObjSetTravIdCurrent(p, pNext);
747 Vec_PtrPush( vNodes, pNext );
748 }
749 pNext = Aig_ObjFanin1(pObj);
750 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) )
751 {
752 Aig_ObjSetTravIdCurrent(p, pNext);
753 Vec_PtrPush( vNodes, pNext );
754 }
755 }
756 Aig_ObjForEachFanout( p, pObj, pNext, iFan, k )
757 {
758 if ( Saig_ObjIsPo(p, pNext) )
759 continue;
760 if ( Saig_ObjIsLi(p, pNext) )
761 pNext = Saig_ObjLiToLo(p, pNext);
762 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) )
763 {
764 Aig_ObjSetTravIdCurrent(p, pNext);
765 Vec_PtrPush( vNodes, pNext );
766 }
767 }
768 }
769}
Here is the call graph for this function:
Here is the caller graph for this function: