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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Gia_CollectSuper_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
 DECLARATIONS ///. More...
 
void Gia_CollectSuper (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
 
void Gia_ManPrintSignals (Gia_Man_t *p, int *pFreq, char *pStr)
 
void Gia_ManDetectSeqSignals (Gia_Man_t *p, int fSetReset, int fVerbose)
 
Vec_Int_tGia_ManDetectSeqSignalsWithFanout (Gia_Man_t *p, int nFanMax, int fVerbose)
 
Vec_Int_tGia_ManTransferFrames (Gia_Man_t *pAig, Gia_Man_t *pFrames, int nFrames, Gia_Man_t *pNew, Vec_Int_t *vSigs)
 
Gia_Man_tGia_ManUnrollInit (Gia_Man_t *p, int nFrames)
 
Gia_Man_tGia_ManUnrollAndCofactor (Gia_Man_t *p, int nFrames, int nFanMax, int fVerbose)
 
Gia_Man_tGia_ManRemoveEnables2 (Gia_Man_t *p)
 
Gia_Man_tGia_ManRemoveEnables (Gia_Man_t *p)
 

Function Documentation

void Gia_CollectSuper ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vSuper 
)

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file giaEnable.c.

71 {
72  assert( !Gia_IsComplement(pObj) );
73  Vec_IntClear( vSuper );
74 // Gia_CollectSuper_rec( p, pObj, vSuper );
75  if ( Gia_ObjIsAnd(pObj) )
76  {
77  Vec_IntPushUnique( vSuper, Gia_ObjId(p, Gia_ObjFanin0(pObj)) );
78  Vec_IntPushUnique( vSuper, Gia_ObjId(p, Gia_ObjFanin1(pObj)) );
79  }
80  else
81  Vec_IntPushUnique( vSuper, Gia_ObjId(p, Gia_Regular(pObj)) );
82 
83 }
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_NAMESPACE_IMPL_START void Gia_CollectSuper_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vSuper 
)

DECLARATIONS ///.

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

FileName [gia.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Structural detection of enables, sets and resets.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file giaEnable.c.

46 {
47  // if the new node is complemented or a PI, another gate begins
48  if ( Gia_IsComplement(pObj) || Gia_ObjIsCi(pObj) )
49  {
50  Vec_IntPushUnique( vSuper, Gia_ObjId(p, Gia_Regular(pObj)) );
51  return;
52  }
53  assert( Gia_ObjIsAnd(pObj) );
54  // go through the branches
55  Gia_CollectSuper_rec( p, Gia_ObjChild0(pObj), vSuper );
56  Gia_CollectSuper_rec( p, Gia_ObjChild1(pObj), vSuper );
57 }
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
ABC_NAMESPACE_IMPL_START void Gia_CollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
DECLARATIONS ///.
Definition: giaEnable.c:45
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
void Gia_ManDetectSeqSignals ( Gia_Man_t p,
int  fSetReset,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file giaEnable.c.

131 {
132  Vec_Int_t * vSuper;
133  Gia_Obj_t * pFlop, * pObjC, * pObj0, * pObj1, * pNode, * pTemp;
134  int i, k, Ent, * pSets, * pResets, * pEnables;
135  int nHaveSetReset = 0, nHaveEnable = 0;
136  assert( Gia_ManRegNum(p) > 0 );
137  pSets = ABC_CALLOC( int, Gia_ManObjNum(p) );
138  pResets = ABC_CALLOC( int, Gia_ManObjNum(p) );
139  pEnables = ABC_CALLOC( int, Gia_ManObjNum(p) );
140  vSuper = Vec_IntAlloc( 100 );
141  Gia_ManForEachRi( p, pFlop, i )
142  {
143  pNode = Gia_ObjFanin0(pFlop);
144  if ( !Gia_ObjIsAnd(pNode) )
145  continue;
146  // detect sets/resets
147  Gia_CollectSuper( p, pNode, vSuper );
148  if ( Gia_ObjFaninC0(pFlop) )
149  Vec_IntForEachEntry( vSuper, Ent, k )
150  pSets[Ent]++;
151  else
152  Vec_IntForEachEntry( vSuper, Ent, k )
153  pResets[Ent]++;
154  // detect enables
155  if ( !Gia_ObjIsMuxType(pNode) )
156  continue;
157  pObjC = Gia_ObjRecognizeMux( pNode, &pObj0, &pObj1 );
158  pTemp = Gia_ObjRiToRo( p, pFlop );
159  if ( Gia_Regular(pObj0) != pTemp && Gia_Regular(pObj1) != pTemp )
160  continue;
161  if ( !Gia_ObjFaninC0(pFlop) )
162  {
163  pObj0 = Gia_Not(pObj0);
164  pObj1 = Gia_Not(pObj1);
165  }
166  if ( Gia_IsComplement(pObjC) )
167  {
168  pObjC = Gia_Not(pObjC);
169  pTemp = pObj0;
170  pObj0 = pObj1;
171  pObj1 = pTemp;
172  }
173  // detect controls
174 // Gia_CollectSuper( p, pObjC, vSuper );
175 // Vec_IntForEachEntry( vSuper, Ent, k )
176 // pEnables[Ent]++;
177  pEnables[Gia_ObjId(p, pObjC)]++;
178  nHaveEnable++;
179  }
180  Gia_ManForEachRi( p, pFlop, i )
181  {
182  pNode = Gia_ObjFanin0(pFlop);
183  if ( !Gia_ObjIsAnd(pNode) )
184  continue;
185  // detect sets/resets
186  Gia_CollectSuper( p, pNode, vSuper );
187  Vec_IntForEachEntry( vSuper, Ent, k )
188  if ( pSets[Ent] > 1 || pResets[Ent] > 1 )
189  {
190  nHaveSetReset++;
191  break;
192  }
193  }
194  Vec_IntFree( vSuper );
195  ABC_FREE( p->pRefs );
196  Gia_ManCreateRefs( p );
197  if ( fVerbose )
198  {
199  printf( "Flops with set/reset = %6d. Flops with enable = %6d.\n", nHaveSetReset, nHaveEnable );
200  if ( fSetReset )
201  {
202  Gia_ManPrintSignals( p, pSets, "Set signals" );
203  Gia_ManPrintSignals( p, pResets, "Reset signals" );
204  }
205  Gia_ManPrintSignals( p, pEnables, "Enable signals" );
206  }
207  ABC_FREE( p->pRefs );
208  ABC_FREE( pSets );
209  ABC_FREE( pResets );
210  ABC_FREE( pEnables );
211 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
void Gia_CollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
Definition: giaEnable.c:70
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
void Gia_ManPrintSignals(Gia_Man_t *p, int *pFreq, char *pStr)
Definition: giaEnable.c:96
static Gia_Obj_t * Gia_Not(Gia_Obj_t *p)
Definition: gia.h:378
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Gia_Obj_t * Gia_ObjRiToRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:447
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Vec_Int_t* Gia_ManDetectSeqSignalsWithFanout ( Gia_Man_t p,
int  nFanMax,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file giaEnable.c.

225 {
226  Vec_Int_t * vResult;
227  Vec_Int_t * vSuper;
228  Gia_Obj_t * pFlop, * pObjC, * pObj0, * pObj1, * pNode, * pTemp;
229  int i, k, Ent, * pSets, * pResets, * pEnables;
230  int nHaveSetReset = 0, nHaveEnable = 0;
231  assert( Gia_ManRegNum(p) > 0 );
232  pSets = ABC_CALLOC( int, Gia_ManObjNum(p) );
233  pResets = ABC_CALLOC( int, Gia_ManObjNum(p) );
234  pEnables = ABC_CALLOC( int, Gia_ManObjNum(p) );
235  vSuper = Vec_IntAlloc( 100 );
236  Gia_ManForEachRi( p, pFlop, i )
237  {
238  pNode = Gia_ObjFanin0(pFlop);
239  if ( !Gia_ObjIsAnd(pNode) )
240  continue;
241  // detect sets/resets
242  Gia_CollectSuper( p, pNode, vSuper );
243  if ( Gia_ObjFaninC0(pFlop) )
244  Vec_IntForEachEntry( vSuper, Ent, k )
245  pSets[Ent]++;
246  else
247  Vec_IntForEachEntry( vSuper, Ent, k )
248  pResets[Ent]++;
249  // detect enables
250  if ( !Gia_ObjIsMuxType(pNode) )
251  continue;
252  pObjC = Gia_ObjRecognizeMux( pNode, &pObj0, &pObj1 );
253  pTemp = Gia_ObjRiToRo( p, pFlop );
254  if ( Gia_Regular(pObj0) != pTemp && Gia_Regular(pObj1) != pTemp )
255  continue;
256  if ( !Gia_ObjFaninC0(pFlop) )
257  {
258  pObj0 = Gia_Not(pObj0);
259  pObj1 = Gia_Not(pObj1);
260  }
261  if ( Gia_IsComplement(pObjC) )
262  {
263  pObjC = Gia_Not(pObjC);
264  pTemp = pObj0;
265  pObj0 = pObj1;
266  pObj1 = pTemp;
267  }
268  // detect controls
269 // Gia_CollectSuper( p, pObjC, vSuper );
270 // Vec_IntForEachEntry( vSuper, Ent, k )
271 // pEnables[Ent]++;
272  pEnables[Gia_ObjId(p, pObjC)]++;
273  nHaveEnable++;
274  }
275  Gia_ManForEachRi( p, pFlop, i )
276  {
277  pNode = Gia_ObjFanin0(pFlop);
278  if ( !Gia_ObjIsAnd(pNode) )
279  continue;
280  // detect sets/resets
281  Gia_CollectSuper( p, pNode, vSuper );
282  Vec_IntForEachEntry( vSuper, Ent, k )
283  if ( pSets[Ent] > 1 || pResets[Ent] > 1 )
284  {
285  nHaveSetReset++;
286  break;
287  }
288  }
289  Vec_IntFree( vSuper );
290  vResult = Vec_IntAlloc( 100 );
291  for ( i = 1; i < Gia_ManObjNum(p); i++ )
292  if ( pSets[i] > nFanMax )
293  {
294  if ( fVerbose )
295  printf( "Adding set signal %d related to %d flops.\n", i, pSets[i] );
296  Vec_IntPushUnique( vResult, i );
297  }
298  for ( i = 1; i < Gia_ManObjNum(p); i++ )
299  if ( pResets[i] > nFanMax )
300  {
301  if ( fVerbose )
302  printf( "Adding reset signal %d related to %d flops.\n", i, pResets[i] );
303  Vec_IntPushUnique( vResult, i );
304  }
305  for ( i = 1; i < Gia_ManObjNum(p); i++ )
306  if ( pEnables[i] > nFanMax )
307  {
308  if ( fVerbose )
309  printf( "Adding enable signal %d related to %d flops.\n", i, pEnables[i] );
310  Vec_IntPushUnique( vResult, i );
311  }
312  ABC_FREE( pSets );
313  ABC_FREE( pResets );
314  ABC_FREE( pEnables );
315  return vResult;
316 }
void Gia_CollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
Definition: giaEnable.c:70
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
Definition: gia.h:75
static Gia_Obj_t * Gia_Not(Gia_Obj_t *p)
Definition: gia.h:378
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Gia_Obj_t * Gia_ObjRiToRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:447
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Gia_ManPrintSignals ( Gia_Man_t p,
int *  pFreq,
char *  pStr 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file giaEnable.c.

97 {
98  Vec_Int_t * vObjs;
99  int i, Counter = 0, nTotal = 0;
100  vObjs = Vec_IntAlloc( 100 );
101  for ( i = 0; i < Gia_ManObjNum(p); i++ )
102  if ( pFreq[i] > 1 )
103  {
104  nTotal += pFreq[i];
105  Counter++;
106  }
107  printf( "%s (total = %d driven = %d)\n", pStr, Counter, nTotal );
108  Counter = 0;
109  for ( i = 0; i < Gia_ManObjNum(p); i++ )
110  if ( pFreq[i] > 10 )
111  {
112  printf( "%3d : Obj = %6d Refs = %6d Freq = %6d\n",
113  ++Counter, i, Gia_ObjRefNum(p, Gia_ManObj(p,i)), pFreq[i] );
114  Vec_IntPush( vObjs, i );
115  }
116  Vec_IntFree( vObjs );
117 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
Gia_Man_t* Gia_ManRemoveEnables ( Gia_Man_t p)

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

Synopsis [Transform seq circuits with enables by removing enables.]

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file giaEnable.c.

515 {
516  Vec_Ptr_t * vCtrls, * vDatas;
517  Vec_Int_t * vFlopClasses;
518  Gia_Man_t * pNew, * pAux;
519  Gia_Obj_t * pFlopIn, * pFlopOut, * pDriver, * pFan0, * pFan1, * pCtrl, * pData, * pObj;
520  int i, iClass, fCompl, Counter = 0;
521  vCtrls = Vec_PtrAlloc( 100 );
522  Vec_PtrPush( vCtrls, NULL );
523  vDatas = Vec_PtrAlloc( Gia_ManRegNum(p) );
524  vFlopClasses = Vec_IntAlloc( Gia_ManRegNum(p) );
525  Gia_ManForEachRi( p, pFlopIn, i )
526  {
527  fCompl = Gia_ObjFaninC0(pFlopIn);
528  pDriver = Gia_ObjFanin0(pFlopIn);
529  if ( !Gia_ObjIsAnd(pDriver) )
530  {
531  printf( "The flop driver %d is not a node.\n", i );
532  Vec_PtrPush( vDatas, NULL );
533  Vec_IntPush( vFlopClasses, 0 );
534  Counter++;
535  continue;
536  }
537  if ( !Gia_ObjFaninC0(pDriver) || !Gia_ObjFaninC1(pDriver) )
538  {
539  printf( "The flop driver %d is not an OR gate.\n", i );
540  Vec_PtrPush( vDatas, NULL );
541  Vec_IntPush( vFlopClasses, 0 );
542  Counter++;
543  continue;
544  }
545  pFan0 = Gia_ObjFanin0(pDriver);
546  pFan1 = Gia_ObjFanin1(pDriver);
547  if ( !Gia_ObjIsAnd(pFan0) || !Gia_ObjIsAnd(pFan1) )
548  {
549  printf( "The flop driver fanin %d is not a node.\n", i );
550  Vec_PtrPush( vDatas, NULL );
551  Vec_IntPush( vFlopClasses, 0 );
552  Counter++;
553  continue;
554  }
555  pFlopOut = Gia_ObjRiToRo( p, pFlopIn );
556  pFlopOut = Gia_NotCond( pFlopOut, !fCompl );
557  if ( Gia_ObjChild0(pFan0) != pFlopOut && Gia_ObjChild1(pFan0) != pFlopOut &&
558  Gia_ObjChild0(pFan1) != pFlopOut && Gia_ObjChild1(pFan1) != pFlopOut )
559  {
560  printf( "The flop %d does not have a self-loop.\n", i );
561  Vec_PtrPush( vDatas, NULL );
562  Vec_IntPush( vFlopClasses, 0 );
563  Counter++;
564  continue;
565  }
566  pData = NULL;
567  if ( Gia_ObjChild0(pFan0) == pFlopOut )
568  {
569  pCtrl = Gia_Not( Gia_ObjChild1(pFan0) );
570  if ( Gia_ObjFanin0(pFan1) == Gia_Regular(pCtrl) )
571  pData = Gia_ObjChild1(pFan1);
572  else
573  pData = Gia_ObjChild0(pFan1);
574  }
575  else if ( Gia_ObjChild1(pFan0) == pFlopOut )
576  {
577  pCtrl = Gia_Not( Gia_ObjChild0(pFan0) );
578  if ( Gia_ObjFanin0(pFan1) == Gia_Regular(pCtrl) )
579  pData = Gia_ObjChild1(pFan1);
580  else
581  pData = Gia_ObjChild0(pFan1);
582  }
583  else if ( Gia_ObjChild0(pFan1) == pFlopOut )
584  {
585  pCtrl = Gia_Not( Gia_ObjChild1(pFan1) );
586  if ( Gia_ObjFanin0(pFan0) == Gia_Regular(pCtrl) )
587  pData = Gia_ObjChild1(pFan0);
588  else
589  pData = Gia_ObjChild0(pFan0);
590  }
591  else if ( Gia_ObjChild1(pFan1) == pFlopOut )
592  {
593  pCtrl = Gia_Not( Gia_ObjChild0(pFan1) );
594  if ( Gia_ObjFanin0(pFan0) == Gia_Regular(pCtrl) )
595  pData = Gia_ObjChild1(pFan0);
596  else
597  pData = Gia_ObjChild0(pFan0);
598  }
599  else assert( 0 );
600  if ( Vec_PtrFind( vCtrls, pCtrl ) == -1 )
601  Vec_PtrPush( vCtrls, pCtrl );
602  iClass = Vec_PtrFind( vCtrls, pCtrl );
603  pData = Gia_NotCond( pData, !fCompl );
604  Vec_PtrPush( vDatas, pData );
605  Vec_IntPush( vFlopClasses, iClass );
606  }
607  assert( Vec_PtrSize( vDatas ) == Gia_ManRegNum(p) );
608  assert( Vec_IntSize( vFlopClasses ) == Gia_ManRegNum(p) );
609  printf( "Detected %d classes.\n", Vec_PtrSize(vCtrls) - (Counter == 0) );
610  Vec_PtrFree( vCtrls );
611 
612 
613  pNew = Gia_ManStart( Gia_ManObjNum(p) );
614  pNew->pName = Abc_UtilStrsav( p->pName );
615  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
616  Gia_ManConst0(p)->Value = 0;
617  Gia_ManForEachObj1( p, pObj, i )
618  {
619  if ( Gia_ObjIsAnd(pObj) )
620  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
621  else if ( Gia_ObjIsCi(pObj) )
622  pObj->Value = Gia_ManAppendCi( pNew );
623  else if ( Gia_ObjIsPo(p, pObj) )
624  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
625  }
626  Gia_ManForEachRi( p, pObj, i )
627  {
628  pData = (Gia_Obj_t *)Vec_PtrEntry(vDatas, i);
629  if ( pData == NULL )
630  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
631  else
632  pObj->Value = Gia_ManAppendCo( pNew, Abc_LitNotCond(Gia_Regular(pData)->Value, Gia_IsComplement(pData)) );
633  }
634  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
635  Vec_PtrFree( vDatas );
636 
637 
638  pNew = Gia_ManCleanup( pAux = pNew );
639  Gia_ManStop( pAux );
640  pNew->vFlopClasses = vFlopClasses;
641  return pNew;
642 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Gia_Obj_t * Gia_NotCond(Gia_Obj_t *p, int c)
Definition: gia.h:379
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
Vec_Int_t * vFlopClasses
Definition: gia.h:140
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
static Gia_Obj_t * Gia_Not(Gia_Obj_t *p)
Definition: gia.h:378
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static Gia_Obj_t * Gia_ObjRiToRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:447
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Gia_ObjIsPo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:442
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_Man_t* Gia_ManRemoveEnables2 ( Gia_Man_t p)

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

Synopsis [Transform seq circuits with enables by removing enables.]

Description []

SideEffects []

SeeAlso []

Definition at line 436 of file giaEnable.c.

437 {
438  Gia_Man_t * pNew, * pAux;
439  Gia_Obj_t * pTemp, * pObjC, * pObj0, * pObj1, * pFlopIn, * pFlopOut;
440  Gia_Obj_t * pThis, * pNode;
441  int i;
442  pNew = Gia_ManStart( Gia_ManObjNum(p) );
443  pNew->pName = Abc_UtilStrsav( p->pName );
444  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
445  Gia_ManHashAlloc( pNew );
446  Gia_ManFillValue( p );
447  Gia_ManConst0(p)->Value = 0;
448  Gia_ManForEachCi( p, pThis, i )
449  pThis->Value = Gia_ManAppendCi( pNew );
450  Gia_ManForEachAnd( p, pThis, i )
451  pThis->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pThis), Gia_ObjFanin1Copy(pThis) );
452  Gia_ManForEachPo( p, pThis, i )
453  pThis->Value = Gia_ObjFanin0Copy(pThis);
454  Gia_ManForEachRi( p, pFlopIn, i )
455  {
456  pNode = Gia_ObjFanin0(pFlopIn);
457  if ( !Gia_ObjIsMuxType(pNode) )
458  {
459  printf( "Cannot recognize enable of flop %d.\n", i );
460  continue;
461  }
462  pObjC = Gia_ObjRecognizeMux( pNode, &pObj1, &pObj0 );
463  pFlopOut = Gia_ObjRiToRo( p, pFlopIn );
464  if ( Gia_Regular(pObj0) != pFlopOut && Gia_Regular(pObj1) != pFlopOut )
465  {
466  printf( "Cannot recognize self-loop of enable flop %d.\n", i );
467  continue;
468  }
469  if ( !Gia_ObjFaninC0(pFlopIn) )
470  {
471  pObj0 = Gia_Not(pObj0);
472  pObj1 = Gia_Not(pObj1);
473  }
474  if ( Gia_IsComplement(pObjC) )
475  {
476  pObjC = Gia_Not(pObjC);
477  pTemp = pObj0;
478  pObj0 = pObj1;
479  pObj1 = pTemp;
480  }
481  if ( Gia_Regular(pObj0) == pFlopOut )
482  {
483 // printf( "FlopIn compl = %d. FlopOut is d0. Complement = %d.\n",
484 // Gia_ObjFaninC0(pFlopIn), Gia_IsComplement(pObj0) );
485  pFlopIn->Value = Abc_LitNotCond(Gia_Regular(pObj1)->Value, !Gia_IsComplement(pObj1));
486  }
487  else if ( Gia_Regular(pObj1) == pFlopOut )
488  {
489 // printf( "FlopIn compl = %d. FlopOut is d1. Complement = %d.\n",
490 // Gia_ObjFaninC0(pFlopIn), Gia_IsComplement(pObj1) );
491  pFlopIn->Value = Abc_LitNotCond(Gia_Regular(pObj0)->Value, !Gia_IsComplement(pObj0));
492  }
493  }
494  Gia_ManForEachCo( p, pThis, i )
495  Gia_ManAppendCo( pNew, pThis->Value );
496  Gia_ManHashStop( pNew );
497  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
498  pNew = Gia_ManCleanup( pAux = pNew );
499  Gia_ManStop( pAux );
500  return pNew;
501 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static Gia_Obj_t * Gia_Not(Gia_Obj_t *p)
Definition: gia.h:378
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static Gia_Obj_t * Gia_ObjRiToRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:447
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Vec_Int_t* Gia_ManTransferFrames ( Gia_Man_t pAig,
Gia_Man_t pFrames,
int  nFrames,
Gia_Man_t pNew,
Vec_Int_t vSigs 
)

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

Synopsis [Transfers attributes from the original one to the final one.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file giaEnable.c.

331 {
332  Vec_Int_t * vSigsNew;
333  Gia_Obj_t * pObj, * pObjF;
334  int k, f;
335  vSigsNew = Vec_IntAlloc( 100 );
336  Gia_ManForEachObjVec( vSigs, pAig, pObj, k )
337  {
338  assert( Gia_ObjIsCand(pObj) );
339  for ( f = 0; f < nFrames; f++ )
340  {
341  pObjF = Gia_ManObj( pFrames, Abc_Lit2Var(Gia_ObjCopyF( pAig, f, pObj )) );
342  if ( pObjF->Value && ~pObjF->Value )
343  Vec_IntPushUnique( vSigsNew, Abc_Lit2Var(pObjF->Value) );
344  }
345  }
346  return vSigsNew;
347 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static int Gia_ObjCopyF(Gia_Man_t *p, int f, Gia_Obj_t *pObj)
Definition: gia.h:485
Gia_Man_t* Gia_ManUnrollAndCofactor ( Gia_Man_t p,
int  nFrames,
int  nFanMax,
int  fVerbose 
)

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

Synopsis [Unrolls initialized timeframes while cofactoring some vars.]

Description []

SideEffects []

SeeAlso []

Definition at line 403 of file giaEnable.c.

404 {
405  Vec_Int_t * vCofSigs, * vTemp;
406  Gia_Man_t * pAig, * pFrames, * pNew;
407  // compute initialized timeframes
408  pFrames = Gia_ManUnrollInit( p, nFrames );
409  pAig = Gia_ManCleanup( pFrames );
410  // compute and remap set/reset/enable signals
411  vCofSigs = Gia_ManDetectSeqSignalsWithFanout( p, nFanMax, fVerbose );
412  vCofSigs = Gia_ManTransferFrames( p, pFrames, nFrames, pAig, vTemp = vCofSigs );
413  Vec_IntFree( vTemp );
414  Gia_ManStop( pFrames );
415  Vec_IntErase( &p->vCopies );
416  // cofactor all these variables
417  pNew = Gia_ManDupCofAllInt( pAig, vCofSigs, fVerbose );
418  Vec_IntFree( vCofSigs );
419  Gia_ManStop( pAig );
420  return pNew;
421 }
Vec_Int_t * Gia_ManDetectSeqSignalsWithFanout(Gia_Man_t *p, int nFanMax, int fVerbose)
Definition: giaEnable.c:224
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Gia_Man_t * Gia_ManDupCofAllInt(Gia_Man_t *p, Vec_Int_t *vSigs, int fVerbose)
Definition: giaCof.c:936
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_IntErase(Vec_Int_t *p)
Definition: vecInt.h:266
Vec_Int_t * Gia_ManTransferFrames(Gia_Man_t *pAig, Gia_Man_t *pFrames, int nFrames, Gia_Man_t *pNew, Vec_Int_t *vSigs)
Definition: giaEnable.c:330
Definition: gia.h:95
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Gia_Man_t * Gia_ManUnrollInit(Gia_Man_t *p, int nFrames)
Definition: giaEnable.c:360
Vec_Int_t vCopies
Definition: gia.h:138
Gia_Man_t* Gia_ManUnrollInit ( Gia_Man_t p,
int  nFrames 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 360 of file giaEnable.c.

361 {
362  Gia_Man_t * pNew;
363  Gia_Obj_t * pObj, * pObjRi, * pObjRo;
364  int f, i;
365  Vec_IntFill( &p->vCopies, nFrames * Gia_ManObjNum(p), -1 );
366  pNew = Gia_ManStart( nFrames * Gia_ManObjNum(p) );
367  pNew->pName = Abc_UtilStrsav( p->pName );
368  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
369  Gia_ManHashAlloc( pNew );
370  Gia_ManForEachRo( p, pObj, i )
371  Gia_ObjSetCopyF( p, 0, pObj, 0 );
372  for ( f = 0; f < nFrames; f++ )
373  {
374  Gia_ObjSetCopyF( p, f, Gia_ManConst0(p), 0 );
375  Gia_ManForEachPi( p, pObj, i )
376  Gia_ObjSetCopyF( p, f, pObj, Gia_ManAppendCi(pNew) );
377  Gia_ManForEachAnd( p, pObj, i )
378  Gia_ObjSetCopyF( p, f, pObj, Gia_ManHashAnd(pNew, Gia_ObjFanin0CopyF(p, f, pObj), Gia_ObjFanin1CopyF(p, f, pObj)) );
379  Gia_ManForEachCo( p, pObj, i )
380  Gia_ObjSetCopyF( p, f, pObj, Gia_ObjFanin0CopyF(p, f, pObj) );
381  Gia_ManForEachPo( p, pObj, i )
382  Gia_ManAppendCo( pNew, Gia_ObjCopyF(p, f, pObj) );
383  if ( f == nFrames - 1 )
384  break;
385  Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
386  Gia_ObjSetCopyF( p, f+1, pObjRo, Gia_ObjCopyF(p, f, pObjRi) );
387  }
388  Gia_ManHashStop( pNew );
389  return pNew;
390 }
static void Gia_ObjSetCopyF(Gia_Man_t *p, int f, Gia_Obj_t *pObj, int iLit)
Definition: gia.h:486
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static int Gia_ObjFanin1CopyF(Gia_Man_t *p, int f, Gia_Obj_t *pObj)
Definition: gia.h:492
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
for(p=first;p->value< newval;p=p->next)
Definition: gia.h:75
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition: gia.h:1042
char * pName
Definition: gia.h:97
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
if(last==0)
Definition: sparse_int.h:34
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ObjFanin0CopyF(Gia_Man_t *p, int f, Gia_Obj_t *pObj)
Definition: gia.h:491
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Vec_Int_t vCopies
Definition: gia.h:138
static int Gia_ObjCopyF(Gia_Man_t *p, int f, Gia_Obj_t *pObj)
Definition: gia.h:485