ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcRr.c File Reference
#include "base/abc/abc.h"
#include "proof/fraig/fraig.h"
#include "opt/sim/sim.h"
Include dependency graph for abcRr.c:

Go to the source code of this file.

Classes

struct  Abc_RRMan_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Abc_RRMan_t_ Abc_RRMan_t
 DECLARATIONS ///.
 

Functions

int Abc_NtkRR (Abc_Ntk_t *pNtk, int nFaninLevels, int nFanoutLevels, int fUseFanouts, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
Vec_Str_tAbc_NtkRRSimulate (Abc_Ntk_t *pNtk)
 

Typedef Documentation

◆ Abc_RRMan_t

typedef typedefABC_NAMESPACE_IMPL_START struct Abc_RRMan_t_ Abc_RRMan_t

DECLARATIONS ///.

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

FileName [abcRr.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Redundancy removal.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 32 of file abcRr.c.

Function Documentation

◆ Abc_NtkRR()

int Abc_NtkRR ( Abc_Ntk_t * pNtk,
int nFaninLevels,
int nFanoutLevels,
int fUseFanouts,
int fVerbose )

FUNCTION DEFINITIONS ///.

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

Synopsis [Removes stuck-at redundancies.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file abcRr.c.

99{
100 ProgressBar * pProgress;
101 Abc_RRMan_t * p;
102 Abc_Obj_t * pNode, * pFanin, * pFanout;
103 int i, k, m, nNodes, RetValue;
104 abctime clk, clkTotal = Abc_Clock();
105 // start the manager
106 p = Abc_RRManStart();
107 p->pNtk = pNtk;
108 p->nFaninLevels = nFaninLevels;
109 p->nFanoutLevels = nFanoutLevels;
110 p->nNodesOld = Abc_NtkNodeNum(pNtk);
111 p->nLevelsOld = Abc_AigLevel(pNtk);
112 // remember latch values
113// Abc_NtkForEachLatch( pNtk, pNode, i )
114// pNode->pNext = pNode->pData;
115 // go through the nodes
116 Abc_NtkCleanCopy(pNtk);
117 nNodes = Abc_NtkObjNumMax(pNtk);
118 Abc_NtkRRSimulateStart(pNtk);
119 pProgress = Extra_ProgressBarStart( stdout, nNodes );
120 Abc_NtkForEachNode( pNtk, pNode, i )
121 {
122 Extra_ProgressBarUpdate( pProgress, i, NULL );
123 // stop if all nodes have been tried once
124 if ( i >= nNodes )
125 break;
126 // skip the constant node
127// if ( Abc_NodeIsConst(pNode) )
128// continue;
129 // skip persistant nodes
130 if ( Abc_NodeIsPersistant(pNode) )
131 continue;
132 // skip the nodes with many fanouts
133 if ( Abc_ObjFanoutNum(pNode) > 1000 )
134 continue;
135 // construct the window
136 if ( !fUseFanouts )
137 {
138 Abc_ObjForEachFanin( pNode, pFanin, k )
139 {
140 // skip the nodes with only one fanout (tree nodes)
141 if ( Abc_ObjFanoutNum(pFanin) == 1 )
142 continue;
143/*
144 if ( pFanin->Id == 228 && pNode->Id == 2649 )
145 {
146 int k = 0;
147 }
148*/
149 p->nEdgesTried++;
150 Abc_RRManClean( p );
151 p->pNode = pNode;
152 p->pFanin = pFanin;
153 p->pFanout = NULL;
154
155 clk = Abc_Clock();
156 RetValue = Abc_NtkRRWindow( p );
157 p->timeWindow += Abc_Clock() - clk;
158 if ( !RetValue )
159 continue;
160/*
161 if ( pFanin->Id == 228 && pNode->Id == 2649 )
162 {
163 Abc_NtkShowAig( p->pWnd, 0 );
164 }
165*/
166 clk = Abc_Clock();
167 RetValue = Abc_NtkRRProve( p );
168 p->timeMiter += Abc_Clock() - clk;
169 if ( !RetValue )
170 continue;
171//printf( "%d -> %d (%d)\n", pFanin->Id, pNode->Id, k );
172
173 clk = Abc_Clock();
174 Abc_NtkRRUpdate( pNtk, p->pNode, p->pFanin, p->pFanout );
175 p->timeUpdate += Abc_Clock() - clk;
176
177 p->nEdgesRemoved++;
178 break;
179 }
180 continue;
181 }
182 // use the fanouts
183 Abc_ObjForEachFanin( pNode, pFanin, k )
184 Abc_ObjForEachFanout( pNode, pFanout, m )
185 {
186 // skip the nodes with only one fanout (tree nodes)
187// if ( Abc_ObjFanoutNum(pFanin) == 1 && Abc_ObjFanoutNum(pNode) == 1 )
188// continue;
189
190 p->nEdgesTried++;
191 Abc_RRManClean( p );
192 p->pNode = pNode;
193 p->pFanin = pFanin;
194 p->pFanout = pFanout;
195
196 clk = Abc_Clock();
197 RetValue = Abc_NtkRRWindow( p );
198 p->timeWindow += Abc_Clock() - clk;
199 if ( !RetValue )
200 continue;
201
202 clk = Abc_Clock();
203 RetValue = Abc_NtkRRProve( p );
204 p->timeMiter += Abc_Clock() - clk;
205 if ( !RetValue )
206 continue;
207
208 clk = Abc_Clock();
209 Abc_NtkRRUpdate( pNtk, p->pNode, p->pFanin, p->pFanout );
210 p->timeUpdate += Abc_Clock() - clk;
211
212 p->nEdgesRemoved++;
213 break;
214 }
215 }
216 Abc_NtkRRSimulateStop(pNtk);
217 Extra_ProgressBarStop( pProgress );
218 p->timeTotal = Abc_Clock() - clkTotal;
219 if ( fVerbose )
220 Abc_RRManPrintStats( p );
221 Abc_RRManStop( p );
222 // restore latch values
223// Abc_NtkForEachLatch( pNtk, pNode, i )
224// pNode->pData = pNode->pNext, pNode->pNext = NULL;
225 // put the nodes into the DFS order and reassign their IDs
226 Abc_NtkReassignIds( pNtk );
227 Abc_NtkLevel( pNtk );
228 // check
229 if ( !Abc_NtkCheck( pNtk ) )
230 {
231 printf( "Abc_NtkRR: The network check has failed.\n" );
232 return 0;
233 }
234 return 1;
235}
typedefABC_NAMESPACE_IMPL_START struct Abc_RRMan_t_ Abc_RRMan_t
DECLARATIONS ///.
Definition abcRr.c:32
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition abcAig.c:292
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1809
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
ABC_INT64_T abctime
Definition abc_global.h:332
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
Cube * p
Definition exorList.c:222
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Here is the call graph for this function:

◆ Abc_NtkRRSimulate()

Vec_Str_t * Abc_NtkRRSimulate ( Abc_Ntk_t * pNtk)

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

Synopsis [Simulation to detect non-redundant edges.]

Description []

SideEffects []

SeeAlso []

Definition at line 786 of file abcRr.c.

787{
788 Vec_Ptr_t * vNodes, * vField;
789 Vec_Str_t * vTargets;
790 Abc_Obj_t * pObj;
791 unsigned uData, uData0, uData1;
792 int PrevCi, Phase, i, k;
793
794 // start the candidates
795 vTargets = Vec_StrStart( Abc_NtkObjNumMax(pNtk) + 1 );
796 Abc_NtkForEachNode( pNtk, pObj, i )
797 {
798 Phase = ((Abc_ObjFanoutNum(Abc_ObjFanin1(pObj)) > 1) << 1);
799 Phase |= (Abc_ObjFanoutNum(Abc_ObjFanin0(pObj)) > 1);
800 Vec_StrWriteEntry( vTargets, pObj->Id, (char)Phase );
801 }
802
803 // simulate patters and store them in copy
804 Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)~((unsigned)0);
805 Abc_NtkForEachCi( pNtk, pObj, i )
806 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)SIM_RANDOM_UNSIGNED;
807 Abc_NtkForEachNode( pNtk, pObj, i )
808 {
809 if ( i == 0 ) continue;
810 uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData;
811 uData1 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pData;
812 uData = Abc_ObjFaninC0(pObj)? ~uData0 : uData0;
813 uData &= Abc_ObjFaninC1(pObj)? ~uData1 : uData1;
814 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)uData;
815 }
816 // store the result in data
817 Abc_NtkForEachCo( pNtk, pObj, i )
818 {
819 uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData;
820 if ( Abc_ObjFaninC0(pObj) )
821 pObj->pData = (void *)(ABC_PTRUINT_T)~uData0;
822 else
823 pObj->pData = (void *)(ABC_PTRUINT_T)uData0;
824 }
825
826 // refine the candidates
827 for ( PrevCi = 0; PrevCi < Abc_NtkCiNum(pNtk); PrevCi = i )
828 {
829 vNodes = Vec_PtrAlloc( 10 );
830 Abc_NtkIncrementTravId( pNtk );
831 for ( i = PrevCi; i < Abc_NtkCiNum(pNtk); i++ )
832 {
833 Sim_TraverseNodes_rec( Abc_NtkCi(pNtk, i), vTargets, vNodes );
834 if ( Vec_PtrSize(vNodes) > 128 )
835 break;
836 }
837 // collect the marked nodes in the topological order
838 vField = Vec_PtrAlloc( 10 );
839 Abc_NtkIncrementTravId( pNtk );
840 Abc_NtkForEachCo( pNtk, pObj, k )
841 Sim_CollectNodes_rec( pObj, vField );
842
843 // simulate these nodes
844 Sim_SimulateCollected( vTargets, vNodes, vField );
845 // prepare for the next loop
846 Vec_PtrFree( vNodes );
847 }
848
849 // clean
850 Abc_NtkForEachObj( pNtk, pObj, i )
851 pObj->pData = NULL;
852 return vTargets;
853}
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
#define SIM_RANDOM_UNSIGNED
Definition sim.h:158
void * pData
Definition abc.h:145
int Id
Definition abc.h:132
Abc_Obj_t * pCopy
Definition abc.h:148
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function: