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

Go to the source code of this file.

Classes

struct  Slv_Man_t_
 

Macros

#define Slv_ManForEachObj(p, iObj)
 
#define Slv_ObjForEachFanout(p, iObj, iFanLit)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Slv_Man_t_ Slv_Man_t
 DECLARATIONS ///.
 

Functions

Slv_Man_tSlv_ManAlloc (int nObjs)
 FUNCTION DEFINITIONS ///.
 
void Slv_ManFree (Slv_Man_t *p)
 
void Slv_ManPrintFanouts (Slv_Man_t *p)
 
Slv_Man_tSlv_ManFromGia (Gia_Man_t *p)
 
Gia_Man_tSlv_ManToGia (Slv_Man_t *p)
 
Gia_Man_tSlv_ManToAig (Gia_Man_t *pGia)
 
Gia_Man_tGia_ManCofPisVars (Gia_Man_t *p, int nVars)
 
void Gia_ManStructExperiment (Gia_Man_t *p)
 
int Gia_EnumFirstUnused (int *pUsed, int nVars)
 
void Gia_EnumPerms_rec (int *pUsed, int nVars, int *pPerm, int nPerm, int *pCount, FILE *pFile, int nLogVars)
 
void Gia_EnumPerms (int nVars)
 

Macro Definition Documentation

◆ Slv_ManForEachObj

#define Slv_ManForEachObj ( p,
iObj )
Value:
for ( iObj = 1; iObj < Slv_ManObjNum(p); iObj++ )
Cube * p
Definition exorList.c:222

Definition at line 62 of file gia.c.

62#define Slv_ManForEachObj( p, iObj ) \
63 for ( iObj = 1; iObj < Slv_ManObjNum(p); iObj++ )

◆ Slv_ObjForEachFanout

#define Slv_ObjForEachFanout ( p,
iObj,
iFanLit )
Value:
for ( iFanLit = Slv_ObjFanout0(p, iObj); iFanLit; iFanLit = Slv_ObjNextFanout(p, iFanLit) )

Definition at line 65 of file gia.c.

65#define Slv_ObjForEachFanout( p, iObj, iFanLit ) \
66 for ( iFanLit = Slv_ObjFanout0(p, iObj); iFanLit; iFanLit = Slv_ObjNextFanout(p, iFanLit) )

Typedef Documentation

◆ Slv_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Slv_Man_t_ Slv_Man_t

DECLARATIONS ///.

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

FileName [gia.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file gia.c.

Function Documentation

◆ Gia_EnumFirstUnused()

int Gia_EnumFirstUnused ( int * pUsed,
int nVars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 312 of file gia.c.

313{
314 int i;
315 for ( i = 0; i < nVars; i++ )
316 if ( pUsed[i] == 0 )
317 return i;
318 return -1;
319}
Here is the caller graph for this function:

◆ Gia_EnumPerms()

void Gia_EnumPerms ( int nVars)

Definition at line 368 of file gia.c.

369{
370 int nLogVars = 0, Count = 0;
371 int * pUsed = ABC_CALLOC( int, nVars );
372 int * pPerm = ABC_CALLOC( int, nVars );
373 FILE * pFile = fopen( "pairset.pla", "wb" );
374 assert( nVars % 2 == 0 );
375
376 printf( "Printing sets of pairs for %d objects:\n", nVars );
377 Gia_EnumPerms_rec( pUsed, nVars, pPerm, 0, &Count, NULL, -1 );
378 if ( Count > 20 )
379 printf( "...\n" );
380 printf( "Finished enumerating %d sets of pairs.\n", Count );
381
382 nLogVars = Abc_Base2Log( Count );
383 printf( "Need %d variables to encode %d sets.\n", nLogVars, Count );
384 Count = 0;
385 fprintf( pFile, ".i %d\n", nLogVars );
386 fprintf( pFile, ".o %d\n", nVars*nVars );
387 Gia_EnumPerms_rec( pUsed, nVars, pPerm, 0, &Count, pFile, nLogVars );
388 fprintf( pFile, ".e\n" );
389 fclose( pFile );
390 printf( "Finished dumping file \"%s\".\n", "pairset.pla" );
391
392 ABC_FREE( pUsed );
393 ABC_FREE( pPerm );
394}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
void Gia_EnumPerms_rec(int *pUsed, int nVars, int *pPerm, int nPerm, int *pCount, FILE *pFile, int nLogVars)
Definition gia.c:320
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Gia_EnumPerms_rec()

void Gia_EnumPerms_rec ( int * pUsed,
int nVars,
int * pPerm,
int nPerm,
int * pCount,
FILE * pFile,
int nLogVars )

Definition at line 320 of file gia.c.

321{
322 int i, k, New;
323 if ( nPerm == nVars )
324 {
325 if ( pFile )
326 {
327 for ( i = 0; i < nLogVars; i++ )
328 fprintf( pFile, "%c", '0' + ((*pCount) >> (nLogVars-1-i) & 1) );
329 fprintf( pFile, " " );
330 for ( i = 0; i < nVars; i++ )
331 for ( k = 0; k < nVars; k++ )
332 fprintf( pFile, "%c", '0' + (pPerm[i] == k) );
333 fprintf( pFile, "\n" );
334 }
335 else
336 {
337 if ( *pCount < 20 )
338 {
339 printf( "%5d : ", (*pCount) );
340 for ( i = 0; i < nVars; i += 2 )
341 printf( "%d %d ", pPerm[i], pPerm[i+1] );
342 printf( "\n" );
343 }
344 }
345 (*pCount)++;
346 return;
347 }
348 New = Gia_EnumFirstUnused( pUsed, nVars );
349 assert( New >= 0 );
350 pPerm[nPerm] = New;
351 assert( pUsed[New] == 0 );
352 pUsed[New] = 1;
353 // try remaining ones
354 for ( i = 0; i < nVars; i++ )
355 {
356 if ( pUsed[i] == 1 )
357 continue;
358 pPerm[nPerm+1] = i;
359 assert( pUsed[i] == 0 );
360 pUsed[i] = 1;
361 Gia_EnumPerms_rec( pUsed, nVars, pPerm, nPerm+2, pCount, pFile, nLogVars );
362 assert( pUsed[i] == 1 );
363 pUsed[i] = 0;
364 }
365 assert( pUsed[New] == 1 );
366 pUsed[New] = 0;
367}
int Gia_EnumFirstUnused(int *pUsed, int nVars)
Definition gia.c:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCofPisVars()

Gia_Man_t * Gia_ManCofPisVars ( Gia_Man_t * p,
int nVars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 219 of file gia.c.

220{
221 Gia_Man_t * pNew, * pTemp;
222 Gia_Obj_t * pObj; int i, m;
223 pNew = Gia_ManStart( 1000 );
224 pNew->pName = Abc_UtilStrsav( p->pName );
225 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
226 Gia_ManForEachPi( p, pObj, i )
227 Gia_ManAppendCi( pNew );
228 Gia_ManHashStart( pNew );
229 for ( m = 0; m < (1 << nVars); m++ )
230 {
232 Gia_ManConst0(p)->Value = 0;
233 Gia_ManForEachPi( p, pObj, i )
234 {
235 if ( i < nVars )
236 pObj->Value = (m >> i) & 1;
237 else
238 pObj->Value = Gia_ObjToLit(pNew, Gia_ManCi(pNew, i));
239 }
240 Gia_ManForEachAnd( p, pObj, i )
241 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
242 Gia_ManForEachPo( p, pObj, i )
243 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
244 }
245 Gia_ManHashStop( pNew );
246 pNew = Gia_ManCleanup( pTemp = pNew );
247 Gia_ManStop( pTemp );
248 return pNew;
249}
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
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
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
Here is the call graph for this function:

◆ Gia_ManStructExperiment()

void Gia_ManStructExperiment ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file gia.c.

265{
266 extern int Cec_ManVerifyTwo( Gia_Man_t * p0, Gia_Man_t * p1, int fVerbose );
267 Gia_Man_t * pTemp, * pUsed;
268 Vec_Ptr_t * vGias = Vec_PtrAlloc( 100 );
269 Gia_Obj_t * pObj; int i, k;
270 Gia_ManForEachCo( p, pObj, i )
271 {
272 int iFan0 = Gia_ObjFaninId0p(p, pObj);
273 pTemp = Gia_ManDupAndCones( p, &iFan0, 1, 1 );
274 Vec_PtrForEachEntry( Gia_Man_t *, vGias, pUsed, k )
275 if ( Gia_ManCiNum(pTemp) == Gia_ManCiNum(pUsed) && Cec_ManVerifyTwo(pTemp, pUsed, 0) == 1 )
276 {
277 ABC_SWAP( void *, Vec_PtrArray(vGias)[0], Vec_PtrArray(vGias)[k] );
278 break;
279 }
280 else
281 ABC_FREE( pTemp->pCexComb );
282
283 printf( "\nOut %6d : ", i );
284 if ( k == Vec_PtrSize(vGias) )
285 printf( "Equiv to none " );
286 else
287 printf( "Equiv to %6d ", k );
288 Gia_ManPrintStats( pTemp, NULL );
289
290 if ( k == Vec_PtrSize(vGias) )
291 Vec_PtrPush( vGias, pTemp );
292 else
293 Gia_ManStop( pTemp );
294 }
295 printf( "\nComputed %d classes.\n\n", Vec_PtrSize(vGias) );
296 Vec_PtrForEachEntry( Gia_Man_t *, vGias, pTemp, i )
297 Gia_ManStop( pTemp );
298 Vec_PtrFree( vGias );
299}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
int Cec_ManVerifyTwo(Gia_Man_t *p0, Gia_Man_t *p1, int fVerbose)
Definition cecCec.c:453
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition giaMan.c:495
Gia_Man_t * Gia_ManDupAndCones(Gia_Man_t *p, int *pAnds, int nAnds, int fTrimPis)
Definition giaDup.c:3941
Abc_Cex_t * pCexComb
Definition gia.h:149
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Slv_ManAlloc()

Slv_Man_t * Slv_ManAlloc ( int nObjs)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file gia.c.

84{
86 Vec_IntGrow( &p->vCis, 100 );
87 Vec_IntGrow( &p->vCos, 100 );
88 Vec_IntGrow( &p->vFanins, 2*nObjs );
89 Vec_IntGrow( &p->vFanoutN, 2*nObjs );
90 Vec_IntGrow( &p->vFanout0, nObjs );
91 Vec_StrGrow( &p->vValues, nObjs );
92 // constant node
93 Vec_IntFill( &p->vFanins, 2, 0 );
94 Vec_IntFill( &p->vFanoutN, 2, 0 );
95 Vec_IntFill( &p->vFanout0, 1, 0 );
96 return p;
97}
typedefABC_NAMESPACE_IMPL_START struct Slv_Man_t_ Slv_Man_t
DECLARATIONS ///.
Definition gia.c:31
Here is the caller graph for this function:

◆ Slv_ManFree()

void Slv_ManFree ( Slv_Man_t * p)

Definition at line 98 of file gia.c.

99{
100 Vec_IntErase( &p->vCis );
101 Vec_IntErase( &p->vCos );
102 Vec_IntErase( &p->vFanins );
103 Vec_IntErase( &p->vFanoutN );
104 Vec_IntErase( &p->vFanout0 );
105 Vec_StrErase( &p->vValues );
106 Vec_IntErase( &p->vCopies );
107 ABC_FREE( p );
108}
Here is the caller graph for this function:

◆ Slv_ManFromGia()

Slv_Man_t * Slv_ManFromGia ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file gia.c.

153{
154 Gia_Obj_t * pObj; int i;
155 Slv_Man_t * pNew = Slv_ManAlloc( Gia_ManObjNum(p) );
156 Gia_ManConst0(p)->Value = 0;
157 Gia_ManForEachObj1( p, pObj, i )
158 {
159 if ( Gia_ObjIsAnd(pObj) )
160 pObj->Value = Slv_ManAppendObj( pNew, Abc_LitNotCond(Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj)), Abc_LitNotCond(Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj)) );
161 else if ( Gia_ObjIsCo(pObj) )
162 pObj->Value = Slv_ManAppendObj( pNew, Abc_LitNotCond(Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj)), 0 );
163 else if ( Gia_ObjIsCi(pObj) )
164 pObj->Value = Slv_ManAppendObj( pNew, 0, 0 );
165 else
166 assert( 0 );
167 }
168 assert( Gia_ManObjNum(p) == Slv_ManObjNum(pNew) );
169 return pNew;
170}
Slv_Man_t * Slv_ManAlloc(int nObjs)
FUNCTION DEFINITIONS ///.
Definition gia.c:83
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Slv_ManPrintFanouts()

void Slv_ManPrintFanouts ( Slv_Man_t * p)

Definition at line 109 of file gia.c.

110{
111 int iObj, iFanLit;
112 Slv_ManForEachObj( p, iObj )
113 {
114 printf( "Fanouts of node %d: ", iObj );
115 Slv_ObjForEachFanout( p, iObj, iFanLit )
116 printf( "%d ", Abc_Lit2Var(iFanLit) );
117 printf( "\n" );
118 }
119}
#define Slv_ObjForEachFanout(p, iObj, iFanLit)
Definition gia.c:65
#define Slv_ManForEachObj(p, iObj)
Definition gia.c:62
Here is the caller graph for this function:

◆ Slv_ManToAig()

Gia_Man_t * Slv_ManToAig ( Gia_Man_t * pGia)

Definition at line 195 of file gia.c.

196{
197 Slv_Man_t * p = Slv_ManFromGia( pGia );
198 Gia_Man_t * pNew = Slv_ManToGia( p );
199 pNew->pName = Abc_UtilStrsav( pGia->pName );
200 pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
202 Slv_ManFree( p );
203 return pNew;
204}
void Slv_ManFree(Slv_Man_t *p)
Definition gia.c:98
Slv_Man_t * Slv_ManFromGia(Gia_Man_t *p)
Definition gia.c:152
Gia_Man_t * Slv_ManToGia(Slv_Man_t *p)
Definition gia.c:171
void Slv_ManPrintFanouts(Slv_Man_t *p)
Definition gia.c:109
Here is the call graph for this function:

