abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigFrames.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [aigFrames.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [AIG package.]
8 
9  Synopsis [Performs timeframe expansion of the AIG.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: aigFrames.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "aig.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static inline Aig_Obj_t * Aig_ObjFrames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return pObjMap[nFs*pObj->Id + i]; }
31 static inline void Aig_ObjSetFrames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i, Aig_Obj_t * pNode ) { pObjMap[nFs*pObj->Id + i] = pNode; }
32 
33 static inline Aig_Obj_t * Aig_ObjChild0Frames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return Aig_ObjFanin0(pObj)? Aig_NotCond(Aig_ObjFrames(pObjMap,nFs,Aig_ObjFanin0(pObj),i), Aig_ObjFaninC0(pObj)) : NULL; }
34 static inline Aig_Obj_t * Aig_ObjChild1Frames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return Aig_ObjFanin1(pObj)? Aig_NotCond(Aig_ObjFrames(pObjMap,nFs,Aig_ObjFanin1(pObj),i), Aig_ObjFaninC1(pObj)) : NULL; }
35 
36 ////////////////////////////////////////////////////////////////////////
37 /// FUNCTION DEFINITIONS ///
38 ////////////////////////////////////////////////////////////////////////
39 
40 /**Function*************************************************************
41 
42  Synopsis [Performs timeframe expansion of the AIG.]
43 
44  Description []
45 
46  SideEffects []
47 
48  SeeAlso []
49 
50 ***********************************************************************/
51 Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int fRegs, int fEnlarge, Aig_Obj_t *** ppObjMap )
52 {
53  Aig_Man_t * pFrames;
54  Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjNew;
55  Aig_Obj_t ** pObjMap;
56  int i, f;
57 
58  // create mapping for the frames nodes
59  pObjMap = ABC_ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) );
60  memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFs * Aig_ManObjNumMax(pAig) );
61 
62  // start the fraig package
63  pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFs );
64  pFrames->pName = Abc_UtilStrsav( pAig->pName );
65  pFrames->pSpec = Abc_UtilStrsav( pAig->pSpec );
66  // map constant nodes
67  for ( f = 0; f < nFs; f++ )
68  Aig_ObjSetFrames( pObjMap, nFs, Aig_ManConst1(pAig), f, Aig_ManConst1(pFrames) );
69  // create PI nodes for the frames
70  for ( f = 0; f < nFs; f++ )
71  Aig_ManForEachPiSeq( pAig, pObj, i )
72  Aig_ObjSetFrames( pObjMap, nFs, pObj, f, Aig_ObjCreateCi(pFrames) );
73  // set initial state for the latches
74  if ( fInit )
75  {
76  Aig_ManForEachLoSeq( pAig, pObj, i )
77  Aig_ObjSetFrames( pObjMap, nFs, pObj, 0, Aig_ManConst0(pFrames) );
78  }
79  else
80  {
81  Aig_ManForEachLoSeq( pAig, pObj, i )
82  Aig_ObjSetFrames( pObjMap, nFs, pObj, 0, Aig_ObjCreateCi(pFrames) );
83  }
84 
85  // add timeframes
86  for ( f = 0; f < nFs; f++ )
87  {
88 // printf( "Frame = %d.\n", f );
89  // add internal nodes of this frame
90  Aig_ManForEachNode( pAig, pObj, i )
91  {
92 // Aig_Obj_t * pFanin0 = Aig_ObjChild0Frames(pObjMap,nFs,pObj,f);
93 // Aig_Obj_t * pFanin1 = Aig_ObjChild1Frames(pObjMap,nFs,pObj,f);
94 // printf( "Node = %3d. Fanin0 = %3d. Fanin1 = %3d.\n", pObj->Id, Aig_Regular(pFanin0)->Id, Aig_Regular(pFanin1)->Id );
95  pObjNew = Aig_And( pFrames, Aig_ObjChild0Frames(pObjMap,nFs,pObj,f), Aig_ObjChild1Frames(pObjMap,nFs,pObj,f) );
96  Aig_ObjSetFrames( pObjMap, nFs, pObj, f, pObjNew );
97  }
98  // set the latch inputs and copy them into the latch outputs of the next frame
99  Aig_ManForEachLiLoSeq( pAig, pObjLi, pObjLo, i )
100  {
101  pObjNew = Aig_ObjChild0Frames(pObjMap,nFs,pObjLi,f);
102  if ( f < nFs - 1 )
103  Aig_ObjSetFrames( pObjMap, nFs, pObjLo, f+1, pObjNew );
104  }
105  }
106  if ( fOuts )
107  {
108  for ( f = fEnlarge?nFs-1:0; f < nFs; f++ )
109  Aig_ManForEachPoSeq( pAig, pObj, i )
110  {
111  pObjNew = Aig_ObjCreateCo( pFrames, Aig_ObjChild0Frames(pObjMap,nFs,pObj,f) );
112  Aig_ObjSetFrames( pObjMap, nFs, pObj, f, pObjNew );
113  }
114  }
115  if ( fRegs )
116  {
117  pFrames->nRegs = pAig->nRegs;
118  Aig_ManForEachLiSeq( pAig, pObj, i )
119  {
120  pObjNew = Aig_ObjCreateCo( pFrames, Aig_ObjChild0Frames(pObjMap,nFs,pObj,fEnlarge?0:nFs-1) );
121  Aig_ObjSetFrames( pObjMap, nFs, pObj, nFs-1, pObjNew );
122  }
123  Aig_ManSetRegNum( pFrames, Aig_ManRegNum(pAig) );
124  }
125  Aig_ManCleanup( pFrames );
126  // return the new manager
127  if ( ppObjMap )
128  *ppObjMap = pObjMap;
129  else
130  ABC_FREE( pObjMap );
131  return pFrames;
132 }
133 
134 ////////////////////////////////////////////////////////////////////////
135 /// END OF FILE ///
136 ////////////////////////////////////////////////////////////////////////
137 
138 
140 
char * memset()
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static Aig_Obj_t * Aig_ObjChild1Frames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
Definition: aigFrames.c:34
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static void Aig_ObjSetFrames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
Definition: aigFrames.c:31
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition: aig.h:450
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: aig.h:69
static ABC_NAMESPACE_IMPL_START Aig_Obj_t * Aig_ObjFrames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
DECLARATIONS ///.
Definition: aigFrames.c:30
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Aig_Obj_t * Aig_ObjChild0Frames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
Definition: aigFrames.c:33
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition: aig.h:447
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition: aig.h:444
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Id
Definition: aig.h:85
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
Aig_Man_t * Aig_ManFrames(Aig_Man_t *pAig, int nFs, int fInit, int fOuts, int fRegs, int fEnlarge, Aig_Obj_t ***ppObjMap)
FUNCTION DEFINITIONS ///.
Definition: aigFrames.c:51
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438