src/base/abci/abcLut.c File Reference

#include "abc.h"
#include "cut.h"
Include dependency graph for abcLut.c:

Go to the source code of this file.

Data Structures

struct  Abc_ManScl_t_

Defines

#define SCL_LUT_MAX   6
#define SCL_VARS_MAX   15
#define SCL_NODE_MAX   1000

Typedefs

typedef struct Abc_ManScl_t_ Abc_ManScl_t

Functions

static Cut_Man_tAbc_NtkStartCutManForScl (Abc_Ntk_t *pNtk, int nLutSize)
static Abc_ManScl_tAbc_ManSclStart (int nLutSize, int nCutSizeMax, int nNodesMax)
static void Abc_ManSclStop (Abc_ManScl_t *p)
static void Abc_NodeLutMap (Cut_Man_t *pManCuts, Abc_Obj_t *pObj)
static Abc_Obj_tAbc_NodeSuperChoiceLut (Abc_ManScl_t *pManScl, Abc_Obj_t *pObj)
static int Abc_NodeDecomposeStep (Abc_ManScl_t *pManScl)
int Abc_NtkSuperChoiceLut (Abc_Ntk_t *pNtk, int nLutSize, int nCutSizeMax, int fVerbose)
unsigned * Abc_NodeSuperChoiceTruth (Abc_ManScl_t *pManScl)
void Abc_NodeSuperChoiceCollect2_rec (Abc_Obj_t *pObj, Vec_Ptr_t *vVolume)
void Abc_NodeSuperChoiceCollect2 (Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
void Abc_NodeSuperChoiceCollect_rec (Abc_Obj_t *pObj, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
void Abc_NodeSuperChoiceCollect (Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
void Abc_NodeLeavesRemove (Vec_Ptr_t *vLeaves, unsigned uPhase, int nVars)
int Abc_NodeGetLevel (Abc_Obj_t *pObj)
int Abc_NodeCompareLevelsInc (int *pp1, int *pp2)
void Abc_NodeDecomposeSort (Abc_Obj_t **pLeaves, int nVars, int *pBSet, int nLutSize)

Variables

static Vec_Ptr_ts_pLeaves = NULL

Define Documentation

#define SCL_LUT_MAX   6

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

FileName [abcLut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Superchoicing for K-LUTs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] DECLARATIONS ///

Definition at line 28 of file abcLut.c.

#define SCL_NODE_MAX   1000

Definition at line 30 of file abcLut.c.

#define SCL_VARS_MAX   15

Definition at line 29 of file abcLut.c.


Typedef Documentation

typedef struct Abc_ManScl_t_ Abc_ManScl_t

Definition at line 32 of file abcLut.c.


Function Documentation

Abc_ManScl_t * Abc_ManSclStart ( int  nLutSize,
int  nCutSizeMax,
int  nNodesMax 
) [static]

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

Synopsis [Starts the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file abcLut.c.

00283 {
00284     Abc_ManScl_t * p;
00285     int i, k;
00286     assert( sizeof(unsigned) == 4 );
00287     p = ALLOC( Abc_ManScl_t, 1 );
00288     memset( p, 0, sizeof(Abc_ManScl_t) );
00289     p->nLutSize    = nLutSize;
00290     p->nCutSizeMax = nCutSizeMax;
00291     p->nNodesMax   = nNodesMax;
00292     p->nWords      = Extra_TruthWordNum(nCutSizeMax);
00293     // allocate simulation info
00294     p->uVars = (unsigned **)Extra_ArrayAlloc( nCutSizeMax, p->nWords, 4 );
00295     p->uSims = (unsigned **)Extra_ArrayAlloc( nNodesMax, p->nWords, 4 );
00296     p->uCofs = (unsigned **)Extra_ArrayAlloc( 2 << nLutSize, p->nWords, 4 );
00297     memset( p->uVars[0], 0, nCutSizeMax * p->nWords * 4 );
00298     // assign elementary truth tables
00299     for ( k = 0; k < p->nCutSizeMax; k++ )
00300         for ( i = 0; i < p->nWords * 32; i++ )
00301             if ( i & (1 << k) )
00302                 p->uVars[k][i>>5] |= (1 << (i&31));
00303     // other data structures
00304 //    p->vBound = Vec_IntAlloc( nCutSizeMax );
00305     return p;
00306 }

void Abc_ManSclStop ( Abc_ManScl_t p  )  [static]

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

Synopsis [Stops the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file abcLut.c.

00320 {
00321 //    Vec_IntFree( p->vBound );
00322     free( p->uVars );
00323     free( p->uSims );
00324     free( p->uCofs );
00325     free( p );
00326 }

int Abc_NodeCompareLevelsInc ( int *  pp1,
int *  pp2 
)

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

Synopsis [Procedure used for sorting the nodes in increasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 597 of file abcLut.c.

00598 {
00599     Abc_Obj_t * pNode1, * pNode2;
00600     pNode1 = Vec_PtrEntry(s_pLeaves, *pp1);
00601     pNode2 = Vec_PtrEntry(s_pLeaves, *pp2);
00602     if ( pNode1->Level < pNode2->Level )
00603         return -1;
00604     if ( pNode1->Level > pNode2->Level ) 
00605         return 1;
00606     return 0; 
00607 }

void Abc_NodeDecomposeSort ( Abc_Obj_t **  pLeaves,
int  nVars,
int *  pBSet,
int  nLutSize 
)

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

Synopsis [Selects the earliest arriving nodes from the array.]

Description []

SideEffects []

SeeAlso []

Definition at line 620 of file abcLut.c.

00621 {
00622     Abc_Obj_t * pTemp[SCL_VARS_MAX];
00623     int i, k, kBest, LevelMin;
00624     assert( nLutSize < nVars );
00625     assert( nVars <= SCL_VARS_MAX );
00626     // copy nodes into the internal storage
00627 //    printf( "(" );
00628     for ( i = 0; i < nVars; i++ )
00629     {
00630         pTemp[i] = pLeaves[i];
00631 //        printf( " %d", pLeaves[i]->Level );
00632     }
00633 //    printf( " )\n" );
00634     // choose one node at a time
00635     for ( i = 0; i < nLutSize; i++ )
00636     {
00637         kBest = -1;
00638         LevelMin = ABC_INFINITY;
00639         for ( k = 0; k < nVars; k++ )
00640             if ( pTemp[k] && LevelMin > (int)pTemp[k]->Level )
00641             {
00642                 LevelMin = pTemp[k]->Level;
00643                 kBest = k;
00644             }
00645         pBSet[i] = kBest;
00646         pTemp[kBest] = NULL;
00647     }
00648 }

int Abc_NodeDecomposeStep ( Abc_ManScl_t p  )  [static]

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 661 of file abcLut.c.

00662 {
00663     static char pCofClasses[1<<SCL_LUT_MAX][1<<SCL_LUT_MAX];
00664     static char nCofClasses[1<<SCL_LUT_MAX];
00665     Abc_Ntk_t * pNtk;
00666     Abc_Obj_t * pObjNew, * pFanin, * pNodesNew[SCL_LUT_MAX];
00667     unsigned * pTruthCof, * pTruthClass, * pTruth, uPhase;
00668     int i, k, c, v, w, nVars, nVarsNew, nClasses, nCofs;
00669     // set the network
00670     pNtk = ((Abc_Obj_t *)Vec_PtrEntry(p->vLeaves, 0))->pNtk;
00671     // find the earliest nodes
00672     nVars = Vec_PtrSize(p->vLeaves);
00673     assert( nVars > p->nLutSize );
00674 /*
00675     for ( v = 0; v < nVars; v++ )
00676         p->pBSet[v] = v;
00677     qsort( (void *)p->pBSet, nVars, sizeof(int), 
00678             (int (*)(const void *, const void *)) Abc_NodeCompareLevelsInc );
00679 */
00680     Abc_NodeDecomposeSort( (Abc_Obj_t **)Vec_PtrArray(p->vLeaves), Vec_PtrSize(p->vLeaves), p->pBSet, p->nLutSize );
00681     assert( ((Abc_Obj_t *)Vec_PtrEntry(p->vLeaves, p->pBSet[0]))->Level <=
00682         ((Abc_Obj_t *)Vec_PtrEntry(p->vLeaves, p->pBSet[1]))->Level );
00683     // cofactor w.r.t. the selected variables
00684     Extra_TruthCopy( p->uCofs[1], p->uTruth, nVars );
00685     c = 2;
00686     for ( v = 0; v < p->nLutSize; v++ )
00687         for ( k = 0; k < (1<<v); k++ )
00688         {
00689             Extra_TruthCopy( p->uCofs[c], p->uCofs[c/2], nVars );
00690             Extra_TruthCopy( p->uCofs[c+1], p->uCofs[c/2], nVars );
00691             Extra_TruthCofactor0( p->uCofs[c], nVars, p->pBSet[v] );
00692             Extra_TruthCofactor1( p->uCofs[c+1], nVars, p->pBSet[v] );
00693             c += 2;
00694         }
00695     assert( c == (2 << p->nLutSize) );
00696     // count unique cofactors
00697     nClasses = 0;
00698     nCofs = (1 << p->nLutSize);
00699     for ( i = 0; i < nCofs; i++ )
00700     {
00701         pTruthCof = p->uCofs[ nCofs + i ];
00702         for ( k = 0; k < nClasses; k++ )
00703         {
00704             pTruthClass = p->uCofs[ nCofs + pCofClasses[k][0] ];
00705             if ( Extra_TruthIsEqual( pTruthCof, pTruthClass, nVars ) )
00706             {
00707                 pCofClasses[k][ nCofClasses[k]++ ] = i;
00708                 break;
00709             }
00710         }
00711         if ( k != nClasses )
00712             continue;
00713         // not found
00714         pCofClasses[nClasses][0] = i;
00715         nCofClasses[nClasses] = 1;
00716         nClasses++;
00717         if ( nClasses > nCofs/2 )
00718             return 0;
00719     }
00720     // the number of cofactors is acceptable
00721     nVarsNew = Extra_Base2Log( nClasses );
00722     assert( nVarsNew < p->nLutSize );
00723     // create the remainder truth table
00724     // for each class of cofactors, multiply cofactor truth table by its code
00725     Extra_TruthClear( p->uTruth, nVars );
00726     for ( k = 0; k < nClasses; k++ )
00727     {
00728         pTruthClass = p->uCofs[ nCofs + pCofClasses[k][0] ];
00729         for ( v = 0; v < nVarsNew; v++ )
00730             if ( k & (1 << v) )
00731                 Extra_TruthAnd( pTruthClass, pTruthClass, p->uVars[p->pBSet[v]], nVars );
00732             else
00733                 Extra_TruthSharp( pTruthClass, pTruthClass, p->uVars[p->pBSet[v]], nVars );
00734         Extra_TruthOr( p->uTruth, p->uTruth, pTruthClass, nVars );
00735     }
00736     // create nodes
00737     pTruth = p->uCofs[0];
00738     for ( v = 0; v < nVarsNew; v++ )
00739     {
00740         Extra_TruthClear( pTruth, p->nLutSize );
00741         for ( k = 0; k < nClasses; k++ )
00742             if ( k & (1 << v) )
00743                 for ( i = 0; i < nCofClasses[k]; i++ )
00744                 {
00745                     pTruthCof = p->uCofs[1];
00746                     Extra_TruthFill( pTruthCof, p->nLutSize );
00747                     for ( w = 0; w < p->nLutSize; w++ )
00748                         if ( pCofClasses[k][i] & (1 << (p->nLutSize-1-w)) )
00749                             Extra_TruthAnd( pTruthCof, pTruthCof, p->uVars[w], p->nLutSize );
00750                         else
00751                             Extra_TruthSharp( pTruthCof, pTruthCof, p->uVars[w], p->nLutSize );
00752                     Extra_TruthOr( pTruth, pTruth, pTruthCof, p->nLutSize );
00753                 }
00754         // implement the node
00755         pObjNew = Abc_NtkCreateNode( pNtk );
00756         for ( i = 0; i < p->nLutSize; i++ )
00757         {
00758             pFanin = Vec_PtrEntry( p->vLeaves, p->pBSet[i] );
00759             Abc_ObjAddFanin( pObjNew, pFanin );
00760         }
00761         // create the function
00762         pObjNew->pData = Abc_SopCreateFromTruth( pNtk->pManFunc, p->nLutSize, pTruth ); // need ISOP
00763         pObjNew->Level = Abc_NodeGetLevel( pObjNew );
00764         pNodesNew[v] = pObjNew;
00765     }
00766     // put the new nodes back into the list
00767     for ( v = 0; v < nVarsNew; v++ )
00768         Vec_PtrWriteEntry( p->vLeaves, p->pBSet[v], pNodesNew[v] );
00769     // compute the variables that should be removed
00770     uPhase = 0;
00771     for ( v = nVarsNew; v < p->nLutSize; v++ )
00772         uPhase |= (1 << p->pBSet[v]);
00773     // remove entries from the array
00774     Abc_NodeLeavesRemove( p->vLeaves, uPhase, nVars );
00775     // update truth table
00776     Extra_TruthShrink( p->uCofs[0], p->uTruth, nVars - p->nLutSize + nVarsNew, nVars, ((1 << nVars) - 1) & ~uPhase );
00777     Extra_TruthCopy( p->uTruth, p->uCofs[0], nVars );
00778     assert( !Extra_TruthVarInSupport( p->uTruth, nVars, nVars - p->nLutSize + nVarsNew ) );
00779     return 1;
00780 }

int Abc_NodeGetLevel ( Abc_Obj_t pObj  ) 

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 508 of file abcLut.c.

00509 {
00510     Abc_Obj_t * pFanin;
00511     int i, Level;
00512     Level = 0;
00513     Abc_ObjForEachFanin( pObj, pFanin, i )
00514         Level = ABC_MAX( Level, (int)pFanin->Level );
00515     return Level + 1;
00516 }

void Abc_NodeLeavesRemove ( Vec_Ptr_t vLeaves,
unsigned  uPhase,
int  nVars 
)

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file abcLut.c.

00490 {
00491     int i;
00492     for ( i = nVars - 1; i >= 0; i-- )
00493         if ( uPhase & (1 << i) )
00494             Vec_PtrRemove( vLeaves, Vec_PtrEntry(vLeaves, i) );
00495 }

void Abc_NodeLutMap ( Cut_Man_t pManCuts,
Abc_Obj_t pObj 
) [static]

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

Synopsis [Performs LUT mapping of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file abcLut.c.

00207 {
00208     Cut_Cut_t * pCut;
00209     Abc_Obj_t * pFanin;
00210     int i, DelayMax;
00211     pCut = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCuts, pObj, 0, 0 );
00212     assert( pCut != NULL );
00213     assert( pObj->Level == 0 );
00214     // go through the cuts
00215     pObj->Level = ABC_INFINITY;
00216     for ( pCut = pCut->pNext; pCut; pCut = pCut->pNext )
00217     {
00218         DelayMax = 0;
00219         for ( i = 0; i < (int)pCut->nLeaves; i++ )
00220         {
00221             pFanin = Abc_NtkObj( pObj->pNtk, pCut->pLeaves[i] );
00222 //            assert( Abc_ObjIsCi(pFanin) || pFanin->Level > 0 ); // should hold if node ordering is topological
00223             if ( DelayMax < (int)pFanin->Level )
00224                 DelayMax = pFanin->Level;
00225         }
00226         if ( (int)pObj->Level > DelayMax )
00227             pObj->Level = DelayMax;
00228     }
00229     assert( pObj->Level < ABC_INFINITY );
00230     pObj->Level++;
00231 //    printf( "%d(%d) ", pObj->Id, pObj->Level );
00232 }

void Abc_NodeSuperChoiceCollect ( Abc_Obj_t pRoot,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vVolume 
)

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

Synopsis [Performs superchoicing for one node.]

Description [Orders the leaves topologically.]

SideEffects []

SeeAlso []

Definition at line 461 of file abcLut.c.

00462 {
00463     Abc_Obj_t * pObj;
00464     int i, nLeaves;
00465     nLeaves = Vec_PtrSize(vLeaves);
00466     Vec_PtrForEachEntry( vLeaves, pObj, i )
00467         pObj->fMarkB = pObj->fMarkC = 1;
00468     Vec_PtrClear( vVolume );
00469     Vec_PtrClear( vLeaves );
00470     Abc_NodeSuperChoiceCollect_rec( pRoot, vLeaves, vVolume );
00471     assert( Vec_PtrSize(vLeaves) == nLeaves );
00472     Vec_PtrForEachEntry( vLeaves, pObj, i )
00473         pObj->fMarkC = 0;
00474     Vec_PtrForEachEntry( vVolume, pObj, i )
00475         pObj->fMarkC = 0;
00476 }

void Abc_NodeSuperChoiceCollect2 ( Abc_Obj_t pRoot,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vVolume 
)

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 409 of file abcLut.c.

00410 {
00411     Abc_Obj_t * pObj;
00412     int i;
00413     Vec_PtrForEachEntry( vLeaves, pObj, i )
00414         pObj->fMarkC = 1;
00415     Vec_PtrClear( vVolume );
00416     Abc_NodeSuperChoiceCollect2_rec( pRoot, vVolume );
00417     Vec_PtrForEachEntry( vLeaves, pObj, i )
00418         pObj->fMarkC = 0;
00419     Vec_PtrForEachEntry( vVolume, pObj, i )
00420         pObj->fMarkC = 0;
00421 }

void Abc_NodeSuperChoiceCollect2_rec ( Abc_Obj_t pObj,
Vec_Ptr_t vVolume 
)

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 387 of file abcLut.c.

00388 {
00389     if ( pObj->fMarkC )
00390         return;
00391     pObj->fMarkC = 1;
00392     assert( Abc_ObjFaninNum(pObj) == 2 );
00393     Abc_NodeSuperChoiceCollect2_rec( Abc_ObjFanin0(pObj), vVolume );
00394     Abc_NodeSuperChoiceCollect2_rec( Abc_ObjFanin1(pObj), vVolume );
00395     Vec_PtrPush( vVolume, pObj );
00396 }

void Abc_NodeSuperChoiceCollect_rec ( Abc_Obj_t pObj,
Vec_Ptr_t vLeaves,
Vec_Ptr_t vVolume 
)

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 434 of file abcLut.c.

00435 {
00436     if ( pObj->fMarkB )
00437     {
00438         Vec_PtrPush( vLeaves, pObj );
00439         pObj->fMarkB = 0;
00440     }
00441     if ( pObj->fMarkC )
00442         return;
00443     pObj->fMarkC = 1;
00444     assert( Abc_ObjFaninNum(pObj) == 2 );
00445     Abc_NodeSuperChoiceCollect_rec( Abc_ObjFanin0(pObj), vLeaves, vVolume );
00446     Abc_NodeSuperChoiceCollect_rec( Abc_ObjFanin1(pObj), vLeaves, vVolume );
00447     Vec_PtrPush( vVolume, pObj );
00448 }

Abc_Obj_t * Abc_NodeSuperChoiceLut ( Abc_ManScl_t p,
Abc_Obj_t pObj 
) [static]

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 529 of file abcLut.c.

00530 {
00531     Abc_Obj_t * pFanin, * pObjNew;
00532     int i, nVars, uSupport, nSuppVars;
00533     // collect the cone using DFS (excluding leaves)
00534     Abc_NodeSuperChoiceCollect2( pObj, p->vLeaves, p->vVolume );
00535     assert( Vec_PtrEntryLast(p->vVolume) == pObj );  
00536     // compute the truth table
00537     p->uTruth = Abc_NodeSuperChoiceTruth( p );
00538     // get the support of this truth table
00539     nVars = Vec_PtrSize(p->vLeaves);
00540     uSupport = Extra_TruthSupport(p->uTruth, nVars);
00541     nSuppVars = Extra_WordCountOnes(uSupport);
00542     assert( nSuppVars <= nVars );
00543     if ( nSuppVars == 0 )
00544     {
00545         pObj->Level = 0;
00546         return NULL;
00547     }
00548     if ( nSuppVars == 1 )
00549     {
00550         // find the variable
00551         for ( i = 0; i < nVars; i++ )
00552             if ( uSupport & (1 << i) )
00553                 break;
00554         assert( i < nVars );
00555         pFanin = Vec_PtrEntry( p->vLeaves, i );
00556         pObj->Level = pFanin->Level;
00557         return NULL;
00558     }
00559     // support-minimize the truth table
00560     if ( nSuppVars != nVars )
00561     {
00562         Extra_TruthShrink( p->uCofs[0], p->uTruth, nSuppVars, nVars, uSupport );
00563         Extra_TruthCopy( p->uTruth, p->uCofs[0], nVars );
00564         Abc_NodeLeavesRemove( p->vLeaves, ((1 << nVars) - 1) & ~uSupport, nVars );
00565     }
00566 //    return NULL;
00567     // decompose the truth table recursively
00568     while ( Vec_PtrSize(p->vLeaves) > p->nLutSize )
00569         if ( !Abc_NodeDecomposeStep( p ) )
00570         {
00571             Vec_PtrForEachEntry( p->vLeaves, pFanin, i )
00572                 if ( Abc_ObjIsNode(pFanin) && Abc_ObjFanoutNum(pFanin) == 0 )
00573                     Abc_NtkDeleteObj_rec( pFanin, 1 );
00574             return NULL;
00575         }
00576     // create the topmost node
00577     pObjNew = Abc_NtkCreateNode( pObj->pNtk );
00578     Vec_PtrForEachEntry( p->vLeaves, pFanin, i )
00579         Abc_ObjAddFanin( pObjNew, pFanin );
00580     // create the function
00581     pObjNew->pData = Abc_SopCreateFromTruth( pObj->pNtk->pManFunc, Vec_PtrSize(p->vLeaves), p->uTruth ); // need ISOP
00582     pObjNew->Level = Abc_NodeGetLevel( pObjNew );
00583     return pObjNew;
00584 }

unsigned* Abc_NodeSuperChoiceTruth ( Abc_ManScl_t pManScl  ) 

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

Synopsis [Performs superchoicing for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 340 of file abcLut.c.

00341 {
00342     Abc_Obj_t * pObj;
00343     unsigned * puData0, * puData1, * puData;
00344     char * pSop;
00345     int i, k;
00346     // set elementary truth tables
00347     Vec_PtrForEachEntry( pManScl->vLeaves, pObj, i )
00348         pObj->pNext = (Abc_Obj_t *)pManScl->uVars[i];
00349     // compute truth tables for internal nodes
00350     Vec_PtrForEachEntry( pManScl->vVolume, pObj, i )
00351     {
00352         // set storage for the node's simulation info
00353         pObj->pNext = (Abc_Obj_t *)pManScl->uSims[i];
00354         // get pointer to the simulation info
00355         puData  = (unsigned *)pObj->pNext;
00356         puData0 = (unsigned *)Abc_ObjFanin0(pObj)->pNext;
00357         puData1 = (unsigned *)Abc_ObjFanin1(pObj)->pNext;
00358         // simulate
00359         pSop = pObj->pData;
00360         if ( pSop[0] == '0' && pSop[1] == '0' )
00361             for ( k = 0; k < pManScl->nWords; k++ )
00362                 puData[k] = ~puData0[k] & ~puData1[k];
00363         else if ( pSop[0] == '0' )
00364             for ( k = 0; k < pManScl->nWords; k++ )
00365                 puData[k] = ~puData0[k] & puData1[k];
00366         else if ( pSop[1] == '0' )
00367             for ( k = 0; k < pManScl->nWords; k++ )
00368                 puData[k] = puData0[k] & ~puData1[k];
00369         else 
00370             for ( k = 0; k < pManScl->nWords; k++ )
00371                 puData[k] = puData0[k] & puData1[k];
00372     }
00373     return puData;
00374 }

Cut_Man_t * Abc_NtkStartCutManForScl ( Abc_Ntk_t pNtk,
int  nLutSize 
) [static]

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

Synopsis [Starts the cut manager for rewriting.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file abcLut.c.

00246 {
00247     static Cut_Params_t Params, * pParams = &Params;
00248     Cut_Man_t * pManCut;
00249     Abc_Obj_t * pObj;
00250     int i;
00251     // start the cut manager
00252     memset( pParams, 0, sizeof(Cut_Params_t) );
00253     pParams->nVarsMax  = nLutSize; // the max cut size ("k" of the k-feasible cuts)
00254     pParams->nKeepMax  = 500;   // the max number of cuts kept at a node
00255     pParams->fTruth    = 0;     // compute truth tables
00256     pParams->fFilter   = 1;     // filter dominated cuts
00257     pParams->fSeq      = 0;     // compute sequential cuts
00258     pParams->fDrop     = 0;     // drop cuts on the fly
00259     pParams->fVerbose  = 0;     // the verbosiness flag
00260     pParams->nIdsMax   = Abc_NtkObjNumMax( pNtk );
00261     pManCut = Cut_ManStart( pParams );
00262     if ( pParams->fDrop )
00263         Cut_ManSetFanoutCounts( pManCut, Abc_NtkFanoutCounts(pNtk) );
00264     // set cuts for PIs
00265     Abc_NtkForEachCi( pNtk, pObj, i )
00266         if ( Abc_ObjFanoutNum(pObj) > 0 )
00267             Cut_NodeSetTriv( pManCut, pObj->Id );
00268     return pManCut;
00269 }

int Abc_NtkSuperChoiceLut ( Abc_Ntk_t pNtk,
int  nLutSize,
int  nCutSizeMax,
int  fVerbose 
)

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

Synopsis [Performs superchoicing for K-LUTs.]

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file abcLut.c.

00078 {
00079     ProgressBar * pProgress;
00080     Abc_ManCut_t * pManCut;
00081     Abc_ManScl_t * pManScl;
00082     Cut_Man_t * pManCuts;
00083     Abc_Obj_t * pObj, * pFanin, * pObjTop;
00084     int i, LevelMax, nNodes;
00085     int nNodesTried, nNodesDec, nNodesExist, nNodesUsed;
00086 
00087     assert( Abc_NtkIsSopLogic(pNtk) );
00088     if ( nLutSize < 3 || nLutSize > SCL_LUT_MAX )
00089     {
00090         printf( "LUT size (%d) does not belong to the interval: 3 <= LUT size <= %d\n", nLutSize, SCL_LUT_MAX );
00091         return 0;
00092     }
00093     if ( nCutSizeMax <= nLutSize || nCutSizeMax > SCL_VARS_MAX )
00094     {
00095         printf( "Cut size (%d) does not belong to the interval: LUT size (%d) < Cut size <= %d\n", nCutSizeMax, nLutSize, SCL_VARS_MAX );
00096         return 0;
00097     }
00098 
00099     assert( nLutSize <= SCL_LUT_MAX );
00100     assert( nCutSizeMax <= SCL_VARS_MAX );
00101     nNodesTried = nNodesDec = nNodesExist = nNodesUsed = 0;
00102 
00103     // set the delays of the CIs
00104     Abc_NtkForEachCi( pNtk, pObj, i )
00105         pObj->Level = 0;
00106 
00107 //Abc_NtkLevel( pNtk );
00108  
00109     // start the managers
00110     pManScl = Abc_ManSclStart( nLutSize, nCutSizeMax, 1000 );
00111     pManCuts = Abc_NtkStartCutManForScl( pNtk, nLutSize );
00112     pManCut = Abc_NtkManCutStart( nCutSizeMax, 100000, 100000, 100000 );
00113     s_pLeaves = Abc_NtkManCutReadCutSmall( pManCut );
00114     pManScl->vVolume = Abc_NtkManCutReadVisited( pManCut );
00115 
00116     // process each internal node (assuming topological order of nodes!!!)
00117     nNodes = Abc_NtkObjNumMax(pNtk);
00118     pProgress = Extra_ProgressBarStart( stdout, nNodes );
00119     Abc_NtkForEachObj( pNtk, pObj, i )
00120     {
00121 //        if ( i != nNodes-1 )
00122 //            continue;
00123         Extra_ProgressBarUpdate( pProgress, i, NULL );
00124         if ( i >= nNodes )
00125             break;
00126         if ( Abc_ObjFaninNum(pObj) != 2 )
00127             continue;
00128         nNodesTried++;
00129 
00130         // map this node using regular cuts
00131 //        pObj->Level = 0;
00132         Abc_NodeLutMap( pManCuts, pObj );
00133         // compute the cut
00134         pManScl->vLeaves = Abc_NodeFindCut( pManCut, pObj, 0 );
00135         if ( Vec_PtrSize(pManScl->vLeaves) <= nLutSize )
00136             continue;
00137         // get the volume of the cut
00138         if ( Vec_PtrSize(pManScl->vVolume) > SCL_NODE_MAX )
00139             continue;
00140         nNodesDec++;
00141 
00142         // decompose the cut
00143         pObjTop = Abc_NodeSuperChoiceLut( pManScl, pObj );
00144         if ( pObjTop == NULL )
00145             continue;
00146         nNodesExist++;
00147 
00148         // if there is no delay improvement, skip; otherwise, update level
00149         if ( pObjTop->Level >= pObj->Level )
00150         {
00151             Abc_NtkDeleteObj_rec( pObjTop, 1 );
00152             continue;
00153         }
00154         pObj->Level = pObjTop->Level;
00155         nNodesUsed++;
00156     }
00157     Extra_ProgressBarStop( pProgress );
00158 
00159     // delete the managers
00160     Abc_ManSclStop( pManScl );
00161     Abc_NtkManCutStop( pManCut );
00162     Cut_ManStop( pManCuts );
00163 
00164     // get the largest arrival time
00165     LevelMax = 0;
00166     Abc_NtkForEachCo( pNtk, pObj, i )
00167     {
00168         pFanin = Abc_ObjFanin0( pObj );
00169         // skip inv/buf
00170         if ( Abc_ObjFaninNum(pFanin) == 1 )
00171             pFanin = Abc_ObjFanin0( pFanin );
00172         // get the new level
00173         LevelMax = ABC_MAX( LevelMax, (int)pFanin->Level );
00174     }
00175 
00176     if ( fVerbose )
00177     printf( "Try = %d. Dec = %d. Exist = %d. Use = %d. SUPER = %d levels of %d-LUTs.\n", 
00178         nNodesTried, nNodesDec, nNodesExist, nNodesUsed, LevelMax, nLutSize );
00179 //    if ( fVerbose )
00180 //    printf( "The network is superchoiced for %d levels of %d-LUTs.\n", LevelMax, nLutSize );
00181 
00182     // clean the data field
00183     Abc_NtkForEachObj( pNtk, pObj, i )
00184         pObj->pNext = NULL;
00185 
00186     // check
00187     if ( !Abc_NtkCheck( pNtk ) )
00188     {
00189         printf( "Abc_NtkSuperChoiceLut: The network check has failed.\n" );
00190         return 0;
00191     }
00192     return 1;
00193 }


Variable Documentation

Vec_Ptr_t* s_pLeaves = NULL [static]

Definition at line 52 of file abcLut.c.


Generated on Tue Jan 5 12:18:37 2010 for abc70930 by  doxygen 1.6.1