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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Abc_NtkOrderFaninsById (Abc_Ntk_t *pNtk)
 DECLARATIONS ///.
 
void Abc_NtkSopTranspose (char *pSop, int nVars, Vec_Ptr_t *vCubes, Vec_Str_t *vStore)
 
void Abc_NtkOrderFaninsBySortingColumns (Abc_Ntk_t *pNtk)
 
void Abc_NtkOrderFaninsByLitCount (Abc_Ntk_t *pNtk)
 
void Abc_NtkOrderFaninsByLitCountAndCubeCount (Abc_Ntk_t *pNtk)
 
void Abc_NodeSplitLarge (Abc_Obj_t *pNode)
 
void Abc_NtkSplitLarge (Abc_Ntk_t *pNtk, int nFaninsMax, int nCubesMax)
 
int Abc_NodeCompareCubes1 (char **pp1, char **pp2)
 
int Abc_NodeCompareCubes2 (char **pp1, char **pp2)
 
void Abc_NodeSortCubes (Abc_Obj_t *pNode, Vec_Ptr_t *vCubes, Vec_Str_t *vStore, int fWeight)
 
void Abc_NtkSortCubes (Abc_Ntk_t *pNtk, int fWeight)
 
void Abc_NtkSortSops (Abc_Ntk_t *pNtk)
 
int Abc_NodeMakeSCCFree (Abc_Obj_t *pNode)
 
void Abc_NodeMakeDist1Free (Abc_Obj_t *pNode)
 
void Abc_NodeCheckDist1Free (Abc_Obj_t *pNode)
 
int Abc_NodeMakeLegit (Abc_Obj_t *pNode)
 
int Abc_NtkMakeLegit (Abc_Ntk_t *pNtk)
 

Function Documentation

◆ Abc_NodeCheckDist1Free()

void Abc_NodeCheckDist1Free ( Abc_Obj_t * pNode)

Definition at line 606 of file abcFanOrder.c.

607{
608 char * pSop = (char *)pNode->pData;
609 char * pCube, * pCube2;
610 int i, nVars = Abc_ObjFaninNum(pNode);
611 Abc_SopForEachCube( pSop, nVars, pCube )
612 Abc_SopForEachCube( pSop, nVars, pCube2 )
613 {
614 int Counter = 0;
615 if ( pCube == pCube2 )
616 continue;
617 for ( i = 0; i < nVars; i++ )
618 if ( pCube[i] != pCube2[i] )
619 Counter++;
620 assert( Counter > 1 );
621 }
622}
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
void * pData
Definition abc.h:145
#define assert(ex)
Definition util_old.h:213

◆ Abc_NodeCompareCubes1()

int Abc_NodeCompareCubes1 ( char ** pp1,
char ** pp2 )

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

