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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Gia_ManMarkAutonomous_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 DECLARATIONS ///.
 
void Gia_ManMarkAutonomous (Gia_Man_t *p)
 
void Gia_ManRetimeDup_rec (Gia_Man_t *pNew, Gia_Obj_t *pObj)
 
Gia_Man_tGia_ManRetimeDupForward (Gia_Man_t *p, Vec_Ptr_t *vCut)
 
Gia_Man_tGia_ManRetimeForwardOne (Gia_Man_t *p, int *pnRegFixed, int *pnRegMoves)
 
Gia_Man_tGia_ManRetimeForward (Gia_Man_t *p, int nMaxIters, int fVerbose)
 

Function Documentation

◆ Gia_ManMarkAutonomous()

void Gia_ManMarkAutonomous ( Gia_Man_t * p)

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

Synopsis [Marks with current trav ROs reachable from Const0 and PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file giaRetime.c.

75{
76 Gia_Obj_t * pObj;
77 int i;
80 Gia_ManForEachRo( p, pObj, i )
83 Gia_ManForEachRo( p, pObj, i )
84 if ( pObj->fMark0 )
85 Gia_ObjSetTravIdCurrent( p, pObj );
87}
Cube * p
Definition exorList.c:222
ABC_NAMESPACE_IMPL_START int Gia_ManMarkAutonomous_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
DECLARATIONS ///.
Definition giaRetime.c:45
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition giaUtil.c:256
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
unsigned fMark0
Definition gia.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManMarkAutonomous_rec()

ABC_NAMESPACE_IMPL_START int Gia_ManMarkAutonomous_rec ( Gia_Man_t * p,
Gia_Obj_t * pObj )

DECLARATIONS ///.

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

FileName [giaRetime.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Performs most-forward retiming for AIG with flop classes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Marks objects reachables from Const0 and PIs/

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file giaRetime.c.

46{
47 if ( Gia_ObjIsTravIdCurrent(p, pObj) )
48 return pObj->fMark0;
49 Gia_ObjSetTravIdCurrent(p, pObj);
50 assert( pObj->fMark0 == 0 );
51 if ( Gia_ObjIsPi(p, pObj) || Gia_ObjIsConst0(pObj) )
52 return pObj->fMark0 = 1;
53 if ( Gia_ObjIsCo(pObj) )
54 return pObj->fMark0 = Gia_ManMarkAutonomous_rec( p, Gia_ObjFanin0(pObj) );
55 if ( Gia_ObjIsCi(pObj) )
56 return pObj->fMark0 = Gia_ManMarkAutonomous_rec( p, Gia_ObjRoToRi(p, pObj) );
57 assert( Gia_ObjIsAnd(pObj) );
58 if ( Gia_ManMarkAutonomous_rec( p, Gia_ObjFanin0(pObj) ) )
59 return pObj->fMark0 = 1;
60 return pObj->fMark0 = Gia_ManMarkAutonomous_rec( p, Gia_ObjFanin1(pObj) );
61}
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManRetimeDup_rec()

void Gia_ManRetimeDup_rec ( Gia_Man_t * pNew,
Gia_Obj_t * pObj )

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

Synopsis [Duplicates the AIG recursively.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file giaRetime.c.

101{
102 if ( ~pObj->Value )
103 return;
104 assert( Gia_ObjIsAnd(pObj) );
105 Gia_ManRetimeDup_rec( pNew, Gia_ObjFanin0(pObj) );
106 Gia_ManRetimeDup_rec( pNew, Gia_ObjFanin1(pObj) );
107 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
108}
void Gia_ManRetimeDup_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj)
Definition giaRetime.c:100
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManRetimeDupForward()

Gia_Man_t * Gia_ManRetimeDupForward ( Gia_Man_t * p,
Vec_Ptr_t * vCut )

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

Synopsis [Duplicates the AIG while retiming the registers to the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file giaRetime.c.

122{
123 Gia_Man_t * pNew, * pTemp;
124 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
125 int i;
126 // create the new manager
127 pNew = Gia_ManStart( Gia_ManObjNum(p) );
128 pNew->pName = Abc_UtilStrsav( p->pName );
129 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
130 Gia_ManHashAlloc( pNew );
131 // create the true PIs
134 Gia_ManConst0(p)->Value = 0;
135 Gia_ManForEachPi( p, pObj, i )
136 pObj->Value = Gia_ManAppendCi( pNew );
137 // create the registers
138 Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
139 pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), pObj->fPhase );
140 // duplicate logic above the cut
141 Gia_ManForEachCo( p, pObj, i )
142 Gia_ManRetimeDup_rec( pNew, Gia_ObjFanin0(pObj) );
143 // create the true POs
144 Gia_ManForEachPo( p, pObj, i )
145 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
146 // remember value in LI
147 Gia_ManForEachRi( p, pObj, i )
148 pObj->Value = Gia_ObjFanin0Copy(pObj);
149 // transfer values from the LIs to the LOs
150 Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
151 pObjRo->Value = pObjRi->Value;
152 // erase the data values on the internal nodes of the cut
153 Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
154 if ( Gia_ObjIsAnd(pObj) )
155 pObj->Value = ~0;
156 // duplicate logic below the cut
157 Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
158 {
159 Gia_ManRetimeDup_rec( pNew, pObj );
160 Gia_ManAppendCo( pNew, Abc_LitNotCond( pObj->Value, pObj->fPhase ) );
161 }
162 Gia_ManHashStop( pNew );
163 Gia_ManSetRegNum( pNew, Vec_PtrSize(vCut) );
164 pNew = Gia_ManCleanup( pTemp = pNew );
165 Gia_ManStop( pTemp );
166 return pNew;
167}
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition gia.h:1256
void Gia_ManSetPhase(Gia_Man_t *p)
Definition giaUtil.c:420
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned fPhase
Definition gia.h:87
#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:

◆ Gia_ManRetimeForward()

Gia_Man_t * Gia_ManRetimeForward ( Gia_Man_t * p,
int nMaxIters,
int fVerbose )

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

Synopsis [Derives the cut for forward retiming.]

Description [Assumes topological ordering of the nodes.]

SideEffects []

SeeAlso []

Definition at line 267 of file giaRetime.c.

268{
269 Gia_Man_t * pNew, * pTemp;
270 int i, nRegFixed, nRegMoves = 1;
271 abctime clk;
272 pNew = p;
273 for ( i = 0; i < nMaxIters && nRegMoves > 0; i++ )
274 {
275 clk = Abc_Clock();
276 pNew = Gia_ManRetimeForwardOne( pTemp = pNew, &nRegFixed, &nRegMoves );
277 if ( fVerbose )
278 {
279 printf( "%2d : And = %6d. Reg = %5d. Unret = %5d. Move = %6d. ",
280 i + 1, Gia_ManAndNum(pTemp), Gia_ManRegNum(pTemp), nRegFixed, nRegMoves );
281 ABC_PRT( "Time", Abc_Clock() - clk );
282 }
283 if ( pTemp != p )
284 Gia_ManStop( pTemp );
285 }
286/*
287 clk = Abc_Clock();
288 pNew = Gia_ManReduceLaches( pNew, fVerbose );
289 if ( fVerbose )
290 {
291 ABC_PRT( "Register sharing time", Abc_Clock() - clk );
292 }
293*/
294 return pNew;
295}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Gia_Man_t * Gia_ManRetimeForwardOne(Gia_Man_t *p, int *pnRegFixed, int *pnRegMoves)
Definition giaRetime.c:180
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManRetimeForwardOne()

Gia_Man_t * Gia_ManRetimeForwardOne ( Gia_Man_t * p,
int * pnRegFixed,
int * pnRegMoves )

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

Synopsis [Derives the cut for forward retiming.]

Description [Assumes topological ordering of the nodes.]

SideEffects []

SeeAlso []

Definition at line 180 of file giaRetime.c.

181{
182 Vec_Int_t * vFlopClasses = NULL;
183 Vec_Int_t * vObjClasses = NULL;
184 Gia_Man_t * pNew;
185 Vec_Ptr_t * vCut;
186 Gia_Obj_t * pObj;
187 int i;
188 if ( p->vFlopClasses )
189 {
190// printf( "Performing retiming with register classes.\n" );
191 vObjClasses = Vec_IntAlloc( Gia_ManObjNum(p) );
192 for ( i = 0; i < Gia_ManObjNum(p); i++ )
193 Vec_IntPush( vObjClasses, -1 );
194 Gia_ManForEachRo( p, pObj, i )
195 Vec_IntWriteEntry( vObjClasses, Gia_ObjId(p, pObj), Vec_IntEntry(p->vFlopClasses, i) );
196 vFlopClasses = Vec_IntAlloc( Gia_ManRegNum(p) );
197 }
198 // mark the retimable nodes
201 // mark the retimable registers with the fresh trav ID
203 *pnRegFixed = 0;
204 Gia_ManForEachRo( p, pObj, i )
205 if ( Gia_ObjIsTravIdPrevious(p, pObj) )
206 Gia_ObjSetTravIdCurrent(p, pObj);
207 else
208 (*pnRegFixed)++;
209 // mark all the nodes that can be retimed forward
210 *pnRegMoves = 0;
211 Gia_ManForEachAnd( p, pObj, i )
212 if ( Gia_ObjIsTravIdCurrent(p, Gia_ObjFanin0(pObj)) && Gia_ObjIsTravIdCurrent(p, Gia_ObjFanin1(pObj)) )
213 {
214 if ( vObjClasses && Vec_IntEntry(vObjClasses, Gia_ObjFaninId0(pObj, i)) != Vec_IntEntry(vObjClasses, Gia_ObjFaninId1(pObj, i)) )
215 continue;
216 if ( vObjClasses )
217 Vec_IntWriteEntry( vObjClasses, Gia_ObjId(p, pObj), Vec_IntEntry(vObjClasses, Gia_ObjFaninId0(pObj, i)) );
218 Gia_ObjSetTravIdCurrent(p, pObj);
219 (*pnRegMoves)++;
220 }
221 // mark the remaining registers
222 Gia_ManForEachRo( p, pObj, i )
223 Gia_ObjSetTravIdCurrent(p, pObj);
224 // find the cut (all such marked objects that fanout into unmarked nodes)
225 vCut = Vec_PtrAlloc( 1000 );
227 Gia_ManForEachObj( p, pObj, i )
228 {
229 if ( Gia_ObjIsTravIdPrevious(p, pObj) )
230 continue;
231 if ( (Gia_ObjIsCo(pObj) || Gia_ObjIsAnd(pObj)) && Gia_ObjIsTravIdPrevious(p, Gia_ObjFanin0(pObj)) )
232 {
233 if ( vFlopClasses )
234 Vec_IntPush( vFlopClasses, Vec_IntEntry(vObjClasses, Gia_ObjFaninId0(pObj, i)) );
235 Vec_PtrPush( vCut, Gia_ObjFanin0(pObj) );
236 Gia_ObjSetTravIdCurrent( p, Gia_ObjFanin0(pObj) );
237 }
238 if ( Gia_ObjIsAnd(pObj) && Gia_ObjIsTravIdPrevious(p, Gia_ObjFanin1(pObj)) )
239 {
240 if ( vFlopClasses )
241 Vec_IntPush( vFlopClasses, Vec_IntEntry(vObjClasses, Gia_ObjFaninId1(pObj, i)) );
242 Vec_PtrPush( vCut, Gia_ObjFanin1(pObj) );
243 Gia_ObjSetTravIdCurrent( p, Gia_ObjFanin1(pObj) );
244 }
245 }
246 assert( vFlopClasses == NULL || Vec_IntSize(vFlopClasses) == Vec_PtrSize(vCut) );
247 // finally derive the new manager
248 pNew = Gia_ManRetimeDupForward( p, vCut );
249 Vec_PtrFree( vCut );
250 if ( vObjClasses )
251 Vec_IntFree( vObjClasses );
252 pNew->vFlopClasses = vFlopClasses;
253 return pNew;
254}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Gia_Man_t * Gia_ManRetimeDupForward(Gia_Man_t *p, Vec_Ptr_t *vCut)
Definition giaRetime.c:121
void Gia_ManMarkAutonomous(Gia_Man_t *p)
Definition giaRetime.c:74
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
Vec_Int_t * vFlopClasses
Definition gia.h:156
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function: