ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
extraUtilPath.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "aig/gia/gia.h"
#include "misc/vec/vecHsh.h"
#include <math.h>
#include "sat/bmc/bmc.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "misc/extra/extra.h"
Include dependency graph for extraUtilPath.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Abc_NodeVarX (int nSize, int y, int x)
 DECLARATIONS ///.
 
int Abc_NodeVarY (int nSize, int y, int x)
 
Gia_Man_tAbc_EnumeratePaths (int nSize)
 
void Abc_EnumeratePathsTest ()
 
Vec_Int_tAbc_GraphGrid (int n)
 
Vec_Int_tAbc_GraphNodeLife (Vec_Int_t *vEdges, int n)
 
Vec_Wec_tAbc_GraphFrontiers (Vec_Int_t *vEdges, Vec_Int_t *vLife)
 
void Abc_GraphPathPrint4 (int *pBuffer, Vec_Int_t *vEdges)
 
void Abc_GraphPathPrint5 (int *pBuffer, Vec_Int_t *vEdges)
 
double Abc_GraphCountPaths_rec (int Lev, int Node, Vec_Wec_t *vNodes, double **pCache, int *pBuffer, Vec_Int_t *vEdges)
 
double Abc_GraphCountPaths (Vec_Wec_t *vNodes, Vec_Int_t *vEdges)
 
int Abc_GraphDeriveGia_rec (Gia_Man_t *p, int Lev, int Node, Vec_Wec_t *vNodes, int **pCache, int *pBuffer, Vec_Int_t *vEdges)
 
Gia_Man_tAbc_GraphDeriveGia (Vec_Wec_t *vNodes, Vec_Int_t *vEdges)
 
void Abc_GraphDeriveGiaDump (Vec_Wec_t *vNodes, Vec_Int_t *vEdges, int Size)
 
int Abc_GraphBuildState (Vec_Int_t *vState, int e, int x, Vec_Int_t *vEdges, Vec_Int_t *vLife, Vec_Wec_t *vFronts, int *pFront, Vec_Int_t *vStateNew, int fVerbose)
 
void Abc_GraphBuildFrontier (int nSize, Vec_Int_t *vEdges, Vec_Int_t *vLife, Vec_Wec_t *vFronts, int fVerbose)
 
void Abc_EnumerateFrontierTest (int nSize)
 
double Abc_Word2Double (word w)
 
void Abc_GraphSolve (Gia_Man_t *pGia)
 

Function Documentation

◆ Abc_EnumerateFrontierTest()

void Abc_EnumerateFrontierTest ( int nSize)

Definition at line 509 of file extraUtilPath.c.

510{
511 //int nSize = 3;
512 int fVerbose = 0;
513 Vec_Int_t * vEdges = Abc_GraphGrid( nSize );
514 Vec_Int_t * vLife = Abc_GraphNodeLife( vEdges, nSize );
515 Vec_Wec_t * vFronts = Abc_GraphFrontiers( vEdges, vLife );
516
517 Abc_GraphBuildFrontier( nSize, vEdges, vLife, vFronts, fVerbose );
518
519 Vec_WecFree( vFronts );
520 Vec_IntFree( vLife );
521 Vec_IntFree( vEdges );
522}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Vec_Wec_t * Abc_GraphFrontiers(Vec_Int_t *vEdges, Vec_Int_t *vLife)
Vec_Int_t * Abc_GraphNodeLife(Vec_Int_t *vEdges, int n)
Vec_Int_t * Abc_GraphGrid(int n)
void Abc_GraphBuildFrontier(int nSize, Vec_Int_t *vEdges, Vec_Int_t *vLife, Vec_Wec_t *vFronts, int fVerbose)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:

◆ Abc_EnumeratePaths()

Gia_Man_t * Abc_EnumeratePaths ( int nSize)

Definition at line 65 of file extraUtilPath.c.

66{
67 Gia_Man_t * pTemp, * pGia = Gia_ManStart( 10000 );
68 int * pNodes = ABC_CALLOC( int, nSize+1 );
69 int x, y, nVars = 2*nSize*(nSize+1);
70 for ( x = 0; x < nVars; x++ )
71 Gia_ManAppendCi( pGia );
72 Gia_ManHashAlloc( pGia );
73 // y = 0; x = 0;
74 pNodes[0] = 1;
75 // y = 0; x > 0
76 for ( x = 1; x <= nSize; x++ )
77 pNodes[x] = Gia_ManHashAnd( pGia, pNodes[x-1], Abc_NodeVarX(nSize, 0, x) );
78 // y > 0; x >= 0
79 for ( y = 1; y <= nSize; y++ )
80 {
81 // y > 0; x = 0
82 pNodes[0] = Gia_ManHashAnd( pGia, pNodes[0], Abc_NodeVarY(nSize, y, 0) );
83 // y > 0; x > 0
84 for ( x = 1; x <= nSize; x++ )
85 {
86 int iHor = Gia_ManHashAnd( pGia, pNodes[x-1], Abc_NodeVarX(nSize, y, x) );
87 int iVer = Gia_ManHashAnd( pGia, pNodes[x], Abc_NodeVarY(nSize, y, x) );
88 pNodes[x] = Gia_ManHashOr( pGia, iHor, iVer );
89 }
90 }
91 Gia_ManAppendCo( pGia, pNodes[nSize] );
92 pGia = Gia_ManCleanup( pTemp = pGia );
93 Gia_ManStop( pTemp );
94 ABC_FREE( pNodes );
95 return pGia;
96}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
ABC_NAMESPACE_IMPL_START int Abc_NodeVarX(int nSize, int y, int x)
DECLARATIONS ///.
int Abc_NodeVarY(int nSize, int y, int x)
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_EnumeratePathsTest()

void Abc_EnumeratePathsTest ( )

Definition at line 97 of file extraUtilPath.c.

98{
99 int nSize = 2;
100 Gia_Man_t * pGia = Abc_EnumeratePaths( nSize );
101 Gia_AigerWrite( pGia, "testpath.aig", 0, 0, 0 );
102 Gia_ManStop( pGia );
103}
Gia_Man_t * Abc_EnumeratePaths(int nSize)
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Definition giaAiger.c:1595
Here is the call graph for this function:

◆ Abc_GraphBuildFrontier()

void Abc_GraphBuildFrontier ( int nSize,
Vec_Int_t * vEdges,
Vec_Int_t * vLife,
Vec_Wec_t * vFronts,
int fVerbose )

Definition at line 450 of file extraUtilPath.c.

