abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fpgaTime.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [fpgaTime.c]
4 
5  PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
6 
7  Synopsis [Technology mapping for variable-size-LUT FPGAs.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 2.0. Started - August 18, 2004.]
14 
15  Revision [$Id: fpgaTime.c,v 1.1 2005/01/23 06:59:42 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "fpgaInt.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 /**Function*************************************************************
33 
34  Synopsis [Computes the arrival times of the cut.]
35 
36  Description [Computes the maximum arrival time of the cut leaves and
37  adds the delay of the LUT.]
38 
39  SideEffects []
40 
41  SeeAlso []
42 
43 ***********************************************************************/
45 {
46  int i;
47  float tArrival;
48  tArrival = -FPGA_FLOAT_LARGE;
49  for ( i = 0; i < pCut->nLeaves; i++ )
50  if ( tArrival < pCut->ppLeaves[i]->pCutBest->tArrival )
51  tArrival = pCut->ppLeaves[i]->pCutBest->tArrival;
52  tArrival += pMan->pLutLib->pLutDelays[(int)pCut->nLeaves][0];
53  return tArrival;
54 }
55 
56 /**Function*************************************************************
57 
58  Synopsis [Computes the arrival times of the cut recursively.]
59 
60  Description [When computing the arrival time for the previously unused
61  cuts, their arrival time may be incorrect because their fanins have
62  incorrect arrival time. This procedure is called to fix this problem.]
63 
64  SideEffects []
65 
66  SeeAlso []
67 
68 ***********************************************************************/
70 {
71  int i;
72  for ( i = 0; i < pCut->nLeaves; i++ )
73  if ( pCut->ppLeaves[i]->nRefs == 0 )
75  return Fpga_TimeCutComputeArrival( pMan, pCut );
76 }
77 
78 /**Function*************************************************************
79 
80  Synopsis [Computes the maximum arrival times.]
81 
82  Description []
83 
84  SideEffects []
85 
86  SeeAlso []
87 
88 ***********************************************************************/
90 {
91  float fRequired;
92  int i;
93  if ( p->fLatchPaths && p->nLatches == 0 )
94  {
95  printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
96  p->fLatchPaths = 0;
97  }
98  // get the critical PO arrival time
99  fRequired = -FPGA_FLOAT_LARGE;
100  if ( p->fLatchPaths )
101  {
102  for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
103  {
104  if ( Fpga_NodeIsConst(p->pOutputs[i]) )
105  continue;
106  fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
107 // printf( " %5.1f", Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
108  }
109 // printf( "Required latches = %5.1f\n", fRequired );
110  }
111  else
112  {
113  for ( i = 0; i < p->nOutputs; i++ )
114  {
115  if ( Fpga_NodeIsConst(p->pOutputs[i]) )
116  continue;
117  fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
118 // printf( " %5.1f", Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
119  }
120 // printf( "Required outputs = %5.1f\n", fRequired );
121  }
122  return fRequired;
123 }
124 
125 /**Function*************************************************************
126 
127  Synopsis [Computes the required times of all nodes.]
128 
129  Description []
130 
131  SideEffects []
132 
133  SeeAlso []
134 
135 ***********************************************************************/
136 void Fpga_TimeComputeRequiredGlobal( Fpga_Man_t * p, int fFirstTime )
137 {
139  // update the required times according to the target
140  if ( p->DelayTarget != -1 )
141  {
142  if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon )
143  {
144  if ( fFirstTime )
145  printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->DelayTarget );
146  }
147  else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon )
148  {
149  if ( fFirstTime )
150  printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget );
151  p->fRequiredGlo = p->DelayTarget;
152  }
153  }
155 }
156 
157 /**Function*************************************************************
158 
159  Synopsis [Computes the required times of all nodes.]
160 
161  Description []
162 
163  SideEffects []
164 
165  SeeAlso []
166 
167 ***********************************************************************/
168 void Fpga_TimeComputeRequired( Fpga_Man_t * p, float fRequired )
169 {
170  int i;
171  // clean the required times and the fanout counts for all nodes
172  for ( i = 0; i < p->vAnds->nSize; i++ )
174  // set the required times for the POs
175  if ( p->fLatchPaths )
176  for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
177  Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
178  else
179  for ( i = 0; i < p->nOutputs; i++ )
180  Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
181  // collect nodes reachable from POs in the DFS order through the best cuts
183 /*
184  {
185  int Counter = 0;
186  for ( i = 0; i < p->vAnds->nSize; i++ )
187  if ( p->vAnds->pArray[i]->tRequired > FPGA_FLOAT_LARGE - 100 )
188  Counter++;
189  printf( "The number of nodes with large required times = %d.\n", Counter );
190  }
191 */
192 }
193 
194 /**Function*************************************************************
195 
196  Synopsis [Computes the required times of the given nodes.]
197 
198  Description []
199 
200  SideEffects []
201 
202  SeeAlso []
203 
204 ***********************************************************************/
206 {
207  Fpga_Node_t * pNode, * pChild;
208  float fRequired;
209  int i, k;
210 
211  // sorts the nodes in the decreasing order of levels
212 // Fpga_MappingSortByLevel( p, vNodes, 0 );
213  // the nodes area already sorted in Fpga_MappingSetRefsAndArea()
214 
215  // go through the nodes in the reverse topological order
216  for ( k = 0; k < vNodes->nSize; k++ )
217  {
218  pNode = vNodes->pArray[k];
219  if ( !Fpga_NodeIsAnd(pNode) )
220  continue;
221  // get the required time for children
222  fRequired = pNode->tRequired - p->pLutLib->pLutDelays[(int)pNode->pCutBest->nLeaves][0];
223  // update the required time of the children
224  for ( i = 0; i < pNode->pCutBest->nLeaves; i++ )
225  {
226  pChild = pNode->pCutBest->ppLeaves[i];
227  pChild->tRequired = FPGA_MIN( pChild->tRequired, fRequired );
228  }
229  }
230 }
231 
232 
233 
234 /**Function*************************************************************
235 
236  Synopsis [Computes the required times of all nodes.]
237 
238  Description []
239 
240  SideEffects []
241 
242  SeeAlso []
243 
244 ***********************************************************************/
246 {
247  Fpga_Node_t * pNode;
248  Fpga_Cut_t * pCut;
249  int i;
250 
251  // clean the required times and the fanout counts for all nodes
252  for ( i = 0; i < p->vAnds->nSize; i++ )
253  {
254  pNode = p->vAnds->pArray[i];
255  for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext )
256  pCut->tArrival = Fpga_TimeCutComputeArrival( p, pCut );
257  }
258 }
259 
260 
261 ////////////////////////////////////////////////////////////////////////
262 /// END OF FILE ///
263 ////////////////////////////////////////////////////////////////////////
264 
265 
267 
float Fpga_TimeCutComputeArrival_rec(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
Definition: fpgaTime.c:69
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
float Fpga_TimeComputeArrivalMax(Fpga_Man_t *p)
Definition: fpgaTime.c:89
#define FPGA_FLOAT_LARGE
Definition: fpgaInt.h:65
Fpga_NodeVec_t * vMapping
Definition: fpgaInt.h:113
#define FPGA_MAX(a, b)
Definition: fpgaInt.h:62
for(p=first;p->value< newval;p=p->next)
Fpga_Cut_t * pCuts
Definition: fpgaInt.h:224
void Fpga_TimeComputeRequiredGlobal(Fpga_Man_t *p, int fFirstTime)
Definition: fpgaTime.c:136
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
#define FPGA_MIN(a, b)
Definition: fpgaInt.h:61
void Fpga_TimePropagateArrival(Fpga_Man_t *p)
Definition: fpgaTime.c:245
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
if(last==0)
Definition: sparse_int.h:34
int Fpga_NodeIsConst(Fpga_Node_t *p)
Definition: fpgaCreate.c:125
void Fpga_TimeComputeRequired(Fpga_Man_t *p, float fRequired)
Definition: fpgaTime.c:168
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
STRUCTURE DEFINITIONS ///.
Definition: fpgaInt.h:99
#define Fpga_Regular(p)
Definition: fpga.h:58
void Fpga_TimePropagateRequired(Fpga_Man_t *p, Fpga_NodeVec_t *vNodes)
Definition: fpgaTime.c:205
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
ABC_NAMESPACE_IMPL_START float Fpga_TimeCutComputeArrival(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
DECLARATIONS ///.
Definition: fpgaTime.c:44
float DelayTarget
Definition: fpgaInt.h:127
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
float fRequiredGlo
Definition: fpgaInt.h:145