summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifCache.c
blob: c36139d9af8bb21ae9a6c2d3b003469ac99b8b36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**CFile****************************************************************

  FileName    [ifCache.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [FPGA mapping based on priority cuts.]

  Synopsis    []

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - November 21, 2006.]

  Revision    [$Id: ifCache.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]

***********************************************************************/

#include "if.h"
#include "misc/vec/vecHsh.h"

ABC_NAMESPACE_IMPL_START

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd )
{
    assert( nShared >= 0 && nShared <= p->pPars->nLutSize );
    if ( p->vCutData == NULL )
        p->vCutData = Vec_IntAlloc( 10000 );
    if ( iDsd0 > iDsd1 )
        ABC_SWAP( int, iDsd0, iDsd1 );
    Vec_IntPush( p->vCutData, iDsd0 );
    Vec_IntPush( p->vCutData, iDsd1 );
    Vec_IntPush( p->vCutData, nShared );
    Vec_IntPush( p->vCutData, iDsd );
//    printf( "%6d %6d %6d %6d\n", iDsd0, iDsd1, nShared, iDsd );
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void If_ManCacheAnalize( If_Man_t * p )
{
    Vec_Int_t * vRes, * vTest[32];
    int i, Entry, uUnique;
    vRes = Hsh_IntManHashArray( p->vCutData, 4 );
    for ( i = 0; i <= p->pPars->nLutSize; i++ )
        vTest[i] = Vec_IntAlloc( 1000 );
    Vec_IntForEachEntry( vRes, Entry, i )
        Vec_IntPush( vTest[Vec_IntEntry(p->vCutData, 4*i+2)], Entry );
    for ( i = 0; i <= p->pPars->nLutSize; i++ )
    {
        uUnique = Vec_IntCountUnique(vTest[i]);
        printf( "%2d-var entries = %8d. (%6.2f %%)  Unique entries = %8d. (%6.2f %%)\n", 
            i, Vec_IntSize(vTest[i]), 100.0*Vec_IntSize(vTest[i])/Abc_MaxInt(1, Vec_IntSize(vRes)), 
            uUnique, 100.0*uUnique/Abc_MaxInt(1, Vec_IntSize(vTest[i])) );
    }
    for ( i = 0; i <= p->pPars->nLutSize; i++ )
        Vec_IntFree( vTest[i] );
    uUnique = Vec_IntCountUnique(vRes);
    printf( "Total  entries = %8d. (%6.2f %%)  Unique entries = %8d. (%6.2f %%)\n", 
        Vec_IntSize(p->vCutData)/4, 100.0, uUnique, 100.0*uUnique/Abc_MaxInt(1, Vec_IntSize(p->vCutData)/4) );
    Vec_IntFree( vRes );
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


ABC_NAMESPACE_IMPL_END