111 int Me[102][102] = {{0}};
112 int pN[102][2] = {{0}};
113 int I = Gia_ManPiNum(
p);
114 int G = I + Gia_ManAndNum(
p);
115 int i, x, y, t, g, c, status, RetValue, Lit, iVar, nClauses = 0;
117 assert( X <= 100 && Y <= 100 && T <= 100 && G <= 100 );
120 for ( i = 0; i < I; i++ )
121 pN[i][0] = pN[i][1] = -1;
124 pN[i-1][0] = Gia_ObjFaninId0(pObj, i)-1;
125 pN[i-1][1] = Gia_ObjFaninId1(pObj, i)-1;
129 printf(
"The graph has %d inputs: ", Gia_ManPiNum(
p) );
130 for ( i = 0; i < I; i++ )
131 printf(
"%c ",
'a' + i );
132 printf(
" and %d nodes: ", Gia_ManAndNum(
p) );
133 for ( i = I; i < G; i++ )
134 printf(
"%c=%c%c ",
'a' + i,
'a' + pN[i][0] ,
'a' + pN[i][1] );
141 for ( y = 0; y < Y; y++ )
142 for ( x = 0; x < X; x++ )
146 iVar += T + G +
NCPARS + 1;
151 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 );
156 for ( x = 0; x < X; x++ )
157 for ( y = 0; y < Y; y++ )
159 int iTVar = Bmc_MeshTVar( Me, x, y );
160 int iGVar = Bmc_MeshGVar( Me, x, y );
162 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )
165 for ( t = 0; t < T; t++ )
167 Lit = Abc_Var2Lit( iTVar+t, (
int)(t > 0) );
171 for ( g = I; g < G; g++ )
173 Lit = Abc_Var2Lit( iGVar+g, 1 );
179 Lit = Abc_Var2Lit( iTVar, 1 );
183 for ( x = 1; x < X-1; x++ )
184 for ( y = 1; y < Y-1; y++ )
186 int pLits[100], nLits;
188 int iTVar = Bmc_MeshTVar( Me, x, y );
189 int iGVar = Bmc_MeshGVar( Me, x, y );
190 int iCVar = Bmc_MeshCVar( Me, x, y );
191 int iUVar = Bmc_MeshUVar( Me, x, y );
197 iTVars[0] = Bmc_MeshTVar( Me, x-1, y );
198 iGVars[0] = Bmc_MeshGVar( Me, x-1, y );
200 iTVars[1] = Bmc_MeshTVar( Me, x, y-1 );
201 iGVars[1] = Bmc_MeshGVar( Me, x, y-1 );
203 iTVars[2] = Bmc_MeshTVar( Me, x+1, y );
204 iGVars[2] = Bmc_MeshGVar( Me, x+1, y );
206 iTVars[3] = Bmc_MeshTVar( Me, x, y+1 );
207 iGVars[3] = Bmc_MeshGVar( Me, x, y+1 );
210 for ( g = 0; g < G; g++ )
212 pLits[0] = Abc_Var2Lit( iGVar+g, 1 );
213 pLits[1] = Abc_Var2Lit( iUVar, 0 );
219 pLits[0] = Abc_Var2Lit( iUVar, 1 );
220 for ( t = 1; t < T; t++ )
221 pLits[t] = Abc_Var2Lit( iTVar+t, 0 );
226 pLits[0] = Abc_Var2Lit( iUVar, 1 );
227 for ( c = 0; c <
NCPARS; c++ )
228 pLits[c+1] = Abc_Var2Lit( iCVar+c, 0 );
233 for ( t = 1; t < T; t++ )
235 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}};
237 for ( g = 0; g < G; g++ )
238 for ( c = 0; c < 4; c++ )
241 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
242 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
243 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c, 1 );
244 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[c]+t-1, 0 );
248 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
249 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
250 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c, 1 );
251 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[c]+g, 0 );
256 for ( g = 0; g < I; g++ )
257 for ( c = 4; c <
NCPARS; c++ )
259 pLits[0] = Abc_Var2Lit( iGVar+g, 1 );
260 pLits[1] = Abc_Var2Lit( iCVar+c, 1 );
265 for ( g = I; g < G; g++ )
266 for ( c = 0; c < 12; c++ )
268 assert( pN[g][0] >= 0 && pN[g][1] >= 0 );
271 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
272 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
273 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
274 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[Conf[c][0]]+t-1, 0 );
278 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
279 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
280 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
281 pLits[ nLits++ ] = Abc_Var2Lit( iTVars[Conf[c][1]]+t-1, 0 );
286 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
287 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
288 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
289 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[Conf[c][0]]+pN[g][0], 0 );
293 pLits[ nLits++ ] = Abc_Var2Lit( iTVar+t, 1 );
294 pLits[ nLits++ ] = Abc_Var2Lit( iGVar+g, 1 );
295 pLits[ nLits++ ] = Abc_Var2Lit( iCVar+c+4, 1 );
296 pLits[ nLits++ ] = Abc_Var2Lit( iGVars[Conf[c][1]]+pN[g][1], 0 );
306 int iGVar = Bmc_MeshGVar( Me, 1, 1 ) + G-1;
307 Lit = Abc_Var2Lit( iGVar, 0 );
311 printf(
"Problem has no solution. " );
312 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
319 printf(
"Finished adding %d clauses. Started solving...\n", nClauses );
327 printf(
"Problem has no solution. " );
332 printf(
"Computation timed out. " );
337 for ( x = 0; x < X; x++ )
338 for ( y = 0; y < Y; y++ )
340 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )
342 int iGVar = Bmc_MeshGVar( Me, x, y );
347 int iTVar = Bmc_MeshTVar( Me, x, y );
348 int iGVar = Bmc_MeshGVar( Me, x, y );
349 int iCVar = Bmc_MeshCVar( Me, x, y );
355 if ( nAddClauses > 0 )
357 printf(
"Adding %d one-hotness clauses.\n", nAddClauses );
360 printf(
"Satisfying solution found. " );
370 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
374 int nBuffs = 0, nNodes = 0;
375 for ( y = 1; y < Y-1; y++ )
376 for ( x = 1; x < X-1; x++ )
378 int iCVar = Bmc_MeshCVar( Me, x, y );
379 for ( c = 0; c < 4; c++ )
380 if ( Bmc_MeshVarValue(pSat, iCVar+c) )
385 for ( c = 4; c <
NCPARS; c++ )
386 if ( Bmc_MeshVarValue(pSat, iCVar+c) )
392 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 );
395 for ( x = 0; x < X; x++ )
396 printf(
" %-2d ", x );
398 for ( y = 0; y < Y; y++ )
400 printf(
" %-2d ", y );
401 for ( x = 0; x < X; x++ )
403 int iTVar = Bmc_MeshTVar( Me, x, y );
404 int iGVar = Bmc_MeshGVar( Me, x, y );
407 for ( t = 0; t < T; t++ )
408 for ( g = 0; g < G; g++ )
409 if ( Bmc_MeshVarValue(pSat, iTVar+t) && Bmc_MeshVarValue(pSat, iGVar+g) )
411 printf(
" %c%-2d ",
'a' + g, t );
416 if ( x == 0 || x == X-1 || y == 0 || y == Y-1 )