Synopsis [Sorts the cubes in a topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 446 of file abcFanOrder.c.

447{
448 return strcmp( *pp1, *pp2 );
449}
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeCompareCubes2()

int Abc_NodeCompareCubes2 ( char ** pp1,
char ** pp2 )

Definition at line 450 of file abcFanOrder.c.

451{
452 char * pStr1 = *pp1;
453 char * pStr2 = *pp2;
454 int i, nNum1 = 0, nNum2 = 0;
455 for ( i = 0; pStr1[i]; i++ )
456 {
457 nNum1 += (pStr1[i] != '-');
458 nNum2 += (pStr2[i] != '-');
459 }
460 if ( nNum1 > nNum2 )
461 return -1;
462 if ( nNum1 < nNum2 )
463 return 1;
464 return strcmp( *pp1, *pp2 );
465}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeMakeDist1Free()

void Abc_NodeMakeDist1Free ( Abc_Obj_t * pNode)

Definition at line 590 of file abcFanOrder.c.

591{
592 char * pSop = (char *)pNode->pData;
593 char * pCube, * pCube2;
594 int i, nVars = Abc_ObjFaninNum(pNode);
595 Abc_SopForEachCube( pSop, nVars, pCube )
596 Abc_SopForEachCube( pCube + nVars + 3, nVars, pCube2 )
597 {
598 int Counter = 0, iDiff = -1;
599 for ( i = 0; i < nVars; i++ )
600 if ( pCube[i] != pCube2[i] )
601 Counter++, iDiff = i;
602 if ( Counter == 1 && ((pCube[iDiff] == '0' && pCube2[iDiff] == '1') || (pCube[iDiff] == '1' && pCube2[iDiff] == '0')) )
603 pCube[iDiff] = pCube2[iDiff] = '-';
604 }
605}
Here is the caller graph for this function:

◆ Abc_NodeMakeLegit()

int Abc_NodeMakeLegit ( Abc_Obj_t * pNode)

Definition at line 623 of file abcFanOrder.c.

624{
625 int i, fChanges = 1;
626 for ( i = 0; fChanges; i++ )
627 {
628 Abc_NodeMakeDist1Free( pNode );
629 fChanges = Abc_NodeMakeSCCFree( pNode );
630 }
631// Abc_NodeCheckDist1Free( pNode );
632 return i > 1;
633}
int Abc_NodeMakeSCCFree(Abc_Obj_t *pNode)
void Abc_NodeMakeDist1Free(Abc_Obj_t *pNode)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeMakeSCCFree()

int Abc_NodeMakeSCCFree ( Abc_Obj_t * pNode)

Definition at line 559 of file abcFanOrder.c.

560{
561 char * pSop = (char *)pNode->pData;
562 char * pCube, * pCube2, * pSopNew;
563 int nVars = Abc_ObjFaninNum(pNode);
564 int Status, nCount = 0;
565 Abc_SopForEachCubePair( pSop, nVars, pCube, pCube2 )
566 {
567 if ( pCube[0] == 'z' || pCube2[0] == 'z' )
568 continue;
569 Status = Abc_CubeContain( pCube, pCube2, nVars );
570 nCount += (int)(Status > 0);
571 if ( Status & 1 )
572 pCube2[0] = 'z';
573 else if ( Status & 2 )
574 pCube[0] = 'z';
575 }
576 if ( nCount == 0 )
577 return 0;
578 // create new cover
579 pSopNew = (char *)pNode->pData;
580 Abc_SopForEachCube( pSop, nVars, pCube )
581 {
582 if ( pCube[0] == 'z' )
583 continue;
584 memcpy( pSopNew, pCube, (size_t)(nVars + 3) );
585 pSopNew += nVars + 3;
586 }
587 *pSopNew = 0;
588 return 1;
589}
#define Abc_SopForEachCubePair(pSop, nFanins, pCube, pCube2)
Definition abc.h:540
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeSortCubes()

void Abc_NodeSortCubes ( Abc_Obj_t * pNode,
Vec_Ptr_t * vCubes,
Vec_Str_t * vStore,
int fWeight )

Definition at line 466 of file abcFanOrder.c.

467{
468 char * pCube, * pPivot;
469 char * pSop = (char *)pNode->pData;
470 int i, nVars = Abc_ObjFaninNum(pNode);
471 Vec_PtrClear( vCubes );
472 Abc_SopForEachCube( pSop, nVars, pCube )
473 {
474 assert( pCube[nVars] == ' ' );
475 pCube[nVars] = 0;
476 Vec_PtrPush( vCubes, pCube );
477 }
478 if ( fWeight )
479 Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes2 );
480 else
481 Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes1 );
482 Vec_StrGrow( vStore, Vec_PtrSize(vCubes) * (nVars + 3) );
483 pPivot = Vec_StrArray( vStore );
484 Vec_PtrForEachEntry( char *, vCubes, pCube, i )
485 {
486 assert( pCube[nVars] == 0 );
487 pCube[nVars] = ' ';
488 memcpy( pPivot, pCube, (size_t)(nVars + 3) );
489 pPivot += nVars + 3;
490 }
491 memcpy( pSop, Vec_StrArray(vStore), (size_t)(Vec_PtrSize(vCubes) * (nVars + 3)) );
492}
int Abc_NodeCompareCubes1(char **pp1, char **pp2)
int Abc_NodeCompareCubes2(char **pp1, char **pp2)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NodeSplitLarge()

void Abc_NodeSplitLarge ( Abc_Obj_t * pNode)

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

Synopsis [Split large nodes by dividing their SOPs in half.]

Description []

SideEffects []

SeeAlso []

Definition at line 397 of file abcFanOrder.c.

398{
399 Abc_Obj_t * pNode1, * pNode2, * pFanin;
400 int CutPoint, nVars = Abc_ObjFaninNum(pNode);
401 int i, nCubes = Abc_SopGetCubeNum((char *)pNode->pData);
402 pNode1 = Abc_NtkDupObj( pNode->pNtk, pNode, 0 );
403 pNode2 = Abc_NtkDupObj( pNode->pNtk, pNode, 0 );
404 Abc_ObjForEachFanin( pNode, pFanin, i )
405 Abc_ObjAddFanin( pNode1, pFanin );
406 Abc_ObjForEachFanin( pNode, pFanin, i )
407 Abc_ObjAddFanin( pNode2, pFanin );
408 // update the node
409 Abc_ObjRemoveFanins( pNode );
410 Abc_ObjAddFanin( pNode, pNode1 );
411 Abc_ObjAddFanin( pNode, pNode2 );
412 pNode->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNode->pNtk->pManFunc, 2, NULL );
413 // update covers of the nodes
414 assert( nCubes > 1 );
415 CutPoint = (nCubes / 2) * (nVars + 3);
416 ((char *)pNode1->pData)[CutPoint] = 0;
417 pNode2->pData = (char *)pNode2->pData + CutPoint;
418}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:212
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition abcFanio.c:141
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void * pManFunc
Definition abc.h:191
Abc_Ntk_t * pNtk
Definition abc.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkMakeLegit()

int Abc_NtkMakeLegit ( Abc_Ntk_t * pNtk)

Definition at line 634 of file abcFanOrder.c.

635{
636 Abc_Obj_t * pNode;
637 int i, Counter = 0;
638 assert( Abc_NtkHasSop(pNtk) );
639 Abc_NtkForEachNode( pNtk, pNode, i )
640 Counter += Abc_NodeMakeLegit( pNode );
641 if ( Counter )
642 Abc_Print( 0, "%d nodes were made dist1-cube-free and/or single-cube-containment-free.\n", Counter );
643 return 1;
644}
int Abc_NodeMakeLegit(Abc_Obj_t *pNode)
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
Here is the call graph for this function:

◆ Abc_NtkOrderFaninsById()

ABC_NAMESPACE_IMPL_START void Abc_NtkOrderFaninsById ( Abc_Ntk_t * pNtk)

DECLARATIONS ///.

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

FileName [abcFanOrder.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Fanin ordering procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Reorder fanins of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file abcFanOrder.c.

47{
48 Vec_Int_t * vOrder;
49 Vec_Str_t * vStore;
50 Abc_Obj_t * pNode;
51 char * pSop, * pSopNew;
52 char * pCube, * pCubeNew;
53 int nVars, i, v, * pOrder;
54 assert( Abc_NtkHasSop(pNtk) );
55 vOrder = Vec_IntAlloc( 100 );
56 vStore = Vec_StrAlloc( 100 );
57 Abc_NtkForEachNode( pNtk, pNode, i )
58 {
59 pSop = (char *)pNode->pData;
60 nVars = Abc_SopGetVarNum(pSop);
61 assert( nVars == Abc_ObjFaninNum(pNode) );
62 Vec_IntClear( vOrder );
63 for ( v = 0; v < nVars; v++ )
64 Vec_IntPush( vOrder, v );
65 pOrder = Vec_IntArray(vOrder);
66 Vec_IntSelectSortCost( pOrder, nVars, &pNode->vFanins );
67 // copy the cover
68 Vec_StrGrow( vStore, Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1 );
69 memcpy( Vec_StrArray(vStore), pSop, (size_t)(Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1) );
70 pSopNew = pCubeNew = pSop;
71 pSop = Vec_StrArray(vStore);
72 // generate permuted one
73 Abc_SopForEachCube( pSop, nVars, pCube )
74 {
75 for ( v = 0; v < nVars; v++ )
76 pCubeNew[v] = '-';
77 for ( v = 0; v < nVars; v++ )
78 if ( pCube[pOrder[v]] == '0' )
79 pCubeNew[v] = '0';
80 else if ( pCube[pOrder[v]] == '1' )
81 pCubeNew[v] = '1';
82 pCubeNew += nVars + 3;
83 }
84 pNode->pData = pSopNew;
85 Vec_IntSort( &pNode->vFanins, 0 );
86// Vec_IntPrint( vOrder );
87 }
88 Vec_IntFree( vOrder );
89 Vec_StrFree( vStore );
90}
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Vec_Int_t vFanins
Definition abc.h:143
Here is the call graph for this function:

◆ Abc_NtkOrderFaninsByLitCount()

void Abc_NtkOrderFaninsByLitCount ( Abc_Ntk_t * pNtk)

Definition at line 231 of file abcFanOrder.c.

232{
233 Vec_Int_t * vOrder;
234 Vec_Int_t * vCounts;
235 Vec_Int_t * vFanins;
236 Vec_Str_t * vStore;
237 Vec_Ptr_t * vCubes;
238 Abc_Obj_t * pNode;
239 char * pSop, * pSopNew;
240 char * pCube, * pCubeNew;
241 int nVars, i, v, * pOrder;
242 assert( Abc_NtkHasSop(pNtk) );
243 vOrder = Vec_IntAlloc( 100 );
244 vStore = Vec_StrAlloc( 100 );
245 vCubes = Vec_PtrAlloc( 100 );
246 vCounts = Vec_IntAlloc( 100 );
247 vFanins = Vec_IntAlloc( 100 );
248 Abc_NtkForEachNode( pNtk, pNode, i )
249 {
250 pSop = (char *)pNode->pData;
251 nVars = Abc_SopGetVarNum(pSop);
252 assert( nVars == Abc_ObjFaninNum(pNode) );
253 // count literals
254 Vec_IntFill( vCounts, nVars, 0 );
255 Abc_SopForEachCube( pSop, nVars, pCube )
256 for ( v = 0; v < nVars; v++ )
257 if ( pCube[v] != '-' )
258 Vec_IntAddToEntry( vCounts, v, 1 );
259
260 // create a transposed SOP
261 Abc_NtkSopTranspose( pSop, nVars, vCubes, vStore );
262 // create permutation
263 Vec_StrSelectSortCost2( (char **)Vec_PtrArray(vCubes), nVars, vCounts, vOrder );
264 pOrder = Vec_IntArray(vOrder);
265/*
266 // find good order
267 Vec_IntClear( vOrder );
268 for ( v = 0; v < nVars; v++ )
269 Vec_IntPush( vOrder, v );
270 pOrder = Vec_IntArray(vOrder);
271 Vec_IntSelectSortCost( pOrder, nVars, vCounts );
272*/
273 // copy the cover
274 Vec_StrGrow( vStore, Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1 );
275 memcpy( Vec_StrArray(vStore), pSop, (size_t)(Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1) );
276 pSopNew = pCubeNew = pSop;
277 pSop = Vec_StrArray(vStore);
278 // generate permuted one
279 Abc_SopForEachCube( pSop, nVars, pCube )
280 {
281 for ( v = 0; v < nVars; v++ )
282 pCubeNew[v] = '-';
283 for ( v = 0; v < nVars; v++ )
284 if ( pCube[pOrder[v]] == '0' )
285 pCubeNew[v] = '0';
286 else if ( pCube[pOrder[v]] == '1' )
287 pCubeNew[v] = '1';
288 pCubeNew += nVars + 3;
289 }
290 pNode->pData = pSopNew;
291 // generate the fanin order
292 Vec_IntClear( vFanins );
293 for ( v = 0; v < nVars; v++ )
294 Vec_IntPush( vFanins, Abc_ObjFaninId( pNode, pOrder[v] ) );
295 Vec_IntClear( &pNode->vFanins );
296 Vec_IntAppend( &pNode->vFanins, vFanins );
297 }
298 Vec_IntFree( vFanins );
299 Vec_IntFree( vCounts );
300 Vec_IntFree( vOrder );
301 Vec_StrFree( vStore );
302 Vec_PtrFree( vCubes );
303}
void Abc_NtkSopTranspose(char *pSop, int nVars, Vec_Ptr_t *vCubes, Vec_Str_t *vStore)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkOrderFaninsByLitCountAndCubeCount()

void Abc_NtkOrderFaninsByLitCountAndCubeCount ( Abc_Ntk_t * pNtk)

Definition at line 304 of file abcFanOrder.c.

305{
306 // assuming that the fanins are sorted by the number of literals in each cube
307 // this procedure sorts the literals appearing only once by the number of their cube
308 Vec_Int_t * vOrder;
309 Vec_Int_t * vCounts;
310 Vec_Int_t * vFanins;
311 Vec_Int_t * vCubeNum;
312 Vec_Str_t * vStore;
313 Abc_Obj_t * pNode;
314 char * pSop, * pSopNew;
315 char * pCube, * pCubeNew;
316 int nVars, i, v, iCube, * pOrder;
317 assert( Abc_NtkHasSop(pNtk) );
318 vStore = Vec_StrAlloc( 100 );
319 vOrder = Vec_IntAlloc( 100 );
320 vCounts = Vec_IntAlloc( 100 );
321 vFanins = Vec_IntAlloc( 100 );
322 vCubeNum = Vec_IntAlloc( 100 );
323 Abc_NtkForEachNode( pNtk, pNode, i )
324 {
325 pSop = (char *)pNode->pData;
326 nVars = Abc_SopGetVarNum(pSop);
327 assert( nVars == Abc_ObjFaninNum(pNode) );
328 // count literals and remember the cube where each literal appears
329 Vec_IntFill( vCounts, nVars, 0 );
330 Vec_IntFill( vCubeNum, nVars, 0 );
331 iCube = 0;
332 Abc_SopForEachCube( pSop, nVars, pCube )
333 {
334 for ( v = 0; v < nVars; v++ )
335 if ( pCube[v] != '-' )
336 {
337 Vec_IntAddToEntry( vCounts, v, 1 );
338 Vec_IntWriteEntry( vCubeNum, v, iCube );
339 }
340 iCube++;
341 }
342 // create new order
343 for ( v = 0; v < nVars; v++ )
344 if ( Vec_IntEntry(vCounts, v) == 1 )
345 Vec_IntWriteEntry( vCounts, v, Vec_IntEntry(vCubeNum, v) );
346 else
347 Vec_IntWriteEntry( vCounts, v, ABC_INFINITY );
348 // find good order
349 Vec_IntClear( vOrder );
350 for ( v = 0; v < nVars; v++ )
351 Vec_IntPush( vOrder, v );
352 pOrder = Vec_IntArray(vOrder);
353 Vec_IntSelectSortCost( pOrder, nVars, vCounts );
354 // copy the cover
355 Vec_StrGrow( vStore, Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1 );
356 memcpy( Vec_StrArray(vStore), pSop, (size_t)(Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1) );
357 pSopNew = pCubeNew = pSop;
358 pSop = Vec_StrArray(vStore);
359 // generate permuted one
360 Abc_SopForEachCube( pSop, nVars, pCube )
361 {
362 for ( v = 0; v < nVars; v++ )
363 pCubeNew[v] = '-';
364 for ( v = 0; v < nVars; v++ )
365 if ( pCube[pOrder[v]] == '0' )
366 pCubeNew[v] = '0';
367 else if ( pCube[pOrder[v]] == '1' )
368 pCubeNew[v] = '1';
369 pCubeNew += nVars + 3;
370 }
371 pNode->pData = pSopNew;
372 // generate the fanin order
373 Vec_IntClear( vFanins );
374 for ( v = 0; v < nVars; v++ )
375 Vec_IntPush( vFanins, Abc_ObjFaninId( pNode, pOrder[v] ) );
376 Vec_IntClear( &pNode->vFanins );
377 Vec_IntAppend( &pNode->vFanins, vFanins );
378 }
379 Vec_IntFree( vCubeNum );
380 Vec_IntFree( vFanins );
381 Vec_IntFree( vCounts );
382 Vec_IntFree( vOrder );
383 Vec_StrFree( vStore );
384}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkOrderFaninsBySortingColumns()

void Abc_NtkOrderFaninsBySortingColumns ( Abc_Ntk_t * pNtk)

Definition at line 142 of file abcFanOrder.c.

143{
144 Vec_Int_t * vOrder;
145 Vec_Int_t * vCounts;
146 Vec_Int_t * vFanins;
147 Vec_Str_t * vStore;
148 Vec_Ptr_t * vCubes;
149 Abc_Obj_t * pNode;
150 char * pSop, * pSopNew;
151 char * pCube, * pCubeNew;
152 int nVars, i, v, * pOrder;
153 assert( Abc_NtkHasSop(pNtk) );
154 vOrder = Vec_IntAlloc( 100 );
155 vStore = Vec_StrAlloc( 100 );
156 vCubes = Vec_PtrAlloc( 100 );
157 vCounts = Vec_IntAlloc( 100 );
158 vFanins = Vec_IntAlloc( 100 );
159 Abc_NtkForEachNode( pNtk, pNode, i )
160 {
161 pSop = (char *)pNode->pData;
162 nVars = Abc_SopGetVarNum(pSop);
163 assert( nVars == Abc_ObjFaninNum(pNode) );
164 // create a transposed SOP
165 Abc_NtkSopTranspose( pSop, nVars, vCubes, vStore );
166 // create permutation
167 Vec_StrSelectSortCost( (char **)Vec_PtrArray(vCubes), nVars, vOrder );
168 pOrder = Vec_IntArray(vOrder);
169 // copy the cover
170 Vec_StrGrow( vStore, Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1 );
171 memcpy( Vec_StrArray(vStore), pSop, (size_t)(Abc_SopGetCubeNum(pSop) * (nVars + 3) + 1) );
172 pSopNew = pCubeNew = pSop;
173 pSop = Vec_StrArray(vStore);
174 // generate permuted one
175 Abc_SopForEachCube( pSop, nVars, pCube )
176 {
177 for ( v = 0; v < nVars; v++ )
178 pCubeNew[v] = '-';
179 for ( v = 0; v < nVars; v++ )
180 if ( pCube[pOrder[v]] == '0' )
181 pCubeNew[v] = '0';
182 else if ( pCube[pOrder[v]] == '1' )
183 pCubeNew[v] = '1';
184 pCubeNew += nVars + 3;
185 }
186 pNode->pData = pSopNew;
187 // generate the fanin order
188 Vec_IntClear( vFanins );
189 for ( v = 0; v < nVars; v++ )
190 Vec_IntPush( vFanins, Abc_ObjFaninId( pNode, pOrder[v] ) );
191 Vec_IntClear( &pNode->vFanins );
192 Vec_IntAppend( &pNode->vFanins, vFanins );
193 }
194 Vec_IntFree( vFanins );
195 Vec_IntFree( vCounts );
196 Vec_IntFree( vOrder );
197 Vec_StrFree( vStore );
198 Vec_PtrFree( vCubes );
199}
Here is the call graph for this function:

◆ Abc_NtkSopTranspose()

void Abc_NtkSopTranspose ( char * pSop,
int nVars,
Vec_Ptr_t * vCubes,
Vec_Str_t * vStore )

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

Synopsis [Returns fanin permutation to reorders columns lexicographically.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file abcFanOrder.c.

104{
105 char * pCube;
106 int nCubes, v, c;
107 // collect original cubes
108 Vec_PtrClear( vCubes );
109 Abc_SopForEachCube( pSop, nVars, pCube )
110 Vec_PtrPush( vCubes, pCube );
111 // rebuild the cubes
112 Vec_StrClear( vStore );
113 for ( v = 0; v < nVars; v++ )
114 {
115 Vec_PtrForEachEntry( char *, vCubes, pCube, c )
116 Vec_StrPush( vStore, pCube[v] );
117 Vec_StrPush( vStore, '\0' );
118 }
119 // get the cubes
120 nCubes = Vec_PtrSize( vCubes );
121 Vec_PtrClear( vCubes );
122 for ( v = 0; v < nVars; v++ )
123 Vec_PtrPush( vCubes, Vec_StrEntryP(vStore, v*(nCubes+1)) );
124}
Here is the caller graph for this function:

◆ Abc_NtkSortCubes()

void Abc_NtkSortCubes ( Abc_Ntk_t * pNtk,
int fWeight )

Definition at line 493 of file abcFanOrder.c.

494{
495 Vec_Ptr_t * vCubes;
496 Vec_Str_t * vStore;
497 Abc_Obj_t * pNode;
498 int i;
499 assert( Abc_NtkHasSop(pNtk) );
500 vCubes = Vec_PtrAlloc( 1000 );
501 vStore = Vec_StrAlloc( 1000 );
502 Abc_NtkForEachNode( pNtk, pNode, i )
503 Abc_NodeSortCubes( pNode, vCubes, vStore, fWeight );
504 Vec_StrFree( vStore );
505 Vec_PtrFree( vCubes );
506}
void Abc_NodeSortCubes(Abc_Obj_t *pNode, Vec_Ptr_t *vCubes, Vec_Str_t *vStore, int fWeight)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkSortSops()

void Abc_NtkSortSops ( Abc_Ntk_t * pNtk)

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

Synopsis [Sorts fanins of each node to make SOPs more readable.]

Description []

SideEffects []

SeeAlso []

Definition at line 520 of file abcFanOrder.c.

521{
522 Abc_NtkSortCubes( pNtk, 1 );
524 Abc_NtkSortCubes( pNtk, 0 );
526 Abc_NtkSortCubes( pNtk, 0 );
527}
void Abc_NtkOrderFaninsByLitCount(Abc_Ntk_t *pNtk)
void Abc_NtkOrderFaninsByLitCountAndCubeCount(Abc_Ntk_t *pNtk)
void Abc_NtkSortCubes(Abc_Ntk_t *pNtk, int fWeight)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkSplitLarge()

void Abc_NtkSplitLarge ( Abc_Ntk_t * pNtk,
int nFaninsMax,
int nCubesMax )

Definition at line 419 of file abcFanOrder.c.

420{
421 Abc_Obj_t * pNode;
422 int nObjOld = Abc_NtkObjNumMax(pNtk);
423 int i, nCubes;
424 assert( Abc_NtkHasSop(pNtk) );
425 Abc_NtkForEachNode( pNtk, pNode, i )
426 {
427 if ( i == nObjOld )
428 break;
429 nCubes = Abc_SopGetCubeNum((char *)pNode->pData);
430 if ( (Abc_ObjFaninNum(pNode) > nFaninsMax && nCubes > 1) || nCubes > nCubesMax )
431 Abc_NodeSplitLarge( pNode );
432 }
433}
void Abc_NodeSplitLarge(Abc_Obj_t *pNode)
Here is the call graph for this function: