115 int Me[102][102] = {{0}};
116 int pN[102][2] = {{0}};
117 int I = Gia_ManPiNum(
p);
118 int G = I + Gia_ManAndNum(
p);
119 int i, x, y, t, g, c, status, RetValue, Lit, iVar, nClauses = 0;
121 assert( X <= 100 && Y <= 100 && T <= 100 && G <= 100 );
124 for ( i = 0; i < I; i++ )
125 pN[i][0] = pN[i][1] = -1;
128 pN[i-1][0] = Gia_ObjFaninId0(pObj, i)-1;
129 pN[i-1][1] = Gia_ObjFaninId1(pObj, i)-1;
133 printf(
"The graph has %d inputs: ", Gia_ManPiNum(
p) );
134 for ( i = 0; i < I; i++ )
135 printf(
"%c ",
'a' + i );
136 printf(
" and %d nodes: ", Gia_ManAndNum(
p) );
137 for ( i = I; i < G; i++ )
138 printf(
"%c=%c%c ",
'a' + i,
'a' + pN[i][0] ,
'a' + pN[i][1] );
145 for ( y = 0; y < Y; y++ )
146 for ( x = 0; x < X; x++ )
150 iVar += T + G +
NCPARS + 1;
155 printf(
"SAT variable count is %d (%d time vars + %d graph vars + %d config vars + %d aux vars)\n", iVar, X*Y*T, X*Y*G, X*Y*
NCPARS, X*Y );
160 for ( x = 0; x < X; x++ )
161 for ( y = 0; y < Y; y++ )
163 int iTVar = Bmc_MeshTVar( Me, x, y );
164 int iGVar = Bmc_MeshGVar( Me, x, y );
166 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )
169 for ( t = 0; t < T; t++ )
171 Lit = Abc_Var2Lit( iTVar+t, (
int)(t > 0) );
175 for ( g = I; g < G; g++ )
177 Lit = Abc_Var2Lit( iGVar+g, 1 );
183 Lit = Abc_Var2Lit( iTVar, 1 );
187 for ( x = 1; x < X-1; x++ )
188 for ( y = 1; y < Y-1; y++ )
190 int pLits[100], nLits;
192 int iTVar = Bmc_MeshTVar( Me, x, y );
193 int iGVar = Bmc_MeshGVar( Me, x, y );
194 int iCVar = Bmc_MeshCVar( Me, x, y );
195 int iUVar = Bmc_MeshUVar( Me, x, y );
201 iTVars[0] = Bmc_MeshTVar( Me, x-1, y );
202 iGVars[0] = Bmc_MeshGVar( Me, x-1, y );
204 iTVars[1] = Bmc_MeshTVar( Me, x, y-1 );
205 iGVars[1] = Bmc_MeshGVar( Me, x, y-1 );
207 iTVars[2] = Bmc_MeshTVar( Me, x+1, y );
208 iGVars[2] = Bmc_MeshGVar( Me, x+1, y );
210 iTVars[3] = Bmc_MeshTVar( Me, x, y+1 );
211 iGVars[3] = Bmc_MeshGVar( Me, x, y+1 );
214 for ( g = 0; g < G; g++ )
216 pLits[0] = Abc_Var2Lit( iGVar+g, 1 );
217 pLits[1] = Abc_Var2Lit( iUVar, 0 );
223 pLits[0] = Abc_Var2Lit( iUVar, 1 );
224 for ( t = 1; t < T; t++ )
225 pLits[t] = Abc_Var2Lit( iTVar+t, 0 );
230 pLits[0] = Abc_Var2Lit( iUVar, 1 );
231 for ( c = 0; c <
NCPARS; c++ )
232 pLits[c+1] = Abc_Var2Lit( iCVar+c, 0 );
237 for ( t = 1; t < T; t++ )
239 int Conf[12][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}, {1, 0}, {2, 0}, {3, 0}, {2, 1}, {3, 1}, {3, 2}};
241 for ( g = 0; g < G; g++ )
242 for ( c = 0; c < 4; c++ )
245 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
246 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
247 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c, 1 );
248 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[c]+t-1, 0 );
252 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
253 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
254 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c, 1 );
255 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[c]+g, 0 );
260 for ( g = 0; g < I; g++ )
261 for ( c = 4; c <
NCPARS; c++ )
263 pLits[0] = Abc_Var2Lit( iGVar+g, 1 );
264 pLits[1] = Abc_Var2Lit( iCVar+c, 1 );
269 for ( g = I; g < G; g++ )
270 for ( c = 0; c < 12; c++ )
272 assert( pN[g][0] >= 0 && pN[g][1] >= 0 );
273 assert( pN[g][0] < g && pN[g][1] < g );
276 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
277 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
278 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
279 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[Conf[c][0]]+t-1, 0 );
283 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
284 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
285 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
286 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[Conf[c][1]]+t-1, 0 );
291 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
292 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
293 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
294 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[Conf[c][0]]+pN[g][0], 0 );
298 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
299 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
300 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
301 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[Conf[c][1]]+pN[g][1], 0 );
311 int iGVar = Bmc_MeshGVar( Me, 1, 1 ) + G-1;
312 Lit = Abc_Var2Lit( iGVar, 0 );
316 printf(
"Problem has no solution. " );
317 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
325 printf(
"Finished adding %d clauses. Started solving...\n", nClauses );
335 printf(
"Problem has no solution. " );
341 printf(
"Computation timed out. " );
347 for ( x = 0; x < X; x++ )
348 for ( y = 0; y < Y; y++ )
350 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )
352 int iGVar = Bmc_MeshGVar( Me, x, y );
357 int iTVar = Bmc_MeshTVar( Me, x, y );
358 int iGVar = Bmc_MeshGVar( Me, x, y );
359 int iCVar = Bmc_MeshCVar( Me, x, y );
365 if ( nAddClauses > 0 )
367 printf(
"Adding %d one-hotness clauses.\n", nAddClauses );
370 printf(
"Satisfying solution found. " );
381 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
386 int nBuffs = 0, nNodes = 0;
387 for ( y = 1; y < Y-1; y++ )
388 for ( x = 1; x < X-1; x++ )
390 int iCVar = Bmc_MeshCVar( Me, x, y );
391 for ( c = 0; c < 4; c++ )
392 if ( Bmc_MeshVarValue2(pSat, iCVar+c) )
397 for ( c = 4; c <
NCPARS; c++ )
398 if ( Bmc_MeshVarValue2(pSat, iCVar+c) )
404 printf(
"The %d x %d mesh with latency %d with %d active cells (%d nodes and %d buffers):\n", X, Y, T, nNodes+nBuffs, nNodes, nBuffs );
407 for ( x = 0; x < X; x++ )
408 printf(
" %-2d ", x );
410 for ( y = 0; y < Y; y++ )
412 printf(
" %-2d ", y );
413 for ( x = 0; x < X; x++ )
415 int iTVar = Bmc_MeshTVar( Me, x, y );
416 int iGVar = Bmc_MeshGVar( Me, x, y );
419 for ( t = 0; t < T; t++ )
420 for ( g = 0; g < G; g++ )
421 if ( Bmc_MeshVarValue2(pSat, iTVar+t) && Bmc_MeshVarValue2(pSat, iGVar+g) )
423 printf(
" %c%-2d ",
'a' + g, t );
428 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )