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

Go to the source code of this file.

Classes

struct  saucy_stats
 
struct  saucy_graph
 
struct  coloring
 
struct  sim_result
 
struct  saucy
 

Macros

#define REFINE_BY_SIM_1   0
 
#define REFINE_BY_SIM_2   0
 
#define BACKTRACK_BY_SAT   1
 
#define SELECT_DYNAMICALLY   0
 
#define CLAUSE_DECAY   0.9
 
#define MAX_LEARNTS   50
 

Functions

void prepare_permutation_ntk (struct saucy *s)
 
void unprepare_permutation_ntk (struct saucy *s)
 
void saucy_search (Abc_Ntk_t *pNtk, struct saucy *s, int directed, const int *colors, struct saucy_stats *stats)
 
void saucy_free (struct saucy *s)
 
struct saucysaucy_alloc (Abc_Ntk_t *pNtk)
 
void saucyGateWay (Abc_Ntk_t *pNtkOrig, Abc_Obj_t *pNodePo, FILE *gFile, int fBooleanMatching, int fLookForSwaps, int fFixOutputs, int fFixInputs, int fQuiet, int fPrintTree)
 

Variables

int NUM_SIM1_ITERATION
 
int NUM_SIM2_ITERATION
 

Macro Definition Documentation

◆ BACKTRACK_BY_SAT

#define BACKTRACK_BY_SAT   1

Definition at line 35 of file abcSaucy.c.

◆ CLAUSE_DECAY

#define CLAUSE_DECAY   0.9

Definition at line 43 of file abcSaucy.c.

◆ MAX_LEARNTS

#define MAX_LEARNTS   50

Definition at line 44 of file abcSaucy.c.

◆ REFINE_BY_SIM_1

#define REFINE_BY_SIM_1   0

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

FileName [abcSaucy.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Symmetry Detection Package.]

Synopsis [Finds symmetries under permutation (but not negation) of I/Os.]

Author [Hadi Katebi]

Affiliation [University of Michigan]

Date [Ver. 1.0. Started - April, 2012.]

Revision [No revisions so far]

Comments []

Debugging [There are some part of the code that are commented out. Those parts mostly print the contents of the data structures to the standard output. Un-comment them if you find them useful for debugging.]

Definition at line 33 of file abcSaucy.c.

◆ REFINE_BY_SIM_2

#define REFINE_BY_SIM_2   0

Definition at line 34 of file abcSaucy.c.

◆ SELECT_DYNAMICALLY

#define SELECT_DYNAMICALLY   0

Definition at line 36 of file abcSaucy.c.

Function Documentation

◆ prepare_permutation_ntk()

void prepare_permutation_ntk ( struct saucy * s)

Definition at line 2155 of file abcSaucy.c.

2156{
2157 int i;
2158 Abc_Obj_t * pObj, * pObjPerm;
2159 int numouts = Abc_NtkPoNum(s->pNtk);
2160
2162 s->pNtk_permuted->pManName = Nm_ManCreate( Abc_NtkCiNum(s->pNtk) + Abc_NtkCoNum(s->pNtk) + Abc_NtkBoxNum(s->pNtk) );
2163
2164 for (i = 0; i < s->n; ++i) {
2165 if (i < numouts) {
2166 pObj = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk->vPos, i);
2167 pObjPerm = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk_permuted->vPos, s->gamma[i]);
2168 }
2169 else {
2170 pObj = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk->vPis, i - numouts);
2171 pObjPerm = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk_permuted->vPis, s->gamma[i] - numouts);
2172
2173 }
2174 Abc_ObjAssignName( pObjPerm, Abc_ObjName(pObj), NULL );
2175 }
2176
2178
2179 /* print the permutation */
2180 /*for (i = 0; i < s->ndiffs; ++i)
2181 printf(" %d->%d", s->unsupp[i], s->diffs[i]);
2182 printf("\n");
2183 Abc_NtkForEachCo( s->pNtk, pObj, i )
2184 printf (" %d", Abc_ObjId(pObj)-1-Abc_NtkPiNum(s->pNtk));
2185 Abc_NtkForEachCi( s->pNtk, pObj, i )
2186 printf (" %d", Abc_ObjId(pObj)-1+Abc_NtkPoNum(s->pNtk));
2187 printf("\n");
2188 Abc_NtkForEachCo( s->pNtk_permuted, pObj, i )
2189 printf (" %d", Abc_ObjId(pObj)-1-Abc_NtkPiNum(s->pNtk_permuted));
2190 Abc_NtkForEachCi( s->pNtk_permuted, pObj, i )
2191 printf (" %d", Abc_ObjId(pObj)-1+Abc_NtkPoNum(s->pNtk_permuted));
2192 printf("\n");*/
2193}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL void Abc_NtkOrderObjsByName(Abc_Ntk_t *pNtk, int fComb)
Definition abcNames.c:330
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
void Nm_ManFree(Nm_Man_t *p)
Definition nmApi.c:76
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
Definition nmApi.c:45
Vec_Ptr_t * vPos
Definition abc.h:164
Nm_Man_t * pManName
Definition abc.h:160
Vec_Ptr_t * vPis
Definition abc.h:163
int n
Definition abcSaucy.c:91
Abc_Ntk_t * pNtk_permuted
Definition abcSaucy.c:174
int * gamma
Definition abcSaucy.c:119
Abc_Ntk_t * pNtk
Definition abcSaucy.c:173
Here is the call graph for this function:

◆ saucy_alloc()

struct saucy * saucy_alloc ( Abc_Ntk_t * pNtk)

Definition at line 2576 of file abcSaucy.c.

2577{
2578 int i;
2579 int numouts = Abc_NtkPoNum(pNtk);
2580 int numins = Abc_NtkPiNum(pNtk);
2581 int n = numins + numouts;
2582 struct saucy *s = ABC_ALLOC(struct saucy, 1);
2583 if (s == NULL) return NULL;
2584
2585 s->ninduce = ints(n);
2586 s->sinduce = ints(n);
2587 s->indmark = bits(n);
2588 s->left.cfront = zeros(n);
2589 s->left.clen = ints(n);
2590 s->right.cfront = zeros(n);
2591 s->right.clen = ints(n);
2592 s->stuff = bits(n+1);
2593 s->bucket = ints(n+2);
2594 s->count = ints(n+1);
2595 s->ccount = zeros(n);
2596 s->clist = ints(n);
2597 s->nextnon = ints(n+1) + 1;
2598 s->prevnon = ints(n+1);
2599 s->anctar = ints(n);
2600 s->start = ints(n);
2601 s->gamma = ints(n);
2602 s->junk = ints(n);
2603 s->theta = ints(n);
2604 s->thsize = ints(n);
2605 s->left.lab = ints(n);
2606 s->left.unlab = ints(n);
2607 s->right.lab = ints(n);
2608 s->right.unlab = ints(n);
2609 s->splitvar = ints(n);
2610 s->splitwho = ints(n);
2611 s->splitfrom = ints(n);
2612 s->splitlev = ints(n+1);
2613 s->unsupp = ints(n);
2614 s->conncnts = zeros(n);
2615 s->diffmark = bits(n);
2616 s->diffs = ints(n);
2617 s->difflev = ints(n);
2618 s->undifflev = ints(n);
2619 s->specmin = ints(n);
2620 s->thnext = ints(n);
2621 s->thprev = ints(n);
2622 s->threp = ints(n);
2623 s->thfront = ints(n);
2624 s->pairs = ints(n);
2625 s->unpairs = ints(n);
2626 s->diffnons = ints(n);
2627 s->undiffnons = ints(n);
2628 s->marks = bits(n);
2629
2630 s->iDep = ABC_ALLOC( Vec_Int_t*, numins );
2631 s->oDep = ABC_ALLOC( Vec_Int_t*, numouts );
2632 s->obs = ABC_ALLOC( Vec_Int_t*, numins );
2633 s->ctrl = ABC_ALLOC( Vec_Int_t*, numouts );
2634
2635 for(i = 0; i < numins; i++) {
2636 s->iDep[i] = Vec_IntAlloc( 1 );
2637 s->obs[i] = Vec_IntAlloc( 1 );
2638 }
2639 for(i = 0; i < numouts; i++) {
2640 s->oDep[i] = Vec_IntAlloc( 1 );
2641 s->ctrl[i] = Vec_IntAlloc( 1 );
2642 }
2643
2644 s->randomVectorArray_sim1 = Vec_PtrAlloc( n );
2645 s->randomVectorSplit_sim1 = zeros( n );
2646 s->randomVectorArray_sim2 = Vec_PtrAlloc( n );
2647 s->randomVectorSplit_sim2= zeros( n );
2648
2649 s->satCounterExamples = Vec_PtrAlloc( 1 );
2650 s->pModel = ints( numins );
2651
2652 if (s->ninduce && s->sinduce && s->left.cfront && s->left.clen
2653 && s->right.cfront && s->right.clen
2654 && s->stuff && s->bucket && s->count && s->ccount
2655 //&& s->clist && s->nextnon-1 && s->prevnon
2656 && s->clist && s->nextnon[-1] && s->prevnon
2657 && s->start && s->gamma && s->theta && s->left.unlab
2658 && s->right.lab && s->right.unlab
2659 && s->left.lab && s->splitvar && s->splitwho && s->junk
2660 && s->splitfrom && s->splitlev && s->thsize
2661 && s->unsupp && s->conncnts && s->anctar
2662 && s->diffmark && s->diffs && s->indmark
2663 && s->thnext && s->thprev && s->threp && s->thfront
2664 && s->pairs && s->unpairs && s->diffnons && s->undiffnons
2665 && s->difflev && s->undifflev && s->specmin)
2666 {
2667 return s;
2668 }
2669 else {
2670 saucy_free(s);
2671 return NULL;
2672 }
2673}
void saucy_free(struct saucy *s)
Definition abcSaucy.c:2491
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
int * clen
Definition abcSaucy.c:78
int * lab
Definition abcSaucy.c:75
int * unlab
Definition abcSaucy.c:76
int * cfront
Definition abcSaucy.c:77
int * ninduce
Definition abcSaucy.c:104
int * pModel
Definition abcSaucy.c:185
Vec_Int_t ** ctrl
Definition abcSaucy.c:178
int * sinduce
Definition abcSaucy.c:105
int * nextnon
Definition abcSaucy.c:99
int * splitlev
Definition abcSaucy.c:143
int * conncnts
Definition abcSaucy.c:120
int * anctar
Definition abcSaucy.c:125
int * splitwho
Definition abcSaucy.c:141
int * randomVectorSplit_sim2
Definition abcSaucy.c:183
int * undifflev
Definition abcSaucy.c:151
int * theta
Definition abcSaucy.c:132
Vec_Int_t ** iDep
Definition abcSaucy.c:177
int * splitvar
Definition abcSaucy.c:140
int * clist
Definition abcSaucy.c:110
int * threp
Definition abcSaucy.c:136
struct coloring left right
Definition abcSaucy.c:98
Vec_Ptr_t * satCounterExamples
Definition abcSaucy.c:186
int * undiffnons
Definition abcSaucy.c:159
int * thprev
Definition abcSaucy.c:135
int * prevnon
Definition abcSaucy.c:100
int * specmin
Definition abcSaucy.c:154
char * diffmark
Definition abcSaucy.c:147
int * thsize
Definition abcSaucy.c:133
int * count
Definition abcSaucy.c:117
int * thnext
Definition abcSaucy.c:134
char * stuff
Definition abcSaucy.c:114
char * marks
Definition abcSaucy.c:184
Vec_Int_t ** oDep
Definition abcSaucy.c:177
int * diffs
Definition abcSaucy.c:148
Vec_Ptr_t * randomVectorArray_sim2
Definition abcSaucy.c:182
int * junk
Definition abcSaucy.c:118
int * splitfrom
Definition abcSaucy.c:142
int * thfront
Definition abcSaucy.c:137
int * start
Definition abcSaucy.c:127
int * pairs
Definition abcSaucy.c:155
int * unsupp
Definition abcSaucy.c:153
int * diffnons
Definition abcSaucy.c:158
int * bucket
Definition abcSaucy.c:116
int * ccount
Definition abcSaucy.c:115
int * randomVectorSplit_sim1
Definition abcSaucy.c:181
Vec_Int_t ** obs
Definition abcSaucy.c:178
int * unpairs
Definition abcSaucy.c:156
char * indmark
Definition abcSaucy.c:103
Vec_Ptr_t * randomVectorArray_sim1
Definition abcSaucy.c:180
int * difflev
Definition abcSaucy.c:149
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saucy_free()

void saucy_free ( struct saucy * s)

Definition at line 2491 of file abcSaucy.c.

2492{
2493 int i;
2494
2495 ABC_FREE(s->undiffnons);
2496 ABC_FREE(s->diffnons);
2497 ABC_FREE(s->unpairs);
2498 ABC_FREE(s->pairs);
2499 ABC_FREE(s->thfront);
2500 ABC_FREE(s->threp);
2501 ABC_FREE(s->thnext);
2502 ABC_FREE(s->thprev);
2503 ABC_FREE(s->specmin);
2504 ABC_FREE(s->anctar);
2505 ABC_FREE(s->thsize);
2506 ABC_FREE(s->undifflev);
2507 ABC_FREE(s->difflev);
2508 ABC_FREE(s->diffs);
2509 ABC_FREE(s->diffmark);
2510 ABC_FREE(s->conncnts);
2511 ABC_FREE(s->unsupp);
2512 ABC_FREE(s->splitlev);
2513 ABC_FREE(s->splitfrom);
2514 ABC_FREE(s->splitwho);
2515 ABC_FREE(s->splitvar);
2516 ABC_FREE(s->right.unlab);
2517 ABC_FREE(s->right.lab);
2518 ABC_FREE(s->left.unlab);
2519 ABC_FREE(s->left.lab);
2520 ABC_FREE(s->theta);
2521 ABC_FREE(s->junk);
2522 ABC_FREE(s->gamma);
2523 ABC_FREE(s->start);
2524 ABC_FREE(s->prevnon);
2525 free(s->nextnon-1);
2526 ABC_FREE(s->clist);
2527 ABC_FREE(s->ccount);
2528 ABC_FREE(s->count);
2529 ABC_FREE(s->bucket);
2530 ABC_FREE(s->stuff);
2531 ABC_FREE(s->right.clen);
2532 ABC_FREE(s->right.cfront);
2533 ABC_FREE(s->left.clen);
2534 ABC_FREE(s->left.cfront);
2535 ABC_FREE(s->indmark);
2536 ABC_FREE(s->sinduce);
2537 ABC_FREE(s->ninduce);
2538 ABC_FREE(s->depAdj);
2539 ABC_FREE(s->depEdg);
2540 ABC_FREE(s->marks);
2541 for (i = 0; i < Abc_NtkPiNum(s->pNtk); i++) {
2542 Vec_IntFree( s->iDep[i] );
2543 Vec_IntFree( s->obs[i] );
2544 Vec_PtrFree( s->topOrder[i] );
2545 }
2546 for (i = 0; i < Abc_NtkPoNum(s->pNtk); i++) {
2547 Vec_IntFree( s->oDep[i] );
2548 Vec_IntFree( s->ctrl[i] );
2549 }
2550 for (i = 0; i < Vec_PtrSize(s->randomVectorArray_sim1); i++)
2551 Vec_IntFree((Vec_Int_t *)Vec_PtrEntry(s->randomVectorArray_sim1, i));
2552 for (i = 0; i < Vec_PtrSize(s->randomVectorArray_sim2); i++)
2553 Vec_IntFree((Vec_Int_t *)Vec_PtrEntry(s->randomVectorArray_sim2, i));
2554 Vec_PtrFree( s->randomVectorArray_sim1 );
2555 Vec_PtrFree( s->randomVectorArray_sim2 );
2559 for (i = 0; i < Vec_PtrSize(s->satCounterExamples); i++) {
2560 struct sim_result * cex = (struct sim_result *)Vec_PtrEntry(s->satCounterExamples, i);
2561 ABC_FREE( cex->inVec );
2562 ABC_FREE( cex->outVec );
2563 ABC_FREE( cex );
2564 }
2565 Vec_PtrFree(s->satCounterExamples);
2566 ABC_FREE( s->pModel );
2567 ABC_FREE( s->iDep );
2568 ABC_FREE( s->oDep );
2569 ABC_FREE( s->obs );
2570 ABC_FREE( s->ctrl );
2571 ABC_FREE( s->topOrder );
2572 ABC_FREE(s);
2573}
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
#define ABC_FREE(obj)
Definition abc_global.h:267
int * depAdj
Definition abcSaucy.c:175
Vec_Ptr_t ** topOrder
Definition abcSaucy.c:179
int * depEdg
Definition abcSaucy.c:176
int * outVec
Definition abcSaucy.c:83
int * inVec
Definition abcSaucy.c:82
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saucy_search()

void saucy_search ( Abc_Ntk_t * pNtk,
struct saucy * s,
int directed,
const int * colors,
struct saucy_stats * stats )

Definition at line 2311 of file abcSaucy.c.

2317{
2318 int i, j, max = 0;
2319 struct saucy_graph *g;
2320
2321 extern Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk );
2322
2323 /* Save network information */
2324 s->pNtk = pNtk;
2325 s->pNtk_permuted = Abc_NtkDup( pNtk );
2326
2327 /* Builde dependency graph */
2328 g = buildDepGraph(pNtk, s->iDep, s->oDep);
2329
2330 /* Save graph information */
2331 s->n = g->n;
2332 s->depAdj = g->adj;
2333 s->depEdg = g->edg;
2334 /*s->dadj = g->adj + g->n + 1;
2335 s->dedg = g->edg + g->e;*/
2336
2337 /* Save client information */
2338 s->stats = stats;
2339
2340 /* Polymorphism */
2341 if (directed) {
2342 s->is_automorphism = is_directed_automorphism;
2343 s->ref_singleton = ref_singleton_directed;
2344 s->ref_nonsingle = ref_nonsingle_directed;
2345 }
2346 else {
2347 s->is_automorphism = is_undirected_automorphism;
2348 s->ref_singleton = ref_singleton_undirected;
2349 s->ref_nonsingle = ref_nonsingle_undirected;
2350 }
2351
2352 /* Initialize scalars */
2353 s->indmin = 0;
2354 s->lev = s->anc = 1;
2355 s->ndiffs = s->nundiffs = s->ndiffnons = 0;
2356 s->activityInc = 1;
2357
2358 /* The initial orbit partition is discrete */
2359 for (i = 0; i < s->n; ++i) {
2360 s->theta[i] = i;
2361 }
2362
2363 /* The initial permutation is the identity */
2364 for (i = 0; i < s->n; ++i) {
2365 s->gamma[i] = i;
2366 }
2367
2368 /* Initially every cell of theta has one element */
2369 for (i = 0; i < s->n; ++i) {
2370 s->thsize[i] = 1;
2371 }
2372
2373 /* Every theta rep list is singleton */
2374 for (i = 0; i < s->n; ++i) {
2375 s->thprev[i] = s->thnext[i] = i;
2376 }
2377
2378 /* We have no pairs yet */
2379 s->npairs = 0;
2380 for (i = 0; i < s->n; ++i) {
2381 s->unpairs[i] = -1;
2382 }
2383
2384 /* Ensure no stray pointers in undiffnons, which is checked by removed_diffnon() */
2385 for (i = 0; i < s->n; ++i) {
2386 s->undiffnons[i] = -1;
2387 }
2388
2389 /* Initialize stats */
2390 s->stats->grpsize_base = 1.0;
2391 s->stats->grpsize_exp = 0;
2392 s->stats->nodes = 1;
2393 s->stats->bads = s->stats->gens = s->stats->support = 0;
2394
2395 /* Prepare for refinement */
2396 s->nninduce = s->nsinduce = 0;
2397 s->csize = 0;
2398
2399 /* Count cell sizes */
2400 for (i = 0; i < s->n; ++i) {
2401 s->ccount[colors[i]]++;
2402 if (max < colors[i]) max = colors[i];
2403 }
2404 s->nsplits = max + 1;
2405
2406 /* Build cell lengths */
2407 s->left.clen[0] = s->ccount[0] - 1;
2408 for (i = 0; i < max; ++i) {
2409 s->left.clen[s->ccount[i]] = s->ccount[i+1] - 1;
2410 s->ccount[i+1] += s->ccount[i];
2411 }
2412
2413 /* Build the label array */
2414 for (i = 0; i < s->n; ++i) {
2415 set_label(&s->left, --s->ccount[colors[i]], i);
2416 }
2417
2418 /* Clear out ccount */
2419 for (i = 0; i <= max; ++i) {
2420 s->ccount[i] = 0;
2421 }
2422
2423 /* Update refinement stuff based on initial partition */
2424 for (i = 0; i < s->n; i += s->left.clen[i]+1) {
2425 add_induce(s, &s->left, i);
2426 fix_fronts(&s->left, i, i);
2427 }
2428
2429 /* Prepare lists based on cell lengths */
2430 for (i = 0, j = -1; i < s->n; i += s->left.clen[i] + 1) {
2431 if (!s->left.clen[i]) continue;
2432 s->prevnon[i] = j;
2433 s->nextnon[j] = i;
2434 j = i;
2435 }
2436
2437 /* Fix the end */
2438 s->prevnon[s->n] = j;
2439 s->nextnon[j] = s->n;
2440
2441 /* Preprocessing after initial coloring */
2442 s->split = split_init;
2443 s->refineBySim1 = refineBySim1_init;
2444 s->refineBySim2 = refineBySim2_init;
2445
2446 //print_partition(&s->left, NULL, s->n, s->pNtk, 1);
2447 printf("Initial Refine by Dependency graph ... ");
2448 refineByDepGraph(s, &s->left);
2449 //print_partition(&s->left, NULL, s->n, s->pNtk, 1);
2450 printf("done!\n");
2451
2452 printf("Initial Refine by Simulation ... ");
2453 if (REFINE_BY_SIM_1) s->refineBySim1(s, &s->left);
2454 //print_partition(&s->left, NULL, s->n, s->pNtk, 1);
2455 if (REFINE_BY_SIM_2) s->refineBySim2(s, &s->left);
2456 //print_partition(&s->left, NULL, s->n, s->pNtk, 1);
2457 printf("done!\n\t--------------------\n");
2458
2459 /* Descend along the leftmost branch and compute zeta */
2460 s->refineBySim1 = refineBySim1_left;
2461 s->refineBySim2 = refineBySim2_left;
2462 descend_leftmost(s);
2463 s->split = split_other;
2464 s->refineBySim1 = refineBySim1_other;
2465 s->refineBySim2 = refineBySim2_other;
2466
2467 /* Our common ancestor with zeta is the current level */
2468 s->stats->levels = s->anc = s->lev;
2469
2470 /* Copy over this data to our non-leftmost coloring */
2471 memcpy(s->right.lab, s->left.lab, s->n * sizeof(int));
2472 memcpy(s->right.unlab, s->left.unlab, s->n * sizeof(int));
2473 memcpy(s->right.clen, s->left.clen, s->n * sizeof(int));
2474 memcpy(s->right.cfront, s->left.cfront, s->n * sizeof(int));
2475
2476 /* The reps are just the labels at this point */
2477 memcpy(s->threp, s->left.lab, s->n * sizeof(int));
2478 memcpy(s->thfront, s->left.unlab, s->n * sizeof(int));
2479
2480 /* choose cell selection method */
2481 if (SELECT_DYNAMICALLY) s->select_decomposition = select_dynamically;
2482 else s->select_decomposition = select_statically;
2483
2484 /* Keep running till we're out of automorphisms */
2485 while (do_search(s));
2486
2487 ABC_FREE(g);
2488}
#define REFINE_BY_SIM_1
Definition abcSaucy.c:33
#define REFINE_BY_SIM_2
Definition abcSaucy.c:34
#define SELECT_DYNAMICALLY
Definition abcSaucy.c:36
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
int * adj
Definition abcSaucy.c:70
int * edg
Definition abcSaucy.c:71
double grpsize_base
Definition abcSaucy.c:58
int grpsize_exp
Definition abcSaucy.c:59
int support
Definition abcSaucy.c:64
int(* ref_nonsingle)(struct saucy *, struct coloring *, int)
Definition abcSaucy.c:166
int(* is_automorphism)(struct saucy *)
Definition abcSaucy.c:164
void(* select_decomposition)(struct saucy *, int *, int *, int *)
Definition abcSaucy.c:167
int lev
Definition abcSaucy.c:123
int(* refineBySim2)(struct saucy *, struct coloring *)
Definition abcSaucy.c:195
struct saucy_stats * stats
Definition abcSaucy.c:170
int nsplits
Definition abcSaucy.c:144
int csize
Definition abcSaucy.c:111
int npairs
Definition abcSaucy.c:157
int nundiffs
Definition abcSaucy.c:152
int indmin
Definition abcSaucy.c:128
int anc
Definition abcSaucy.c:124
int(* ref_singleton)(struct saucy *, struct coloring *, int)
Definition abcSaucy.c:165
int ndiffnons
Definition abcSaucy.c:160
int nsinduce
Definition abcSaucy.c:107
int(* refineBySim1)(struct saucy *, struct coloring *)
Definition abcSaucy.c:194
int ndiffs
Definition abcSaucy.c:150
int(* split)(struct saucy *, struct coloring *, int, int)
Definition abcSaucy.c:163
int nninduce
Definition abcSaucy.c:106
double activityInc
Definition abcSaucy.c:187
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saucyGateWay()

void saucyGateWay ( Abc_Ntk_t * pNtkOrig,
Abc_Obj_t * pNodePo,
FILE * gFile,
int fBooleanMatching,
int fLookForSwaps,
int fFixOutputs,
int fFixInputs,
int fQuiet,
int fPrintTree )

Definition at line 3249 of file abcSaucy.c.

3251{
3252 Abc_Ntk_t * pNtk;
3253 struct saucy *s;
3254 struct saucy_stats stats;
3255 int *colors;
3256 int i, clk = clock();
3257
3258 if (pNodePo == NULL)
3259 pNtk = Abc_NtkDup( pNtkOrig );
3260 else
3261 pNtk = Abc_NtkCreateCone( pNtkOrig, Abc_ObjFanin0(pNodePo), Abc_ObjName(pNodePo), 0 );
3262
3263 if (Abc_NtkPiNum(pNtk) == 0) {
3264 Abc_Print( 0, "This output is not dependent on any input\n" );
3265 Abc_NtkDelete( pNtk );
3266 return;
3267 }
3268
3269 s = saucy_alloc( pNtk );
3270
3271 /******* Getting Dependencies *******/
3272 printf("Build functional dependency graph (dependency stats are below) ... ");
3273 getDependencies( pNtk, s->iDep, s->oDep );
3274 printf("\t--------------------\n");
3275 /************************************/
3276
3277 /* Finding toplogical orde */
3278 s->topOrder = findTopologicalOrder( pNtk );
3279
3280 /* Setting graph colors: outputs = 0 and inputs = 1 */
3281 colors = ints(Abc_NtkPoNum(pNtk) + Abc_NtkPiNum(pNtk));
3282 if (fFixOutputs) {
3283 for (i = 0; i < Abc_NtkPoNum(pNtk); i++)
3284 colors[i] = i;
3285 } else {
3286 for (i = 0; i < Abc_NtkPoNum(pNtk); i++)
3287 colors[i] = 0;
3288 }
3289 if (fFixInputs) {
3290 int c = (fFixOutputs) ? Abc_NtkPoNum(pNtk) : 1;
3291 for (i = 0; i < Abc_NtkPiNum(pNtk); i++)
3292 colors[i+Abc_NtkPoNum(pNtk)] = c+i;
3293 } else {
3294 int c = (fFixOutputs) ? Abc_NtkPoNum(pNtk) : 1;
3295 for (i = 0; i < Abc_NtkPiNum(pNtk); i++)
3296 colors[i+Abc_NtkPoNum(pNtk)] = c;
3297 }
3298
3299 /* Are we looking for Boolean matching? */
3300 s->fBooleanMatching = fBooleanMatching;
3301 if (fBooleanMatching) {
3302 NUM_SIM1_ITERATION = 50;
3303 NUM_SIM2_ITERATION = 50;
3304 } else {
3305 NUM_SIM1_ITERATION = 200;
3306 NUM_SIM2_ITERATION = 200;
3307 }
3308
3309 /* Set the print automorphism routine */
3310 if (!fQuiet)
3311 s->print_automorphism = print_automorphism_ntk;
3312 else
3313 s->print_automorphism = print_automorphism_quiet;
3314
3315 /* Set the output file for generators */
3316 if (gFile == NULL)
3317 s->gFile = stdout;
3318 else
3319 s->gFile = gFile;
3320
3321 /* Set print tree option */
3322 s->fPrintTree = fPrintTree;
3323
3324 /* Set input permutations option */
3325 s->fLookForSwaps = fLookForSwaps;
3326
3327 saucy_search(pNtk, s, 0, colors, &stats);
3328 print_stats(stdout, stats);
3329 if (fBooleanMatching) {
3330 if (stats.grpsize_base > 1 || stats.grpsize_exp > 0)
3331 printf("*** Networks are equivalent ***\n");
3332 else
3333 printf("*** Networks are NOT equivalent ***\n");
3334 }
3335 saucy_free(s);
3336 Abc_NtkDelete(pNtk);
3337
3338 if (1) {
3339 FILE * hadi = fopen("hadi.txt", "a");
3340 fprintf(hadi, "group size = %fe%d\n",
3341 stats.grpsize_base, stats.grpsize_exp);
3342 fclose(hadi);
3343 }
3344
3345 ABC_PRT( "Runtime", clock() - clk );
3346
void getDependencies(Abc_Ntk_t *pNtk, Vec_Int_t **iDep, Vec_Int_t **oDep)
Definition abcBm.c:46
Vec_Ptr_t ** findTopologicalOrder(Abc_Ntk_t *pNtk)
Definition abcBm.c:422
int NUM_SIM2_ITERATION
Definition abcSaucy.c:40
void saucy_search(Abc_Ntk_t *pNtk, struct saucy *s, int directed, const int *colors, struct saucy_stats *stats)
Definition abcSaucy.c:2311
int NUM_SIM1_ITERATION
Definition abcSaucy.c:39
struct saucy * saucy_alloc(Abc_Ntk_t *pNtk)
Definition abcSaucy.c:2576
ABC_DLL Abc_Ntk_t * Abc_NtkCreateCone(Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, char *pNodeName, int fUseAllCis)
Definition abcNtk.c:925
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_NAMESPACE_IMPL_END
int(* print_automorphism)(FILE *f, int n, const int *gamma, int nsupp, const int *support, char *marks, Abc_Ntk_t *pNtk)
Definition abcSaucy.c:196
int fLookForSwaps
Definition abcSaucy.c:191
int fPrintTree
Definition abcSaucy.c:190
FILE * gFile
Definition abcSaucy.c:192
int fBooleanMatching
Definition abcSaucy.c:189
Here is the call graph for this function:

◆ unprepare_permutation_ntk()

void unprepare_permutation_ntk ( struct saucy * s)

Definition at line 2209 of file abcSaucy.c.

2210{
2211 int i;
2212 Abc_Obj_t * pObj, * pObjPerm;
2213 int numouts = Abc_NtkPoNum(s->pNtk);
2214
2216 s->pNtk_permuted->pManName = Nm_ManCreate( Abc_NtkCiNum(s->pNtk) + Abc_NtkCoNum(s->pNtk) + Abc_NtkBoxNum(s->pNtk) );
2217
2218 for (i = 0; i < s->n; ++i) {
2219 if (i < numouts) {
2220 pObj = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk->vPos, s->gamma[i]);
2221 pObjPerm = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk_permuted->vPos, i);
2222 }
2223 else {
2224 pObj = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk->vPis, s->gamma[i] - numouts);
2225 pObjPerm = (Abc_Obj_t *)Vec_PtrEntry(s->pNtk_permuted->vPis, i - numouts);
2226
2227 }
2228 Abc_ObjAssignName( pObjPerm, Abc_ObjName(pObj), NULL );
2229 }
2230
2232}
Here is the call graph for this function:

Variable Documentation

◆ NUM_SIM1_ITERATION

int NUM_SIM1_ITERATION

Definition at line 39 of file abcSaucy.c.

◆ NUM_SIM2_ITERATION

int NUM_SIM2_ITERATION

Definition at line 40 of file abcSaucy.c.