ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
aigFrames.c
Go to the documentation of this file.
1
20
21#include "aig.h"
22
24
25
29
30static inline Aig_Obj_t * Aig_ObjFrames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return pObjMap[nFs*pObj->Id + i]; }
31static 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
33static 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; }
34static 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
39
51Aig_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
137
138
140
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
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
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition aigMan.c:438
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition aig.h:447
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
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#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
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition aig.h:438
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition aig.h:444
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition aig.h:441
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
Definition aig.h:450
int Id
Definition aig.h:85
char * memset()