summaryrefslogtreecommitdiffstats
path: root/src/map/pga/pgaCore.c
blob: 240c24fd91da527e22ee1fe8529934afd5876718 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**CFile****************************************************************

  FileName    [pgaCore.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [FPGA mapper.]

  Synopsis    [External APIs of the FPGA manager.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

  Revision    [$Id: pgaCore.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

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

#include "pgaInt.h"

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

static void Pga_MappingInitCis( Pga_Man_t * p );

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

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

  Synopsis    [Performs technology mapping for the given object graph.]

  Description [The object graph is stored in the mapping manager.
  First, all the AND-nodes, which fanout into the POs, are collected
  in the DFS fashion. Next, three steps are performed: the k-feasible
  cuts are computed for each node, the truth tables are computed for
  each cut, and the delay-optimal matches are assigned for each node.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Vec_Ptr_t * Pga_DoMapping( Pga_Man_t * p )
{
    int fShowSwitching = 0;
    float aAreaTotalCur;
    int Iter, clk, clkTotal = clock();
    
    // assign the arrival times of the PIs
    Pga_MappingInitCis( p );

    // map the AIG for delay
clk = clock();
    Pga_MappingMatches( p, 0 );
p->timeDelay = clock() - clk;

    // compute area, set references, and collect nodes used in the mapping
    Iter = 1;
    aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
if ( p->pParams->fVerbose )
{
printf( "Iteration %dD :  Area = %8.1f  ", Iter++, aAreaTotalCur );
if ( fShowSwitching )
printf( "Switch = %8.1f  ", Pga_MappingGetSwitching(p) );
PRT( "Time", p->timeDelay );
}

    if ( p->pParams->fAreaFlow )
    {
clk = clock();
        // compute the required times and the fanouts
        Pga_MappingComputeRequired( p );
        // remap topologically
        Pga_MappingMatches( p, 1 );
p->timeAreaFlow = clock() - clk;
        // get the resulting area
        aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
        // note that here we do not update the reference counter
        // for some reason, this works better on benchmarks
if ( p->pParams->fVerbose )
{
printf( "Iteration %dF :  Area = %8.1f  ", Iter++, aAreaTotalCur );
if ( fShowSwitching )
printf( "Switch = %8.1f  ", Pga_MappingGetSwitching(p) );
PRT( "Time", p->timeAreaFlow );
}
    }

    if ( p->pParams->fArea )
    {
clk = clock();
        // compute the required times and the fanouts
        Pga_MappingComputeRequired( p );
        // remap topologically
        if ( p->pParams->fSwitching )
            Pga_MappingMatches( p, 3 );
        else
            Pga_MappingMatches( p, 2 );
p->timeArea = clock() - clk;
        // get the resulting area
        aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
if ( p->pParams->fVerbose )
{
printf( "Iteration %d%s :  Area = %8.1f  ", Iter++, (p->pParams->fSwitching?"S":"A"), aAreaTotalCur );
if ( fShowSwitching )
printf( "Switch = %8.1f  ", Pga_MappingGetSwitching(p) );
PRT( "Time", p->timeArea );
}
    }
    p->AreaGlobal = aAreaTotalCur;

    if ( p->pParams->fVerbose )
        Pga_MappingPrintOutputArrivals( p );

    // return the mapping
    return Pga_MappingResults( p );
}

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

  Synopsis    [Initializes the CI node arrival times.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Pga_MappingInitCis( Pga_Man_t * p )
{
    Pga_Node_t * pNode;
    float * pCiArrs;
    int i;
    // get the CI arrival times
    pCiArrs = Abc_NtkGetCiArrivalFloats( p->pParams->pNtk );
    // assign the arrival times of the PIs
    Pga_ManForEachCi( p, pNode, i )
        pNode->Match.Delay = pCiArrs[i];
    free( pCiArrs );
}

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