Exemplo n.º 1
0
/**Function*************************************************************

  Synopsis    [Computes and adds all single-cube divisors to storage.]

  Description [This procedure should be called once when the matrix is
  already contructed before the process of logic extraction begins..]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fxu_MatrixComputeSingles( Fxu_Matrix * p )
{
    Fxu_Var * pVar;
    // iterate through the columns in the matrix
    Fxu_MatrixForEachVariable( p, pVar )
        Fxu_MatrixComputeSinglesOne( p, pVar );
}
Exemplo n.º 2
0
/**Function*************************************************************

  Synopsis    [Computes and adds all single-cube divisors to storage.]

  Description [This procedure should be called once when the matrix is
  already contructed before the process of logic extraction begins..]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax )
{
    Fxu_Var * pVar;
    Vec_Ptr_t * vSingles;
    int i, k;
    // set the weight limit
    p->nWeightLimit = 1 - fUse0;
    // iterate through columns in the matrix and collect single-cube divisors
    vSingles = Vec_PtrAlloc( 10000 );
    Fxu_MatrixForEachVariable( p, pVar )
        Fxu_MatrixComputeSinglesOneCollect( p, pVar, vSingles );
    p->nSingleTotal = Vec_PtrSize(vSingles) / 3;
    // check if divisors should be filtered
    if ( Vec_PtrSize(vSingles) > nSingleMax )
    {
        int * pWeigtCounts, nDivCount, Weight, i, c;;
        assert( Vec_PtrSize(vSingles) % 3 == 0 );
        // count how many divisors have the given weight
        pWeigtCounts = ABC_ALLOC( int, 1000 );
        memset( pWeigtCounts, 0, sizeof(int) * 1000 );
        for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 )
        {
            Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i);
            if ( Weight >= 999 )
                pWeigtCounts[999]++;
            else
                pWeigtCounts[Weight]++;
        }
        // select the bound on the weight (above this bound, singles will be included)
        nDivCount = 0;
        for ( c = 999; c >= 0; c-- )
        {
            nDivCount += pWeigtCounts[c];
            if ( nDivCount >= nSingleMax )
                break;
        }
        ABC_FREE( pWeigtCounts );
        // collect singles with the given costs
        k = 0;
        for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 )
        {
            Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i);
            if ( Weight < c )
                continue;
            Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i-2) );
            Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i-1) );
            Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i) );
            if ( k/3 == nSingleMax )
                break;
        }
        Vec_PtrShrink( vSingles, k );
        // adjust the weight limit
        p->nWeightLimit = c;
    }
Exemplo n.º 3
0
/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fxu_MatrixPrint( FILE * pFile, Fxu_Matrix * p )
{
	Fxu_Var * pVar;
	Fxu_Cube * pCube;
	Fxu_Double * pDiv;
    Fxu_Single * pSingle;
	Fxu_Lit * pLit;
	Fxu_Pair * pPair;
	int i, LastNum;
	int fStdout;

	fStdout = 1;
	if ( pFile == NULL )
	{
		pFile = fopen( "matrix.txt", "w" );
		fStdout = 0;
	}

	fprintf( pFile, "Matrix has %d vars, %d cubes, %d literals, %d divisors.\n", 
		p->lVars.nItems, p->lCubes.nItems, p->nEntries, p->nDivs );
	fprintf( pFile, "Divisors selected so far: single = %d, double = %d.\n", 
		p->nDivs1, p->nDivs2 );
	fprintf( pFile, "\n" );

	// print the numbers on top of the matrix
	for ( i = 0; i < 12; i++ )
		fprintf( pFile, " " );
	Fxu_MatrixForEachVariable( p, pVar )
		fprintf( pFile, "%d", pVar->iVar % 10 );
	fprintf( pFile, "\n" );

	// print the rows
	Fxu_MatrixForEachCube( p, pCube )
	{
		fprintf( pFile, "%4d", pCube->iCube );
		fprintf( pFile, "  " );
		fprintf( pFile, "%4d", pCube->pVar->iVar );
		fprintf( pFile, "  " );

		// print the literals
		LastNum = -1;
		Fxu_CubeForEachLiteral( pCube, pLit )
		{
			for ( i = LastNum + 1; i < pLit->pVar->iVar; i++ )
				fprintf( pFile, "." );
			fprintf( pFile, "1" );
			LastNum = i;
		}
		for ( i = LastNum + 1; i < p->lVars.nItems; i++ )
			fprintf( pFile, "." );
		fprintf( pFile, "\n" );
	}