summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifSeq.c
blob: bc4ab8062ae3e8141042011b067decf688a970e6 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**CFile****************************************************************

  FileName    [ifSeq.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [FPGA mapping based on priority cuts.]

  Synopsis    [Sequential mapping.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

#include "if.h"

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

static void If_ObjPerformMappingLI( If_Man_t * p, If_Obj_t * pLatch );
static void If_ObjPerformMappingLO( If_Man_t * p, If_Obj_t * pLatch, If_Obj_t * pObj );
static int  If_ManMappingSeqConverged( If_Man_t * p );

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

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

  Synopsis    [Performs sequential mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int If_ManPerformMappingSeq( If_Man_t * p )
{
    If_Obj_t * pObj, * pLatch;
    int i, clkTotal = clock();
    // set the number of cuts used
    p->nCutsUsed = p->pPars->nCutsMax;
    // set arrival times and trivial cuts at const 1 and PIs
    If_ManConst1(p)->Cuts[0].Delay = 0.0;
    If_ManForEachPi( p, pObj, i )
        pObj->Cuts[0].Delay = p->pPars->pTimesArr[i];
    // set the fanout estimates of the PIs
    If_ManForEachPi( p, pObj, i )
        pObj->EstRefs = (float)1.0;
    // delay oriented mapping
    p->pPars->fFancy = 1;
    If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 0 );
    p->pPars->fFancy = 0;

    // perform iterations over the circuit
    while ( !If_ManMappingSeqConverged( p ) )
    {
        // assign cuts to latches
        If_ManForEachLatch( p, pLatch, i )
            If_ObjPerformMappingLI( p, pLatch );
        // assign cuts to primary inputs
        If_ManForEachLatch( p, pLatch, i )
            If_ObjPerformMappingLO( p, pLatch, If_ManPi(p, If_ManPiNum(p) - If_ManPoNum(p) + i) );
        // map the nodes
        If_ManForEachNode( p, pObj, i )
            If_ObjPerformMapping( p, pObj, 0 );
    }

    if ( p->pPars->fVerbose )
    {
        PRT( "Total time", clock() - clkTotal );
    }
    return 1;
}

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

  Synopsis    [Performs sequential mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void If_CutLift( If_Cut_t * pCut )
{
    unsigned i;
    for ( i = 0; i < pCut->nLeaves; i++ )
        pCut->pLeaves[i] = ((pCut->pLeaves[i] >> 8) << 8) | ((pCut->pLeaves[i] & 255) + 1);
}

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

  Synopsis    [Performs sequential mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void If_ObjPerformMappingLI( If_Man_t * p, If_Obj_t * pLatch )
{
    If_Obj_t * pFanin;
    int c;
    assert( If_ObjIsPo(pLatch) );
    pFanin = If_ObjFanin0(pLatch);
    for ( c = 0; c < pFanin->nCuts; c++ )
        If_CutCopy( pLatch->Cuts + c, pFanin->Cuts + c );
}

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

  Synopsis    [Performs sequential mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void If_ObjPerformMappingLO( If_Man_t * p, If_Obj_t * pLatch, If_Obj_t * pObj )
{
    If_Cut_t * pCut;
    int c, Limit = IF_MIN( p->nCuts + 1, p->nCutsUsed );
    assert( If_ObjIsPo(pLatch) );
    for ( c = 1; c < Limit; c++ )
    {
        pCut = pObj->Cuts + c;
        If_CutCopy( pCut, pLatch->Cuts + c - 1 );
        If_CutLift( pCut );
        pCut->Delay -= p->Fi;
    }
}

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

  Synopsis    [Performs sequential mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int If_ManMappingSeqConverged( If_Man_t * p )
{
    return 0;
}


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