src/aig/rwt/rwtUtil.c File Reference

#include "rwt.h"
Include dependency graph for rwtUtil.c:

Go to the source code of this file.

Functions

void Rwt_ListAddToTail (Rwt_Node_t **ppList, Rwt_Node_t *pNode)
Rwt_Node_tRwt_ManAddVar (Rwt_Man_t *p, unsigned uTruth, int fPrecompute)
Rwt_Node_tRwt_ManAddNode (Rwt_Man_t *p, Rwt_Node_t *p0, Rwt_Node_t *p1, int fExor, int Level, int Volume)
void Rwt_Trav_rec (Rwt_Man_t *p, Rwt_Node_t *pNode, int *pVolume)
void Rwt_ManIncTravId (Rwt_Man_t *p)
int Rwt_ManNodeVolume (Rwt_Man_t *p, Rwt_Node_t *p0, Rwt_Node_t *p1)
void Rwt_ManLoadFromArray (Rwt_Man_t *p, int fVerbose)
char * Rwt_ManGetPractical (Rwt_Man_t *p)

Variables

static unsigned short s_RwtPracticalClasses []
static unsigned short s_RwtAigSubgraphs []

Function Documentation

void Rwt_ListAddToTail ( Rwt_Node_t **  ppList,
Rwt_Node_t pNode 
)

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

Synopsis [Adds the node to the end of the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file rwtUtil.c.

00052 {
00053     Rwt_Node_t * pTemp;
00054     // find the last one
00055     for ( pTemp = *ppList; pTemp; pTemp = pTemp->pNext )
00056         ppList = &pTemp->pNext;
00057     // attach at the end
00058     *ppList = pNode;
00059 }

Rwt_Node_t* Rwt_ManAddNode ( Rwt_Man_t p,
Rwt_Node_t p0,
Rwt_Node_t p1,
int  fExor,
int  Level,
int  Volume 
)

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file rwtUtil.c.

00104 {
00105     Rwt_Node_t * pNew;
00106     unsigned uTruth;
00107     // compute truth table, leve, volume
00108     p->nConsidered++;
00109     if ( fExor )
00110         uTruth = (p0->uTruth ^ p1->uTruth);
00111     else
00112         uTruth = (Rwt_IsComplement(p0)? ~Rwt_Regular(p0)->uTruth : Rwt_Regular(p0)->uTruth) & 
00113                  (Rwt_IsComplement(p1)? ~Rwt_Regular(p1)->uTruth : Rwt_Regular(p1)->uTruth) & 0xFFFF;
00114     // create the new node
00115     pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
00116     pNew->Id     = p->vForest->nSize;
00117     pNew->TravId = 0;
00118     pNew->uTruth = uTruth;
00119     pNew->Level  = Level;
00120     pNew->Volume = Volume;
00121     pNew->fUsed  = 0;
00122     pNew->fExor  = fExor;
00123     pNew->p0     = p0;
00124     pNew->p1     = p1;
00125     pNew->pNext  = NULL;
00126     Vec_PtrPush( p->vForest, pNew );
00127     // do not add if the node is not essential
00128     if ( uTruth != p->puCanons[uTruth] )
00129         return pNew;
00130 
00131     // add to the list
00132     p->nAdded++;
00133     if ( p->pTable[uTruth] == NULL )
00134         p->nClasses++;
00135     Rwt_ListAddToTail( p->pTable + uTruth, pNew );
00136     return pNew;
00137 }

Rwt_Node_t* Rwt_ManAddVar ( Rwt_Man_t p,
unsigned  uTruth,
int  fPrecompute 
)

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file rwtUtil.c.

00073 {
00074     Rwt_Node_t * pNew;
00075     pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
00076     pNew->Id     = p->vForest->nSize;
00077     pNew->TravId = 0;
00078     pNew->uTruth = uTruth;
00079     pNew->Level  = 0;
00080     pNew->Volume = 0;
00081     pNew->fUsed  = 1;
00082     pNew->fExor  = 0;
00083     pNew->p0     = NULL;
00084     pNew->p1     = NULL;    
00085     pNew->pNext  = NULL;
00086     Vec_PtrPush( p->vForest, pNew );
00087     if ( fPrecompute )
00088         Rwt_ListAddToTail( p->pTable + uTruth, pNew );
00089     return pNew;
00090 }

char* Rwt_ManGetPractical ( Rwt_Man_t p  ) 

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

Synopsis [Create practical classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 265 of file rwtUtil.c.

00266 {
00267     char * pPractical;
00268     int i;
00269     pPractical = ALLOC( char, p->nFuncs );
00270     memset( pPractical, 0, sizeof(char) * p->nFuncs );
00271     pPractical[0] = 1;
00272     for ( i = 1; ; i++ )
00273     {
00274         if ( s_RwtPracticalClasses[i] == 0 )
00275             break;
00276         pPractical[ s_RwtPracticalClasses[i] ] = 1;
00277     }
00278     return pPractical;
00279 }

void Rwt_ManIncTravId ( Rwt_Man_t p  ) 

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file rwtUtil.c.

00174 {
00175     Rwt_Node_t * pNode;
00176     int i;
00177     if ( p->nTravIds++ < 0x8FFFFFFF )
00178         return;
00179     Vec_PtrForEachEntry( p->vForest, pNode, i )
00180         pNode->TravId = 0;
00181     p->nTravIds = 1;
00182 }

void Rwt_ManLoadFromArray ( Rwt_Man_t p,
int  fVerbose 
)

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

Synopsis [Loads data.]

Description []

SideEffects []

SeeAlso []

Definition at line 215 of file rwtUtil.c.

00216 {
00217     unsigned short * pArray = s_RwtAigSubgraphs;
00218     Rwt_Node_t * p0, * p1;
00219     unsigned Entry0, Entry1;
00220     int Level, Volume, nEntries, fExor;
00221     int i, clk = clock();
00222 
00223     // reconstruct the forest
00224     for ( i = 0; ; i++ )
00225     {
00226         Entry0 = pArray[2*i + 0];
00227         Entry1 = pArray[2*i + 1];
00228         if ( Entry0 == 0 && Entry1 == 0 )
00229             break;
00230         // get EXOR flag
00231         fExor = (Entry0 & 1);
00232         Entry0 >>= 1;
00233         // get the nodes
00234         p0 = p->vForest->pArray[Entry0 >> 1];
00235         p1 = p->vForest->pArray[Entry1 >> 1];
00236         // compute the level and volume of the new nodes
00237         Level  = 1 + RWT_MAX( p0->Level, p1->Level );
00238         Volume = 1 + Rwt_ManNodeVolume( p, p0, p1 );
00239         // set the complemented attributes
00240         p0 = Rwt_NotCond( p0, (Entry0 & 1) );
00241         p1 = Rwt_NotCond( p1, (Entry1 & 1) );
00242         // add the node
00243 //        Rwt_ManTryNode( p, p0, p1, Level, Volume );
00244         Rwt_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
00245     }
00246     nEntries = i - 1;
00247     if ( fVerbose )
00248     {
00249         printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
00250         printf( "The number of nodes loaded = %d.  ", nEntries );  PRT( "Loading", clock() - clk );
00251     }
00252 }

int Rwt_ManNodeVolume ( Rwt_Man_t p,
Rwt_Node_t p0,
Rwt_Node_t p1 
)

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 195 of file rwtUtil.c.

00196 {
00197     int Volume = 0;
00198     Rwt_ManIncTravId( p );
00199     Rwt_Trav_rec( p, p0, &Volume );
00200     Rwt_Trav_rec( p, p1, &Volume );
00201     return Volume;
00202 }

void Rwt_Trav_rec ( Rwt_Man_t p,
Rwt_Node_t pNode,
int *  pVolume 
)

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file rwtUtil.c.

00151 {
00152     if ( pNode->fUsed || pNode->TravId == p->nTravIds )
00153         return;
00154     pNode->TravId = p->nTravIds;
00155     (*pVolume)++;
00156     if ( pNode->fExor )
00157         (*pVolume)++;
00158     Rwt_Trav_rec( p, Rwt_Regular(pNode->p0), pVolume );
00159     Rwt_Trav_rec( p, Rwt_Regular(pNode->p1), pVolume );
00160 }


Variable Documentation

static unsigned short s_RwtAigSubgraphs [static]

Definition at line 33 of file rwtUtil.c.

static unsigned short s_RwtPracticalClasses [static]
Initial value:
 
{
    0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019, 0x001b, 
    0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e, 0x007f, 0x00ff, 
    0x0116, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f, 0x012c, 0x012d, 0x012f, 0x013c, 
    0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016f, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183, 
    0x0186, 0x0189, 0x018b, 0x018f, 0x0198, 0x0199, 0x019b, 0x01a8, 0x01a9, 0x01aa, 0x01ab, 
    0x01ac, 0x01ad, 0x01ae, 0x01af, 0x01bf, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef, 0x01fe, 
    0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b, 0x035f, 0x0368, 
    0x0369, 0x036c, 0x036e, 0x037d, 0x03c0, 0x03c1, 0x03c3, 0x03c7, 0x03cf, 0x03d4, 0x03d5, 
    0x03d7, 0x03d8, 0x03d9, 0x03dc, 0x03dd, 0x03de, 0x03fc, 0x0660, 0x0661, 0x0666, 0x0669, 
    0x066f, 0x0676, 0x067e, 0x0690, 0x0696, 0x0697, 0x069f, 0x06b1, 0x06b6, 0x06f0, 0x06f2, 
    0x06f6, 0x06f9, 0x0776, 0x0778, 0x07b0, 0x07b1, 0x07b4, 0x07bc, 0x07f0, 0x07f2, 0x07f8, 
    0x0ff0, 0x1683, 0x1696, 0x1698, 0x169e, 0x16e9, 0x178e, 0x17e8, 0x18e7, 0x19e6, 0x1be4, 
    0x1ee1, 0x3cc3, 0x6996, 0x0000
}

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

FileName [rwtUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [Various utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] DECLARATIONS ///

END OF FILE ///

Definition at line 32 of file rwtUtil.c.


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