19 #ifndef ABC__misc__mvc__mvc_h
20 #define ABC__misc__mvc__mvc_h
41 #define BITS_PER_WORD 32 // sizeof(Mvc_CubeWord_t) * 8
42 #define BITS_PER_WORD_MINUS 31 // the same minus 1
43 #define BITS_PER_WORD_LOG 5 // log2(sizeof(Mvc_CubeWord_t) * 8)
44 #define BITS_DISJOINT ((Mvc_CubeWord_t)0x55555555) // the mask of the type "01010101"
45 #define BITS_FULL ((Mvc_CubeWord_t)0xffffffff) // the mask of the type "11111111"
121 #define Mvc_CubeReadNext(Cube) ((Cube)->pNext)
122 #define Mvc_CubeReadNextP(Cube) (&(Cube)->pNext)
123 #define Mvc_CubeReadLast(Cube) ((Cube)->iLast)
124 #define Mvc_CubeReadSize(Cube) ((Cube)->nOnes)
126 #define Mvc_CubeSetNext(Cube,Next) ((Cube)->pNext = (Next))
127 #define Mvc_CubeSetLast(Cube,Last) ((Cube)->iLast = (Last))
128 #define Mvc_CubeSetSize(Cube,Size) ((Cube)->nOnes = (Size))
131 #define Mvc_Cube1Words(Cube) ((Cube)->iLast == 0)
132 #define Mvc_Cube2Words(Cube) ((Cube)->iLast == 1)
133 #define Mvc_CubeNWords(Cube) ((Cube)->iLast > 1)
135 #define Mvc_CubeWhichWord(Bit) ((Bit) >> BITS_PER_WORD_LOG)
136 #define Mvc_CubeWhichBit(Bit) ((Bit) & BITS_PER_WORD_MINUS)
138 #define Mvc_CubeBitValue(Cube, Bit) (((Cube)->pData[Mvc_CubeWhichWord(Bit)] & (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit)))) > 0)
139 #define Mvc_CubeBitInsert(Cube, Bit) ((Cube)->pData[Mvc_CubeWhichWord(Bit)] |= (((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit))))
140 #define Mvc_CubeBitRemove(Cube, Bit) ((Cube)->pData[Mvc_CubeWhichWord(Bit)] &= ~(((Mvc_CubeWord_t)1)<<(Mvc_CubeWhichBit(Bit))))
142 #define Mvc_CubeVarValue(Cube, Var) (((Cube)->pData[Mvc_CubeWhichWord(2*(Var))] >> (Mvc_CubeWhichBit(2*(Var)))) & ((Mvc_CubeWord_t)3))
147 #define Mvc_Cube1BitClean( Cube )\
148 ((Cube)->pData[0] = 0)
149 #define Mvc_Cube2BitClean( Cube )\
150 (((Cube)->pData[0] = 0),\
151 ((Cube)->pData[1] = 0))
152 #define Mvc_CubeNBitClean( Cube )\
155 for( _i_ = (Cube)->iLast; _i_ >= 0; _i_--)\
156 (Cube)->pData[_i_] = 0;\
160 #define Mvc_CubeBitCleanUnused( Cube )\
161 ((Cube)->pData[(Cube)->iLast] &= (BITS_FULL >> (Cube)->nUnused))
164 #define Mvc_Cube1BitFill( Cube )\
165 (Cube)->pData[0] = (BITS_FULL >> (Cube)->nUnused);
166 #define Mvc_Cube2BitFill( Cube )\
167 (((Cube)->pData[0] = BITS_FULL),\
168 ((Cube)->pData[1] = (BITS_FULL >> (Cube)->nUnused)))
169 #define Mvc_CubeNBitFill( Cube )\
172 (Cube)->pData[(Cube)->iLast] = (BITS_FULL >> (Cube)->nUnused);\
173 for( _i_ = (Cube)->iLast - 1; _i_ >= 0; _i_-- )\
174 (Cube)->pData[_i_] = BITS_FULL;\
178 #define Mvc_Cube1BitNot( Cube )\
179 ((Cube)->pData[0] ^= (BITS_FULL >> (Cube)->nUnused))
180 #define Mvc_Cube2BitNot( Cube )\
181 (((Cube)->pData[0] ^= BITS_FULL),\
182 ((Cube)->pData[1] ^= (BITS_FULL >> (Cube)->nUnused)))
183 #define Mvc_CubeNBitNot( Cube )\
186 (Cube)->pData[(Cube)->iLast] ^= (BITS_FULL >> (Cube)->nUnused);\
187 for( _i_ = (Cube)->iLast - 1; _i_ >= 0; _i_-- )\
188 (Cube)->pData[_i_] ^= BITS_FULL;\
191 #define Mvc_Cube1BitCopy( Cube1, Cube2 )\
192 (((Cube1)->pData[0]) = ((Cube2)->pData[0]))
193 #define Mvc_Cube2BitCopy( Cube1, Cube2 )\
194 ((((Cube1)->pData[0]) = ((Cube2)->pData[0])),\
195 (((Cube1)->pData[1])= ((Cube2)->pData[1])))
196 #define Mvc_CubeNBitCopy( Cube1, Cube2 )\
199 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
200 ((Cube1)->pData[_i_]) = ((Cube2)->pData[_i_]);\
203 #define Mvc_Cube1BitOr( CubeR, Cube1, Cube2 )\
204 (((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0]))
205 #define Mvc_Cube2BitOr( CubeR, Cube1, Cube2 )\
206 ((((CubeR)->pData[0]) = ((Cube1)->pData[0] | (Cube2)->pData[0])),\
207 (((CubeR)->pData[1]) = ((Cube1)->pData[1] | (Cube2)->pData[1])))
208 #define Mvc_CubeNBitOr( CubeR, Cube1, Cube2 )\
211 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
212 (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] | (Cube2)->pData[_i_]));\
215 #define Mvc_Cube1BitExor( CubeR, Cube1, Cube2 )\
216 (((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0]))
217 #define Mvc_Cube2BitExor( CubeR, Cube1, Cube2 )\
218 ((((CubeR)->pData[0]) = ((Cube1)->pData[0] ^ (Cube2)->pData[0])),\
219 (((CubeR)->pData[1]) = ((Cube1)->pData[1] ^ (Cube2)->pData[1])))
220 #define Mvc_CubeNBitExor( CubeR, Cube1, Cube2 )\
223 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
224 (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] ^ (Cube2)->pData[_i_]));\
227 #define Mvc_Cube1BitAnd( CubeR, Cube1, Cube2 )\
228 (((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0]))
229 #define Mvc_Cube2BitAnd( CubeR, Cube1, Cube2 )\
230 ((((CubeR)->pData[0]) = ((Cube1)->pData[0] & (Cube2)->pData[0])),\
231 (((CubeR)->pData[1]) = ((Cube1)->pData[1] & (Cube2)->pData[1])))
232 #define Mvc_CubeNBitAnd( CubeR, Cube1, Cube2 )\
235 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
236 (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] & (Cube2)->pData[_i_]));\
239 #define Mvc_Cube1BitSharp( CubeR, Cube1, Cube2 )\
240 (((CubeR)->pData[0]) = ((Cube1)->pData[0] & ~((Cube2)->pData[0])))
241 #define Mvc_Cube2BitSharp( CubeR, Cube1, Cube2 )\
242 ((((CubeR)->pData[0]) = ((Cube1)->pData[0] & ~((Cube2)->pData[0]))),\
243 (((CubeR)->pData[1]) = ((Cube1)->pData[1] & ~((Cube2)->pData[1]))))
244 #define Mvc_CubeNBitSharp( CubeR, Cube1, Cube2 )\
247 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
248 (((CubeR)->pData[_i_]) = ((Cube1)->pData[_i_] & ~(Cube2)->pData[_i_]));\
251 #define Mvc_Cube1BitEmpty( Res, Cube )\
252 (Res = ((Cube)->pData[0] == 0))
253 #define Mvc_Cube2BitEmpty( Res, Cube )\
254 (Res = ((Cube)->pData[0] == 0 && (Cube)->pData[1] == 0))
255 #define Mvc_CubeNBitEmpty( Res, Cube )\
258 for (_i_ = (Cube)->iLast; _i_ >= 0; _i_--)\
259 if ( (Cube)->pData[_i_] )\
263 #define Mvc_Cube1BitEqual( Res, Cube1, Cube2 )\
264 (Res = (((Cube1)->pData[0]) == ((Cube2)->pData[0])))
265 #define Mvc_Cube2BitEqual( Res, Cube1, Cube2 )\
266 (Res = ((((Cube1)->pData[0]) == ((Cube2)->pData[0])) &&\
267 (((Cube1)->pData[1]) == ((Cube2)->pData[1]))))
268 #define Mvc_CubeNBitEqual( Res, Cube1, Cube2 )\
271 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
272 if (((Cube1)->pData[_i_]) != ((Cube2)->pData[_i_]))\
276 #define Mvc_Cube1BitLess( Res, Cube1, Cube2 )\
277 (Res = (((Cube1)->pData[0]) < ((Cube2)->pData[0])))
278 #define Mvc_Cube2BitLess( Res, Cube1, Cube2 )\
279 (Res = ((((Cube1)->pData[0]) < ((Cube2)->pData[0])) ||\
280 ((((Cube1)->pData[0]) == ((Cube2)->pData[0])) && (((Cube1)->pData[1]) < ((Cube2)->pData[1])))))
281 #define Mvc_CubeNBitLess( Res, Cube1, Cube2 )\
284 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
285 if (((Cube1)->pData[_i_]) >= ((Cube2)->pData[_i_]))\
289 #define Mvc_Cube1BitMore( Res, Cube1, Cube2 )\
290 (Res = (((Cube1)->pData[0]) > ((Cube2)->pData[0])))
291 #define Mvc_Cube2BitMore( Res, Cube1, Cube2 )\
292 (Res = ((((Cube1)->pData[0]) > ((Cube2)->pData[0])) ||\
293 ((((Cube1)->pData[0]) == ((Cube2)->pData[0])) && (((Cube1)->pData[1]) > ((Cube2)->pData[1])))))
294 #define Mvc_CubeNBitMore( Res, Cube1, Cube2 )\
297 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
298 if (((Cube1)->pData[_i_]) <= ((Cube2)->pData[_i_]))\
302 #define Mvc_Cube1BitNotImpl( Res, Cube1, Cube2 )\
303 (Res = (((Cube1)->pData[0]) & ~((Cube2)->pData[0])))
304 #define Mvc_Cube2BitNotImpl( Res, Cube1, Cube2 )\
305 (Res = ((((Cube1)->pData[0]) & ~((Cube2)->pData[0])) ||\
306 (((Cube1)->pData[1]) & ~((Cube2)->pData[1]))))
307 #define Mvc_CubeNBitNotImpl( Res, Cube1, Cube2 )\
310 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
311 if (((Cube1)->pData[_i_]) & ~((Cube2)->pData[_i_]))\
315 #define Mvc_Cube1BitDisjoint( Res, Cube1, Cube2 )\
316 (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0])) == 0 ))
317 #define Mvc_Cube2BitDisjoint( Res, Cube1, Cube2 )\
318 (Res = (((((Cube1)->pData[0]) & ((Cube2)->pData[0])) == 0 ) &&\
319 ((((Cube1)->pData[1]) & ((Cube2)->pData[1])) == 0 )))
320 #define Mvc_CubeNBitDisjoint( Res, Cube1, Cube2 )\
323 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
324 if (((Cube1)->pData[_i_]) & ((Cube2)->pData[_i_]))\
328 #define Mvc_Cube1BitEqualUnderMask( Res, Cube1, Cube2, Mask )\
329 (Res = ((((Cube1)->pData[0]) & ((Mask)->pData[0])) == (((Cube2)->pData[0]) & ((Mask)->pData[0]))))
330 #define Mvc_Cube2BitEqualUnderMask( Res, Cube1, Cube2, Mask )\
331 (Res = (((((Cube1)->pData[0]) & ((Mask)->pData[0])) == (((Cube2)->pData[0]) & ((Mask)->pData[0]))) &&\
332 ((((Cube1)->pData[1]) & ((Mask)->pData[1])) == (((Cube2)->pData[1]) & ((Mask)->pData[1])))))
333 #define Mvc_CubeNBitEqualUnderMask( Res, Cube1, Cube2, Mask )\
336 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
337 if ((((Cube1)->pData[_i_]) & ((Mask)->pData[_i_])) != (((Cube2)->pData[_i_]) & ((Mask)->pData[_i_])))\
341 #define Mvc_Cube1BitEqualOutsideMask( Res, Cube1, Cube2, Mask )\
342 (Res = ((((Cube1)->pData[0]) | ((Mask)->pData[0])) == (((Cube2)->pData[0]) | ((Mask)->pData[0]))))
343 #define Mvc_Cube2BitEqualOutsideMask( Res, Cube1, Cube2, Mask )\
344 (Res = (((((Cube1)->pData[0]) | ((Mask)->pData[0])) == (((Cube2)->pData[0]) | ((Mask)->pData[0]))) &&\
345 ((((Cube1)->pData[1]) | ((Mask)->pData[1])) == (((Cube2)->pData[1]) | ((Mask)->pData[1])))))
346 #define Mvc_CubeNBitEqualOutsideMask( Res, Cube1, Cube2, Mask )\
349 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
350 if ((((Cube1)->pData[_i_]) | ((Mask)->pData[_i_])) != (((Cube2)->pData[_i_]) | ((Mask)->pData[_i_])))\
354 #define Mvc_Cube1BitIntersectUnderMask( Res, Cube1, Cube2, Mask)\
355 (Res = ((((Cube1)->pData[0]) & ((Cube2)->pData[0]) & ((Mask)->pData[0])) > 0))
356 #define Mvc_Cube2BitIntersectUnderMask( Res, Cube1, Cube2, Mask)\
357 (Res = (((((Cube1)->pData[0]) & ((Cube2)->pData[0]) & ((Mask)->pData[0])) > 0) ||\
358 ((((Cube1)->pData[1]) & ((Cube2)->pData[1]) & ((Mask)->pData[1])) > 0)))
359 #define Mvc_CubeNBitIntersectUnderMask( Res, Cube1, Cube2, Mask)\
362 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
363 if (((Cube1)->pData[_i_]) & ((Cube2)->pData[_i_]) & ((Mask)->pData[_i_]))\
367 #define Mvc_Cube1BitNotImplUnderMask( Res, Cube1, Cube2, Mask )\
368 (Res = (((Mask)->pData[0]) & ((Cube1)->pData[0]) & ~((Cube2)->pData[0])))
369 #define Mvc_Cube2BitNotImplUnderMask( Res, Cube1, Cube2, Mask )\
370 (Res = ((((Mask)->pData[0]) & ((Cube1)->pData[0]) & ~((Cube2)->pData[0])) ||\
371 (((Mask)->pData[1]) & ((Cube1)->pData[1]) & ~((Cube2)->pData[1]))))
372 #define Mvc_CubeNBitNotImplUnderMask( Res, Cube1, Cube2, Mask )\
375 for (_i_ = (Cube1)->iLast; _i_ >= 0; _i_--)\
376 if (((Mask)->pData[_i_]) & ((Cube1)->pData[_i_]) & ~((Cube2)->pData[_i_]))\
381 #define Mvc_CubeBitClean( Cube )\
382 if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitClean( Cube ); }\
383 else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitClean( Cube ); }\
384 else { Mvc_CubeNBitClean( Cube ); }
385 #define Mvc_CubeBitFill( Cube )\
386 if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitFill( Cube ); }\
387 else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitFill( Cube ); }\
388 else { Mvc_CubeNBitFill( Cube ); }
389 #define Mvc_CubeBitNot( Cube )\
390 if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitNot( Cube ); }\
391 else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitNot( Cube ); }\
392 else { Mvc_CubeNBitNot( Cube ); }
393 #define Mvc_CubeBitCopy( Cube1, Cube2 )\
394 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitCopy( Cube1, Cube2 ); }\
395 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitCopy( Cube1, Cube2 ); }\
396 else { Mvc_CubeNBitCopy( Cube1, Cube2 ); }
397 #define Mvc_CubeBitOr( CubeR, Cube1, Cube2 )\
398 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitOr( CubeR, Cube1, Cube2 ); }\
399 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitOr( CubeR, Cube1, Cube2 ); }\
400 else { Mvc_CubeNBitOr( CubeR, Cube1, Cube2 ); }
401 #define Mvc_CubeBitExor( CubeR, Cube1, Cube2 )\
402 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitExor( CubeR, Cube1, Cube2 ); }\
403 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitExor( CubeR, Cube1, Cube2 ); }\
404 else { Mvc_CubeNBitExor( CubeR, Cube1, Cube2 ); }
405 #define Mvc_CubeBitAnd( CubeR, Cube1, Cube2 )\
406 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitAnd( CubeR, Cube1, Cube2 ); }\
407 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitAnd( CubeR, Cube1, Cube2 ); }\
408 else { Mvc_CubeNBitAnd( CubeR, Cube1, Cube2 ); }
409 #define Mvc_CubeBitSharp( CubeR, Cube1, Cube2 )\
410 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitSharp( CubeR, Cube1, Cube2 ); }\
411 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitSharp( CubeR, Cube1, Cube2 ); }\
412 else { Mvc_CubeNBitSharp( CubeR, Cube1, Cube2 ); }
413 #define Mvc_CubeBitEmpty( Res, Cube )\
414 if ( Mvc_Cube1Words(Cube) ) { Mvc_Cube1BitEmpty( Res, Cube ); }\
415 else if ( Mvc_Cube2Words(Cube) ) { Mvc_Cube2BitEmpty( Res, Cube ); }\
416 else { Mvc_CubeNBitEmpty( Res, Cube ); }
417 #define Mvc_CubeBitEqual( Res, Cube1, Cube2 )\
418 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqual( Res, Cube1, Cube2 ); }\
419 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqual( Res, Cube1, Cube2 ); }\
420 else { Mvc_CubeNBitEqual( Res, Cube1, Cube2 ); }
421 #define Mvc_CubeBitLess( Res, Cube1, Cube2 )\
422 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitLess( Res, Cube1, Cube2 ); }\
423 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitLess( Res, Cube1, Cube2 ); }\
424 else { Mvc_CubeNBitLess( Res, Cube1, Cube2 ); }
425 #define Mvc_CubeBitMore( Res, Cube1, Cube2 )\
426 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitMore( Res, Cube1, Cube2 ); }\
427 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitMore( Res, Cube1, Cube2 ); }\
428 else { Mvc_CubeNBitMore( Res, Cube1, Cube2 ); }
429 #define Mvc_CubeBitNotImpl( Res, Cube1, Cube2 )\
430 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitNotImpl( Res, Cube1, Cube2 ); }\
431 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitNotImpl( Res, Cube1, Cube2 ); }\
432 else { Mvc_CubeNBitNotImpl( Res, Cube1, Cube2 ); }
433 #define Mvc_CubeBitDisjoint( Res, Cube1, Cube2 )\
434 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitDisjoint( Res, Cube1, Cube2 ); }\
435 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitDisjoint( Res, Cube1, Cube2 ); }\
436 else { Mvc_CubeNBitDisjoint( Res, Cube1, Cube2 ); }
437 #define Mvc_CubeBitEqualUnderMask( Res, Cube1, Cube2, Mask )\
438 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqualUnderMask( Res, Cube1, Cube2, Mask ); }\
439 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqualUnderMask( Res, Cube1, Cube2, Mask ); }\
440 else { Mvc_CubeNBitEqualUnderMask( Res, Cube1, Cube2, Mask ); }
441 #define Mvc_CubeBitEqualOutsideMask( Res, Cube1, Cube2, Mask )\
442 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }\
443 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }\
444 else { Mvc_CubeNBitEqualOutsideMask( Res, Cube1, Cube2, Mask ); }
445 #define Mvc_CubeBitIntersectUnderMask( Res, Cube1, Cube2, Mask )\
446 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }\
447 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }\
448 else { Mvc_CubeNBitIntersectUnderMask( Res, Cube1, Cube2, Mask ); }
449 #define Mvc_CubeBitNotImplUnderMask( Res, Cube1, Cube2, Mask )\
450 if ( Mvc_Cube1Words(Cube1) ) { Mvc_Cube1BitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }\
451 else if ( Mvc_Cube2Words(Cube1) ){ Mvc_Cube2BitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }\
452 else { Mvc_CubeNBitNotImplUnderMask( Res, Cube1, Cube2, Mask ); }
456 #define Mvc_ListAddCubeHead( pList, pCube )\
458 if ( pList->pHead == NULL )\
460 Mvc_CubeSetNext( pCube, NULL );\
461 pList->pHead = pCube;\
462 pList->pTail = pCube;\
466 Mvc_CubeSetNext( pCube, pList->pHead );\
467 pList->pHead = pCube;\
471 #define Mvc_ListAddCubeTail( pList, pCube )\
473 if ( pList->pHead == NULL )\
474 pList->pHead = pCube;\
476 Mvc_CubeSetNext( pList->pTail, pCube );\
477 pList->pTail = pCube;\
478 Mvc_CubeSetNext( pCube, NULL );\
481 #define Mvc_ListDeleteCube( pList, pPrev, pCube )\
483 if ( pPrev == NULL )\
484 pList->pHead = pCube->pNext;\
486 pPrev->pNext = pCube->pNext;\
487 if ( pList->pTail == pCube )\
489 assert( pCube->pNext == NULL );\
490 pList->pTail = pPrev;\
496 #define Mvc_CoverAddCubeHead( pCover, pCube )\
498 Mvc_List_t * pList = &pCover->lCubes;\
499 Mvc_ListAddCubeHead( pList, pCube );\
501 #define Mvc_CoverAddCubeTail( pCover, pCube )\
503 Mvc_List_t * pList = &pCover->lCubes;\
504 Mvc_ListAddCubeTail( pList, pCube );\
506 #define Mvc_CoverDeleteCube( pCover, pPrev, pCube )\
508 Mvc_List_t * pList = &pCover->lCubes;\
509 Mvc_ListDeleteCube( pList, pPrev, pCube );\
518 #define Mvc_ListForEachCube( List, Cube )\
519 for ( Cube = List->pHead;\
522 #define Mvc_ListForEachCubeSafe( List, Cube, Cube2 )\
523 for ( Cube = List->pHead, Cube2 = (Cube? Cube->pNext: NULL);\
525 Cube = Cube2, Cube2 = (Cube? Cube->pNext: NULL) )
528 #define Mvc_CoverForEachCube( Cover, Cube )\
529 for ( Cube = (Cover)->lCubes.pHead;\
532 #define Mvc_CoverForEachCubeWithIndex( Cover, Cube, Index )\
533 for ( Index = 0, Cube = (Cover)->lCubes.pHead;\
535 Index++, Cube = Cube->pNext )
536 #define Mvc_CoverForEachCubeSafe( Cover, Cube, Cube2 )\
537 for ( Cube = (Cover)->lCubes.pHead, Cube2 = (Cube? Cube->pNext: NULL);\
539 Cube = Cube2, Cube2 = (Cube? Cube->pNext: NULL) )
542 #define Mvc_CoverForEachCubeStart( Start, Cube )\
546 #define Mvc_CoverForEachCubeStartSafe( Start, Cube, Cube2 )\
547 for ( Cube = Start, Cube2 = (Cube? Cube->pNext: NULL);\
549 Cube = Cube2, Cube2 = (Cube? Cube->pNext: NULL) )
553 #define Mvc_CubeForEachBit( Cover, Cube, iBit, Value )\
555 iBit < Cover->nBits && ((Value = Mvc_CubeBitValue(Cube,iBit))>=0);\
558 #define Mvc_CubeForEachVarValue( Cover, Cube, iVar, Value )\
560 iVar < Cover->nBits/2 && (Value = Mvc_CubeVarValue(Cube,iVar));\
567 #define MEM_ALLOC( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) ))
568 #define MEM_FREE( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; }
int Mvc_CoverContain(Mvc_Cover_t *pCover)
FUNCTION DEFINITIONS ///.
void Mvc_CoverFree(Mvc_Cover_t *pCover)
int Mvc_CoverIsIntersecting(Mvc_Data_t *pData, Mvc_Cover_t *pC1, Mvc_Cover_t *pC2)
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Mvc_Manager_t * Mvc_ManagerFreeCube(Mvc_Cover_t *pCube, int nWords)
void Mvc_CoverDeleteLiteralsOfCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Mvc_Cover_t * Mvc_CoverBooleanAnd(Mvc_Data_t *p, Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
void Mvc_CoverAllocateArrayLits(Mvc_Cover_t *pCover)
int Mvc_CoverSupportVarBelongs(Mvc_Cover_t *pCover, int iVar)
int Mvc_CoverReadWordNum(Mvc_Cover_t *pCover)
FUNCTION DEFINITIONS ///.
int Mvc_CoverDist0Cubes(Mvc_Data_t *pData, Mvc_Cube_t *pA, Mvc_Cube_t *pB)
Mvc_Cover_t * Mvc_CoverCommonCubeCover(Mvc_Cover_t *pCover)
void Mvc_CoverDivideInternal(Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem)
int Mvc_CoverReadBitNum(Mvc_Cover_t *pCover)
unsigned int Mvc_CubeWord_t
STRUCTURE DEFINITIONS ///.
void Mvc_CoverRemoveCubes(Mvc_Cover_t *pC)
void Mvc_CoverPrint(Mvc_Cover_t *pCover)
FUNCTION DEFINITIONS ///.
Mvc_Cover_t * Mvc_CoverAlgebraicMultiply(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
DECLARATIONS ///.
Mvc_Cover_t * Mvc_CoverCreateConst(Mvc_Manager_t *pMem, int nBits, int Phase)
void Mvc_CoverDeallocateMask(Mvc_Cover_t *pCover)
void Mvc_CoverDist1Merge(Mvc_Data_t *p, Mvc_Cover_t *pCover)
void Mvc_CoverAddCubeTail_(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
int Mvc_CoverIsOneLiteral(Mvc_Cover_t *pCover)
int Mvc_CoverIsBinaryBuffer(Mvc_Cover_t *pCover)
Mvc_Manager_t * Mvc_ManagerAllocCube(int nWords)
Mvc_Cube_t * Mvc_CoverReadCubeTail(Mvc_Cover_t *pCover)
Mvc_Cover_t * Mvc_CoverCofactor(Mvc_Cover_t *pCover, int iValue, int iValueOther)
void Mvc_CoverDivideByCube(Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem)
Mvc_Cover_t ** Mvc_CoverCofactors(Mvc_Data_t *pData, Mvc_Cover_t *pCover, int iVar)
int Mvc_CoverFirstCubeFirstLit(Mvc_Cover_t *pCover)
void Mvc_CoverMinimizeByReshape(Mvc_Data_t *pData, Mvc_Cover_t *pCover)
void Mvc_CoverSupport(Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
FUNCTION DEFINITIONS ///.
Mvc_Cover_t * Mvc_CoverFlipVar(Mvc_Cover_t *pCover, int iValue0, int iValue1)
Mvc_List_t * Mvc_CoverReadCubeList(Mvc_Cover_t *pCover)
int Mvc_ListReadCubeNum(Mvc_List_t *pList)
int Mvc_CubeCompareIntOutsideMask(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
int Mvc_CoverWorstLiteral(Mvc_Cover_t *pCover, Mvc_Cube_t *pMask)
int Mvc_CubeCompareSizeAndInt(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
void Mvc_CoverSetCubeTail(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
void Mvc_ListAddCubeTail_(Mvc_List_t *pList, Mvc_Cube_t *pCube)
int Mvc_CoverAlgebraicEqual(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
Mvc_Cover_t * Mvc_CoverRemap(Mvc_Cover_t *pCover, int *pVarsRem, int nVarsRem)
void Mvc_CoverDeallocateArrayLits(Mvc_Cover_t *pCover)
void Mvc_CoverArray2List(Mvc_Cover_t *pCover)
void Mvc_CoverMakeCubeFree(Mvc_Cover_t *pCover)
Mvc_Cover_t * Mvc_CoverTranspose(Mvc_Cover_t *pCover)
void Mvc_CoverMakeEmpty(Mvc_Cover_t *pCover)
int Mvc_CoverBestLiteral(Mvc_Cover_t *pCover, Mvc_Cube_t *pMask)
Mvc_Cover_t * Mvc_CoverUnivQuantify(Mvc_Cover_t *p, int iValueA0, int iValueA1, int iValueB0, int iValueB1)
Mvc_Cover_t * Mvc_CoverRemoveDontCareLits(Mvc_Cover_t *pCover)
void Mvc_CoverDivide(Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem)
FUNCTION DEFINITIONS ///.
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
int Mvr_CoverCountLitsWithValue(Mvc_Data_t *pData, Mvc_Cover_t *pCover, int iVar, int iValue)
void Mvc_CoverInverse(Mvc_Cover_t *pCover)
void Mvc_ManagerFree(Mvc_Manager_t *p)
int Mvc_CoverReadCubeNum(Mvc_Cover_t *pCover)
void Mvc_CoverList2Array(Mvc_Cover_t *pCover)
int Mvc_UtilsCheckUnusedZeros(Mvc_Cover_t *pCover)
Mvc_Manager_t * Mvc_ManagerStart()
DECLARATIONS ///.
void Mvc_CoverIntersectCubes(Mvc_Data_t *pData, Mvc_Cover_t *pC1, Mvc_Cover_t *pC2)
int Mvc_CoverGetCubeSize(Mvc_Cube_t *pCube)
int Mvc_CoverIsTautology(Mvc_Cover_t *pCover)
void Mvc_CoverMakeTautology(Mvc_Cover_t *pCover)
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Mvc_Cover_t * Mvc_CoverSharp(Mvc_Data_t *p, Mvc_Cover_t *pA, Mvc_Cover_t *pB)
Mvc_Manager_t * Mvc_ManagerAllocCover()
int Mvc_CubeCompareInt(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
DECLARATIONS ///.
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
void Mvc_ListAddCubeHead_(Mvc_List_t *pList, Mvc_Cube_t *pCube)
DECLARATIONS ///.
void Mvc_CoverPrintMv(Mvc_Data_t *pData, Mvc_Cover_t *pCover)
int Mvc_CubeCompareIntOutsideAndUnderMask(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
void Mvc_CoverSetCubeHead(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
#define ABC_NAMESPACE_HEADER_END
void Mvc_CoverSetCubeList(Mvc_Cover_t *pCover, Mvc_List_t *pList)
Mvc_Cover_t * Mvc_CoverComplement(Mvc_Data_t *p, Mvc_Cover_t *pCover)
int Mvc_CubeCompareIntUnderMask(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
Mvc_Cube_t * Mvc_ListGetTailFromHead(Mvc_Cube_t *pHead)
void Mvc_CoverCopyAndAppendCubes(Mvc_Cover_t *pC1, Mvc_Cover_t *pC2)
void Mvc_CoverDivideByLiteralQuo(Mvc_Cover_t *pCover, int iLit)
Mvc_Cover_t * Mvc_CoverBooleanOr(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
DECLARATIONS ///.
void Mvc_CoverAppendCubes(Mvc_Cover_t *pC1, Mvc_Cover_t *pC2)
void Mvc_CoverSetCubeNum(Mvc_Cover_t *pCover, int nItems)
int Mvc_CoverCheckSuppContainment(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
Mvc_Cover_t * Mvc_CoverBestLiteralCover(Mvc_Cover_t *pCover, Mvc_Cover_t *pSimple)
int Mvc_CoverCountCubePairDiffs(Mvc_Cover_t *pCover, unsigned char pDiffs[])
void Mvc_CoverDivideByLiteral(Mvc_Cover_t *pCover, Mvc_Cover_t *pDiv, Mvc_Cover_t **ppQuo, Mvc_Cover_t **ppRem)
void Mvc_CoverCommonCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube)
int Mvc_CoverIsCubeFree(Mvc_Cover_t *pCover)
Mvc_Cube_t * Mvc_ListReadCubeHead(Mvc_List_t *pList)
int Mvc_CoverSetCubeSizes(Mvc_Cover_t *pCover)
void Mvc_CoverAllocateArrayCubes(Mvc_Cover_t *pCover)
void Mvc_CoverAddDupCubeTail(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Mvc_Cover_t * Mvc_CoverCreateEmpty(Mvc_Cover_t *pCover)
int Mvc_CoverBooleanEqual(Mvc_Data_t *p, Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
void Mvc_CoverDeleteCube_(Mvc_Cover_t *pCover, Mvc_Cube_t *pPrev, Mvc_Cube_t *pCube)
void Mvc_ListDeleteCube_(Mvc_List_t *pList, Mvc_Cube_t *pPrev, Mvc_Cube_t *pCube)
Mvc_Cover_t * Mvc_CoverCreateTautology(Mvc_Cover_t *pCover)
void Mvc_CoverAddLiteralsOfCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
int Mvc_CoverCountLiterals(Mvc_Cover_t *pCover)
void Mvc_CubeBitRemoveDcs(Mvc_Cube_t *pCube)
Mvc_Cube_t * Mvc_ListReadCubeTail(Mvc_List_t *pList)
Mvc_Manager_t * Mvc_ManagerFreeCover(Mvc_Cover_t *pCover)
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
void Mvc_CoverSort(Mvc_Cover_t *pCover, Mvc_Cube_t *pMask, int(*pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *))
FuNCTION DEFINITIONS ///.
Mvc_Cover_t * Mvc_CoverAlgebraicSubtract(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
Mvc_Cover_t * Mvc_CoverAlloc(Mvc_Manager_t *pMem, int nBits)
DECLARATIONS ///.
void Mvc_CubePrint(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
int Mvc_CoverAnyLiteral(Mvc_Cover_t *pCover, Mvc_Cube_t *pMask)
DECLARATIONS ///.
Mvc_Cover_t * Mvc_CoverDup(Mvc_Cover_t *pCover)
Mvc_Cube_t * Mvc_CoverReadCubeHead(Mvc_Cover_t *pCover)
int Mvc_CoverTautology(Mvc_Data_t *p, Mvc_Cover_t *pCover)
void Mvc_CoverAllocateMask(Mvc_Cover_t *pCover)
void Mvc_CoverAddDupCubeHead(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
int Mvc_CoverSupportSizeBinary(Mvc_Cover_t *pCover)
void Mvc_CoverAddCubeHead_(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
int Mvc_CoverIsEmpty(Mvc_Cover_t *pCover)
Mvc_Cover_t * Mvc_CoverDivisor(Mvc_Cover_t *pCover)
FUNCTION DEFINITIONS ///.
void Mvc_CubePrintMv(Mvc_Data_t *pData, Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)