src/opt/cut/cutCut.c File Reference

#include "cutInt.h"
Include dependency graph for cutCut.c:

Go to the source code of this file.

Functions

Cut_Cut_tCut_CutAlloc (Cut_Man_t *p)
void Cut_CutRecycle (Cut_Man_t *p, Cut_Cut_t *pCut)
int Cut_CutCompare (Cut_Cut_t *pCut1, Cut_Cut_t *pCut2)
Cut_Cut_tCut_CutDupList (Cut_Man_t *p, Cut_Cut_t *pList)
void Cut_CutRecycleList (Cut_Man_t *p, Cut_Cut_t *pList)
int Cut_CutCountList (Cut_Cut_t *pList)
Cut_Cut_tCut_CutMergeLists (Cut_Cut_t *pList1, Cut_Cut_t *pList2)
void Cut_CutNumberList (Cut_Cut_t *pList)
Cut_Cut_tCut_CutCreateTriv (Cut_Man_t *p, int Node)
void Cut_CutPrint (Cut_Cut_t *pCut, int fSeq)
void Cut_CutPrintList (Cut_Cut_t *pList, int fSeq)
void Cut_CutPrintMerge (Cut_Cut_t *pCut, Cut_Cut_t *pCut0, Cut_Cut_t *pCut1)

Function Documentation

Cut_Cut_t* Cut_CutAlloc ( Cut_Man_t p  ) 

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

FileName [cutNode.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [K-feasible cut computation package.]

Synopsis [Procedures to compute cuts for a node.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Allocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file cutCut.c.

00043 {
00044     Cut_Cut_t * pCut;
00045     // cut allocation
00046     pCut = (Cut_Cut_t *)Extra_MmFixedEntryFetch( p->pMmCuts );
00047     memset( pCut, 0, sizeof(Cut_Cut_t) );
00048     pCut->nVarsMax   = p->pParams->nVarsMax;
00049     pCut->fSimul     = p->fSimul;
00050     // statistics
00051     p->nCutsAlloc++;
00052     p->nCutsCur++;
00053     if ( p->nCutsPeak < p->nCutsAlloc - p->nCutsDealloc )
00054         p->nCutsPeak = p->nCutsAlloc - p->nCutsDealloc;
00055     return pCut;
00056 }

int Cut_CutCompare ( Cut_Cut_t pCut1,
Cut_Cut_t pCut2 
)

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

Synopsis [Compares two cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file cutCut.c.

00090 {
00091     int i;
00092     if ( pCut1->nLeaves < pCut2->nLeaves )
00093         return -1;
00094     if ( pCut1->nLeaves > pCut2->nLeaves )
00095         return 1;
00096     for ( i = 0; i < (int)pCut1->nLeaves; i++ )
00097     {
00098         if ( pCut1->pLeaves[i] < pCut2->pLeaves[i] )
00099             return -1;
00100         if ( pCut1->pLeaves[i] > pCut2->pLeaves[i] )
00101             return 1;
00102     }
00103     return 0;
00104 }

int Cut_CutCountList ( Cut_Cut_t pList  ) 

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

Synopsis [Counts the number of cuts in the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file cutCut.c.

00164 {
00165     int Counter = 0;
00166     Cut_ListForEachCut( pList, pList )
00167         Counter++;
00168     return Counter;
00169 }

Cut_Cut_t* Cut_CutCreateTriv ( Cut_Man_t p,
int  Node 
)

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

Synopsis [Creates the trivial cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 235 of file cutCut.c.

00236 {
00237     Cut_Cut_t * pCut;
00238     if ( p->pParams->fSeq )
00239         Node <<= CUT_SHIFT;
00240     pCut = Cut_CutAlloc( p );
00241     pCut->nLeaves    = 1;
00242     pCut->pLeaves[0] = Node;
00243     pCut->uSign      = Cut_NodeSign( Node );
00244     if ( p->pParams->fTruth )
00245     {
00246 /*
00247         if ( pCut->nVarsMax == 4 )
00248             Cut_CutWriteTruth( pCut, p->uTruthVars[0] );
00249         else
00250             Extra_BitCopy( pCut->nLeaves, p->uTruths[0], (uint8*)Cut_CutReadTruth(pCut) );
00251 */
00252         unsigned * pTruth = Cut_CutReadTruth(pCut);
00253         int i;
00254         for ( i = 0; i < p->nTruthWords; i++ )
00255             pTruth[i] = 0xAAAAAAAA;
00256     }
00257     p->nCutsTriv++;
00258     return pCut;
00259 } 

Cut_Cut_t* Cut_CutDupList ( Cut_Man_t p,
Cut_Cut_t pList 
)

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

Synopsis [Duplicates the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file cutCut.c.

00118 {
00119     Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
00120     Cut_Cut_t * pTemp, * pCopy;
00121     if ( pList == NULL )
00122         return NULL;
00123     Cut_ListForEachCut( pList, pTemp )
00124     {
00125         pCopy = (Cut_Cut_t *)Extra_MmFixedEntryFetch( p->pMmCuts );
00126         memcpy( pCopy, pTemp, p->EntrySize );
00127         *ppTail = pCopy;
00128         ppTail = &pCopy->pNext;
00129     }
00130     *ppTail = NULL;
00131     return pHead;
00132 }

Cut_Cut_t* Cut_CutMergeLists ( Cut_Cut_t pList1,
Cut_Cut_t pList2 
)

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

Synopsis [Merges two NULL-terminated linked lists.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file cutCut.c.

00183 {
00184     Cut_Cut_t * pList = NULL, ** ppTail = &pList;
00185     Cut_Cut_t * pCut;
00186     while ( pList1 && pList2 )
00187     {
00188         if ( Cut_CutCompare(pList1, pList2) < 0 )
00189         {
00190             pCut = pList1;
00191             pList1 = pList1->pNext;
00192         }
00193         else
00194         {
00195             pCut = pList2;
00196             pList2 = pList2->pNext;
00197         }
00198         *ppTail = pCut;
00199         ppTail = &pCut->pNext;
00200     }
00201     *ppTail = pList1? pList1: pList2;
00202     return pList;
00203 }

void Cut_CutNumberList ( Cut_Cut_t pList  ) 

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

Synopsis [Sets the number of the cuts in the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 216 of file cutCut.c.

00217 {
00218     Cut_Cut_t * pCut;
00219     int i = 0;
00220     Cut_ListForEachCut( pList, pCut )
00221         pCut->Num0 = i++;
00222 }

void Cut_CutPrint ( Cut_Cut_t pCut,
int  fSeq 
)

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

Synopsis [Print the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file cutCut.c.

00274 {
00275     int i;
00276     assert( pCut->nLeaves > 0 );
00277     printf( "%d : {", pCut->nLeaves );
00278     for ( i = 0; i < (int)pCut->nLeaves; i++ )
00279     {
00280         if ( fSeq )
00281         {
00282             printf( " %d", pCut->pLeaves[i] >> CUT_SHIFT );
00283             if ( pCut->pLeaves[i] & CUT_MASK )
00284                 printf( "(%d)", pCut->pLeaves[i] & CUT_MASK );
00285         }
00286         else
00287             printf( " %d", pCut->pLeaves[i] );
00288     }
00289     printf( " }" );
00290 //    printf( "\nSign = " );
00291 //    Extra_PrintBinary( stdout, &pCut->uSign, 32 );
00292 }

void Cut_CutPrintList ( Cut_Cut_t pList,
int  fSeq 
)

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

Synopsis [Print the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 305 of file cutCut.c.

00306 {
00307     Cut_Cut_t * pCut;
00308     for ( pCut = pList; pCut; pCut = pCut->pNext )
00309         Cut_CutPrint( pCut, fSeq ), printf( "\n" );
00310 }

void Cut_CutPrintMerge ( Cut_Cut_t pCut,
Cut_Cut_t pCut0,
Cut_Cut_t pCut1 
)

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

Synopsis [Consider dropping cuts if they are useless by now.]

Description []

SideEffects []

SeeAlso []

Definition at line 323 of file cutCut.c.

00324 {
00325     printf( "\n" );
00326     printf( "%d : %5d %5d %5d %5d %5d\n", 
00327         pCut0->nLeaves, 
00328         pCut0->nLeaves > 0 ? pCut0->pLeaves[0] : -1, 
00329         pCut0->nLeaves > 1 ? pCut0->pLeaves[1] : -1, 
00330         pCut0->nLeaves > 2 ? pCut0->pLeaves[2] : -1, 
00331         pCut0->nLeaves > 3 ? pCut0->pLeaves[3] : -1, 
00332         pCut0->nLeaves > 4 ? pCut0->pLeaves[4] : -1
00333         );
00334     printf( "%d : %5d %5d %5d %5d %5d\n", 
00335         pCut1->nLeaves, 
00336         pCut1->nLeaves > 0 ? pCut1->pLeaves[0] : -1, 
00337         pCut1->nLeaves > 1 ? pCut1->pLeaves[1] : -1, 
00338         pCut1->nLeaves > 2 ? pCut1->pLeaves[2] : -1, 
00339         pCut1->nLeaves > 3 ? pCut1->pLeaves[3] : -1, 
00340         pCut1->nLeaves > 4 ? pCut1->pLeaves[4] : -1
00341         );
00342     if ( pCut == NULL )
00343         printf( "Cannot merge\n" );
00344     else
00345         printf( "%d : %5d %5d %5d %5d %5d\n", 
00346             pCut->nLeaves, 
00347             pCut->nLeaves > 0 ? pCut->pLeaves[0] : -1, 
00348             pCut->nLeaves > 1 ? pCut->pLeaves[1] : -1, 
00349             pCut->nLeaves > 2 ? pCut->pLeaves[2] : -1, 
00350             pCut->nLeaves > 3 ? pCut->pLeaves[3] : -1, 
00351             pCut->nLeaves > 4 ? pCut->pLeaves[4] : -1
00352             );
00353 }

void Cut_CutRecycle ( Cut_Man_t p,
Cut_Cut_t pCut 
)

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

Synopsis [Recybles the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file cutCut.c.

00070 {
00071     p->nCutsDealloc++;
00072     p->nCutsCur--;
00073     if ( pCut->nLeaves == 1 )
00074         p->nCutsTriv--;
00075     Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
00076 }

void Cut_CutRecycleList ( Cut_Man_t p,
Cut_Cut_t pList 
)

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

Synopsis [Recycles the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file cutCut.c.

00146 {
00147     Cut_Cut_t * pCut, * pCut2;
00148     Cut_ListForEachCutSafe( pList, pCut, pCut2 )
00149         Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
00150 }


Generated on Tue Jan 5 12:19:23 2010 for abc70930 by  doxygen 1.6.1