ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
llb1Hint.c
Go to the documentation of this file.
1
20
21#include "llbInt.h"
22
24
25
29
33
46{
47 Aig_Obj_t * pObj;
48 int i, WeightMax = -ABC_INFINITY, iInput = -1;
49 Aig_ManForEachCi( pAig, pObj, i )
50 if ( WeightMax < Aig_ObjRefs(pObj) )
51 {
52 WeightMax = Aig_ObjRefs(pObj);
53 iInput = i;
54 }
55 assert( iInput >= 0 );
56 return iInput;
57}
58
70Aig_Man_t * Llb_ManPerformHints( Aig_Man_t * pAig, int nHintDepth )
71{
72 Aig_Man_t * pNew, * pTemp;
73 int i, iInput;
74 pNew = Aig_ManDupDfs( pAig );
75 for ( i = 0; i < nHintDepth; i++ )
76 {
77 iInput = Llb_ManMaxFanoutCi( pNew );
78 Abc_Print( 1, "%d %3d\n", i, iInput );
79 pNew = Aig_ManDupCof( pTemp = pNew, iInput, 1 );
80 Aig_ManStop( pTemp );
81 }
82 return pNew;
83}
84
96Vec_Int_t * Llb_ManCollectHighFanoutObjects( Aig_Man_t * pAig, int nCandMax, int fCisOnly )
97{
98 Vec_Int_t * vFanouts, * vResult;
99 Aig_Obj_t * pObj;
100 int i, fChanges, PivotValue;
101// int Entry;
102 // collect fanout counts
103 vFanouts = Vec_IntAlloc( 100 );
104 Aig_ManForEachObj( pAig, pObj, i )
105 {
106// if ( !Aig_ObjIsCi(pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
107 if ( !Saig_ObjIsLo(pAig,pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
108 continue;
109 Vec_IntPush( vFanouts, Aig_ObjRefs(pObj) );
110 }
111 Vec_IntSort( vFanouts, 1 );
112 // pick the separator
113 nCandMax = Abc_MinInt( nCandMax, Vec_IntSize(vFanouts) - 1 );
114 PivotValue = Vec_IntEntry( vFanouts, nCandMax );
115 Vec_IntFree( vFanouts );
116 // collect obj satisfying the constraints
117 vResult = Vec_IntAlloc( 100 );
118 Aig_ManForEachObj( pAig, pObj, i )
119 {
120// if ( !Aig_ObjIsCi(pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
121 if ( !Saig_ObjIsLo(pAig,pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
122 continue;
123 if ( Aig_ObjRefs(pObj) < PivotValue )
124 continue;
125 Vec_IntPush( vResult, Aig_ObjId(pObj) );
126 }
127 assert( Vec_IntSize(vResult) >= nCandMax );
128 // order in the decreasing order of fanouts
129 do
130 {
131 fChanges = 0;
132 for ( i = 0; i < Vec_IntSize(vResult) - 1; i++ )
133 if ( Aig_ObjRefs(Aig_ManObj(pAig, Vec_IntEntry(vResult, i))) <
134 Aig_ObjRefs(Aig_ManObj(pAig, Vec_IntEntry(vResult, i+1))) )
135 {
136 int Temp = Vec_IntEntry( vResult, i );
137 Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vResult, i+1) );
138 Vec_IntWriteEntry( vResult, i+1, Temp );
139 fChanges = 1;
140 }
141 }
142 while ( fChanges );
143/*
144 Vec_IntForEachEntry( vResult, Entry, i )
145 printf( "%d ", Aig_ObjRefs(Aig_ManObj(pAig, Entry)) );
146printf( "\n" );
147*/
148 return vResult;
149}
150
163{
164 DdManager * ddGlo = NULL;
165 Vec_Int_t * vHints;
166 Vec_Int_t * vHFCands;
167 int i, Entry, RetValue = -1;
168 abctime clk = Abc_Clock();
169 assert( pPars->nHintDepth > 0 );
170/*
171 // perform reachability without hints
172 RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, NULL, NULL );
173 if ( RetValue >= 0 )
174 return RetValue;
175*/
176 // create hints representation
177 vHFCands = Llb_ManCollectHighFanoutObjects( pAigGlo, pPars->nHintDepth+pPars->HintFirst, 1 );
178 vHints = Vec_IntStartFull( Aig_ManObjNumMax(pAigGlo) );
179 // add one hint at a time till the problem is solved
180 Vec_IntForEachEntryStart( vHFCands, Entry, i, pPars->HintFirst )
181 {
182 Vec_IntWriteEntry( vHints, Entry, 1 ); // change to 1 to start from zero cof!!!
183 // solve under hints
184 RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, vHints, &ddGlo );
185 if ( RetValue == 0 )
186 goto Finish;
187 if ( RetValue == 1 )
188 break;
189 }
190 if ( RetValue == -1 )
191 goto Finish;
192 // undo the hints one at a time
193 for ( ; i >= pPars->HintFirst; i-- )
194 {
195 Entry = Vec_IntEntry( vHFCands, i );
196 Vec_IntWriteEntry( vHints, Entry, -1 );
197 // solve under relaxed hints
198 RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, vHints, &ddGlo );
199 if ( RetValue == 0 )
200 goto Finish;
201 if ( RetValue == 1 )
202 continue;
203 break;
204 }
205Finish:
206 if ( ddGlo )
207 {
208 if ( ddGlo->bFunc )
209 Cudd_RecursiveDeref( ddGlo, ddGlo->bFunc );
210 Extra_StopManager( ddGlo );
211 }
212 Vec_IntFreeP( &vHFCands );
213 Vec_IntFreeP( &vHints );
214 if ( pPars->fVerbose )
215 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clk );
216 return RetValue;
217}
218
219
223
224
226
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Aig_Man_t * Aig_ManDupDfs(Aig_Man_t *p)
Definition aigDup.c:563
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Aig_Man_t * Aig_ManDupCof(Aig_Man_t *p, int iInput, int Value)
Definition aigDup.c:345
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Extra_StopManager(DdManager *dd)
int Llb_ManModelCheckAig(Aig_Man_t *pAigGlo, Gia_ParLlb_t *pPars, Vec_Int_t *vHints, DdManager **pddGlo)
Definition llb1Core.c:112
Vec_Int_t * Llb_ManCollectHighFanoutObjects(Aig_Man_t *pAig, int nCandMax, int fCisOnly)
Definition llb1Hint.c:96
ABC_NAMESPACE_IMPL_START int Llb_ManMaxFanoutCi(Aig_Man_t *pAig)
DECLARATIONS ///.
Definition llb1Hint.c:45
Aig_Man_t * Llb_ManPerformHints(Aig_Man_t *pAig, int nHintDepth)
Definition llb1Hint.c:70
int Llb_ManModelCheckAigWithHints(Aig_Man_t *pAigGlo, Gia_ParLlb_t *pPars)
Definition llb1Hint.c:162
typedefABC_NAMESPACE_HEADER_START struct Gia_ParLlb_t_ Gia_ParLlb_t
INCLUDES ///.
Definition llb.h:41
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56