ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ivyRwr.c File Reference
#include "ivy.h"
#include "bool/deco/deco.h"
#include "opt/rwt/rwt.h"
Include dependency graph for ivyRwr.c:

Go to the source code of this file.

Functions

int Ivy_ManRewritePre (Ivy_Man_t *p, int fUpdateLevel, int fUseZeroCost, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
unsigned Ivy_NodeGetTruth_rec (Ivy_Obj_t *pObj, int *pNums, int nNums)
 
Ivy_Obj_tIvy_GraphToNetwork (Ivy_Man_t *p, Dec_Graph_t *pGraph)
 
void Ivy_GraphUpdateNetwork3 (Ivy_Man_t *p, Ivy_Obj_t *pRoot, Dec_Graph_t *pGraph, int fUpdateLevel, int nGain)
 

Function Documentation

◆ Ivy_GraphToNetwork()

Ivy_Obj_t * Ivy_GraphToNetwork ( Ivy_Man_t * p,
Dec_Graph_t * pGraph )

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description [AIG nodes for the fanins should be assigned to pNode->pFunc of the leaves of the graph before calling this procedure.]

SideEffects []

SeeAlso []

Definition at line 485 of file ivyRwr.c.

486{
487 Ivy_Obj_t * pAnd0, * pAnd1;
488 Dec_Node_t * pNode = NULL; // Suppress "might be used uninitialized"
489 int i;
490 // check for constant function
491 if ( Dec_GraphIsConst(pGraph) )
492 return Ivy_NotCond( Ivy_ManConst1(p), Dec_GraphIsComplement(pGraph) );
493 // check for a literal
494 if ( Dec_GraphIsVar(pGraph) )
495 return Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
496 // build the AIG nodes corresponding to the AND gates of the graph
497 Dec_GraphForEachNode( pGraph, pNode, i )
498 {
499 pAnd0 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
500 pAnd1 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
501 pNode->pFunc = Ivy_And( p, pAnd0, pAnd1 );
502 }
503 // complement the result if necessary
504 return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
505}
struct Dec_Node_t_ Dec_Node_t
Definition dec.h:49
#define Dec_GraphForEachNode(pGraph, pAnd, i)
Definition dec.h:101
Cube * p
Definition exorList.c:222
struct Ivy_Obj_t_ Ivy_Obj_t
Definition ivy.h:47
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
Definition ivyOper.c:84
Dec_Edge_t eEdge1
Definition dec.h:53
void * pFunc
Definition dec.h:56
Dec_Edge_t eEdge0
Definition dec.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ivy_GraphUpdateNetwork3()

void Ivy_GraphUpdateNetwork3 ( Ivy_Man_t * p,
Ivy_Obj_t * pRoot,
Dec_Graph_t * pGraph,
int fUpdateLevel,
int nGain )

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

Synopsis [Replaces MFFC of the node by the new factored form.]

Description []

SideEffects []

SeeAlso []

Definition at line 559 of file ivyRwr.c.

560{
561 Ivy_Obj_t * pRootNew, * pFanin;
562 int nNodesNew, nNodesOld, i, nRefsOld;
563 nNodesOld = Ivy_ManNodeNum(p);
564
565//printf( "Before = %d. ", Ivy_ManNodeNum(p) );
566 // mark the cut
567 Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
568 Ivy_ObjRefsInc( Ivy_Regular(pFanin) );
569 // deref the old cone
570 nRefsOld = pRoot->nRefs;
571 pRoot->nRefs = 0;
572 Ivy_ObjDelete_rec( p, pRoot, 0 );
573 pRoot->nRefs = nRefsOld;
574 // unmark the cut
575 Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
576 Ivy_ObjRefsDec( Ivy_Regular(pFanin) );
577//printf( "Deref = %d. ", Ivy_ManNodeNum(p) );
578
579 // create the new structure of nodes
580 pRootNew = Ivy_GraphToNetwork( p, pGraph );
581//printf( "Create = %d. ", Ivy_ManNodeNum(p) );
582 // remove the old nodes
583// Ivy_AigReplace( pMan->pManFunc, pRoot, pRootNew, fUpdateLevel );
584/*
585 if ( Ivy_IsComplement(pRootNew) )
586 printf( "c" );
587 else
588 printf( "d" );
589 if ( Ivy_ObjRefs(Ivy_Regular(pRootNew)) > 0 )
590 printf( "%d", Ivy_ObjRefs(Ivy_Regular(pRootNew)) );
591 printf( " " );
592*/
593 Ivy_ObjReplace( p, pRoot, pRootNew, 0, 0, 1 );
594//printf( "Replace = %d. ", Ivy_ManNodeNum(p) );
595
596 // delete remaining dangling nodes
597 Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
598 {
599 pFanin = Ivy_Regular(pFanin);
600 if ( !Ivy_ObjIsNone(pFanin) && Ivy_ObjRefs(pFanin) == 0 )
601 Ivy_ObjDelete_rec( p, pFanin, 1 );
602 }
603//printf( "Deref = %d. ", Ivy_ManNodeNum(p) );
604//printf( "\n" );
605
606 // compare the gains
607 nNodesNew = Ivy_ManNodeNum(p);
608 assert( nGain <= nNodesOld - nNodesNew );
609}
Ivy_Obj_t * Ivy_GraphToNetwork(Ivy_Man_t *p, Dec_Graph_t *pGraph)
Definition ivyRwr.c:485
void Ivy_ObjReplace(Ivy_Man_t *p, Ivy_Obj_t *pObjOld, Ivy_Obj_t *pObjNew, int fDeleteOld, int fFreeTop, int fUpdateLevel)
Definition ivyObj.c:328
void Ivy_ObjDelete_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
Definition ivyObj.c:299
struct Rwt_Man_t_ Rwt_Man_t
Definition rwt.h:55
int nRefs
Definition ivy.h:85
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Ivy_ManRewritePre()

int Ivy_ManRewritePre ( Ivy_Man_t * p,
int fUpdateLevel,
int fUseZeroCost,
int fVerbose )

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs incremental rewriting of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file ivyRwr.c.

56{
57 Rwt_Man_t * pManRwt;
58 Ivy_Obj_t * pNode;
59 int i, nNodes, nGain;
60 abctime clk, clkStart = Abc_Clock();
61 // start the rewriting manager
62 pManRwt = Rwt_ManStart( 0 );
63 p->pData = pManRwt;
64 if ( pManRwt == NULL )
65 return 0;
66 // create fanouts
67 if ( fUpdateLevel && p->fFanout == 0 )
69 // compute the reverse levels if level update is requested
70 if ( fUpdateLevel )
72 // set the number of levels
73// p->nLevelMax = Ivy_ManLevels( p );
74 // resynthesize each node once
75 nNodes = Ivy_ManObjIdMax(p);
76 Ivy_ManForEachNode( p, pNode, i )
77 {
78 // fix the fanin buffer problem
79 Ivy_NodeFixBufferFanins( p, pNode, 1 );
80 if ( Ivy_ObjIsBuf(pNode) )
81 continue;
82 // stop if all nodes have been tried once
83 if ( i > nNodes )
84 break;
85 // for each cut, try to resynthesize it
86 nGain = Ivy_NodeRewrite( p, pManRwt, pNode, fUpdateLevel, fUseZeroCost );
87 if ( nGain > 0 || (nGain == 0 && fUseZeroCost) )
88 {
89 Dec_Graph_t * pGraph = (Dec_Graph_t *)Rwt_ManReadDecs(pManRwt);
90 int fCompl = Rwt_ManReadCompl(pManRwt);
91/*
92 {
93 Ivy_Obj_t * pObj;
94 int i;
95 printf( "USING: (" );
96 Vec_PtrForEachEntry( Ivy_Obj_t *, Rwt_ManReadLeaves(pManRwt), pObj, i )
97 printf( "%d ", Ivy_ObjFanoutNum(Ivy_Regular(pObj)) );
98 printf( ") Gain = %d.\n", nGain );
99 }
100 if ( nGain > 0 )
101 { // print stats on the MFFC
102 extern void Ivy_NodeMffcConeSuppPrint( Ivy_Obj_t * pNode );
103 printf( "Node %6d : Gain = %4d ", pNode->Id, nGain );
104 Ivy_NodeMffcConeSuppPrint( pNode );
105 }
106*/
107 // complement the FF if needed
108clk = Abc_Clock();
109 if ( fCompl ) Dec_GraphComplement( pGraph );
110 Ivy_GraphUpdateNetwork( p, pNode, pGraph, fUpdateLevel, nGain );
111 if ( fCompl ) Dec_GraphComplement( pGraph );
112Rwt_ManAddTimeUpdate( pManRwt, Abc_Clock() - clk );
113 }
114 }
115Rwt_ManAddTimeTotal( pManRwt, Abc_Clock() - clkStart );
116 // print stats
117 if ( fVerbose )
118 Rwt_ManPrintStats( pManRwt );
119 // delete the managers
120 Rwt_ManStop( pManRwt );
121 p->pData = NULL;
122 // fix the levels
123 if ( fUpdateLevel )
124 Vec_IntFree( p->vRequired ), p->vRequired = NULL;
125 else
127 // check
128 if ( (i = Ivy_ManCleanup(p)) )
129 printf( "Cleanup after rewriting removed %d dangling nodes.\n", i );
130 if ( !Ivy_ManCheck(p) )
131 printf( "Ivy_ManRewritePre(): The check has failed.\n" );
132 return 1;
133}
ABC_INT64_T abctime
Definition abc_global.h:332
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
int Ivy_ManCheck(Ivy_Man_t *p)
DECLARATIONS ///.
Definition ivyCheck.c:45
Vec_Int_t * Ivy_ManRequiredLevels(Ivy_Man_t *p)
Definition ivyDfs.c:250
void Ivy_ManResetLevels(Ivy_Man_t *p)
Definition ivyUtil.c:292
int Ivy_ManCleanup(Ivy_Man_t *p)
Definition ivyMan.c:265
#define Ivy_ManForEachNode(p, pObj, i)
Definition ivy.h:402
void Ivy_NodeFixBufferFanins(Ivy_Man_t *p, Ivy_Obj_t *pNode, int fUpdateLevel)
Definition ivyObj.c:442
void Ivy_ManStartFanout(Ivy_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition ivyFanout.c:136
void Rwt_ManPrintStats(Rwt_Man_t *p)
Definition rwtMan.c:183
int Rwt_ManReadCompl(Rwt_Man_t *p)
Definition rwtMan.c:285
void Rwt_ManAddTimeUpdate(Rwt_Man_t *p, abctime Time)
Definition rwtMan.c:317
void * Rwt_ManReadDecs(Rwt_Man_t *p)
Definition rwtMan.c:253
void Rwt_ManAddTimeTotal(Rwt_Man_t *p, abctime Time)
Definition rwtMan.c:333
void Rwt_ManStop(Rwt_Man_t *p)
Definition rwtMan.c:149
Rwt_Man_t * Rwt_ManStart(int fPrecompute)
Definition rwtMan.c:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ivy_NodeGetTruth_rec()

unsigned Ivy_NodeGetTruth_rec ( Ivy_Obj_t * pObj,
int * pNums,
int nNums )

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

Synopsis [Computes the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 312 of file ivyRwr.c.

313{
314 static unsigned uMasks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
315 unsigned uTruth0, uTruth1;
316 int i;
317 for ( i = 0; i < nNums; i++ )
318 if ( pObj->Id == pNums[i] )
319 return uMasks[i];
320 assert( Ivy_ObjIsNode(pObj) || Ivy_ObjIsBuf(pObj) );
321 uTruth0 = Ivy_NodeGetTruth_rec( Ivy_ObjFanin0(pObj), pNums, nNums );
322 if ( Ivy_ObjFaninC0(pObj) )
323 uTruth0 = ~uTruth0;
324 if ( Ivy_ObjIsBuf(pObj) )
325 return uTruth0;
326 uTruth1 = Ivy_NodeGetTruth_rec( Ivy_ObjFanin1(pObj), pNums, nNums );
327 if ( Ivy_ObjFaninC1(pObj) )
328 uTruth1 = ~uTruth1;
329 return uTruth0 & uTruth1;
330}
unsigned Ivy_NodeGetTruth_rec(Ivy_Obj_t *pObj, int *pNums, int nNums)
Definition ivyRwr.c:312
int Id
Definition ivy.h:75
Here is the call graph for this function:
Here is the caller graph for this function: