ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifSeq.c File Reference
#include "if.h"
Include dependency graph for ifSeq.c:

Go to the source code of this file.

Functions

void If_ManPrepareMappingSeq (If_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
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 ///.
 

Function Documentation

◆ If_ManBinarySearch_rec()

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;
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}
Cube * p
Definition exorList.c:222
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
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManBinarySearchPeriod()

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
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}
int If_ManPerformMappingRoundSeq(If_Man_t *p, int nIter)
Definition ifSeq.c:123
#define If_ManForEachObj(p, pObj, i)
Definition if.h:491
#define If_ManForEachPi(p, pObj, i)
Definition if.h:480
void If_ManMarkMapping(If_Man_t *p)
Definition ifUtil.c:434
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition ifTime.c:269
struct If_Obj_t_ If_Obj_t
Definition if.h:79
#define IF_INFINITY
Definition if.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManCollectLatches()

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}
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:488
unsigned fMark
Definition if.h:338
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManCollectLatches_rec()

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:349
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManPerformMappingRoundSeq()

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
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}
ABC_INT64_T abctime
Definition abc_global.h:332
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition ifMap.c:162
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition ifMap.c:521
#define If_ManForEachNode(p, pObj, i)
Definition if.h:497
int nVisits
Definition if.h:347
unsigned fRepr
Definition if.h:337
int nVisitsCopy
Definition if.h:348
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManPerformMappingSeq()

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
350 p->vLatchOrder = If_ManCollectLatches( p );
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}
Vec_Ptr_t * If_ManCollectLatches(If_Man_t *p)
Definition ifSeq.c:95
void If_ManPerformMappingSeqPost(If_Man_t *p)
Definition ifSeq.c:293
void If_ManPrepareMappingSeq(If_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition ifSeq.c:47
int If_ManPerformMappingRound(If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
Definition ifMap.c:606
abctime s_MappingTime
DECLARATIONS ///.
Definition abcPrint.c:47
Here is the call graph for this function:

◆ If_ManPerformMappingSeqPost()

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}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
int If_ManPerformMappingComb(If_Man_t *p)
Definition ifCore.c:106
#define If_ManForEachLatchInput(p, pObj, i)
Definition if.h:486
#define If_ManForEachPo(p, pObj, i)
Definition if.h:483
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManPrepareMappingSeq()

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}
unsigned fCompl0
Definition if.h:334
Here is the caller graph for this function:

Variable Documentation

◆ s_MappingTime

ABC_NAMESPACE_IMPL_START abctime s_MappingTime
extern

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 47 of file abcPrint.c.