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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Aig_ManRetimeMark_rec (Aig_Man_t *p, Aig_Obj_t *pObj)
 DECLARATIONS ///. More...
 
void Aig_ManRetimeMark (Aig_Man_t *p)
 
Aig_Man_tAig_ManRetimeFrontier (Aig_Man_t *p, int nStepsMax)
 

Function Documentation

Aig_Man_t* Aig_ManRetimeFrontier ( Aig_Man_t p,
int  nStepsMax 
)

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

Synopsis [Performs forward retiming.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file aigRetF.c.

126 {
127  Aig_Obj_t * pObj, * pObjNew, * pObjLo, * pObjLo0, * pObjLo1, * pObjLi, * pObjLi0, * pObjLi1;//, * pObjLi0_, * pObjLi1_, * pObjLi0__, * pObjLi1__;
128  int i, Counter, fCompl, fChange;
129  assert( Aig_ManRegNum(p) > 0 );
130  // remove structural hashing table
131  Aig_TableClear( p );
132  // mark the retimable nodes
133  Aig_ManRetimeMark( p );
134  // mark the register outputs
135  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
136  {
137  pObjLo->fMarkA = 1;
138  pObjLo->pNext = pObjLi;
139  pObjLi->pNext = pObjLo;
140  }
141  // go through the nodes and find retimable ones
142  Counter = 0;
143  fChange = 1;
144  while ( fChange )
145  {
146  fChange = 0;
147  Aig_ManForEachNode( p, pObj, i )
148  {
149  if ( !pObj->fMarkB )
150  continue;
151  if ( Aig_ObjIsBuf(pObj) )
152  continue;
153  // get the real inputs of the node (skipping the buffers)
154  pObjLo0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
155  pObjLo1 = Aig_ObjReal_rec( Aig_ObjChild1(pObj) );
156  if ( !Aig_Regular(pObjLo0)->fMarkA || !Aig_Regular(pObjLo1)->fMarkA )
157  continue;
158  // remember complemented attribute
159  fCompl = Aig_IsComplement(pObjLo0) & Aig_IsComplement(pObjLo1);
160  // get the register inputs
161 // pObjLi0_ = Aig_Regular(pObjLo0)->pNext;
162 // pObjLi1_ = Aig_Regular(pObjLo1)->pNext;
163 // pObjLi0__ = Aig_ObjChild0(Aig_Regular(pObjLo0)->pNext);
164 // pObjLi1__ = Aig_ObjChild0(Aig_Regular(pObjLo1)->pNext);
165  pObjLi0 = Aig_NotCond( Aig_ObjChild0(Aig_Regular(pObjLo0)->pNext), Aig_IsComplement(pObjLo0) );
166  pObjLi1 = Aig_NotCond( Aig_ObjChild0(Aig_Regular(pObjLo1)->pNext), Aig_IsComplement(pObjLo1) );
167  // create new node
168  pObjNew = Aig_And( p, pObjLi0, pObjLi1 );
169  pObjNew->fMarkB = 1;
170  // create new register
171  pObjLo = Aig_ObjCreateCi(p);
172  pObjLo->fMarkA = 1;
173  pObjLi = Aig_ObjCreateCo( p, Aig_NotCond(pObjNew, fCompl) );
174  p->nRegs++;
175  pObjLo->pNext = pObjLi;
176  pObjLi->pNext = pObjLo;
177  // add the buffer
178  Aig_ObjDisconnect( p, pObj );
179  pObj->Type = AIG_OBJ_BUF;
180  p->nObjs[AIG_OBJ_AND]--;
181  p->nObjs[AIG_OBJ_BUF]++;
182  Aig_ObjConnect( p, pObj, Aig_NotCond(pObjLo, fCompl), NULL );
183  // create HAIG if defined
184  // mark the change
185  fChange = 1;
186  // check the limit
187  if ( ++Counter >= nStepsMax )
188  {
189  fChange = 0;
190  break;
191  }
192  }
193  }
194  // clean the markings
195  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
196  {
197  pObjLo->fMarkA = 0;
198  pObjLo->pNext = pObjLi->pNext = NULL;
199  }
200  Aig_ManForEachObj( p, pObj, i )
201  pObj->fMarkB = 0;
202  // remove useless registers
203  Aig_ManSeqCleanup( p );
204  // rehash the nodes
205  return Aig_ManDupOrdered( p );
206 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
Definition: aigUtil.c:476
unsigned int Type
Definition: aig.h:77
unsigned int fMarkB
Definition: aig.h:80
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
unsigned int fMarkA
Definition: aig.h:79
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
void Aig_ObjConnect(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFan0, Aig_Obj_t *pFan1)
Definition: aigObj.c:126
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition: aig.h:450
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static int Counter
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjDisconnect(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:171
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
void Aig_ManRetimeMark(Aig_Man_t *p)
Definition: aigRetF.c:73
void Aig_TableClear(Aig_Man_t *p)
Definition: aigTable.c:265
void Aig_ManRetimeMark ( Aig_Man_t p)

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

Synopsis [Mark the nodes reachable from the true PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file aigRetF.c.

74 {
75  Aig_Obj_t * pObj, * pObjLi, * pObjLo;
76  int fChange, i;
77  // mark the PIs
78  Aig_ManForEachObj( p, pObj, i )
79  assert( pObj->fMarkB == 0 );
80  Aig_ManForEachPiSeq( p, pObj, i )
81  pObj->fMarkB = 1;
82  // map registers into each other
83  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
84  {
85  assert( pObjLo->pNext == NULL );
86  assert( pObjLi->pNext == NULL );
87  pObjLo->pNext = pObjLi;
88  pObjLi->pNext = pObjLo;
89  }
90  // iterativively mark the logic reachable from PIs
91  fChange = 1;
92  while ( fChange )
93  {
94  fChange = 0;
96  Aig_ManForEachCo( p, pObj, i )
97  {
98  if ( pObj->fMarkB )
99  continue;
100  if ( Aig_ManRetimeMark_rec( p, pObj ) )
101  {
102  if ( pObj->pNext )
103  pObj->pNext->fMarkB = 1;
104  fChange = 1;
105  }
106  }
107  }
108  // clean register mapping
109  Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
110  pObjLo->pNext = pObjLi->pNext = NULL;
111 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int fMarkB
Definition: aig.h:80
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition: aig.h:450
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
ABC_NAMESPACE_IMPL_START int Aig_ManRetimeMark_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: aigRetF.c:45
#define assert(ex)
Definition: util_old.h:213
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
ABC_NAMESPACE_IMPL_START int Aig_ManRetimeMark_rec ( Aig_Man_t p,
Aig_Obj_t pObj 
)

DECLARATIONS ///.

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

FileName [aigRetF.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Retiming frontier.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigRetF.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

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

Synopsis [Mark the nodes reachable from the PIs in the reverse order.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file aigRetF.c.

46 {
47  if ( pObj->fMarkB )
48  return 1;
49  if ( Aig_ObjIsCi(pObj) || Aig_ObjIsConst1(pObj) )
50  return 0;
51  if ( Aig_ObjIsTravIdCurrent(p, pObj) )
52  return pObj->fMarkB;
54  if ( Aig_ManRetimeMark_rec( p, Aig_ObjFanin0(pObj) ) )
55  return pObj->fMarkB = 1;
56  if ( Aig_ObjIsNode(pObj) && Aig_ManRetimeMark_rec( p, Aig_ObjFanin1(pObj) ) )
57  return pObj->fMarkB = 1;
58  assert( pObj->fMarkB == 0 );
59  return 0;
60 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
unsigned int fMarkB
Definition: aig.h:80
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
ABC_NAMESPACE_IMPL_START int Aig_ManRetimeMark_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: aigRetF.c:45
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275