src/opt/fxu/fxuReduce.c File Reference

#include "abc.h"
#include "fxuInt.h"
#include "fxu.h"
Include dependency graph for fxuReduce.c:

Go to the source code of this file.

Functions

static int Fxu_CountPairDiffs (char *pCover, unsigned char pDiffs[])
int Fxu_PreprocessCubePairs (Fxu_Matrix *p, Vec_Ptr_t *vCovers, int nPairsTotal, int nPairsMax)

Function Documentation

int Fxu_CountPairDiffs ( char *  pCover,
unsigned char  pDiffs[] 
) [static]

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

FileName [fxuReduce.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [Procedures to reduce the number of considered cube pairs.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
fxuReduce.c,v 1.0 2003/02/01 00:00:00 alanmi Exp

] DECLARATIONS ///

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

Synopsis [Counts the differences in each cube pair in the cover.]

Description [Takes the cover (pCover) and the array where the diff counters go (pDiffs). The array pDiffs should have as many entries as there are different pairs of cubes in the cover: n(n-1)/2. Fills out the array pDiffs with the following info: For each cube pair, included in the array is the number of literals in both cubes after they are made cube free.]

SideEffects []

SeeAlso []

Definition at line 181 of file fxuReduce.c.

00182 {
00183     char * pCube1, * pCube2;
00184     int nOnes, nCubePairs, nFanins, v;
00185     nCubePairs = 0;
00186     nFanins = Abc_SopGetVarNum(pCover);
00187     Abc_SopForEachCube( pCover, nFanins, pCube1 )
00188     Abc_SopForEachCube( pCube1, nFanins, pCube2 )
00189     {
00190         if ( pCube1 == pCube2 )
00191             continue;
00192         nOnes = 0;
00193         for ( v = 0; v < nFanins; v++ )
00194             nOnes += (pCube1[v] != pCube2[v]);
00195         pDiffs[nCubePairs++] = nOnes;
00196     }
00197     return 1;
00198 }

int Fxu_PreprocessCubePairs ( Fxu_Matrix p,
Vec_Ptr_t vCovers,
int  nPairsTotal,
int  nPairsMax 
)

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

Synopsis [Precomputes the pairs to use for creating two-cube divisors.]

Description [This procedure takes the matrix with variables and cubes allocated (p), the original covers of the nodes (i-sets) and their number (ppCovers,nCovers). The maximum number of pairs to compute and the total number of pairs in existence. This procedure adds to the storage of divisors exactly the given number of pairs (nPairsMax) while taking first those pairs that have the smallest number of literals in their cube-free form.]

SideEffects []

SeeAlso []

Definition at line 50 of file fxuReduce.c.

00051 {
00052     unsigned char * pnLitsDiff;   // storage for the counters of diff literals
00053     int * pnPairCounters;         // the counters of pairs for each number of diff literals
00054     Fxu_Cube * pCubeFirst, * pCubeLast;
00055     Fxu_Cube * pCube1, * pCube2;
00056     Fxu_Var * pVar;
00057     int nCubes, nBitsMax, nSum;
00058     int CutOffNum, CutOffQuant;
00059     int iPair, iQuant, k, c;
00060     int clk = clock();
00061     char * pSopCover;
00062     int nFanins;
00063 
00064     assert( nPairsMax < nPairsTotal );
00065 
00066     // allocate storage for counter of diffs
00067     pnLitsDiff = ALLOC( unsigned char, nPairsTotal );
00068     // go through the covers and precompute the distances between the pairs
00069     iPair    =  0;
00070     nBitsMax = -1;
00071     for ( c = 0; c < vCovers->nSize; c++ )
00072         if ( pSopCover = vCovers->pArray[c] )
00073         {
00074             nFanins = Abc_SopGetVarNum(pSopCover);
00075             // precompute the differences
00076             Fxu_CountPairDiffs( pSopCover, pnLitsDiff + iPair );
00077             // update the counter
00078             nCubes = Abc_SopGetCubeNum( pSopCover );
00079             iPair += nCubes * (nCubes - 1) / 2;
00080             if ( nBitsMax < nFanins )
00081                 nBitsMax = nFanins;
00082         }
00083     assert( iPair == nPairsTotal );
00084 
00085     // allocate storage for counters of cube pairs by difference
00086     pnPairCounters = ALLOC( int, 2 * nBitsMax );
00087     memset( pnPairCounters, 0, sizeof(int) * 2 * nBitsMax );
00088     // count the number of different pairs
00089     for ( k = 0; k < nPairsTotal; k++ )
00090         pnPairCounters[ pnLitsDiff[k] ]++;
00091     // determine what pairs to take starting from the lower
00092     // so that there would be exactly pPairsMax pairs
00093     if ( pnPairCounters[0] != 0 )
00094     {
00095         printf( "The SOPs of the nodes are not cube-free. Run \"bdd; sop\" before \"fx\".\n" );
00096         return 0;
00097     }
00098     if ( pnPairCounters[1] != 0 )
00099     {
00100         printf( "The SOPs of the nodes are not SCC-free. Run \"bdd; sop\" before \"fx\".\n" );
00101         return 0;
00102     }
00103     assert( pnPairCounters[0] == 0 ); // otherwise, covers are not dup-free
00104     assert( pnPairCounters[1] == 0 ); // otherwise, covers are not SCC-free
00105     nSum = 0;
00106     for ( k = 0; k < 2 * nBitsMax; k++ )
00107     {
00108         nSum += pnPairCounters[k];
00109         if ( nSum >= nPairsMax )
00110         {
00111             CutOffNum   = k;
00112             CutOffQuant = pnPairCounters[k] - (nSum - nPairsMax);
00113             break;
00114         }
00115     }
00116     FREE( pnPairCounters );
00117 
00118     // set to 0 all the pairs above the cut-off number and quantity
00119     iQuant = 0;
00120     iPair  = 0;
00121     for ( k = 0; k < nPairsTotal; k++ )
00122         if ( pnLitsDiff[k] > CutOffNum ) 
00123             pnLitsDiff[k] = 0;
00124         else if ( pnLitsDiff[k] == CutOffNum )
00125         {
00126             if ( iQuant++ >= CutOffQuant )
00127                 pnLitsDiff[k] = 0;
00128             else
00129                 iPair++;
00130         }
00131         else
00132             iPair++;
00133     assert( iPair == nPairsMax );
00134 
00135     // collect the corresponding pairs and add the divisors
00136     iPair = 0;
00137     for ( c = 0; c < vCovers->nSize; c++ )
00138         if ( pSopCover = vCovers->pArray[c] )
00139         {
00140             // get the var
00141             pVar = p->ppVars[2*c+1];
00142             // get the first cube
00143             pCubeFirst = pVar->pFirst;
00144             // get the last cube
00145             pCubeLast = pCubeFirst;
00146             for ( k = 0; k < pVar->nCubes; k++ )
00147                 pCubeLast = pCubeLast->pNext;
00148             assert( pCubeLast == NULL || pCubeLast->pVar != pVar );
00149 
00150             // go through the cube pairs
00151                     for ( pCube1 = pCubeFirst; pCube1 != pCubeLast; pCube1 = pCube1->pNext )
00152                             for ( pCube2 = pCube1->pNext; pCube2 != pCubeLast; pCube2 = pCube2->pNext )
00153                     if ( pnLitsDiff[iPair++] )
00154                     {   // create the divisors for this pair
00155                             Fxu_MatrixAddDivisor( p, pCube1, pCube2 );
00156                     }
00157         }
00158     assert( iPair == nPairsTotal );
00159     FREE( pnLitsDiff );
00160 //PRT( "Preprocess", clock() - clk );
00161     return 1;
00162 }


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