abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ifSeq.c File Reference
#include "if.h"

Go to the source code of this file.

Functions

void If_ManPrepareMappingSeq (If_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void If_ManCollectLatches_rec (If_Obj_t *pObj, Vec_Ptr_t *vLatches)
 
Vec_Ptr_tIf_ManCollectLatches (If_Man_t *p)
 
int If_ManPerformMappingRoundSeq (If_Man_t *p, int nIter)
 
int If_ManBinarySearchPeriod (If_Man_t *p)
 
int If_ManBinarySearch_rec (If_Man_t *p, int FiMin, int FiMax)
 
void If_ManPerformMappingSeqPost (If_Man_t *p)
 
int If_ManPerformMappingSeq (If_Man_t *p)
 

Variables

ABC_NAMESPACE_IMPL_START abctime s_MappingTime
 DECLARATIONS ///. More...
 

Function Documentation

int If_ManBinarySearch_rec ( If_Man_t p,
int  FiMin,
int  FiMax 
)

Function*************************************************************

Synopsis [Performs binary search for the optimal clock period.]

Description [Assumes that FiMin is infeasible while FiMax is feasible.]

SideEffects []

SeeAlso []

Definition at line 269 of file ifSeq.c.

270 {
271  assert( FiMin < FiMax );
272  if ( FiMin + 1 == FiMax )
273  return FiMax;
274  // compute the median
275  p->Period = FiMin + (FiMax - FiMin)/2;
276  if ( If_ManBinarySearchPeriod( p ) )
277  return If_ManBinarySearch_rec( p, FiMin, p->Period ); // Median is feasible
278  else
279  return If_ManBinarySearch_rec( p, p->Period, FiMax ); // Median is infeasible
280 }
int If_ManBinarySearch_rec(If_Man_t *p, int FiMin, int FiMax)
Definition: ifSeq.c:269
int If_ManBinarySearchPeriod(If_Man_t *p)
Definition: ifSeq.c:198
int Period
Definition: if.h:224
#define assert(ex)
Definition: util_old.h:213
int If_ManBinarySearchPeriod ( If_Man_t p)

Function*************************************************************

Synopsis [Returns 1 if retiming with this clock period is feasible.]

Description []

SideEffects []

SeeAlso []

Definition at line 198 of file ifSeq.c.

199 {
200  If_Obj_t * pObj;
201  int i, c, fConverged;
202 // int fResetRefs = 0;
203  p->nAttempts++;
204 
205  // reset initial LValues (PIs to 0; others to -inf)
206  If_ManForEachObj( p, pObj, i )
207  {
208  If_ObjSetLValue( pObj, (float)-IF_INFINITY );
209  If_ObjSetArrTime( pObj, (float)-IF_INFINITY );
210  // undo any previous mapping, except for CIs
211  if ( If_ObjIsAnd(pObj) )
212  If_ObjCutBest(pObj)->nLeaves = 0;
213  }
214  pObj = If_ManConst1( p );
215  If_ObjSetLValue( pObj, (float)0.0 );
216  If_ObjSetArrTime( pObj, (float)0.0 );
217  If_ManForEachPi( p, pObj, i )
218  {
219  pObj = If_ManCi( p, i );
220  If_ObjSetLValue( pObj, (float)0.0 );
221  If_ObjSetArrTime( pObj, (float)0.0 );
222  }
223 
224  // update all values iteratively
225  fConverged = 0;
226  for ( c = 1; c <= p->nMaxIters; c++ )
227  {
228  if ( !If_ManPerformMappingRoundSeq( p, c ) )
229  {
230  p->RequiredGlo = If_ManDelayMax( p, 1 );
231  fConverged = 1;
232  break;
233  }
234  p->RequiredGlo = If_ManDelayMax( p, 1 );
235 //Abc_Print( 1, "Global = %d \n", (int)p->RequiredGlo );
236  if ( p->RequiredGlo > p->Period + p->fEpsilon )
237  break;
238  }
239 
240  // report the results
241  If_ManMarkMapping( p );
242  if ( p->pPars->fVerbose )
243  {
244 // p->AreaGlo = If_ManScanMapping(p);
245  Abc_Print( 1, "Attempt = %2d. Iters = %3d. Area = %10.2f. Fi = %6.2f. ", p->nAttempts, c, p->AreaGlo, (float)p->Period );
246  if ( fConverged )
247  Abc_Print( 1, " Feasible" );
248  else if ( c > p->nMaxIters )
249  Abc_Print( 1, "Infeasible (timeout)" );
250  else
251  Abc_Print( 1, "Infeasible" );
252  Abc_Print( 1, "\n" );
253  }
254  return fConverged;
255 }
#define IF_INFINITY
Definition: if.h:56
#define If_ManForEachPi(p, pObj, i)
Definition: if.h:451
unsigned nLeaves
Definition: if.h:289
static void If_ObjSetLValue(If_Obj_t *pObj, float LValue)
Definition: if.h:409
int nMaxIters
Definition: if.h:223
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
int fVerbose
Definition: if.h:140
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int If_ManPerformMappingRoundSeq(If_Man_t *p, int nIter)
Definition: ifSeq.c:123
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
float AreaGlo
Definition: if.h:198
float RequiredGlo
Definition: if.h:196
static If_Obj_t * If_ManConst1(If_Man_t *p)
Definition: if.h:365
static If_Obj_t * If_ManCi(If_Man_t *p, int i)
Definition: if.h:366
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nAttempts
Definition: if.h:222
float fEpsilon
Definition: if.h:195
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition: ifTime.c:250
If_Par_t * pPars
Definition: if.h:184
int Period
Definition: if.h:224
void If_ManMarkMapping(If_Man_t *p)
Definition: ifUtil.c:434
Vec_Ptr_t* If_ManCollectLatches ( If_Man_t p)

Function*************************************************************

Synopsis [Collects latches in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file ifSeq.c.

96 {
97  Vec_Ptr_t * vLatches;
98  If_Obj_t * pObj;
99  int i;
100  // collect latches
101  vLatches = Vec_PtrAlloc( p->pPars->nLatchesCi );
102  If_ManForEachLatchOutput( p, pObj, i )
103  If_ManCollectLatches_rec( pObj, vLatches );
104  // clean marks
105  Vec_PtrForEachEntry( If_Obj_t *, vLatches, pObj, i )
106  pObj->fMark = 0;
107  assert( Vec_PtrSize(vLatches) == p->pPars->nLatchesCi );
108  return vLatches;
109 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Definition: if.h:303
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nLatchesCi
Definition: if.h:152
void If_ManCollectLatches_rec(If_Obj_t *pObj, Vec_Ptr_t *vLatches)
Definition: ifSeq.c:73
#define If_ManForEachLatchOutput(p, pObj, i)
Definition: if.h:459
If_Par_t * pPars
Definition: if.h:184
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void If_ManCollectLatches_rec ( If_Obj_t pObj,
Vec_Ptr_t vLatches 
)

Function*************************************************************

Synopsis [Collects latches in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file ifSeq.c.

74 {
75  if ( !If_ObjIsLatch(pObj) )
76  return;
77  if ( pObj->fMark )
78  return;
79  pObj->fMark = 1;
80  If_ManCollectLatches_rec( pObj->pFanin0, vLatches );
81  Vec_PtrPush( vLatches, pObj );
82 }
If_Obj_t * pFanin0
Definition: if.h:321
static int If_ObjIsLatch(If_Obj_t *pObj)
Definition: if.h:376
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void If_ManCollectLatches_rec(If_Obj_t *pObj, Vec_Ptr_t *vLatches)
Definition: ifSeq.c:73
unsigned fMark
Definition: if.h:310
int If_ManPerformMappingRoundSeq ( If_Man_t p,
int  nIter 
)

Function*************************************************************

Synopsis [Performs one pass of l-value computation over all nodes.]

Description [Experimentally it was found that checking POs changes is not enough to detect the convergence of l-values in the network.]

SideEffects []

SeeAlso []

Definition at line 123 of file ifSeq.c.

124 {
125  If_Obj_t * pObj;
126  int i;
127  abctime clk = Abc_Clock();
128  int fVeryVerbose = 0;
129  int fChange = 0;
130 
131  if ( nIter == 1 )
132  {
133  // if some latches depend on PIs, update their values
134  Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
135  {
136  If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
137  If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
138  }
139  }
140 
141  // map the internal nodes
142  p->nCutsMerged = 0;
143  If_ManForEachNode( p, pObj, i )
144  {
145  If_ObjPerformMappingAnd( p, pObj, 0, 0, 0 );
146  if ( pObj->fRepr )
147  If_ObjPerformMappingChoice( p, pObj, 0, 0 );
148  }
149 
150  // postprocess the mapping
151 //Abc_Print( 1, "Itereation %d: \n", nIter );
152  If_ManForEachNode( p, pObj, i )
153  {
154  // update the LValues stored separately
155  if ( If_ObjLValue(pObj) < If_ObjCutBest(pObj)->Delay - p->fEpsilon )
156  {
157  If_ObjSetLValue( pObj, If_ObjCutBest(pObj)->Delay );
158  fChange = 1;
159  }
160 //Abc_Print( 1, "%d ", (int)If_ObjLValue(pObj) );
161  // reset the visit counters
162  assert( pObj->nVisits == 0 );
163  pObj->nVisits = pObj->nVisitsCopy;
164  }
165 //Abc_Print( 1, "\n" );
166 
167  // propagate LValues over the registers
168  Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
169  {
170  If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
171  If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
172  }
173 
174  // compute area and delay
175  If_ManMarkMapping( p );
176  if ( fVeryVerbose )
177  {
178  p->RequiredGlo = If_ManDelayMax( p, 1 );
179 // p->AreaGlo = If_ManScanMapping(p);
180  Abc_Print( 1, "S%d: Fi = %6.2f. Del = %6.2f. Area = %8.2f. Cuts = %8d. ",
181  nIter, (float)p->Period, p->RequiredGlo, p->AreaGlo, p->nCutsMerged );
182  Abc_PrintTime( 1, "T", Abc_Clock() - clk );
183  }
184  return fChange;
185 }
static void If_ObjSetLValue(If_Obj_t *pObj, float LValue)
Definition: if.h:409
#define If_ManForEachNode(p, pObj, i)
Definition: if.h:468
Definition: if.h:303
unsigned fRepr
Definition: if.h:309
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition: ifMap.c:95
int nCutsMerged
Definition: if.h:202
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
float AreaGlo
Definition: if.h:198
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition: ifMap.c:407
float RequiredGlo
Definition: if.h:196
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
float fEpsilon
Definition: if.h:195
int nVisitsCopy
Definition: if.h:320
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition: ifTime.c:250
int Period
Definition: if.h:224
int nVisits
Definition: if.h:319
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t * vLatchOrder
Definition: if.h:220
static float If_ObjLValue(If_Obj_t *pObj)
Definition: if.h:408
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void If_ManMarkMapping(If_Man_t *p)
Definition: ifUtil.c:434
int If_ManPerformMappingSeq ( If_Man_t p)

Function*************************************************************

Synopsis [Performs sequential mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 334 of file ifSeq.c.

335 {
336  abctime clkTotal = Abc_Clock();
337  int PeriodBest;
338 
339  p->SortMode = 0;
340 
341  // perform combinational mapping to get the upper bound on the clock period
342  If_ManPerformMappingRound( p, 1, 0, 0, 1, NULL );
343  p->RequiredGlo = If_ManDelayMax( p, 0 );
344  p->RequiredGlo2 = p->RequiredGlo;
345 
346  // set direct linking of latches with their inputs
348 
349  // collect latches
351 
352  // set parameters
353  p->nCutsUsed = p->pPars->nCutsMax;
354  p->nAttempts = 0;
355  p->nMaxIters = 50;
356  p->Period = (int)p->RequiredGlo;
357 
358  // make sure the clock period works
359  if ( !If_ManBinarySearchPeriod( p ) )
360  {
361  Abc_Print( 1, "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
362  return 0;
363  }
364 
365  // perform binary search
366  PeriodBest = If_ManBinarySearch_rec( p, 0, p->Period );
367 
368  // recompute the best l-values
369  if ( p->Period != PeriodBest )
370  {
371  p->Period = PeriodBest;
372  if ( !If_ManBinarySearchPeriod( p ) )
373  {
374  Abc_Print( 1, "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
375  return 0;
376  }
377  }
378 // if ( p->pPars->fVerbose )
379  {
380  Abc_Print( 1, "The best clock period is %3d. ", p->Period );
381  Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
382  }
383  p->RequiredGlo = (float)(PeriodBest);
384 
385  // postprocess it using combinational mapping
387  s_MappingTime = Abc_Clock() - clkTotal;
388  return 1;
389 }
float RequiredGlo2
Definition: if.h:197
int nCutsUsed
Definition: if.h:201
int nMaxIters
Definition: if.h:223
int If_ManBinarySearch_rec(If_Man_t *p, int FiMin, int FiMax)
Definition: ifSeq.c:269
int If_ManPerformMappingRound(If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
Definition: ifMap.c:491
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int If_ManBinarySearchPeriod(If_Man_t *p)
Definition: ifSeq.c:198
float RequiredGlo
Definition: if.h:196
if(last==0)
Definition: sparse_int.h:34
Vec_Ptr_t * If_ManCollectLatches(If_Man_t *p)
Definition: ifSeq.c:95
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nAttempts
Definition: if.h:222
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition: ifTime.c:250
void If_ManPrepareMappingSeq(If_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: ifSeq.c:47
ABC_NAMESPACE_IMPL_START abctime s_MappingTime
DECLARATIONS ///.
Definition: abcPrint.c:44
If_Par_t * pPars
Definition: if.h:184
int Period
Definition: if.h:224
void If_ManPerformMappingSeqPost(If_Man_t *p)
Definition: ifSeq.c:293
int nCutsMax
Definition: if.h:104
int SortMode
Definition: if.h:205
Vec_Ptr_t * vLatchOrder
Definition: if.h:220
ABC_INT64_T abctime
Definition: abc_global.h:278
void If_ManPerformMappingSeqPost ( If_Man_t p)

Function*************************************************************

Synopsis [Performs sequential mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file ifSeq.c.

294 {
295  If_Obj_t * pObjLi, * pObjLo, * pObj;
296  int i;
297  assert( 0 );
298 
299  // set arrival times
300  assert( p->pPars->pTimesArr != NULL );
301  If_ManForEachLatchOutput( p, pObjLo, i )
302  p->pPars->pTimesArr[i] = If_ObjLValue(pObjLo);
303 
304  // set the required times
305  assert( p->pPars->pTimesReq == NULL );
306  p->pPars->pTimesReq = ABC_ALLOC( float, If_ManCoNum(p) );
307  If_ManForEachPo( p, pObj, i )
308  p->pPars->pTimesReq[i] = p->RequiredGlo2;
309  If_ManForEachLatchInput( p, pObjLi, i )
310  p->pPars->pTimesReq[i] = If_ObjLValue(If_ObjFanin0(pObjLi));
311 
312  // undo previous mapping
313  If_ManForEachObj( p, pObj, i )
314  if ( If_ObjIsAnd(pObj) )
315  If_ObjCutBest(pObj)->nLeaves = 0;
316 
317  // map again combinationally
318 // p->pPars->fSeqMap = 0;
320 // p->pPars->fSeqMap = 1;
321 }
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_ManForEachLatchInput(p, pObj, i)
Definition: if.h:457
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
#define If_ManForEachPo(p, pObj, i)
Definition: if.h:454
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
int If_ManPerformMappingComb(If_Man_t *p)
Definition: ifCore.c:104
if(last==0)
Definition: sparse_int.h:34
float * pTimesArr
Definition: if.h:161
#define If_ManForEachLatchOutput(p, pObj, i)
Definition: if.h:459
If_Par_t * pPars
Definition: if.h:184
#define assert(ex)
Definition: util_old.h:213
static int If_ManCoNum(If_Man_t *p)
Definition: if.h:361
static float If_ObjLValue(If_Obj_t *pObj)
Definition: if.h:408
void If_ManPrepareMappingSeq ( If_Man_t p)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Prepares for sequential mapping by linking the latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ifSeq.c.

48 {
49  If_Obj_t * pObjLi, * pObjLo;
50  int i;
51 
52  // link the latch outputs (CIs) directly to the drivers of latch inputs (COs)
53  for ( i = 0; i < p->pPars->nLatchesCi; i++ )
54  {
55  pObjLi = If_ManLi( p, i );
56  pObjLo = If_ManLo( p, i );
57  pObjLo->pFanin0 = If_ObjFanin0( pObjLi );
58  pObjLo->fCompl0 = If_ObjFaninC0( pObjLi );
59  }
60 }
If_Obj_t * pFanin0
Definition: if.h:321
Definition: if.h:303
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
int nLatchesCi
Definition: if.h:152
If_Par_t * pPars
Definition: if.h:184
static If_Obj_t * If_ManLo(If_Man_t *p, int i)
Definition: if.h:369
static If_Obj_t * If_ManLi(If_Man_t *p, int i)
Definition: if.h:368
unsigned fCompl0
Definition: if.h:306

Variable Documentation

DECLARATIONS ///.

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

]

CFile****************************************************************

FileName [abcPrint.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Printing statistics.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
abcPrint.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 44 of file abcPrint.c.