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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Aig_Man_tAig_ManStart (int nNodesMax)
 DECLARATIONS ///.
 
Aig_Man_tAig_ManStartFrom (Aig_Man_t *p)
 
Aig_Obj_tAig_ManDup_rec (Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
 
Aig_Man_tAig_ManExtractMiter (Aig_Man_t *p, Aig_Obj_t *pNode1, Aig_Obj_t *pNode2)
 
void Aig_ManStop (Aig_Man_t *p)
 
void Aig_ManStopP (Aig_Man_t **p)
 
int Aig_ManCleanup (Aig_Man_t *p)
 
int Aig_ManAntiCleanup (Aig_Man_t *p)
 
int Aig_ManCiCleanup (Aig_Man_t *p)
 
int Aig_ManCoCleanup (Aig_Man_t *p)
 
void Aig_ManPrintStats (Aig_Man_t *p)
 
void Aig_ManReportImprovement (Aig_Man_t *p, Aig_Man_t *pNew)
 
void Aig_ManSetRegNum (Aig_Man_t *p, int nRegs)
 
void Aig_ManFlipFirstPo (Aig_Man_t *p)
 
void * Aig_ManReleaseData (Aig_Man_t *p)
 

Function Documentation

◆ Aig_ManAntiCleanup()

int Aig_ManAntiCleanup ( Aig_Man_t * p)

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

Synopsis [Adds POs for the nodes that otherwise would be dangling.]

Description [Returns the number of POs added.]

SideEffects []

SeeAlso []

Definition at line 293 of file aigMan.c.

294{
295 Aig_Obj_t * pNode;
296 int i, nNodesOld = Aig_ManCoNum(p);
297 Aig_ManForEachObj( p, pNode, i )
298 if ( Aig_ObjIsNode(pNode) && Aig_ObjRefs(pNode) == 0 )
299 Aig_ObjCreateCo( p, pNode );
300 return nNodesOld - Aig_ManCoNum(p);
301}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Cube * p
Definition exorList.c:222
Here is the call graph for this function:

◆ Aig_ManCiCleanup()

int Aig_ManCiCleanup ( Aig_Man_t * p)

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

Synopsis [Removes PIs without fanouts.]

Description [Returns the number of PIs removed.]

SideEffects []

SeeAlso []

Definition at line 314 of file aigMan.c.

315{
316 Aig_Obj_t * pObj;
317 int i, k = 0, nPisOld = Aig_ManCiNum(p);
318 Vec_PtrForEachEntry( Aig_Obj_t *, p->vCis, pObj, i )
319 {
320 if ( i >= Aig_ManCiNum(p) - Aig_ManRegNum(p) )
321 Vec_PtrWriteEntry( p->vCis, k++, pObj );
322 else if ( Aig_ObjRefs(pObj) > 0 )
323 Vec_PtrWriteEntry( p->vCis, k++, pObj );
324 else
325 Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
326 }
327 Vec_PtrShrink( p->vCis, k );
328 p->nObjs[AIG_OBJ_CI] = Vec_PtrSize( p->vCis );
329 if ( Aig_ManRegNum(p) )
330 p->nTruePis = Aig_ManCiNum(p) - Aig_ManRegNum(p);
331 return nPisOld - Aig_ManCiNum(p);
332}
@ AIG_OBJ_CI
Definition aig.h:60
int Id
Definition aig.h:85
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Aig_ManCleanup()

int Aig_ManCleanup ( Aig_Man_t * p)

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

Synopsis [Removes combinational logic that does not feed into POs.]

Description [Returns the number of dangling nodes removed.]

SideEffects []

SeeAlso []

Definition at line 265 of file aigMan.c.

266{
267 Vec_Ptr_t * vObjs;
268 Aig_Obj_t * pNode;
269 int i, nNodesOld = Aig_ManNodeNum(p);
270 // collect roots of dangling nodes
271 vObjs = Vec_PtrAlloc( 100 );
272 Aig_ManForEachObj( p, pNode, i )
273 if ( Aig_ObjIsNode(pNode) && Aig_ObjRefs(pNode) == 0 )
274 Vec_PtrPush( vObjs, pNode );
275 // recursively remove dangling nodes
276 Vec_PtrForEachEntry( Aig_Obj_t *, vObjs, pNode, i )
277 Aig_ObjDelete_rec( p, pNode, 1 );
278 Vec_PtrFree( vObjs );
279 return nNodesOld - Aig_ManNodeNum(p);
280}
void Aig_ObjDelete_rec(Aig_Man_t *p, Aig_Obj_t *pObj, int fFreeTop)
Definition aigObj.c:232
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:

◆ Aig_ManCoCleanup()

int Aig_ManCoCleanup ( Aig_Man_t * p)

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

Synopsis [Removes POs with constant input.]

Description [Returns the number of POs removed.]

SideEffects []

SeeAlso []

Definition at line 345 of file aigMan.c.

346{
347 Aig_Obj_t * pObj;
348 int i, k = 0, nPosOld = Aig_ManCoNum(p);
349 Vec_PtrForEachEntry( Aig_Obj_t *, p->vCos, pObj, i )
350 {
351 if ( i >= Aig_ManCoNum(p) - Aig_ManRegNum(p) )
352 Vec_PtrWriteEntry( p->vCos, k++, pObj );
353 else if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) || !Aig_ObjFaninC0(pObj) ) // non-const or const1
354 Vec_PtrWriteEntry( p->vCos, k++, pObj );
355 else
356 {
357 Aig_ObjDisconnect( p, pObj );
358 Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
359 }
360 }
361 Vec_PtrShrink( p->vCos, k );
362 p->nObjs[AIG_OBJ_CO] = Vec_PtrSize( p->vCos );
363 if ( Aig_ManRegNum(p) )
364 p->nTruePos = Aig_ManCoNum(p) - Aig_ManRegNum(p);
365 return nPosOld - Aig_ManCoNum(p);
366}
void Aig_ObjDisconnect(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigObj.c:171
@ AIG_OBJ_CO
Definition aig.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManDup_rec()

Aig_Obj_t * Aig_ManDup_rec ( Aig_Man_t * pNew,
Aig_Man_t * p,
Aig_Obj_t * pObj )

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

Synopsis [Duplicates the AIG manager recursively.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file aigMan.c.

124{
125 Aig_Obj_t * pObjNew;
126 if ( pObj->pData )
127 return (Aig_Obj_t *)pObj->pData;
128 Aig_ManDup_rec( pNew, p, Aig_ObjFanin0(pObj) );
129 if ( Aig_ObjIsBuf(pObj) )
130 return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
131 Aig_ManDup_rec( pNew, p, Aig_ObjFanin1(pObj) );
132 pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
133 return (Aig_Obj_t *)(pObj->pData = pObjNew);
134}
Aig_Obj_t * Aig_ManDup_rec(Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
Definition aigMan.c:123
Aig_Obj_t * Aig_Oper(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1, Aig_Type_t Type)
Definition aigOper.c:83
void * pData
Definition aig.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManExtractMiter()

Aig_Man_t * Aig_ManExtractMiter ( Aig_Man_t * p,
Aig_Obj_t * pNode1,
Aig_Obj_t * pNode2 )

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

Synopsis [Extracts the miter composed of XOR of the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file aigMan.c.

148{
149 Aig_Man_t * pNew;
150 Aig_Obj_t * pObj;
151 int i;
152 // create the new manager
153 pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
154 pNew->pName = Abc_UtilStrsav( p->pName );
155 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
156 // create the PIs
158 Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
159 Aig_ManForEachCi( p, pObj, i )
160 pObj->pData = Aig_ObjCreateCi(pNew);
161 // dump the nodes
162 Aig_ManDup_rec( pNew, p, pNode1 );
163 Aig_ManDup_rec( pNew, p, pNode2 );
164 // construct the EXOR
165 pObj = Aig_Exor( pNew, (Aig_Obj_t *)pNode1->pData, (Aig_Obj_t *)pNode2->pData );
166 pObj = Aig_NotCond( pObj, Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj) );
167 // add the PO
168 Aig_ObjCreateCo( pNew, pObj );
169 // check the resulting network
170 if ( !Aig_ManCheck(pNew) )
171 printf( "Aig_ManExtractMiter(): The check has failed.\n" );
172 return pNew;
173}
ABC_NAMESPACE_IMPL_START Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:220
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
void Aig_ManCleanData(Aig_Man_t *p)
Definition aigUtil.c:205
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition aigCheck.c:45
Here is the call graph for this function:

◆ Aig_ManFlipFirstPo()

void Aig_ManFlipFirstPo ( Aig_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 457 of file aigMan.c.

458{
459 Aig_ObjChild0Flip( Aig_ManCo(p, 0) );
460}
Here is the caller graph for this function:

◆ Aig_ManPrintStats()

void Aig_ManPrintStats ( Aig_Man_t * p)

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

Synopsis [Stops the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 379 of file aigMan.c.

380{
381 int nChoices = Aig_ManChoiceNum(p);
382 printf( "%-15s : ", p->pName );
383 printf( "pi = %5d ", Aig_ManCiNum(p)-Aig_ManRegNum(p) );
384 printf( "po = %5d ", Aig_ManCoNum(p)-Aig_ManRegNum(p) );
385 if ( Aig_ManRegNum(p) )
386 printf( "lat = %5d ", Aig_ManRegNum(p) );
387 printf( "and = %7d ", Aig_ManAndNum(p) );
388// printf( "Eq = %7d ", Aig_ManHaigCounter(p) );
389 if ( Aig_ManExorNum(p) )
390 printf( "xor = %5d ", Aig_ManExorNum(p) );
391 if ( nChoices )
392 printf( "ch = %5d ", nChoices );
393 if ( Aig_ManBufNum(p) )
394 printf( "buf = %5d ", Aig_ManBufNum(p) );
395// printf( "Cre = %6d ", p->nCreated );
396// printf( "Del = %6d ", p->nDeleted );
397// printf( "Lev = %3d ", Aig_ManLevelNum(p) );
398// printf( "Max = %7d ", Aig_ManObjNumMax(p) );
399 printf( "lev = %3d", Aig_ManLevels(p) );
400 printf( "\n" );
401 fflush( stdout );
402}
int Aig_ManChoiceNum(Aig_Man_t *p)
Definition aigUtil.c:1020
int Aig_ManLevels(Aig_Man_t *p)
Definition aigUtil.c:102
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManReleaseData()

void * Aig_ManReleaseData ( Aig_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file aigMan.c.

474{
475 void * pD = p->pData;
476 p->pData = NULL;
477 return pD;
478}

◆ Aig_ManReportImprovement()

void Aig_ManReportImprovement ( Aig_Man_t * p,
Aig_Man_t * pNew )

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

Synopsis [Reports the reduction of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file aigMan.c.

416{
417 printf( "REG: Beg = %5d. End = %5d. (R =%5.1f %%) ",
418 Aig_ManRegNum(p), Aig_ManRegNum(pNew),
419 Aig_ManRegNum(p)? 100.0*(Aig_ManRegNum(p)-Aig_ManRegNum(pNew))/Aig_ManRegNum(p) : 0.0 );
420 printf( "AND: Beg = %6d. End = %6d. (R =%5.1f %%)",
421 Aig_ManNodeNum(p), Aig_ManNodeNum(pNew),
422 Aig_ManNodeNum(p)? 100.0*(Aig_ManNodeNum(p)-Aig_ManNodeNum(pNew))/Aig_ManNodeNum(p) : 0.0 );
423 printf( "\n" );
424}
Here is the caller graph for this function:

◆ Aig_ManSetRegNum()

void Aig_ManSetRegNum ( Aig_Man_t * p,
int nRegs )

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

Synopsis [Sets the number of registers in the AIG manager.]

Description [This procedure should be called after the manager is fully constructed.]

SideEffects []

SeeAlso []

Definition at line 438 of file aigMan.c.

439{
440 p->nRegs = nRegs;
441 p->nTruePis = Aig_ManCiNum(p) - nRegs;
442 p->nTruePos = Aig_ManCoNum(p) - nRegs;
444}
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
Here is the call graph for this function:

◆ Aig_ManStart()

ABC_NAMESPACE_IMPL_START Aig_Man_t * Aig_ManStart ( int nNodesMax)

DECLARATIONS ///.

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

FileName [aigMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [AIG manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
aigMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

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

Synopsis [Starts the AIG manager.]

Description [The argument of this procedure is a soft limit on the the number of nodes, or 0 if the limit is unknown.]

SideEffects []

SeeAlso []

Definition at line 47 of file aigMan.c.

48{
49 Aig_Man_t * p;
50 if ( nNodesMax <= 0 )
51 nNodesMax = 10007;
52 // start the manager
53 p = ABC_ALLOC( Aig_Man_t, 1 );
54 memset( p, 0, sizeof(Aig_Man_t) );
55 // perform initializations
56 p->nTravIds = 1;
57 p->fCatchExor = 0;
58 // allocate arrays for nodes
59 p->vCis = Vec_PtrAlloc( 100 );
60 p->vCos = Vec_PtrAlloc( 100 );
61 p->vObjs = Vec_PtrAlloc( 1000 );
62 p->vBufs = Vec_PtrAlloc( 100 );
63 //--jlong -- begin
64 p->unfold2_type_I = Vec_PtrAlloc( 4);
65 p->unfold2_type_II = Vec_PtrAlloc( 4);
66 //--jlong -- end
67 // prepare the internal memory manager
68 p->pMemObjs = Aig_MmFixedStart( sizeof(Aig_Obj_t), nNodesMax );
69 // create the constant node
70 p->pConst1 = Aig_ManFetchMemory( p );
71 p->pConst1->Type = AIG_OBJ_CONST1;
72 p->pConst1->fPhase = 1;
73 p->nObjs[AIG_OBJ_CONST1]++;
74 // start the table
75 p->nTableSize = Abc_PrimeCudd( nNodesMax );
76 p->pTable = ABC_ALLOC( Aig_Obj_t *, p->nTableSize );
77 memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
78 return p;
79}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition aigMem.c:96
@ AIG_OBJ_CONST1
Definition aig.h:59
char * memset()
Here is the call graph for this function:

◆ Aig_ManStartFrom()

Aig_Man_t * Aig_ManStartFrom ( Aig_Man_t * p)

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

Synopsis [Duplicates the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file aigMan.c.

93{
94 Aig_Man_t * pNew;
95 Aig_Obj_t * pObj, * pObjNew;
96 int i;
97 // create the new manager
98 pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
99 pNew->pName = Abc_UtilStrsav( p->pName );
100 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
101 // create the PIs
102 Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
103 Aig_ManForEachCi( p, pObj, i )
104 {
105 pObjNew = Aig_ObjCreateCi( pNew );
106 pObjNew->Level = pObj->Level;
107 pObj->pData = pObjNew;
108 }
109 return pNew;
110}
unsigned Level
Definition aig.h:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManStop()

void Aig_ManStop ( Aig_Man_t * p)

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

Synopsis [Stops the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file aigMan.c.

188{
189 Aig_Obj_t * pObj;
190 int i;
191 if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
192 if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
193 // make sure the nodes have clean marks
194 Aig_ManForEachObj( p, pObj, i )
195 assert( !pObj->fMarkA && !pObj->fMarkB );
196 Tim_ManStopP( (Tim_Man_t **)&p->pManTime );
197 if ( p->pFanData )
199 if ( p->pManExdc )
200 Aig_ManStop( p->pManExdc );
201// Aig_TableProfile( p );
202 Aig_MmFixedStop( p->pMemObjs, 0 );
203 Vec_PtrFreeP( &p->vCis );
204 Vec_PtrFreeP( &p->vCos );
205 Vec_PtrFreeP( &p->vObjs );
206 Vec_PtrFreeP( &p->vBufs );
207 //--jlong -- begin
208 Vec_PtrFreeP( &p->unfold2_type_I );
209 Vec_PtrFreeP( &p->unfold2_type_II );
210 //--jlong -- end
211 Vec_IntFreeP( &p->vLevelR );
212 Vec_VecFreeP( &p->vLevels );
213 Vec_IntFreeP( &p->vFlopNums );
214 Vec_IntFreeP( &p->vFlopReprs );
215 Vec_VecFreeP( (Vec_Vec_t **)&p->vOnehots );
216 Vec_VecFreeP( &p->vClockDoms );
217 Vec_IntFreeP( &p->vProbs );
218 Vec_IntFreeP( &p->vCiNumsOrig );
219 Vec_PtrFreeP( &p->vMapped );
220 if ( p->vSeqModelVec )
221 Vec_PtrFreeFree( p->vSeqModelVec );
222 ABC_FREE( p->pTerSimData );
223 ABC_FREE( p->pFastSim );
224 ABC_FREE( p->pData );
225 ABC_FREE( p->pSeqModel );
226 ABC_FREE( p->pName );
227 ABC_FREE( p->pSpec );
228 ABC_FREE( p->pObjCopies );
229 ABC_FREE( p->pReprs );
230 ABC_FREE( p->pEquivs );
231 ABC_FREE( p->pTable );
232 ABC_FREE( p );
233}
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_FREE(obj)
Definition abc_global.h:267
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition aigFanout.c:89
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition aigMem.c:132
unsigned int fMarkB
Definition aig.h:80
unsigned int fMarkA
Definition aig.h:79
void Tim_ManStopP(Tim_Man_t **p)
Definition timMan.c:387
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:

◆ Aig_ManStopP()

void Aig_ManStopP ( Aig_Man_t ** p)

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

Synopsis [Stops the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 246 of file aigMan.c.

247{
248 if ( *p == NULL )
249 return;
250 Aig_ManStop( *p );
251 *p = NULL;
252}
Here is the call graph for this function:
Here is the caller graph for this function: