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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Aig_Obj_t
Saig_ManRetimeNodeFwd (Aig_Man_t *p, Aig_Obj_t *pObj, int fMakeBug)
 DECLARATIONS ///. More...
 
Aig_Obj_tSaig_ManRetimeNodeBwd (Aig_Man_t *p, Aig_Obj_t *pObjLo)
 
int Saig_ManRetimeSteps (Aig_Man_t *p, int nSteps, int fForward, int fAddBugs)
 

Function Documentation

Aig_Obj_t* Saig_ManRetimeNodeBwd ( Aig_Man_t p,
Aig_Obj_t pObjLo 
)

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

Synopsis [Performs one retiming step backward.]

Description [Returns the pointer to node after retiming.]

SideEffects [Remember to run Aig_ManSetCioIds() in advance.]

SeeAlso []

Definition at line 121 of file saigRetStep.c.

122 {
123  Aig_Obj_t * pFanin0, * pFanin1;
124  Aig_Obj_t * pLo0New, * pLo1New;
125  Aig_Obj_t * pLi0New, * pLi1New;
126  Aig_Obj_t * pObj, * pObjNew, * pObjLi;
127  int fCompl0, fCompl1;
128 
129  assert( Saig_ManRegNum(p) > 0 );
130  assert( Aig_ObjCioId(pObjLo) > 0 );
131  assert( Saig_ObjIsLo(p, pObjLo) );
132 
133  // get the corresponding latch input
134  pObjLi = Saig_ManLi( p, Aig_ObjCioId(pObjLo) - Saig_ManPiNum(p) );
135 
136  // get the node
137  pObj = Aig_ObjFanin0(pObjLi);
138  if ( !Aig_ObjIsNode(pObj) )
139  return NULL;
140 
141  // get the fanins
142  pFanin0 = Aig_ObjFanin0(pObj);
143  pFanin1 = Aig_ObjFanin1(pObj);
144 
145  // get the complemented attributes of the fanins
146  fCompl0 = Aig_ObjFaninC0(pObj) ^ Aig_ObjFaninC0(pObjLi);
147  fCompl1 = Aig_ObjFaninC1(pObj) ^ Aig_ObjFaninC0(pObjLi);
148 
149  // create latch inputs
150  pLi0New = Aig_ObjCreateCo( p, Aig_NotCond(pFanin0, fCompl0) );
151  pLi0New->CioId = Aig_ManCoNum(p) - 1;
152  pLi1New = Aig_ObjCreateCo( p, Aig_NotCond(pFanin1, fCompl1) );
153  pLi1New->CioId = Aig_ManCoNum(p) - 1;
154 
155  // create latch outputs
156  pLo0New = Aig_ObjCreateCi(p);
157  pLo0New->CioId = Aig_ManCiNum(p) - 1;
158  pLo1New = Aig_ObjCreateCi(p);
159  pLo1New->CioId = Aig_ManCiNum(p) - 1;
160  pLo0New = Aig_NotCond( pLo0New, fCompl0 );
161  pLo1New = Aig_NotCond( pLo1New, fCompl1 );
162  p->nRegs += 2;
163 
164  // create node
165  pObjNew = Aig_And( p, pLo0New, pLo1New );
166 // assert( pObjNew->fPhase == 0 );
167  return pObjNew;
168 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
int CioId
Definition: aig.h:73
static int Saig_ObjIsLo(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:84
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Aig_Obj_t * Saig_ManLi(Aig_Man_t *p, int i)
Definition: saig.h:80
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static int Aig_ObjCioId(Aig_Obj_t *pObj)
Definition: aig.h:285
ABC_NAMESPACE_IMPL_START Aig_Obj_t* Saig_ManRetimeNodeFwd ( Aig_Man_t p,
Aig_Obj_t pObj,
int  fMakeBug 
)

DECLARATIONS ///.

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

FileName [saigRetStep.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Sequential AIG package.]

Synopsis [Implementation of retiming steps.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Performs one retiming step forward.]

Description [Returns the pointer to the register output after retiming.]

SideEffects [Remember to run Aig_ManSetCioIds() in advance.]

SeeAlso []

Definition at line 45 of file saigRetStep.c.

46 {
47  Aig_Obj_t * pFanin0, * pFanin1;
48  Aig_Obj_t * pInput0, * pInput1;
49  Aig_Obj_t * pObjNew, * pObjLi, * pObjLo;
50  int fCompl;
51 
52  assert( Saig_ManRegNum(p) > 0 );
53  assert( Aig_ObjIsNode(pObj) );
54 
55  // get the fanins
56  pFanin0 = Aig_ObjFanin0(pObj);
57  pFanin1 = Aig_ObjFanin1(pObj);
58  // skip of they are not primary inputs
59  if ( !Aig_ObjIsCi(pFanin0) || !Aig_ObjIsCi(pFanin1) )
60  return NULL;
61 
62  // skip of they are not register outputs
63  if ( !Saig_ObjIsLo(p, pFanin0) || !Saig_ObjIsLo(p, pFanin1) )
64  return NULL;
65  assert( Aig_ObjCioId(pFanin0) > 0 );
66  assert( Aig_ObjCioId(pFanin1) > 0 );
67 
68  // skip latch guns
69  if ( !Aig_ObjIsTravIdCurrent(p, pFanin0) && !Aig_ObjIsTravIdCurrent(p, pFanin1) )
70  return NULL;
71 
72  // get the inputs of these registers
73  pInput0 = Saig_ManLi( p, Aig_ObjCioId(pFanin0) - Saig_ManPiNum(p) );
74  pInput1 = Saig_ManLi( p, Aig_ObjCioId(pFanin1) - Saig_ManPiNum(p) );
75  pInput0 = Aig_ObjChild0( pInput0 );
76  pInput1 = Aig_ObjChild0( pInput1 );
77  pInput0 = Aig_NotCond( pInput0, Aig_ObjFaninC0(pObj) );
78  pInput1 = Aig_NotCond( pInput1, Aig_ObjFaninC1(pObj) );
79  // get the condition when the register should be complemetned
80  fCompl = Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj);
81 
82  if ( fMakeBug )
83  {
84  printf( "Introducing bug during retiming.\n" );
85  pInput1 = Aig_Not( pInput1 );
86  }
87 
88  // create new node
89  pObjNew = Aig_And( p, pInput0, pInput1 );
90 
91  // create new register input
92  pObjLi = Aig_ObjCreateCo( p, Aig_NotCond(pObjNew, fCompl) );
93  pObjLi->CioId = Aig_ManCoNum(p) - 1;
94 
95  // create new register output
96  pObjLo = Aig_ObjCreateCi( p );
97  pObjLo->CioId = Aig_ManCiNum(p) - 1;
98  p->nRegs++;
99 
100  // make sure the register is retimable.
101  Aig_ObjSetTravIdCurrent(p, pObjLo);
102 
103 //printf( "Reg = %4d. Reg = %4d. Compl = %d. Phase = %d.\n",
104 // pFanin0->PioNum, pFanin1->PioNum, Aig_IsComplement(pObjNew), fCompl );
105 
106  // return register output
107  return Aig_NotCond( pObjLo, fCompl );
108 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
int CioId
Definition: aig.h:73
static int Saig_ObjIsLo(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saig.h:84
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
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
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
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
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Aig_Obj_t * Saig_ManLi(Aig_Man_t *p, int i)
Definition: saig.h:80
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Aig_ObjCioId(Aig_Obj_t *pObj)
Definition: aig.h:285
int Saig_ManRetimeSteps ( Aig_Man_t p,
int  nSteps,
int  fForward,
int  fAddBugs 
)

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

Synopsis [Performs the given number of retiming steps.]

Description [Returns the pointer to node after retiming.]

SideEffects [Remember to run Aig_ManSetCioIds() in advance.]

SeeAlso []

Definition at line 181 of file saigRetStep.c.

182 {
183  Aig_Obj_t * pObj, * pObjNew;
184  int RetValue, s, i;
185  Aig_ManSetCioIds( p );
187  p->fCreatePios = 1;
188  if ( fForward )
189  {
191  for ( s = 0; s < nSteps; s++ )
192  {
193  Aig_ManForEachNode( p, pObj, i )
194  {
195  pObjNew = Saig_ManRetimeNodeFwd( p, pObj, fAddBugs && (s == 10) );
196 // pObjNew = Saig_ManRetimeNodeFwd( p, pObj, 0 );
197  if ( pObjNew == NULL )
198  continue;
199  Aig_ObjReplace( p, pObj, pObjNew, 0 );
200  break;
201  }
202  if ( i == Vec_PtrSize(p->vObjs) )
203  break;
204  }
205  }
206  else
207  {
208  for ( s = 0; s < nSteps; s++ )
209  {
210  Saig_ManForEachLo( p, pObj, i )
211  {
212  pObjNew = Saig_ManRetimeNodeBwd( p, pObj );
213  if ( pObjNew == NULL )
214  continue;
215  Aig_ObjReplace( p, pObj, pObjNew, 0 );
216  break;
217  }
218  if ( i == Vec_PtrSize(p->vObjs) )
219  break;
220  }
221  }
222  p->fCreatePios = 0;
223  Aig_ManFanoutStop( p );
224  RetValue = Aig_ManCleanup( p );
225  assert( RetValue == 0 );
226  Aig_ManSetRegNum( p, p->nRegs );
227  return s;
228 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Saig_ManMarkAutonomous(Aig_Man_t *p)
Definition: saigRetFwd.c:111
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: aigFanout.c:56
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition: aigFanout.c:89
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Aig_Obj_t * Saig_ManRetimeNodeBwd(Aig_Man_t *p, Aig_Obj_t *pObjLo)
Definition: saigRetStep.c:121
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
void Aig_ObjReplace(Aig_Man_t *p, Aig_Obj_t *pObjOld, Aig_Obj_t *pObjNew, int fUpdateLevel)
Definition: aigObj.c:467
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition: aigUtil.c:965
ABC_NAMESPACE_IMPL_START Aig_Obj_t * Saig_ManRetimeNodeFwd(Aig_Man_t *p, Aig_Obj_t *pObj, int fMakeBug)
DECLARATIONS ///.
Definition: saigRetStep.c:45
#define assert(ex)
Definition: util_old.h:213
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265