◆ Slv_ManToGia()

Gia_Man_t * Slv_ManToGia ( Slv_Man_t * p)

Definition at line 171 of file gia.c.

172{
173 int iObj;
174 Gia_Man_t * pNew = Gia_ManStart( Slv_ManObjNum(p) );
175 Vec_IntFill( &p->vCopies, Slv_ManObjNum(p), 0 );
176 Slv_ManForEachObj( p, iObj )
177 if ( Slv_ObjIsCi(p, iObj) )
178 Slv_ObjSetCopyLit( p, iObj, Gia_ManAppendCi(pNew) );
179 else if ( Slv_ObjIsCo(p, iObj) )
180 {
181 int iLit0 = Abc_LitNotCond( Slv_ObjCopyLit(p, Slv_ObjFanin(p, iObj, 0)), Slv_ObjFaninC(p, iObj, 0) );
182 Slv_ObjSetCopyLit( p, iObj, Gia_ManAppendCo(pNew, iLit0) );
183 }
184 else if ( Slv_ObjIsAnd(p, iObj) )
185 {
186 int iLit0 = Abc_LitNotCond( Slv_ObjCopyLit(p, Slv_ObjFanin(p, iObj, 0)), Slv_ObjFaninC(p, iObj, 0) );
187 int iLit1 = Abc_LitNotCond( Slv_ObjCopyLit(p, Slv_ObjFanin(p, iObj, 1)), Slv_ObjFaninC(p, iObj, 1) );
188 Slv_ObjSetCopyLit( p, iObj, Gia_ManAppendAnd(pNew, iLit0, iLit1) );
189 }
190 else assert(0);
191 assert( Gia_ManObjNum(pNew) == Slv_ManObjNum(p) );
192 return pNew;
193}
Here is the call graph for this function:
Here is the caller graph for this function: