ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
saigRetStep.c
Go to the documentation of this file.
1
20
21#include "saig.h"
22
24
25
29
33
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}
109
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}
169
181int Saig_ManRetimeSteps( Aig_Man_t * p, int nSteps, int fForward, int fAddBugs )
182{
183 Aig_Obj_t * pObj, * pObjNew;
184 int RetValue, s, i;
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;
224 RetValue = Aig_ManCleanup( p );
225 assert( RetValue == 0 );
226 Aig_ManSetRegNum( p, p->nRegs );
227 return s;
228}
229
233
234
236
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigFanout.c:56
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition aigMan.c:438
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition aigFanout.c:89
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
void Aig_ObjReplace(Aig_Man_t *p, Aig_Obj_t *pObjOld, Aig_Obj_t *pObjNew, int fUpdateLevel)
Definition aigObj.c:467
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
Cube * p
Definition exorList.c:222
ABC_NAMESPACE_IMPL_START Aig_Obj_t * Saig_ManRetimeNodeFwd(Aig_Man_t *p, Aig_Obj_t *pObj, int fMakeBug)
DECLARATIONS ///.
Definition saigRetStep.c:45
Aig_Obj_t * Saig_ManRetimeNodeBwd(Aig_Man_t *p, Aig_Obj_t *pObjLo)
int Saig_ManRetimeSteps(Aig_Man_t *p, int nSteps, int fForward, int fAddBugs)
void Saig_ManMarkAutonomous(Aig_Man_t *p)
Definition saigRetFwd.c:111
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
int CioId
Definition aig.h:73
#define assert(ex)
Definition util_old.h:213