451{
452 abctime clk = Abc_Clock();
453 double nPaths;
454 int nEdges = Vec_IntSize(vEdges)/2;
455 int nNodes = Vec_IntSize(vLife)/2;
456 Vec_Wec_t * vNodes = Vec_WecAlloc( nEdges );
457 Vec_Int_t * vStateNew = Vec_IntAlloc( nNodes );
458 Vec_Int_t * vStateCount = Vec_IntAlloc( nEdges );
459 int e, s, x, Next, * pFront = ABC_CALLOC( int, nNodes );
460 Hsh_VecMan_t * pThis = Hsh_VecManStart( 1000 );
461 Hsh_VecMan_t * pNext = Hsh_VecManStart( 1000 );
462 Hsh_VecManAdd( pThis, vStateNew );
463 for ( e = 0; e < nEdges; e++ )
464 {
465 Vec_Int_t * vNode = Vec_WecPushLevel(vNodes);
466 int nStates = Hsh_VecSize( pThis );
467 Vec_IntPush( vStateCount, nStates );
468 if ( fVerbose )
469 {
470 printf( "\n" );
471 printf( "Processing edge %d = {%d %d}\n", e, Vec_IntEntry(vEdges, 2*e), Vec_IntEntry(vEdges, 2*e+1) );
472 printf( "Frontier: " ); Vec_IntPrint( Vec_WecEntry(vFronts, e) );
473 printf( "\n" );
474 }
475 for ( s = 0; s < nStates; s++ )
476 {
477 Vec_Int_t * vState = Hsh_VecReadEntry(pThis, s);
478 for ( x = 0; x < 2; x++ )
479 {
480 Next = Abc_GraphBuildState(vState, e, x, vEdges, vLife, vFronts, pFront, vStateNew, fVerbose);
481 if ( Next == 1 )
482 {
483 if ( e == nEdges - 1 ) // last edge
484 Next = -2; // const1
485 else
486 Next = Hsh_VecManAdd( pNext, vStateNew );
487 }
488 if ( fVerbose ) printf( "Return value = %d\n", Next );
489 Vec_IntPush( vNode, Next );
490 }
491 }
492 Hsh_VecManStop( pThis );
493 pThis = pNext;
494 pNext = Hsh_VecManStart( 1000 );
495 }
496 nPaths = Abc_GraphCountPaths(vNodes, vEdges);
497 printf( "States = %8d Paths = %24.0f ", Vec_IntSum(vStateCount), nPaths );
498 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
499 if ( fVerbose )
500 Vec_IntPrint( vStateCount );
501 Abc_GraphDeriveGiaDump( vNodes, vEdges, nSize );
502 ABC_FREE( pFront );
503 Vec_WecFree( vNodes );
504 Vec_IntFree( vStateNew );
505 Vec_IntFree( vStateCount );
506 Hsh_VecManStop( pThis );
507 Hsh_VecManStop( pNext );
508}
ABC_INT64_T abctime
Definition abc_global.h:332
double Abc_GraphCountPaths(Vec_Wec_t *vNodes, Vec_Int_t *vEdges)
int Abc_GraphBuildState(Vec_Int_t *vState, int e, int x, Vec_Int_t *vEdges, Vec_Int_t *vLife, Vec_Wec_t *vFronts, int *pFront, Vec_Int_t *vStateNew, int fVerbose)
void Abc_GraphDeriveGiaDump(Vec_Wec_t *vNodes, Vec_Int_t *vEdges, int Size)
struct Hsh_VecMan_t_ Hsh_VecMan_t
Definition vecHsh.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphBuildState()

int Abc_GraphBuildState ( Vec_Int_t * vState,
int e,
int x,
Vec_Int_t * vEdges,
Vec_Int_t * vLife,
Vec_Wec_t * vFronts,
int * pFront,
Vec_Int_t * vStateNew,
int fVerbose )

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

Synopsis [Build frontier.]

Description []

SideEffects []

SeeAlso []

Definition at line 372 of file extraUtilPath.c.

373{
374 Vec_Int_t * vFront = Vec_WecEntry( vFronts, e );
375 Vec_Int_t * vFront2 = Vec_WecEntry( vFronts, e+1 );
376 int * pNodes = Vec_IntEntryP(vEdges, 2*e);
377 int nNodes = Vec_IntSize(vLife)/2;
378 int i, n, Node, First, pEquivs[2];
379 assert( pNodes[0] < pNodes[1] );
380 if ( fVerbose ) printf( "Edge = %d. Arc = %d.\nCurrent state: ", e, x );
381 Vec_IntForEachEntry( vFront, Node, i )
382 {
383 pFront[Node] = Vec_IntEntry(vState, i);
384 if ( fVerbose ) printf( "%d(%d) ", pFront[Node] & 0xFFFF, pFront[Node] >> 16 );
385 }
386 if ( fVerbose ) printf( "\n" );
387 for ( n = 0; n < 2; n++ )
388 if ( Vec_IntEntry(vLife, 2*pNodes[n]) == e ) // first time
389 pFront[pNodes[n]] = pNodes[n]; // degree = 0; comp = singleton
390 if ( x )
391 {
392 if ( (pFront[pNodes[0]] & 0xFFFF) == (pFront[pNodes[1]] & 0xFFFF) ) // the same comp
393 return -1; // const 0
394 for ( n = 0; n < 2; n++ )
395 {
396 int Degree = pFront[pNodes[n]] >> 16;
397 if ( (pNodes[n] == 0 || pNodes[n] == nNodes-1) ? Degree >= 1 : Degree >= 2 )
398 return -1; // const 0
399 pFront[pNodes[n]] += (1 << 16); // degree++
400 }
401 }
402 // remember equivalence classes
403 pEquivs[0] = pFront[pNodes[0]] & 0xFFFF;
404 pEquivs[1] = pFront[pNodes[1]] & 0xFFFF;
405 // remove some nodes from the frontier
406 for ( n = 0; n < 2; n++ )
407 if ( Vec_IntEntry(vLife, 2*pNodes[n]+1) == e ) // last time
408 {
409 int Degree = pFront[pNodes[n]] >> 16;
410 if ( (pNodes[n] == 0 || pNodes[n] == nNodes-1) ? Degree != 1 : Degree != 0 && Degree != 2 )
411 return -1; // const 0
412 // if it is part of the comp, update
413 First = -1;
414 Vec_IntForEachEntry( vFront2, Node, i )
415 {
416 assert( Node != pNodes[n] );
417 if ( (pFront[Node] & 0xFFFF) == pEquivs[n] )
418 {
419 if ( First == -1 )
420 First = Node;
421 pFront[Node] = (pFront[Node] & 0xFFFF0000) | First;
422 }
423 }
424 if ( First != -1 )
425 pEquivs[n] = First;
426 }
427 if ( x )
428 {
429 // union comp
430 int First = -1;
431 Vec_IntForEachEntry( vFront2, Node, i )
432 if ( (pFront[Node] & 0xFFFF) == pEquivs[0] || (pFront[Node] & 0xFFFF) == pEquivs[1] )
433 {
434 if ( First == -1 )
435 First = Node;
436 pFront[Node] = (pFront[Node] & 0xFFFF0000) | First;
437 }
438 }
439 // create next state
440 Vec_IntClear( vStateNew );
441 if ( fVerbose ) printf( "Next state: " );
442 Vec_IntForEachEntry( vFront2, Node, i )
443 {
444 Vec_IntPush( vStateNew, pFront[Node] );
445 if ( fVerbose ) printf( "%d(%d) ", pFront[Node] & 0xFFFF, pFront[Node] >> 16 );
446 }
447 if ( fVerbose ) printf( "\n\n" );
448 return 1;
449}
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Abc_GraphCountPaths()

double Abc_GraphCountPaths ( Vec_Wec_t * vNodes,
Vec_Int_t * vEdges )

Definition at line 282 of file extraUtilPath.c.

283{
284 int i, k, pBuffer[1000] = {0};
285 double ** pCache = ABC_ALLOC( double *, Vec_WecSize(vNodes) );
286 Vec_Int_t * vLevel; double Value;
287 Vec_WecForEachLevel( vNodes, vLevel, i )
288 {
289 pCache[i] = ABC_ALLOC( double, Vec_IntSize(vLevel) );
290 for ( k = 0; k < Vec_IntSize(vLevel); k++ )
291 pCache[i][k] = -1.0;
292 }
293 Value = Abc_GraphCountPaths_rec( 0, 0, vNodes, pCache, pBuffer, vEdges );
294 for ( i = 0; i < Vec_WecSize(vNodes); i++ )
295 ABC_FREE( pCache[i] );
296 ABC_FREE( pCache );
297 return Value;
298}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
double Abc_GraphCountPaths_rec(int Lev, int Node, Vec_Wec_t *vNodes, double **pCache, int *pBuffer, Vec_Int_t *vEdges)
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphCountPaths_rec()

double Abc_GraphCountPaths_rec ( int Lev,
int Node,
Vec_Wec_t * vNodes,
double ** pCache,
int * pBuffer,
Vec_Int_t * vEdges )

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

Synopsis [Count paths.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file extraUtilPath.c.

267{
268 double Res0, Res1;
269// if ( Node == -2 ) Abc_GraphPathPrint4( pBuffer, vEdges );
270 if ( Node == -2 )
271 return 1;
272 if ( Node == -1 )
273 return 0;
274 if ( pCache[Lev][Node] != -1.0 )
275 return pCache[Lev][Node];
276 pBuffer[Lev] = 0;
277 Res0 = Abc_GraphCountPaths_rec( Lev+1, Vec_IntEntry( Vec_WecEntry(vNodes, Lev), 2*Node ), vNodes, pCache, pBuffer, vEdges );
278 pBuffer[Lev] = 1;
279 Res1 = Abc_GraphCountPaths_rec( Lev+1, Vec_IntEntry( Vec_WecEntry(vNodes, Lev), 2*Node+1 ), vNodes, pCache, pBuffer, vEdges );
280 return (pCache[Lev][Node] = Res0 + Res1);
281}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphDeriveGia()

Gia_Man_t * Abc_GraphDeriveGia ( Vec_Wec_t * vNodes,
Vec_Int_t * vEdges )

Definition at line 326 of file extraUtilPath.c.

327{
328 int ** pCache;
329 int i, Value, pBuffer[1000] = {0};
330 Vec_Int_t * vLevel;
331 // start AIG
332 Gia_Man_t * pTemp, * p = Gia_ManStart( 1000 );
333 p->pName = Abc_UtilStrsav("paths");
334 for ( i = 0; i < Vec_IntSize(vEdges)/2; i++ )
335 Gia_ManAppendCi(p);
337 // alloc cache
338 pCache = ABC_ALLOC( int *, Vec_WecSize(vNodes) );
339 Vec_WecForEachLevel( vNodes, vLevel, i )
340 pCache[i] = ABC_FALLOC( int, Vec_IntSize(vLevel) );
341 Value = Abc_GraphDeriveGia_rec( p, 0, 0, vNodes, pCache, pBuffer, vEdges );
342 for ( i = 0; i < Vec_WecSize(vNodes); i++ )
343 ABC_FREE( pCache[i] );
344 ABC_FREE( pCache );
345 // cleanup
346 Gia_ManAppendCo( p, Value );
347 p = Gia_ManCleanup( pTemp = p );
348 Gia_ManStop( pTemp );
349 return p;
350}
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
Cube * p
Definition exorList.c:222
int Abc_GraphDeriveGia_rec(Gia_Man_t *p, int Lev, int Node, Vec_Wec_t *vNodes, int **pCache, int *pBuffer, Vec_Int_t *vEdges)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphDeriveGia_rec()

int Abc_GraphDeriveGia_rec ( Gia_Man_t * p,
int Lev,
int Node,
Vec_Wec_t * vNodes,
int ** pCache,
int * pBuffer,
Vec_Int_t * vEdges )

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

Synopsis [Build AIG for paths.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file extraUtilPath.c.

312{
313 int Res0, Res1;
314 if ( Node == -2 )
315 return 1;
316 if ( Node == -1 )
317 return 0;
318 if ( pCache[Lev][Node] != -1 )
319 return pCache[Lev][Node];
320 pBuffer[Lev] = 0;
321 Res0 = Abc_GraphDeriveGia_rec( p, Lev+1, Vec_IntEntry( Vec_WecEntry(vNodes, Lev), 2*Node ), vNodes, pCache, pBuffer, vEdges );
322 pBuffer[Lev] = 1;
323 Res1 = Abc_GraphDeriveGia_rec( p, Lev+1, Vec_IntEntry( Vec_WecEntry(vNodes, Lev), 2*Node+1 ), vNodes, pCache, pBuffer, vEdges );
324 return ( pCache[Lev][Node] = Gia_ManHashMux(p, Gia_Obj2Lit(p, Gia_ManCi(p, Lev)), Res1, Res0) );
325}
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphDeriveGiaDump()

void Abc_GraphDeriveGiaDump ( Vec_Wec_t * vNodes,
Vec_Int_t * vEdges,
int Size )

Definition at line 351 of file extraUtilPath.c.

352{
353 char pFileName[100];
354 Gia_Man_t * pGia = Abc_GraphDeriveGia( vNodes, vEdges );
355 sprintf( pFileName, "grid_%dx%d_e%03d.aig", Size, Size, Vec_IntSize(vEdges)/2 );
356 Gia_AigerWrite( pGia, pFileName, 0, 0, 0 );
357 Gia_ManStop( pGia );
358 printf( "Finished dumping AIG into file \"%s\".\n", pFileName );
359}
Gia_Man_t * Abc_GraphDeriveGia(Vec_Wec_t *vNodes, Vec_Int_t *vEdges)
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_GraphFrontiers()

Vec_Wec_t * Abc_GraphFrontiers ( Vec_Int_t * vEdges,
Vec_Int_t * vLife )

Definition at line 148 of file extraUtilPath.c.

149{
150 Vec_Wec_t * vFronts = Vec_WecAlloc( Vec_IntSize(vEdges)/2 ); // front for each edge
151 Vec_Int_t * vTemp = Vec_IntAlloc( Vec_IntSize(vLife)/2 );
152 int e, n;
153 Vec_WecPushLevel(vFronts);
154 for ( e = 0; e < Vec_IntSize(vEdges)/2; e++ )
155 {
156 int * pNodes = Vec_IntEntryP(vEdges, 2*e);
157 for ( n = 0; n < 2; n++ )
158 if ( Vec_IntEntry(vLife, 2*pNodes[n]) == e ) // first time
159 Vec_IntPush( vTemp, pNodes[n] );
160 else if ( Vec_IntEntry(vLife, 2*pNodes[n]+1) == e ) // last time
161 Vec_IntRemove( vTemp, pNodes[n] );
162 Vec_IntAppend( Vec_WecPushLevel(vFronts), vTemp );
163 }
164 //Vec_WecPrint( vFronts, 0 );
165 Vec_IntFree( vTemp );
166 return vFronts;
167}
Here is the caller graph for this function:

◆ Abc_GraphGrid()

Vec_Int_t * Abc_GraphGrid ( int n)

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

Synopsis [Generate NxN grid.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file extraUtilPath.c.

118{
119 Vec_Int_t * vEdges = Vec_IntAlloc( 4*n*(n-1) ); // two nodes per edge
120 int i, k;
121 for ( i = 0; i < n; i++ )
122 {
123 for ( k = 0; k < n-1; k++ )
124 Vec_IntPushTwo( vEdges, i*n+k, i*n+k+1 );
125 if ( i == n-1 ) break;
126 for ( k = 0; k < n; k++ )
127 Vec_IntPushTwo( vEdges, i*n+k, i*n+k+n );
128 }
129 //Vec_IntPrint( vEdges );
130 return vEdges;
131}
Here is the caller graph for this function:

◆ Abc_GraphNodeLife()

Vec_Int_t * Abc_GraphNodeLife ( Vec_Int_t * vEdges,
int n )

Definition at line 132 of file extraUtilPath.c.

133{
134 Vec_Int_t * vLife = Vec_IntStartFull( 2*n*n ); // start/stop per node
135 int One, Two, i;
136 Vec_IntForEachEntryDouble( vEdges, One, Two, i )
137 {
138 if ( Vec_IntEntry(vLife, 2*One) == -1 )
139 Vec_IntWriteEntry(vLife, 2*One, i/2);
140 if ( Vec_IntEntry(vLife, 2*Two) == -1 )
141 Vec_IntWriteEntry(vLife, 2*Two, i/2);
142 Vec_IntWriteEntry(vLife, 2*One+1, i/2);
143 Vec_IntWriteEntry(vLife, 2*Two+1, i/2);
144 }
145 //Vec_IntPrint( vLife );
146 return vLife;
147}
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the caller graph for this function:

◆ Abc_GraphPathPrint4()

void Abc_GraphPathPrint4 ( int * pBuffer,
Vec_Int_t * vEdges )

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

Synopsis [Print grid.]

Description []

SideEffects []

SeeAlso []

Definition at line 180 of file extraUtilPath.c.

181{
182 char Box[13][13];
183 int x, y;
184 int e, nEdges = Vec_IntSize(vEdges)/2;
185 for ( y = 0; y < 13; y++ )
186 for ( x = 0; x < 13; x++ )
187 if ( y % 4 == 0 && x % 4 == 0 )
188 Box[y][x] = '*';
189 else
190 Box[y][x] = ' ';
191 for ( e = 0; e < nEdges; e++ )
192 {
193 int * pNodes = Vec_IntEntryP(vEdges, 2*e);
194 int y0 = 4*(pNodes[0]/4);
195 int x0 = 4*(pNodes[0]%4);
196 int y1 = 4*(pNodes[1]/4);
197 int x1 = 4*(pNodes[1]%4);
198 if ( !pBuffer[e] )
199 continue;
200 if ( y0 == y1 )
201 {
202 for ( x = x0+1; x < x1; x++ )
203 Box[y0][x] = '-';
204 }
205 else if ( x0 == x1 )
206 {
207 for ( y = y0+1; y < y1; y++ )
208 Box[y][x0] = '|';
209 }
210 else assert( 0 );
211 }
212 for ( y = 0; y < 13; y++, printf("\n") )
213 for ( x = 0; x < 13; x++ )
214 printf( "%c", Box[y][x] );
215 printf( "\n\n=================================\n\n" );
216}

◆ Abc_GraphPathPrint5()

void Abc_GraphPathPrint5 ( int * pBuffer,
Vec_Int_t * vEdges )

Definition at line 217 of file extraUtilPath.c.

218{
219 char Box[17][17];
220 int x, y;
221 int e, nEdges = Vec_IntSize(vEdges)/2;
222 for ( y = 0; y < 17; y++ )
223 for ( x = 0; x < 17; x++ )
224 if ( y % 4 == 0 && x % 4 == 0 )
225 Box[y][x] = '*';
226 else
227 Box[y][x] = ' ';
228 for ( e = 0; e < nEdges; e++ )
229 {
230 int * pNodes = Vec_IntEntryP(vEdges, 2*e);
231 int y0 = 4*(pNodes[0]/5);
232 int x0 = 4*(pNodes[0]%5);
233 int y1 = 4*(pNodes[1]/5);
234 int x1 = 4*(pNodes[1]%5);
235 if ( !pBuffer[e] )
236 continue;
237 if ( y0 == y1 )
238 {
239 for ( x = x0+1; x < x1; x++ )
240 Box[y0][x] = '-';
241 }
242 else if ( x0 == x1 )
243 {
244 for ( y = y0+1; y < y1; y++ )
245 Box[y][x0] = '|';
246 }
247 else assert( 0 );
248 }
249 for ( y = 0; y < 17; y++, printf("\n") )
250 for ( x = 0; x < 17; x++ )
251 printf( "%c", Box[y][x] );
252 printf( "\n\n=================================\n\n" );
253}

◆ Abc_GraphSolve()

void Abc_GraphSolve ( Gia_Man_t * pGia)

Definition at line 544 of file extraUtilPath.c.

545{
546 int nIters = 1000;
547 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( pGia, 8, 0, 1, 0, 0 );
548 sat_solver * pSat; Vec_Int_t * vLits = Vec_IntAlloc( 100 );
549 int i, k, iLit, nVars = Gia_ManCiNum(pGia);
550 int iCiVarBeg = pCnf->nVars - nVars;
551 word Total = 0;
552 word Mint1 = 0;
553 word Mint2 = 0;
554
555 // restart the SAT solver
556 pSat = sat_solver_new();
557 sat_solver_setnvars( pSat, pCnf->nVars );
558 // add timeframe clauses
559 for ( i = 0; i < pCnf->nClauses; i++ )
560 if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
561 assert( 0 );
562 // create trivial assignment
563 Vec_IntClear( vLits );
564 for ( k = 0; k < nVars; k++ )
565 Vec_IntPush( vLits, Abc_Var2Lit(iCiVarBeg+k, 1) );
566 // generate random assignment
567 for ( i = 0; i < nIters; i++ )
568 {
569 int Status = sat_solver_solve_lexsat( pSat, Vec_IntArray(vLits), Vec_IntSize(vLits) );
570 if ( Status != l_True )
571 break;
572 assert( Status == l_True );
573 // block this assignment
574 Vec_IntForEachEntry( vLits, iLit, k )
575 Vec_IntWriteEntry( vLits, k, Abc_LitNot(iLit) );
576 if ( !sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits) ) )
577 break;
578 Vec_IntForEachEntry( vLits, iLit, k )
579 Vec_IntWriteEntry( vLits, k, Abc_LitNot(iLit) );
580 // collect new minterm
581 Mint2 = 0;
582 Vec_IntForEachEntry( vLits, iLit, k )
583 if ( !Abc_LitIsCompl(iLit) )
584 Mint2 |= ((word)1) << (nVars-1-k);
585 if ( Mint1 == 0 )
586 Mint1 = Mint2;
587 // report
588 //printf( "Iter %3d : ", i );
589 //Extra_PrintBinary( stdout, (unsigned *)&Mint2, Abc_MinInt(64, nVars) ); printf( "\n" );
590 }
591 //Mint1 = 0;
592 Total = (Mint2-Mint1)/nIters;
593 printf( "Vars = %d Iters = %d Ave = %.0f Total = %.0f ", nVars, nIters, Abc_Word2Double(Mint2-Mint1), Abc_Word2Double(Total) );
594 printf( "Estimate = %.0f\n", (pow(2,nVars)-Abc_Word2Double(Mint1))/Abc_Word2Double((Mint2-Mint1)/nIters) );
595
596 sat_solver_delete( pSat );
597 Cnf_DataFree( pCnf );
598 Vec_IntFree( vLits );
599}
#define l_True
Definition bmcBmcS.c:35
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
double Abc_Word2Double(word w)
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
int sat_solver_solve_lexsat(sat_solver *s, int *pLits, int nLits)
Definition satSolver.c:2143
int nVars
Definition cnf.h:59
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
Here is the call graph for this function:

◆ Abc_NodeVarX()

ABC_NAMESPACE_IMPL_START int Abc_NodeVarX ( int nSize,
int y,
int x )

DECLARATIONS ///.

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

FileName [extraUtilPath.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [extra]

Synopsis [Path enumeration.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
extraUtilPath.c,v 1.0 2003/02/01 00:00:00 alanmi Exp

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

Synopsis [Computes AIG representing the set of all paths in the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 56 of file extraUtilPath.c.

57{
58 return Abc_Var2Lit( nSize * y + x, 0 );
59}
Here is the caller graph for this function:

◆ Abc_NodeVarY()

int Abc_NodeVarY ( int nSize,
int y,
int x )

Definition at line 60 of file extraUtilPath.c.

61{
62 return Abc_Var2Lit( nSize * (nSize + 1) + nSize * x + y, 0 );
63}
Here is the caller graph for this function:

◆ Abc_Word2Double()

double Abc_Word2Double ( word w)

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

Synopsis [Performs SAT-based path enumeration.]

Description []

SideEffects []

SeeAlso []

Definition at line 536 of file extraUtilPath.c.

537{
538 double Res = 0; int i;
539 for ( i = 0; i < 64; i++ )
540 if ( (w >> i) & 1 )
541 Res += pow(2,i);
542 return Res;
543}
Here is the caller graph for this function: