ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaSat.c File Reference
#include "gia.h"
Include dependency graph for giaSat.c:

Go to the source code of this file.

Classes

struct  Gia_ManSat_t_
 
struct  Gia_ObjSat1_t_
 
struct  Gia_ObjSat2_t_
 
struct  Gia_ObjSat_t_
 

Macros

#define GIA_LIMIT   10
 DECLARATIONS ///.
 

Typedefs

typedef struct Gia_ManSat_t_ Gia_ManSat_t
 
typedef struct Gia_ObjSat1_t_ Gia_ObjSat1_t
 
typedef struct Gia_ObjSat2_t_ Gia_ObjSat2_t
 
typedef struct Gia_ObjSat_t_ Gia_ObjSat_t
 

Functions

Gia_ManSat_tGia_ManSatStart ()
 FUNCTION DEFINITIONS ///.
 
void Gia_ManSatStop (Gia_ManSat_t *p)
 
void Gia_ManSatPartCollectSuper (Gia_Man_t *p, Gia_Obj_t *pObj, int *pLits, int *pnLits)
 
int Gia_ManSatPartCreate_rec (Gia_Man_t *p, Gia_Obj_t *pObj, int *pObjPlace, int *pStore)
 
int Gia_ManSatPartCreate (Gia_Man_t *p, Gia_Obj_t *pObj, int *pStore)
 
void Gia_ManSatPartCountClauses (Gia_Man_t *p, Gia_Obj_t *pObj, int *pnOnset, int *pnOffset)
 
int Gia_ManSatPartCount (Gia_Man_t *p, Gia_Obj_t *pObj, int *pnLeaves, int *pnNodes)
 
int Gia_ManSatPartCountNodes (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ManSatPartPrint (Gia_Man_t *p, Gia_Obj_t *pObj, int Step)
 
void Gia_ManSatExperiment (Gia_Man_t *p)
 

Macro Definition Documentation

◆ GIA_LIMIT

#define GIA_LIMIT   10

DECLARATIONS ///.

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

FileName [giaSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [New constraint-propagation procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file giaSat.c.

Typedef Documentation

◆ Gia_ManSat_t

typedef struct Gia_ManSat_t_ Gia_ManSat_t

Definition at line 33 of file giaSat.c.

◆ Gia_ObjSat1_t

typedef struct Gia_ObjSat1_t_ Gia_ObjSat1_t

Definition at line 39 of file giaSat.c.

◆ Gia_ObjSat2_t

typedef struct Gia_ObjSat2_t_ Gia_ObjSat2_t

Definition at line 48 of file giaSat.c.

◆ Gia_ObjSat_t

typedef struct Gia_ObjSat_t_ Gia_ObjSat_t

Definition at line 55 of file giaSat.c.

Function Documentation

◆ Gia_ManSatExperiment()

void Gia_ManSatExperiment ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file giaSat.c.

351{
352 int nStored, Storage[1000], * pStart;
353 Gia_ManSat_t * pMan;
354 Gia_Obj_t * pObj;
355 int i, nLevels, nLeaves, nNodes, nCount[2*GIA_LIMIT+2] = {0}, nCountAll = 0;
356 int Num0 = 0, Num1 = 0;
357 clock_t clk = clock();
358 int nWords = 0, nWords2 = 0;
359 pMan = Gia_ManSatStart();
360 // mark the nodes to become roots of leaf-DAGs
362 Gia_ManForEachObj( p, pObj, i )
363 {
364 pObj->fMark0 = 0;
365 if ( Gia_ObjIsCo(pObj) )
366 Gia_ObjFanin0(pObj)->fMark0 = 1;
367 else if ( Gia_ObjIsCi(pObj) )
368 pObj->fMark0 = 1;
369 else if ( Gia_ObjIsAnd(pObj) )
370 {
371 if ( pObj->Value > 1 || Gia_ManSatPartCountNodes(p,pObj) >= GIA_LIMIT )
372 pObj->fMark0 = 1;
373 }
374 pObj->Value = 0;
375 }
376 // compute the sizes of leaf-DAGs
377 Gia_ManForEachAnd( p, pObj, i )
378 {
379 if ( pObj->fMark0 == 0 )
380 continue;
381 pObj->fMark0 = 0;
382
383 nCountAll++;
384 nStored = Gia_ManSatPartCreate( p, pObj, Storage );
385 nWords2 += nStored;
386 assert( nStored < 500 );
387 pStart = (int *)Aig_MmFlexEntryFetch( pMan->pMem, sizeof(int) * nStored );
388 memcpy( pStart, Storage, sizeof(int) * nStored );
389
390 nLeaves = nNodes = 0;
391 nLevels = 1+Gia_ManSatPartCount( p, pObj, &nLeaves, &nNodes );
392 nWords += nLeaves + nNodes;
393 if ( nNodes <= 2*GIA_LIMIT )
394 nCount[nNodes]++;
395 else
396 nCount[2*GIA_LIMIT+1]++;
397// if ( nNodes > 10 && i % 100 == 0 )
398// if ( nNodes > 5 )
399 if ( 0 )
400 {
401 Gia_ManSatPartCountClauses( p, pObj, &Num0, &Num1 );
402 printf( "%8d : And = %3d. Lev = %2d. Clauses = %3d. (%3d + %3d).\n", i, nNodes, nLevels, Num0+Num1, Num0, Num1 );
403 Gia_ManSatPartPrint( p, pObj, 0 );
404 printf( "\n" );
405 }
406
407 pObj->fMark0 = 1;
408 }
409 printf( "\n" );
410 Gia_ManForEachObj( p, pObj, i )
411 pObj->fMark0 = 0;
412 Gia_ManSatStop( pMan );
413 for ( i = 0; i < 2*GIA_LIMIT+2; i++ )
414 printf( "%2d=%6d %7.2f %% %7.2f %%\n", i, nCount[i], 100.0*nCount[i]/nCountAll, 100.0*i*nCount[i]/Gia_ManAndNum(p) );
415 ABC_PRMn( "MemoryEst", 4*nWords );
416 ABC_PRMn( "MemoryReal", 4*nWords2 );
417 printf( "%5.2f bpn ", 4.0*nWords2/Gia_ManObjNum(p) );
418 ABC_PRT( "Time", clock() - clk );
419}
int nWords
Definition abcNpn.c:127
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_PRMn(a, f)
Definition abc_global.h:261
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition aigMem.c:366
Cube * p
Definition exorList.c:222
int Gia_ManSatPartCountNodes(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaSat.c:282
struct Gia_ManSat_t_ Gia_ManSat_t
Definition giaSat.c:33
Gia_ManSat_t * Gia_ManSatStart()
FUNCTION DEFINITIONS ///.
Definition giaSat.c:80
int Gia_ManSatPartCount(Gia_Man_t *p, Gia_Obj_t *pObj, int *pnLeaves, int *pnNodes)
Definition giaSat.c:251
int Gia_ManSatPartCreate(Gia_Man_t *p, Gia_Obj_t *pObj, int *pStore)
Definition giaSat.c:188
void Gia_ManSatPartPrint(Gia_Man_t *p, Gia_Obj_t *pObj, int Step)
Definition giaSat.c:308
void Gia_ManSatStop(Gia_ManSat_t *p)
Definition giaSat.c:99
#define GIA_LIMIT
DECLARATIONS ///.
Definition giaSat.c:30
void Gia_ManSatPartCountClauses(Gia_Man_t *p, Gia_Obj_t *pObj, int *pnOnset, int *pnOffset)
Definition giaSat.c:205
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
void Gia_ManCreateValueRefs(Gia_Man_t *p)
Definition giaUtil.c:750
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
Aig_MmFlex_t * pMem
Definition giaSat.c:36
unsigned Value
Definition gia.h:89
unsigned fMark0
Definition gia.h:81
#define assert(ex)
Definition util_old.h:213
char * memcpy()
Here is the call graph for this function:

◆ Gia_ManSatPartCollectSuper()

void Gia_ManSatPartCollectSuper ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int * pLits,
int * pnLits )

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

Synopsis [Collects the supergate rooted at this ]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file giaSat.c.

118{
119 Gia_Obj_t * pFanin;
120 assert( Gia_ObjIsAnd(pObj) );
121 assert( pObj->fMark0 == 0 );
122 pFanin = Gia_ObjFanin0(pObj);
123 if ( pFanin->fMark0 || Gia_ObjFaninC0(pObj) )
124 pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC0(pObj));
125 else
126 Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits);
127 pFanin = Gia_ObjFanin1(pObj);
128 if ( pFanin->fMark0 || Gia_ObjFaninC1(pObj) )
129 pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC1(pObj));
130 else
131 Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits);
132}
void Gia_ManSatPartCollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, int *pLits, int *pnLits)
Definition giaSat.c:117
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartCount()

int Gia_ManSatPartCount ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int * pnLeaves,
int * pnNodes )

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

Synopsis [Count the number of internal nodes in the leaf-DAG.]

Description []

SideEffects []

SeeAlso []

Definition at line 251 of file giaSat.c.

252{
253 Gia_Obj_t * pFanin;
254 int Level0 = 0, Level1 = 0;
255 assert( Gia_ObjIsAnd(pObj) );
256 assert( pObj->fMark0 == 0 );
257 (*pnNodes)++;
258 pFanin = Gia_ObjFanin0(pObj);
259 if ( pFanin->fMark0 )
260 (*pnLeaves)++;
261 else
262 Level0 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC0(pObj);
263 pFanin = Gia_ObjFanin1(pObj);
264 if ( pFanin->fMark0 )
265 (*pnLeaves)++;
266 else
267 Level1 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC1(pObj);
268 return Abc_MaxInt( Level0, Level1 );
269}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartCountClauses()

void Gia_ManSatPartCountClauses ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int * pnOnset,
int * pnOffset )

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

Synopsis [Count the number of internal nodes in the leaf-DAG.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file giaSat.c.

206{
207 Gia_Obj_t * pFanin;
208 int nOnset0, nOnset1, nOffset0, nOffset1;
209 assert( Gia_ObjIsAnd(pObj) );
210 pFanin = Gia_ObjFanin0(pObj);
211 if ( pFanin->fMark0 )
212 nOnset0 = 1, nOffset0 = 1;
213 else
214 {
215 Gia_ManSatPartCountClauses(p, pFanin, &nOnset0, &nOffset0);
216 if ( Gia_ObjFaninC0(pObj) )
217 {
218 int Temp = nOnset0;
219 nOnset0 = nOffset0;
220 nOffset0 = Temp;
221 }
222 }
223 pFanin = Gia_ObjFanin1(pObj);
224 if ( pFanin->fMark0 )
225 nOnset1 = 1, nOffset1 = 1;
226 else
227 {
228 Gia_ManSatPartCountClauses(p, pFanin, &nOnset1, &nOffset1);
229 if ( Gia_ObjFaninC1(pObj) )
230 {
231 int Temp = nOnset1;
232 nOnset1 = nOffset1;
233 nOffset1 = Temp;
234 }
235 }
236 *pnOnset = nOnset0 * nOnset1;
237 *pnOffset = nOffset0 + nOffset1;
238}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartCountNodes()

int Gia_ManSatPartCountNodes ( Gia_Man_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Count the number of internal nodes in the leaf-DAG.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file giaSat.c.

283{
284 Gia_Obj_t * pFanin;
285 int nNodes0 = 0, nNodes1 = 0;
286 assert( Gia_ObjIsAnd(pObj) );
287 assert( pObj->fMark0 == 0 );
288 pFanin = Gia_ObjFanin0(pObj);
289 if ( !(pFanin->fMark0) )
290 nNodes0 = Gia_ManSatPartCountNodes(p, pFanin);
291 pFanin = Gia_ObjFanin1(pObj);
292 if ( !(pFanin->fMark0) )
293 nNodes1 = Gia_ManSatPartCountNodes(p, pFanin);
294 return nNodes0 + nNodes1 + 1;
295}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartCreate()

int Gia_ManSatPartCreate ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int * pStore )

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

Synopsis [Creates part and returns the number of words used.]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file giaSat.c.

189{
190 return 1 + Gia_ManSatPartCreate_rec( p, pObj, pStore, pStore + 1 );
191}
int Gia_ManSatPartCreate_rec(Gia_Man_t *p, Gia_Obj_t *pObj, int *pObjPlace, int *pStore)
Definition giaSat.c:145
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartCreate_rec()

int Gia_ManSatPartCreate_rec ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int * pObjPlace,
int * pStore )

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

Synopsis [Returns the number of words used.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file giaSat.c.

146{
147 Gia_Obj_t * pFanin;
148 int i, nWordsUsed, nSuperSize = 0, Super[2*GIA_LIMIT];
149 // make sure this is a valid node
150 assert( Gia_ObjIsAnd(pObj) );
151 assert( pObj->fMark0 == 0 );
152 // collect inputs to the supergate
153 Gia_ManSatPartCollectSuper( p, pObj, Super, &nSuperSize );
154 assert( nSuperSize <= 2*GIA_LIMIT );
155 // create the root entry
156 *pObjPlace = 0;
157 ((Gia_ObjSat1_t *)pObjPlace)->nFans = Gia_Var2Lit( nSuperSize, 0 );
158 ((Gia_ObjSat1_t *)pObjPlace)->nOffset = pStore - pObjPlace;
159 nWordsUsed = nSuperSize;
160 for ( i = 0; i < nSuperSize; i++ )
161 {
162 pFanin = Gia_ManObj( p, Gia_Lit2Var(Super[i]) );
163 if ( pFanin->fMark0 )
164 {
165 ((Gia_ObjSat2_t *)(pStore + i))->fTerm = 1;
166 ((Gia_ObjSat2_t *)(pStore + i))->iLit = Super[i];
167 }
168 else
169 {
170 assert( Gia_LitIsCompl(Super[i]) );
171 nWordsUsed += Gia_ManSatPartCreate_rec( p, pFanin, pStore + i, pStore + nWordsUsed );
172 }
173 }
174 return nWordsUsed;
175}
struct Gia_ObjSat1_t_ Gia_ObjSat1_t
Definition giaSat.c:39
struct Gia_ObjSat2_t_ Gia_ObjSat2_t
Definition giaSat.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatPartPrint()

void Gia_ManSatPartPrint ( Gia_Man_t * p,
Gia_Obj_t * pObj,
int Step )

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

Synopsis [Count the number of internal nodes in the leaf-DAG.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file giaSat.c.

309{
310 Gia_Obj_t * pFanin;
311 assert( Gia_ObjIsAnd(pObj) );
312 assert( pObj->fMark0 == 0 );
313 pFanin = Gia_ObjFanin0(pObj);
314 if ( pFanin->fMark0 )
315 printf( "%s%d", Gia_ObjFaninC0(pObj)?"!":"", Gia_ObjId(p,pFanin) );
316 else
317 {
318 if ( Gia_ObjFaninC0(pObj) )
319 printf( "(" );
320 Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC0(pObj));
321 if ( Gia_ObjFaninC0(pObj) )
322 printf( ")" );
323 }
324 printf( "%s", (Step & 1)? " + " : "*" );
325 pFanin = Gia_ObjFanin1(pObj);
326 if ( pFanin->fMark0 )
327 printf( "%s%d", Gia_ObjFaninC1(pObj)?"!":"", Gia_ObjId(p,pFanin) );
328 else
329 {
330 if ( Gia_ObjFaninC1(pObj) )
331 printf( "(" );
332 Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC1(pObj));
333 if ( Gia_ObjFaninC1(pObj) )
334 printf( ")" );
335 }
336}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatStart()

Gia_ManSat_t * Gia_ManSatStart ( )

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file giaSat.c.

81{
84 p->pMem = Aig_MmFlexStart();
85 return p;
86}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Aig_MmFlex_t * Aig_MmFlexStart()
Definition aigMem.c:305
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSatStop()

void Gia_ManSatStop ( Gia_ManSat_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file giaSat.c.

100{
101 Aig_MmFlexStop( p->pMem, 0 );
102 ABC_FREE( p );
103}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition aigMem.c:337
Here is the call graph for this function:
Here is the caller graph for this function: