kitIsop.c 14.9 KB
Newer Older
Alan Mishchenko committed
1 2
/**CFile****************************************************************

Alan Mishchenko committed
3
  FileName    [kitIsop.c]
Alan Mishchenko committed
4 5 6

  SystemName  [ABC: Logic synthesis and verification system.]

Alan Mishchenko committed
7
  PackageName [Computation kit.]
Alan Mishchenko committed
8

Alan Mishchenko committed
9
  Synopsis    [ISOP computation based on Morreale's algorithm.]
Alan Mishchenko committed
10 11 12 13 14

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

Alan Mishchenko committed
15
  Date        [Ver. 1.0. Started - Dec 6, 2006.]
Alan Mishchenko committed
16

Alan Mishchenko committed
17
  Revision    [$Id: kitIsop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
Alan Mishchenko committed
18 19 20

***********************************************************************/

Alan Mishchenko committed
21
#include "kit.h"
Alan Mishchenko committed
22

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
30
// ISOP computation fails if intermediate memory usage exceed this limit
31
#define KIT_ISOP_MEM_LIMIT  (1<<20)
Alan Mishchenko committed
32

Alan Mishchenko committed
33
// static procedures to compute ISOP
Alan Mishchenko committed
34 35
static unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore );
static unsigned   Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore );
Alan Mishchenko committed
36 37 38 39 40 41 42

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

Alan Mishchenko committed
43
  Synopsis    [Computes ISOP from TT.]
Alan Mishchenko committed
44

Alan Mishchenko committed
45
  Description [Returns the cover in vMemory. Uses the rest of array in vMemory
Alan Mishchenko committed
46
  as an intermediate memory storage. Returns the cover with -1 cubes, if the
Alan Mishchenko committed
47
  the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of
Alan Mishchenko committed
48
  intermediate data).]
Alan Mishchenko committed
49 50 51 52 53 54
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
55
int Kit_TruthIsop2( unsigned * puTruth0, unsigned * puTruth1, int nVars, Vec_Int_t * vMemory, int fTryBoth, int fReturnTt )
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
{
    Kit_Sop_t cRes, * pcRes = &cRes;
    Kit_Sop_t cRes2, * pcRes2 = &cRes2;
    unsigned * pResult;
    int RetValue = 0;
    assert( nVars >= 0 && nVars <= 16 );
    // prepare memory manager
    Vec_IntClear( vMemory );
    Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
    // compute ISOP for the direct polarity
    Kit_TruthNot( puTruth0, puTruth0, nVars );
    pResult = Kit_TruthIsop_rec( puTruth1, puTruth0, nVars, pcRes, vMemory );
    Kit_TruthNot( puTruth0, puTruth0, nVars );
    if ( pcRes->nCubes == -1 )
    {
        vMemory->nSize = -1;
        return -1;
    }
    assert( Kit_TruthIsImply( puTruth1, pResult, nVars ) );
    Kit_TruthNot( puTruth0, puTruth0, nVars );
    assert( Kit_TruthIsImply( pResult, puTruth0, nVars ) );
    Kit_TruthNot( puTruth0, puTruth0, nVars );
    if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
    {
        vMemory->pArray[0] = 0;
        Vec_IntShrink( vMemory, pcRes->nCubes );
        return 0;
    }
    if ( fTryBoth )
    {
        // compute ISOP for the complemented polarity
        Kit_TruthNot( puTruth1, puTruth1, nVars );
        pResult = Kit_TruthIsop_rec( puTruth0, puTruth1, nVars, pcRes2, vMemory );
        Kit_TruthNot( puTruth1, puTruth1, nVars );
        if ( pcRes2->nCubes >= 0 )
        {
            assert( Kit_TruthIsImply( puTruth0, pResult, nVars ) );
            Kit_TruthNot( puTruth1, puTruth1, nVars );
            assert( Kit_TruthIsImply( pResult, puTruth1, nVars ) );
            Kit_TruthNot( puTruth1, puTruth1, nVars );
            if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
            {
                RetValue = 1;
                pcRes = pcRes2;
            }
        }
    }
//    printf( "%d ", vMemory->nSize );
    // move the cover representation to the beginning of the memory buffer
105 106 107 108 109 110 111 112 113 114 115
    if ( fReturnTt )
    {
        int nWords = Kit_TruthWordNum( nVars );
        memmove( vMemory->pArray, pResult, nWords * sizeof(unsigned) );
        Vec_IntShrink( vMemory, nWords );
    }
    else
    {
        memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
        Vec_IntShrink( vMemory, pcRes->nCubes );
    }
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    return RetValue;
}


/**Function*************************************************************

  Synopsis    [Computes ISOP from TT.]

  Description [Returns the cover in vMemory. Uses the rest of array in vMemory
  as an intermediate memory storage. Returns the cover with -1 cubes, if the
  the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of
  intermediate data).]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
134
int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth )
Alan Mishchenko committed
135
{
Alan Mishchenko committed
136 137
    Kit_Sop_t cRes, * pcRes = &cRes;
    Kit_Sop_t cRes2, * pcRes2 = &cRes2;
Alan Mishchenko committed
138
    unsigned * pResult;
Alan Mishchenko committed
139
    int RetValue = 0;
Alan Mishchenko committed
140
    assert( nVars >= 0 && nVars <= 16 );
Alan Mishchenko committed
141
    // if nVars < 5, make sure it does not depend on those vars
Alan Mishchenko committed
142
//    for ( i = nVars; i < 5; i++ )
Alan Mishchenko committed
143
//        assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
Alan Mishchenko committed
144
    // prepare memory manager
Alan Mishchenko committed
145 146
    Vec_IntClear( vMemory );
    Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
Alan Mishchenko committed
147
    // compute ISOP for the direct polarity
Alan Mishchenko committed
148
    pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes, vMemory );
Alan Mishchenko committed
149 150
    if ( pcRes->nCubes == -1 )
    {
Alan Mishchenko committed
151
        vMemory->nSize = -1;
Alan Mishchenko committed
152
        return -1;
Alan Mishchenko committed
153
    }
Alan Mishchenko committed
154
    assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
Alan Mishchenko committed
155 156
    if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
    {
Alan Mishchenko committed
157
        vMemory->pArray[0] = 0;
Alan Mishchenko committed
158 159 160
        Vec_IntShrink( vMemory, pcRes->nCubes );
        return 0;
    }
Alan Mishchenko committed
161 162 163
    if ( fTryBoth )
    {
        // compute ISOP for the complemented polarity
Alan Mishchenko committed
164
        Kit_TruthNot( puTruth, puTruth, nVars );
Alan Mishchenko committed
165
        pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes2, vMemory );
Alan Mishchenko committed
166 167
        if ( pcRes2->nCubes >= 0 )
        {
Alan Mishchenko committed
168
            assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
169
            if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
Alan Mishchenko committed
170 171 172 173 174
            {
                RetValue = 1;
                pcRes = pcRes2;
            }
        }
Alan Mishchenko committed
175
        Kit_TruthNot( puTruth, puTruth, nVars );
Alan Mishchenko committed
176
    }
Alan Mishchenko committed
177
//    printf( "%d ", vMemory->nSize );
Alan Mishchenko committed
178
    // move the cover representation to the beginning of the memory buffer
Alan Mishchenko committed
179 180
    memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
    Vec_IntShrink( vMemory, pcRes->nCubes );
Alan Mishchenko committed
181
    return RetValue;
Alan Mishchenko committed
182
}
183
void Kit_TruthIsopPrintCover( Vec_Int_t * vCover, int nVars, int fCompl )
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
{
    int i, k, Entry, Literal;
    if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
    {
        printf( "Constant %d\n", Vec_IntSize(vCover) );
        return;
    }
    Vec_IntForEachEntry( vCover, Entry, i )
    { 
        for ( k = 0; k < nVars; k++ )
        {
            Literal = 3 & (Entry >> (k << 1));
            if ( Literal == 1 ) // neg literal
                printf( "0" );
            else if ( Literal == 2 ) // pos literal
                printf( "1" );
            else if ( Literal == 0 ) 
                printf( "-" );
            else assert( 0 );
        }
204
        printf( " %d\n", !fCompl );
205 206
    }
}
207 208 209 210 211
void Kit_TruthIsopPrint( unsigned * puTruth, int nVars, Vec_Int_t * vCover, int fTryBoth )
{
    int fCompl = Kit_TruthIsop( puTruth, nVars, vCover, fTryBoth );
    Kit_TruthIsopPrintCover( vCover, nVars, fCompl );
}
Alan Mishchenko committed
212 213 214

/**Function*************************************************************

Alan Mishchenko committed
215
  Synopsis    [Computes ISOP 6 variables or more.]
Alan Mishchenko committed
216 217 218 219 220 221 222 223

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
224
unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore )
Alan Mishchenko committed
225
{
Alan Mishchenko committed
226 227
    Kit_Sop_t cRes0, cRes1, cRes2;
    Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
Alan Mishchenko committed
228
    unsigned * puRes0, * puRes1, * puRes2;
Alan Mishchenko committed
229 230
    unsigned * puOn0, * puOn1, * puOnDc0, * puOnDc1, * pTemp, * pTemp0, * pTemp1;
    int i, k, Var, nWords, nWordsAll;
Alan Mishchenko committed
231
//    assert( Kit_TruthIsImply( puOn, puOnDc, nVars ) );
Alan Mishchenko committed
232
    // allocate room for the resulting truth table
Alan Mishchenko committed
233
    nWordsAll = Kit_TruthWordNum( nVars );
Alan Mishchenko committed
234 235 236 237 238 239
    pTemp = Vec_IntFetch( vStore, nWordsAll );
    if ( pTemp == NULL )
    {
        pcRes->nCubes = -1;
        return NULL;
    }
Alan Mishchenko committed
240
    // check for constants
Alan Mishchenko committed
241
    if ( Kit_TruthIsConst0( puOn, nVars ) )
Alan Mishchenko committed
242
    {
243
        pcRes->nLits  = 0;
Alan Mishchenko committed
244 245
        pcRes->nCubes = 0;
        pcRes->pCubes = NULL;
Alan Mishchenko committed
246
        Kit_TruthClear( pTemp, nVars );
Alan Mishchenko committed
247
        return pTemp;
Alan Mishchenko committed
248
    }
Alan Mishchenko committed
249
    if ( Kit_TruthIsConst1( puOnDc, nVars ) )
Alan Mishchenko committed
250
    {
251
        pcRes->nLits  = 0;
Alan Mishchenko committed
252
        pcRes->nCubes = 1;
Alan Mishchenko committed
253 254 255 256 257 258
        pcRes->pCubes = Vec_IntFetch( vStore, 1 );
        if ( pcRes->pCubes == NULL )
        {
            pcRes->nCubes = -1;
            return NULL;
        }
Alan Mishchenko committed
259
        pcRes->pCubes[0] = 0;
Alan Mishchenko committed
260
        Kit_TruthFill( pTemp, nVars );
Alan Mishchenko committed
261
        return pTemp;
Alan Mishchenko committed
262
    }
Alan Mishchenko committed
263
    assert( nVars > 0 );
Alan Mishchenko committed
264 265
    // find the topmost var
    for ( Var = nVars-1; Var >= 0; Var-- )
Alan Mishchenko committed
266 267
        if ( Kit_TruthVarInSupport( puOn, nVars, Var ) || 
             Kit_TruthVarInSupport( puOnDc, nVars, Var ) )
Alan Mishchenko committed
268 269
             break;
    assert( Var >= 0 );
Alan Mishchenko committed
270
    // consider a simple case when one-word computation can be used
Alan Mishchenko committed
271 272
    if ( Var < 5 )
    {
Alan Mishchenko committed
273
        unsigned uRes = Kit_TruthIsop5_rec( puOn[0], puOnDc[0], Var+1, pcRes, vStore );
Alan Mishchenko committed
274 275 276
        for ( i = 0; i < nWordsAll; i++ )
            pTemp[i] = uRes;
        return pTemp;
Alan Mishchenko committed
277
    }
Alan Mishchenko committed
278
    assert( Var >= 5 );
Alan Mishchenko committed
279
    nWords = Kit_TruthWordNum( Var );
Alan Mishchenko committed
280
    // cofactor
Alan Mishchenko committed
281 282 283
    puOn0   = puOn;    puOn1   = puOn + nWords;
    puOnDc0 = puOnDc;  puOnDc1 = puOnDc + nWords;
    pTemp0  = pTemp;   pTemp1  = pTemp + nWords;
Alan Mishchenko committed
284
    // solve for cofactors
Alan Mishchenko committed
285
    Kit_TruthSharp( pTemp0, puOn0, puOnDc1, Var );
Alan Mishchenko committed
286
    puRes0 = Kit_TruthIsop_rec( pTemp0, puOnDc0, Var, pcRes0, vStore );
Alan Mishchenko committed
287 288 289 290 291
    if ( pcRes0->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return NULL;
    }
Alan Mishchenko committed
292
    Kit_TruthSharp( pTemp1, puOn1, puOnDc0, Var );
Alan Mishchenko committed
293
    puRes1 = Kit_TruthIsop_rec( pTemp1, puOnDc1, Var, pcRes1, vStore );
Alan Mishchenko committed
294 295 296 297 298
    if ( pcRes1->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return NULL;
    }
Alan Mishchenko committed
299 300 301 302
    Kit_TruthSharp( pTemp0, puOn0, puRes0, Var );
    Kit_TruthSharp( pTemp1, puOn1, puRes1, Var );
    Kit_TruthOr( pTemp0, pTemp0, pTemp1, Var );
    Kit_TruthAnd( pTemp1, puOnDc0, puOnDc1, Var );
Alan Mishchenko committed
303
    puRes2 = Kit_TruthIsop_rec( pTemp0, pTemp1, Var, pcRes2, vStore );
Alan Mishchenko committed
304 305 306 307 308
    if ( pcRes2->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return NULL;
    }
Alan Mishchenko committed
309
    // create the resulting cover
310
    pcRes->nLits  = pcRes0->nLits  + pcRes1->nLits  + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
Alan Mishchenko committed
311
    pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
Alan Mishchenko committed
312 313 314 315 316 317
    pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
    if ( pcRes->pCubes == NULL )
    {
        pcRes->nCubes = -1;
        return NULL;
    }
Alan Mishchenko committed
318 319
    k = 0;
    for ( i = 0; i < pcRes0->nCubes; i++ )
Alan Mishchenko committed
320
        pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
Alan Mishchenko committed
321
    for ( i = 0; i < pcRes1->nCubes; i++ )
Alan Mishchenko committed
322
        pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
Alan Mishchenko committed
323
    for ( i = 0; i < pcRes2->nCubes; i++ )
Alan Mishchenko committed
324 325 326
        pcRes->pCubes[k++] = pcRes2->pCubes[i];
    assert( k == pcRes->nCubes );
    // create the resulting truth table
Alan Mishchenko committed
327 328
    Kit_TruthOr( pTemp0, puRes0, puRes2, Var );
    Kit_TruthOr( pTemp1, puRes1, puRes2, Var );
Alan Mishchenko committed
329 330 331 332 333 334
    // copy the table if needed
    nWords <<= 1;
    for ( i = 1; i < nWordsAll/nWords; i++ )
        for ( k = 0; k < nWords; k++ )
            pTemp[i*nWords + k] = pTemp[k];
    // verify in the end
Alan Mishchenko committed
335 336
//    assert( Kit_TruthIsImply( puOn, pTemp, nVars ) );
//    assert( Kit_TruthIsImply( pTemp, puOnDc, nVars ) );
Alan Mishchenko committed
337
    return pTemp;
Alan Mishchenko committed
338 339 340 341 342 343 344 345 346 347 348 349 350
}

/**Function*************************************************************

  Synopsis    [Computes ISOP for 5 variables or less.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
351
unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore )
Alan Mishchenko committed
352 353
{
    unsigned uMasks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
Alan Mishchenko committed
354 355
    Kit_Sop_t cRes0, cRes1, cRes2;
    Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
Alan Mishchenko committed
356
    unsigned uOn0, uOn1, uOnDc0, uOnDc1, uRes0, uRes1, uRes2;
Alan Mishchenko committed
357 358
    int i, k, Var;
    assert( nVars <= 5 );
Alan Mishchenko committed
359 360
    assert( (uOn & ~uOnDc) == 0 );
    if ( uOn == 0 )
Alan Mishchenko committed
361
    {
362
        pcRes->nLits  = 0;
Alan Mishchenko committed
363 364 365 366 367 368
        pcRes->nCubes = 0;
        pcRes->pCubes = NULL;
        return 0;
    }
    if ( uOnDc == 0xFFFFFFFF )
    {
369
        pcRes->nLits  = 0;
Alan Mishchenko committed
370
        pcRes->nCubes = 1;
Alan Mishchenko committed
371 372 373 374 375 376
        pcRes->pCubes = Vec_IntFetch( vStore, 1 );
        if ( pcRes->pCubes == NULL )
        {
            pcRes->nCubes = -1;
            return 0;
        }
Alan Mishchenko committed
377 378 379
        pcRes->pCubes[0] = 0;
        return 0xFFFFFFFF;
    }
Alan Mishchenko committed
380
    assert( nVars > 0 );
Alan Mishchenko committed
381 382
    // find the topmost var
    for ( Var = nVars-1; Var >= 0; Var-- )
Alan Mishchenko committed
383 384
        if ( Kit_TruthVarInSupport( &uOn, 5, Var ) || 
             Kit_TruthVarInSupport( &uOnDc, 5, Var ) )
Alan Mishchenko committed
385 386 387
             break;
    assert( Var >= 0 );
    // cofactor
Alan Mishchenko committed
388
    uOn0   = uOn1   = uOn;
Alan Mishchenko committed
389
    uOnDc0 = uOnDc1 = uOnDc;
Alan Mishchenko committed
390 391 392 393
    Kit_TruthCofactor0( &uOn0, Var + 1, Var );
    Kit_TruthCofactor1( &uOn1, Var + 1, Var );
    Kit_TruthCofactor0( &uOnDc0, Var + 1, Var );
    Kit_TruthCofactor1( &uOnDc1, Var + 1, Var );
Alan Mishchenko committed
394
    // solve for cofactors
Alan Mishchenko committed
395
    uRes0 = Kit_TruthIsop5_rec( uOn0 & ~uOnDc1, uOnDc0, Var, pcRes0, vStore );
Alan Mishchenko committed
396 397 398 399 400
    if ( pcRes0->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return 0;
    }
Alan Mishchenko committed
401
    uRes1 = Kit_TruthIsop5_rec( uOn1 & ~uOnDc0, uOnDc1, Var, pcRes1, vStore );
Alan Mishchenko committed
402 403 404 405 406
    if ( pcRes1->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return 0;
    }
Alan Mishchenko committed
407
    uRes2 = Kit_TruthIsop5_rec( (uOn0 & ~uRes0) | (uOn1 & ~uRes1), uOnDc0 & uOnDc1, Var, pcRes2, vStore );
Alan Mishchenko committed
408 409 410 411 412
    if ( pcRes2->nCubes == -1 )
    {
        pcRes->nCubes = -1;
        return 0;
    }
Alan Mishchenko committed
413
    // create the resulting cover
414
    pcRes->nLits  = pcRes0->nLits  + pcRes1->nLits  + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
Alan Mishchenko committed
415
    pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
Alan Mishchenko committed
416 417 418 419 420 421
    pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
    if ( pcRes->pCubes == NULL )
    {
        pcRes->nCubes = -1;
        return 0;
    }
Alan Mishchenko committed
422 423
    k = 0;
    for ( i = 0; i < pcRes0->nCubes; i++ )
Alan Mishchenko committed
424
        pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
Alan Mishchenko committed
425
    for ( i = 0; i < pcRes1->nCubes; i++ )
Alan Mishchenko committed
426
        pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
Alan Mishchenko committed
427
    for ( i = 0; i < pcRes2->nCubes; i++ )
Alan Mishchenko committed
428 429
        pcRes->pCubes[k++] = pcRes2->pCubes[i];
    assert( k == pcRes->nCubes );
Alan Mishchenko committed
430 431 432 433 434
    // derive the final truth table
    uRes2 |= (uRes0 & ~uMasks[Var]) | (uRes1 & uMasks[Var]);
//    assert( (uOn & ~uRes2) == 0 );
//    assert( (uRes2 & ~uOnDc) == 0 );
    return uRes2;
Alan Mishchenko committed
435 436 437 438 439 440 441 442
}


////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


443 444
ABC_NAMESPACE_IMPL_END