ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcCut.c File Reference
#include "base/abc/abc.h"
#include "cut.h"
Include dependency graph for abcCut.c:

Go to the source code of this file.

Functions

Vec_Int_tAbc_NtkGetNodeAttributes (Abc_Ntk_t *pNtk)
 
Cut_Man_tAbc_NtkCuts (Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
 FUNCTION DEFINITIONS ///.
 
void Abc_NtkCutsOracle (Abc_Ntk_t *pNtk, Cut_Oracle_t *p)
 
Cut_Man_tAbc_NtkSeqCuts (Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
 
void * Abc_NodeGetCutsRecursive (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
 
void * Abc_NodeGetCuts (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
 
void Abc_NodeGetCutsSeq (void *p, Abc_Obj_t *pObj, int fTriv)
 
void * Abc_NodeReadCuts (void *p, Abc_Obj_t *pObj)
 
void Abc_NodeFreeCuts (void *p, Abc_Obj_t *pObj)
 

Variables

int nTotal
 DECLARATIONS ///.
 
int nGood
 
int nEqual
 

Function Documentation

◆ Abc_NodeFreeCuts()

void Abc_NodeFreeCuts ( void * p,
Abc_Obj_t * pObj )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 439 of file abcCut.c.

440{
441 Cut_NodeFreeCuts( p, pObj->Id );
442}
void Cut_NodeFreeCuts(Cut_Man_t *p, int Node)
Definition cutApi.c:184
Cube * p
Definition exorList.c:222
int Id
Definition abc.h:132
Here is the call graph for this function:

◆ Abc_NodeGetCuts()

void * Abc_NodeGetCuts ( void * p,
Abc_Obj_t * pObj,
int fDag,
int fTree )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 345 of file abcCut.c.

346{
347 Abc_Obj_t * pFanin;
348 int fDagNode, fTriv, TreeCode = 0;
349// assert( Abc_NtkIsStrash(pObj->pNtk) );
350 assert( Abc_ObjFaninNum(pObj) == 2 );
351
352
353 // check if the node is a DAG node
354 fDagNode = (Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj));
355 // increment the counter of DAG nodes
356 if ( fDagNode ) Cut_ManIncrementDagNodes( p );
357 // add the trivial cut if the node is a DAG node, or if we compute all cuts
358 fTriv = fDagNode || !fDag;
359 // check if fanins are DAG nodes
360 if ( fTree )
361 {
362 pFanin = Abc_ObjFanin0(pObj);
363 TreeCode |= (Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin));
364 pFanin = Abc_ObjFanin1(pObj);
365 TreeCode |= ((Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin)) << 1);
366 }
367
368
369 // changes due to the global/local cut computation
370 {
371 Cut_Params_t * pParams = Cut_ManReadParams(p);
372 if ( pParams->fLocal )
373 {
374 Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs(p);
375 fDagNode = Vec_IntEntry( vNodeAttrs, pObj->Id );
376 if ( fDagNode ) Cut_ManIncrementDagNodes( p );
377// fTriv = fDagNode || !pParams->fGlobal;
378 fTriv = !Vec_IntEntry( vNodeAttrs, pObj->Id );
379 TreeCode = 0;
380 pFanin = Abc_ObjFanin0(pObj);
381 TreeCode |= Vec_IntEntry( vNodeAttrs, pFanin->Id );
382 pFanin = Abc_ObjFanin1(pObj);
383 TreeCode |= (Vec_IntEntry( vNodeAttrs, pFanin->Id ) << 1);
384 }
385 }
386 return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
387 Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv, TreeCode );
388}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
Definition abcUtil.c:1398
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Cut_ManIncrementDagNodes(Cut_Man_t *p)
Definition cutMan.c:309
Cut_Cut_t * Cut_NodeComputeCuts(Cut_Man_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fTriv, int TreeCode)
Definition cutNode.c:369
struct Cut_ParamsStruct_t_ Cut_Params_t
Definition cut.h:51
Vec_Int_t * Cut_ManReadNodeAttrs(Cut_Man_t *p)
Definition cutMan.c:293
Cut_Params_t * Cut_ManReadParams(Cut_Man_t *p)
Definition cutMan.c:277
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Abc_NodeGetCutsRecursive()

void * Abc_NodeGetCutsRecursive ( void * p,
Abc_Obj_t * pObj,
int fDag,
int fTree )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file abcCut.c.

325{
326 void * pList;
327 if ( pList = Abc_NodeReadCuts( p, pObj ) )
328 return pList;
329 Abc_NodeGetCutsRecursive( p, Abc_ObjFanin0(pObj), fDag, fTree );
330 Abc_NodeGetCutsRecursive( p, Abc_ObjFanin1(pObj), fDag, fTree );
331 return Abc_NodeGetCuts( p, pObj, fDag, fTree );
332}
void * Abc_NodeGetCutsRecursive(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
Definition abcCut.c:412
void * Abc_NodeReadCuts(void *p, Abc_Obj_t *pObj)
Definition abcCut.c:511
void * Abc_NodeGetCuts(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
Definition abcCut.c:433
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeGetCutsSeq()

void Abc_NodeGetCutsSeq ( void * p,
Abc_Obj_t * pObj,
int fTriv )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file abcCut.c.

402{
403 int CutSetNum;
404 assert( Abc_NtkIsSeq(pObj->pNtk) );
405 assert( Abc_ObjFaninNum(pObj) == 2 );
406 fTriv = pObj->fMarkC ? 0 : fTriv;
407 CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
408 Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
409 Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Seq_ObjFaninL0(pObj), Seq_ObjFaninL1(pObj), fTriv, CutSetNum );
410}
void Cut_NodeComputeCutsSeq(Cut_Man_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum)
Definition cutSeq.c:72
unsigned fMarkC
Definition abc.h:136
Abc_Ntk_t * pNtk
Definition abc.h:130
Abc_Obj_t * pCopy
Definition abc.h:148
Here is the call graph for this function:

◆ Abc_NodeReadCuts()

void * Abc_NodeReadCuts ( void * p,
Abc_Obj_t * pObj )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 423 of file abcCut.c.

424{
425 return Cut_NodeReadCutsNew( p, pObj->Id );
426}
Cut_Cut_t * Cut_NodeReadCutsNew(Cut_Man_t *p, int Node)
MACRO DEFINITIONS ///.
Definition cutApi.c:45
Here is the call graph for this function:

◆ Abc_NtkCuts()

Cut_Man_t * Abc_NtkCuts ( Abc_Ntk_t * pNtk,
Cut_Params_t * pParams )

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file abcCut.c.

73{
74 ProgressBar * pProgress;
75 Cut_Man_t * p;
76 Abc_Obj_t * pObj, * pNode;
77 Vec_Ptr_t * vNodes;
78 Vec_Int_t * vChoices;
79 int i;
80 clock_t clk = clock();
81
82 extern void Abc_NtkBalanceAttach( Abc_Ntk_t * pNtk );
83 extern void Abc_NtkBalanceDetach( Abc_Ntk_t * pNtk );
84
85 nTotal = nGood = nEqual = 0;
86
87 assert( Abc_NtkIsStrash(pNtk) );
88 // start the manager
89 pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
90 p = Cut_ManStart( pParams );
91 // compute node attributes if local or global cuts are requested
92 if ( pParams->fGlobal || pParams->fLocal )
93 {
94 extern Vec_Int_t * Abc_NtkGetNodeAttributes( Abc_Ntk_t * pNtk );
95 Cut_ManSetNodeAttrs( p, Abc_NtkGetNodeAttributes(pNtk) );
96 }
97 // prepare for cut dropping
98 if ( pParams->fDrop )
100 // set cuts for PIs
101 Abc_NtkForEachCi( pNtk, pObj, i )
102 if ( Abc_ObjFanoutNum(pObj) > 0 )
103 Cut_NodeSetTriv( p, pObj->Id );
104 // compute cuts for internal nodes
105 vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
106 vChoices = Vec_IntAlloc( 100 );
107 pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
108 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
109 {
110 // when we reached a CO, it is time to deallocate the cuts
111 if ( Abc_ObjIsCo(pObj) )
112 {
113 if ( pParams->fDrop )
114 Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
115 continue;
116 }
117 // skip constant node, it has no cuts
118// if ( Abc_NodeIsConst(pObj) )
119// continue;
120 Extra_ProgressBarUpdate( pProgress, i, NULL );
121 // compute the cuts to the internal node
122 Abc_NodeGetCuts( p, pObj, pParams->fDag, pParams->fTree );
123 // consider dropping the fanins cuts
124 if ( pParams->fDrop )
125 {
126 Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
127 Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId1(pObj) );
128 }
129 // add cuts due to choices
130 if ( Abc_AigNodeIsChoice(pObj) )
131 {
132 Vec_IntClear( vChoices );
133 for ( pNode = pObj; pNode; pNode = pNode->pData )
134 Vec_IntPush( vChoices, pNode->Id );
135 Cut_NodeUnionCuts( p, vChoices );
136 }
137 }
138 Extra_ProgressBarStop( pProgress );
139 Vec_PtrFree( vNodes );
140 Vec_IntFree( vChoices );
141PRT( "Total", clock() - clk );
142//Abc_NtkPrintCuts( p, pNtk, 0 );
143// Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk );
144
145 // temporary printout of stats
146 if ( nTotal )
147 printf( "Total cuts = %d. Good cuts = %d. Ratio = %5.2f\n", nTotal, nGood, ((double)nGood)/nTotal );
148 return p;
149}
void Abc_NtkBalanceAttach(Abc_Ntk_t *pNtk)
Definition abcBalance.c:506
void Abc_NtkBalanceDetach(Abc_Ntk_t *pNtk)
Definition abcBalance.c:531
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition abcDfs.c:1198
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Vec_Int_t * Abc_NtkFanoutCounts(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1741
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
int nGood
Definition abcCut.c:34
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
int nEqual
Definition abcCut.c:34
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
#define PRT(FMT,...)
void Cut_NodeTryDroppingCuts(Cut_Man_t *p, int Node)
Definition cutApi.c:162
void Cut_NodeSetTriv(Cut_Man_t *p, int Node)
Definition cutApi.c:145
Cut_Cut_t * Cut_NodeUnionCuts(Cut_Man_t *p, Vec_Int_t *vNodes)
Definition cutNode.c:678
void Cut_ManSetNodeAttrs(Cut_Man_t *p, Vec_Int_t *vFanCounts)
Definition cutMan.c:245
Cut_Man_t * Cut_ManStart(Cut_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition cutMan.c:47
struct Cut_ManStruct_t_ Cut_Man_t
BASIC TYPES ///.
Definition cut.h:48
void Cut_ManSetFanoutCounts(Cut_Man_t *p, Vec_Int_t *vFanCounts)
Definition cutMan.c:229
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void * pData
Definition abc.h:145
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:

◆ Abc_NtkCutsOracle()

void Abc_NtkCutsOracle ( Abc_Ntk_t * pNtk,
Cut_Oracle_t * p )

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

Synopsis [Cut computation using the oracle.]

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file abcCut.c.

163{
164 Abc_Obj_t * pObj;
165 Vec_Ptr_t * vNodes;
166 int i;
167 clock_t clk = clock();
168 int fDrop = Cut_OracleReadDrop(p);
169
170 assert( Abc_NtkIsStrash(pNtk) );
171
172 // prepare cut droppping
173 if ( fDrop )
175
176 // set cuts for PIs
177 Abc_NtkForEachCi( pNtk, pObj, i )
178 if ( Abc_ObjFanoutNum(pObj) > 0 )
179 Cut_OracleNodeSetTriv( p, pObj->Id );
180
181 // compute cuts for internal nodes
182 vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
183 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
184 {
185 // when we reached a CO, it is time to deallocate the cuts
186 if ( Abc_ObjIsCo(pObj) )
187 {
188 if ( fDrop )
189 Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
190 continue;
191 }
192 // skip constant node, it has no cuts
193// if ( Abc_NodeIsConst(pObj) )
194// continue;
195 // compute the cuts to the internal node
196 Cut_OracleComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
197 Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
198 // consider dropping the fanins cuts
199 if ( fDrop )
200 {
201 Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
202 Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId1(pObj) );
203 }
204 }
205 Vec_PtrFree( vNodes );
206//PRT( "Total", clock() - clk );
207//Abc_NtkPrintCuts_( p, pNtk, 0 );
208}
void Cut_OracleTryDroppingCuts(Cut_Oracle_t *p, int Node)
Definition cutOracle.c:407
Cut_Cut_t * Cut_OracleComputeCuts(Cut_Oracle_t *p, int Node, int Node0, int Node1, int fCompl0, int fCompl1)
Definition cutOracle.c:320
int Cut_OracleReadDrop(Cut_Oracle_t *p)
Definition cutOracle.c:176
void Cut_OracleSetFanoutCounts(Cut_Oracle_t *p, Vec_Int_t *vFanCounts)
Definition cutOracle.c:160
void Cut_OracleNodeSetTriv(Cut_Oracle_t *p, int Node)
Definition cutOracle.c:192
Here is the call graph for this function:

◆ Abc_NtkGetNodeAttributes()

Vec_Int_t * Abc_NtkGetNodeAttributes ( Abc_Ntk_t * pNtk)

Definition at line 39 of file abcCut.c.

40{
41 Vec_Int_t * vAttrs = Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
42 int i;
43 Abc_Obj_t * pObj;
44
45// Abc_NtkForEachCi( pNtk, pObj, i )
46// Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
47
48 Abc_NtkForEachObj( pNtk, pObj, i )
49 {
50// if ( Abc_ObjIsNode(pObj) && (rand() % 4 == 0) )
51 if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj) && (rand() % 3 == 0) )
52 Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
53 }
54 return vAttrs;
55}
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
Here is the call graph for this function:

◆ Abc_NtkSeqCuts()

Cut_Man_t * Abc_NtkSeqCuts ( Abc_Ntk_t * pNtk,
Cut_Params_t * pParams )

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

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 222 of file abcCut.c.

223{
224/*
225 Cut_Man_t * p;
226 Abc_Obj_t * pObj, * pNode;
227 int i, nIters, fStatus;
228 Vec_Int_t * vChoices;
229 clock_t clk = clock();
230
231 assert( Abc_NtkIsSeq(pNtk) );
232 assert( pParams->fSeq );
233// assert( Abc_NtkIsDfsOrdered(pNtk) );
234
235 // start the manager
236 pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
237 pParams->nCutSet = Abc_NtkCutSetNodeNum( pNtk );
238 p = Cut_ManStart( pParams );
239
240 // set cuts for the constant node and the PIs
241 pObj = Abc_AigConst1(pNtk);
242 if ( Abc_ObjFanoutNum(pObj) > 0 )
243 Cut_NodeSetTriv( p, pObj->Id );
244 Abc_NtkForEachPi( pNtk, pObj, i )
245 {
246//printf( "Setting trivial cut %d.\n", pObj->Id );
247 Cut_NodeSetTriv( p, pObj->Id );
248 }
249 // label the cutset nodes and set their number in the array
250 // assign the elementary cuts to the cutset nodes
251 Abc_SeqForEachCutsetNode( pNtk, pObj, i )
252 {
253 assert( pObj->fMarkC == 0 );
254 pObj->fMarkC = 1;
255 pObj->pCopy = (Abc_Obj_t *)i;
256 Cut_NodeSetTriv( p, pObj->Id );
257//printf( "Setting trivial cut %d.\n", pObj->Id );
258 }
259
260 // process the nodes
261 vChoices = Vec_IntAlloc( 100 );
262 for ( nIters = 0; nIters < 10; nIters++ )
263 {
264//printf( "ITERATION %d:\n", nIters );
265 // compute the cuts for the internal nodes
266 Abc_AigForEachAnd( pNtk, pObj, i )
267 {
268 Abc_NodeGetCutsSeq( p, pObj, nIters==0 );
269 // add cuts due to choices
270 if ( Abc_AigNodeIsChoice(pObj) )
271 {
272 Vec_IntClear( vChoices );
273 for ( pNode = pObj; pNode; pNode = pNode->pData )
274 Vec_IntPush( vChoices, pNode->Id );
275 Cut_NodeUnionCutsSeq( p, vChoices, (pObj->fMarkC ? (int)pObj->pCopy : -1), nIters==0 );
276 }
277 }
278 // merge the new cuts with the old cuts
279 Abc_NtkForEachPi( pNtk, pObj, i )
280 Cut_NodeNewMergeWithOld( p, pObj->Id );
281 Abc_AigForEachAnd( pNtk, pObj, i )
282 Cut_NodeNewMergeWithOld( p, pObj->Id );
283 // for the cutset, transfer temp cuts to new cuts
284 fStatus = 0;
285 Abc_SeqForEachCutsetNode( pNtk, pObj, i )
286 fStatus |= Cut_NodeTempTransferToNew( p, pObj->Id, i );
287 if ( fStatus == 0 )
288 break;
289 }
290 Vec_IntFree( vChoices );
291
292 // if the status is not finished, transfer new to old for the cutset
293 Abc_SeqForEachCutsetNode( pNtk, pObj, i )
294 Cut_NodeNewMergeWithOld( p, pObj->Id );
295
296 // transfer the old cuts to the new positions
297 Abc_NtkForEachObj( pNtk, pObj, i )
298 Cut_NodeOldTransferToNew( p, pObj->Id );
299
300 // unlabel the cutset nodes
301 Abc_SeqForEachCutsetNode( pNtk, pObj, i )
302 pObj->fMarkC = 0;
303if ( pParams->fVerbose )
304{
305PRT( "Total", clock() - clk );
306printf( "Converged after %d iterations.\n", nIters );
307}
308//Abc_NtkPrintCuts( p, pNtk, 1 );
309 return p;
310*/
311}

Variable Documentation

◆ nEqual

int nEqual

Definition at line 35 of file abcCut.c.

◆ nGood

int nGood

Definition at line 35 of file abcCut.c.

◆ nTotal

int nTotal
extern

DECLARATIONS ///.

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

FileName [cutTruth.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [K-feasible cut computation package.]

Synopsis [Incremental truth table computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 37 of file cutTruth.c.