ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
acecStruct.c
Go to the documentation of this file.
1
20
21#include "acecInt.h"
22#include "misc/vec/vecWec.h"
23#include "misc/extra/extra.h"
24
26
30
31
35
48{
49 Vec_Int_t * vXors = Vec_IntAlloc( 100 );
50 Vec_Bit_t * vXorIns = Vec_BitStart( Gia_ManObjNum(p) );
51 Gia_Obj_t * pFan0, * pFan1, * pObj;
52 int i, k = 0, Entry;
53 Gia_ManForEachAnd( p, pObj, i )
54 {
55 if ( !Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
56 continue;
57 Vec_IntPush( vXors, i );
58 Vec_BitWriteEntry( vXorIns, Gia_ObjId(p, Gia_Regular(pFan0)), 1 );
59 Vec_BitWriteEntry( vXorIns, Gia_ObjId(p, Gia_Regular(pFan1)), 1 );
60 }
61 // collect XORs that not inputs of other XORs
62 Vec_IntForEachEntry( vXors, Entry, i )
63 if ( !Vec_BitEntry(vXorIns, Entry) )
64 Vec_IntWriteEntry( vXors, k++, Entry );
65 Vec_IntShrink( vXors, k );
66 Vec_BitFree( vXorIns );
67 return vXors;
68}
69
82{
83 Vec_Int_t * vDoubles = Vec_IntAlloc( 100 );
84 Gia_Obj_t * pFan0, * pFan1, * pObj;
85 int i, k, Fanins[2], Entry, Rank;
86 // map roots into their ranks
87 Vec_Int_t * vRanks = Vec_IntStartFull( Gia_ManObjNum(p) );
88 Vec_IntForEachEntry( vXorRoots, Entry, i )
89 Vec_IntWriteEntry( vRanks, Entry, i );
90 // map nodes into their ranks
91 Gia_ManForEachAndReverse( p, pObj, i )
92 {
93 if ( !Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
94 continue;
95 Rank = Vec_IntEntry( vRanks, i );
96 // skip XORs that are not part of any tree
97 if ( Rank == -1 )
98 continue;
99 // iterate through XOR inputs
100 Fanins[0] = Gia_ObjId(p, Gia_Regular(pFan0));
101 Fanins[1] = Gia_ObjId(p, Gia_Regular(pFan1));
102 for ( k = 0; k < 2; k++ )
103 {
104 Entry = Vec_IntEntry( vRanks, Fanins[k] );
105 if ( Entry == Rank ) // the same tree -- allow fanout in this tree
106 continue;
107 if ( Entry == -1 )
108 Vec_IntWriteEntry( vRanks, Fanins[k], Rank );
109 else
110 Vec_IntPush( vDoubles, Fanins[k] );
111 if ( Entry != -1 && Gia_ObjIsAnd(Gia_ManObj(p, Fanins[k])))
112 printf( "Xor node %d belongs to Tree %d and Tree %d.\n", Fanins[k], Entry, Rank );
113 }
114 }
115 // remove duplicated entries
116 Vec_IntForEachEntry( vDoubles, Entry, i )
117 Vec_IntWriteEntry( vRanks, Entry, -1 );
118 Vec_IntFree( vDoubles );
119 return vRanks;
120}
121
134{
135 Vec_Bit_t * vMapXors = Vec_BitStart( Gia_ManObjNum(p) );
136 Vec_Wec_t * vTreeLeaves = Vec_WecStart( Vec_IntSize(vXorRoots) );
137 Gia_Obj_t * pFan0, * pFan1, * pObj;
138 int i, k, Fanins[2], Rank;
139 Gia_ManForEachAnd( p, pObj, i )
140 {
141 if ( !Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
142 continue;
143 Vec_BitWriteEntry( vMapXors, i, 1 );
144 Rank = Vec_IntEntry( vRanks, i );
145 // skip XORs that are not part of any tree
146 if ( Rank == -1 )
147 continue;
148 // iterate through XOR inputs
149 Fanins[0] = Gia_ObjId(p, Gia_Regular(pFan0));
150 Fanins[1] = Gia_ObjId(p, Gia_Regular(pFan1));
151 for ( k = 0; k < 2; k++ )
152 {
153 if ( Vec_BitEntry(vMapXors, Fanins[k]) )
154 {
155 assert( Rank == Vec_IntEntry(vRanks, Fanins[k]) );
156 continue;
157 }
158 Vec_WecPush( vTreeLeaves, Rank, Fanins[k] );
159 }
160 }
161 Vec_BitFree( vMapXors );
162 return vTreeLeaves;
163}
164
177{
178 Vec_Int_t * vShadows = Vec_IntDup( vRanks );
179 Gia_Obj_t * pObj; int i, Shad0, Shad1;
180 Gia_ManForEachCi( p, pObj, i )
181 Vec_IntWriteEntry( vShadows, Gia_ObjId(p, pObj), -1 );
182 Gia_ManForEachAnd( p, pObj, i )
183 {
184 if ( Vec_IntEntry(vShadows, i) >= 0 )
185 continue;
186 Shad0 = Vec_IntEntry(vShadows, Gia_ObjFaninId0(pObj, i));
187 Shad1 = Vec_IntEntry(vShadows, Gia_ObjFaninId1(pObj, i));
188 if ( Shad0 == Shad1 && Shad0 != -1 )
189 Vec_IntWriteEntry(vShadows, i, Shad0);
190 }
191 return vShadows;
192}
193
205int Acec_CollectSupp_rec( Gia_Man_t * p, int iNode, int Rank, Vec_Int_t * vRanks )
206{
207 Gia_Obj_t * pObj;
208 int nSize;
209 if ( Gia_ObjIsTravIdCurrentId(p, iNode) )
210 return 0;
211 Gia_ObjSetTravIdCurrentId(p, iNode);
212 pObj = Gia_ManObj(p, iNode);
213 assert( Gia_ObjIsAnd(pObj) );
214 if ( Vec_IntEntry(vRanks, iNode) == Rank )
215 return 1;
216 nSize = Acec_CollectSupp_rec( p, Gia_ObjFaninId0(pObj, iNode), Rank, vRanks );
217 nSize += Acec_CollectSupp_rec( p, Gia_ObjFaninId1(pObj, iNode), Rank, vRanks );
218 return nSize;
219}
220Vec_Wec_t * Acec_FindNexts( Gia_Man_t * p, Vec_Int_t * vRanks, Vec_Int_t * vShadows, Vec_Wec_t * vTreeLeaves )
221{
222 Vec_Wec_t * vNexts = Vec_WecStart( Vec_WecSize(vTreeLeaves) );
223 Vec_Int_t * vTree;
224 int i, k, Node, Fanins[2], Shad0, Shad1, Rank, nSupp;
225 Vec_WecForEachLevel( vTreeLeaves, vTree, i )
226 Vec_IntForEachEntry( vTree, Node, k )
227 {
228 Gia_Obj_t * pObj = Gia_ManObj(p, Node);
229 if ( !Gia_ObjIsAnd(pObj) )
230 continue;
231 Fanins[0] = Gia_ObjFaninId0(pObj, Node);
232 Fanins[1] = Gia_ObjFaninId1(pObj, Node);
233 Shad0 = Vec_IntEntry(vShadows, Fanins[0]);
234 Shad1 = Vec_IntEntry(vShadows, Fanins[1]);
235 if ( Shad0 != Shad1 || Shad0 == -1 )
236 continue;
237 // check support size of Node in terms of the shadow of its fanins
238 Rank = Vec_IntEntry( vRanks, Node );
239 assert( Rank != Shad0 );
241 nSupp = Acec_CollectSupp_rec( p, Node, Shad0, vRanks );
242 assert( nSupp > 1 );
243 if ( nSupp > 3 )
244 continue;
245 Vec_IntPushUniqueOrder( Vec_WecEntry(vNexts, Shad0), Rank );
246 }
247 return vNexts;
248}
249
262{
263}
264
268
269
271
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Vec_Int_t * Acec_StructAssignRanks(Gia_Man_t *p, Vec_Int_t *vXorRoots)
Definition acecStruct.c:81
int Acec_CollectSupp_rec(Gia_Man_t *p, int iNode, int Rank, Vec_Int_t *vRanks)
Definition acecStruct.c:205
Vec_Wec_t * Acec_FindNexts(Gia_Man_t *p, Vec_Int_t *vRanks, Vec_Int_t *vShadows, Vec_Wec_t *vTreeLeaves)
Definition acecStruct.c:220
Vec_Wec_t * Acec_FindTreeLeaves(Gia_Man_t *p, Vec_Int_t *vXorRoots, Vec_Int_t *vRanks)
Definition acecStruct.c:133
ABC_NAMESPACE_IMPL_START Vec_Int_t * Acec_StructDetectXorRoots(Gia_Man_t *p)
DECLARATIONS ///.
Definition acecStruct.c:47
void Acec_StructTest(Gia_Man_t *p)
Definition acecStruct.c:261
Vec_Int_t * Acec_FindShadows(Gia_Man_t *p, Vec_Int_t *vRanks)
Definition acecStruct.c:176
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachAndReverse(p, pObj, i)
Definition gia.h:1222
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ObjRecognizeExor(Gia_Obj_t *pObj, Gia_Obj_t **ppFan0, Gia_Obj_t **ppFan1)
Definition giaUtil.c:1018
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42