src/misc/mvc/mvcCompare.c File Reference

#include "mvc.h"
Include dependency graph for mvcCompare.c:

Go to the source code of this file.

Functions

int Mvc_CubeCompareInt (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
int Mvc_CubeCompareSizeAndInt (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
int Mvc_CubeCompareIntUnderMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
int Mvc_CubeCompareIntOutsideMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
int Mvc_CubeCompareIntOutsideAndUnderMask (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)

Function Documentation

int Mvc_CubeCompareInt ( Mvc_Cube_t pC1,
Mvc_Cube_t pC2,
Mvc_Cube_t pMask 
)

CFile****************************************************************

FileName [mvcCompare.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [Various cube comparison functions.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
mvcCompare.c,v 1.5 2003/04/03 23:25:41 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Compares two cubes according to their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 40 of file mvcCompare.c.

00041 {
00042     if ( Mvc_Cube1Words(pC1) )
00043     {
00044         if ( pC1->pData[0] < pC2->pData[0] )
00045             return -1;
00046         if ( pC1->pData[0] > pC2->pData[0] )
00047             return 1;
00048         return 0;
00049     }
00050     else if ( Mvc_Cube2Words(pC1) )
00051     {
00052         if ( pC1->pData[1] < pC2->pData[1] )
00053             return -1;
00054         if ( pC1->pData[1] > pC2->pData[1] )
00055             return 1;
00056         if ( pC1->pData[0] < pC2->pData[0] )
00057             return -1;
00058         if ( pC1->pData[0] > pC2->pData[0] )
00059             return 1;
00060         return 0;
00061     }
00062     else                            
00063     {
00064         int i = Mvc_CubeReadLast(pC1);
00065         for(; i >= 0; i--)
00066         {
00067             if ( pC1->pData[i] < pC2->pData[i] )
00068                 return -1;
00069             if ( pC1->pData[i] > pC2->pData[i] )
00070                 return 1;
00071         }
00072         return 0;
00073     }
00074 }

int Mvc_CubeCompareIntOutsideAndUnderMask ( Mvc_Cube_t pC1,
Mvc_Cube_t pC2,
Mvc_Cube_t pMask 
)

Function*************************************************************

Synopsis [Compares the cubes (1) outside the mask, (2) under the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 262 of file mvcCompare.c.

00263 {
00264     unsigned uBits1, uBits2;
00265 
00266     if ( Mvc_Cube1Words(pC1) )
00267     {
00268         // compare the cubes outside the mask
00269         uBits1 = pC1->pData[0] & ~(pMask->pData[0]);
00270         uBits2 = pC2->pData[0] & ~(pMask->pData[0]);
00271         if ( uBits1 < uBits2 )
00272             return -1;
00273         if ( uBits1 > uBits2 )
00274             return 1;
00275 
00276         // compare the cubes under the mask
00277         uBits1 = pC1->pData[0] & pMask->pData[0];
00278         uBits2 = pC2->pData[0] & pMask->pData[0];
00279         if ( uBits1 < uBits2 )
00280             return -1;
00281         if ( uBits1 > uBits2 )
00282             return 1;
00283         // cubes are equal
00284         // should never happen
00285         assert( 0 );
00286         return 0;
00287     }
00288     else if ( Mvc_Cube2Words(pC1) )
00289     {
00290         // compare the cubes outside the mask
00291         uBits1 = pC1->pData[1] & ~(pMask->pData[1]);
00292         uBits2 = pC2->pData[1] & ~(pMask->pData[1]);
00293         if ( uBits1 < uBits2 )
00294             return -1;
00295         if ( uBits1 > uBits2 )
00296             return 1;
00297 
00298         uBits1 = pC1->pData[0] & ~(pMask->pData[0]);
00299         uBits2 = pC2->pData[0] & ~(pMask->pData[0]);
00300         if ( uBits1 < uBits2 )
00301             return -1;
00302         if ( uBits1 > uBits2 )
00303             return 1;
00304 
00305         // compare the cubes under the mask
00306         uBits1 = pC1->pData[1] & pMask->pData[1];
00307         uBits2 = pC2->pData[1] & pMask->pData[1];
00308         if ( uBits1 < uBits2 )
00309             return -1;
00310         if ( uBits1 > uBits2 )
00311             return 1;
00312 
00313         uBits1 = pC1->pData[0] & pMask->pData[0];
00314         uBits2 = pC2->pData[0] & pMask->pData[0];
00315         if ( uBits1 < uBits2 )
00316             return -1;
00317         if ( uBits1 > uBits2 )
00318             return 1;
00319 
00320         // cubes are equal
00321         // should never happen
00322         assert( 0 );
00323         return 0;
00324     }
00325     else                            
00326     {
00327         int i;
00328 
00329         // compare the cubes outside the mask
00330         for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- )
00331         {
00332             uBits1 = pC1->pData[i] & ~(pMask->pData[i]);
00333             uBits2 = pC2->pData[i] & ~(pMask->pData[i]);
00334             if ( uBits1 < uBits2 )
00335                 return -1;
00336             if ( uBits1 > uBits2 )
00337                 return 1;
00338         }
00339         // compare the cubes under the mask
00340         for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- )
00341         {
00342             uBits1 = pC1->pData[i] & pMask->pData[i];
00343             uBits2 = pC2->pData[i] & pMask->pData[i];
00344             if ( uBits1 < uBits2 )
00345                 return -1;
00346             if ( uBits1 > uBits2 )
00347                 return 1;
00348         }
00349 /*
00350         {
00351             Mvc_Cover_t * pCover;
00352             pCover = Mvc_CoverAlloc( NULL, 96 );
00353             Mvc_CubePrint( pCover, pC1 );
00354             Mvc_CubePrint( pCover, pC2 );
00355             Mvc_CubePrint( pCover, pMask );
00356         }
00357 */
00358         // cubes are equal
00359         // should never happen
00360         assert( 0 );
00361         return 0;
00362     }
00363 }

int Mvc_CubeCompareIntOutsideMask ( Mvc_Cube_t pC1,
Mvc_Cube_t pC2,
Mvc_Cube_t pMask 
)

Function*************************************************************

Synopsis [Compares two cubes under the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file mvcCompare.c.

00203 {
00204     unsigned uBits1, uBits2;
00205 
00206     // compare the cubes under the mask
00207     if ( Mvc_Cube1Words(pC1) )
00208     {
00209         uBits1 = pC1->pData[0] | pMask->pData[0];
00210         uBits2 = pC2->pData[0] | pMask->pData[0];
00211         if ( uBits1 < uBits2 )
00212             return -1;
00213         if ( uBits1 > uBits2 )
00214             return 1;
00215         // cubes are equal
00216         return 0;
00217     }
00218     else if ( Mvc_Cube2Words(pC1) )
00219     {
00220         uBits1 = pC1->pData[1] | pMask->pData[1];
00221         uBits2 = pC2->pData[1] | pMask->pData[1];
00222         if ( uBits1 < uBits2 )
00223             return -1;
00224         if ( uBits1 > uBits2 )
00225             return 1;
00226         uBits1 = pC1->pData[0] | pMask->pData[0];
00227         uBits2 = pC2->pData[0] | pMask->pData[0];
00228         if ( uBits1 < uBits2 )
00229             return -1;
00230         if ( uBits1 > uBits2 )
00231             return 1;
00232         return 0;
00233     }
00234     else                            
00235     {
00236         int i = Mvc_CubeReadLast(pC1);
00237         for(; i >= 0; i--)
00238         {
00239             uBits1 = pC1->pData[i] | pMask->pData[i];
00240             uBits2 = pC2->pData[i] | pMask->pData[i];
00241             if ( uBits1 < uBits2 )
00242                 return -1;
00243             if ( uBits1 > uBits2 )
00244                 return 1;
00245         }
00246         return 0;
00247     }
00248 }

int Mvc_CubeCompareIntUnderMask ( Mvc_Cube_t pC1,
Mvc_Cube_t pC2,
Mvc_Cube_t pMask 
)

Function*************************************************************

Synopsis [Compares two cubes under the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file mvcCompare.c.

00144 {
00145     unsigned uBits1, uBits2;
00146 
00147     // compare the cubes under the mask
00148     if ( Mvc_Cube1Words(pC1) )
00149     {
00150         uBits1 = pC1->pData[0] & pMask->pData[0];
00151         uBits2 = pC2->pData[0] & pMask->pData[0];
00152         if ( uBits1 < uBits2 )
00153             return -1;
00154         if ( uBits1 > uBits2 )
00155             return 1;
00156         // cubes are equal
00157         return 0;
00158     }
00159     else if ( Mvc_Cube2Words(pC1) )
00160     {
00161         uBits1 = pC1->pData[1] & pMask->pData[1];
00162         uBits2 = pC2->pData[1] & pMask->pData[1];
00163         if ( uBits1 < uBits2 )
00164             return -1;
00165         if ( uBits1 > uBits2 )
00166             return 1;
00167         uBits1 = pC1->pData[0] & pMask->pData[0];
00168         uBits2 = pC2->pData[0] & pMask->pData[0];
00169         if ( uBits1 < uBits2 )
00170             return -1;
00171         if ( uBits1 > uBits2 )
00172             return 1;
00173         return 0;
00174     }
00175     else                            
00176     {
00177         int i = Mvc_CubeReadLast(pC1);
00178         for(; i >= 0; i--)
00179         {
00180             uBits1 = pC1->pData[i] & pMask->pData[i];
00181             uBits2 = pC2->pData[i] & pMask->pData[i];
00182             if ( uBits1 < uBits2 )
00183                 return -1;
00184             if ( uBits1 > uBits2 )
00185                 return 1;
00186         }
00187         return 0;
00188     }
00189 }

int Mvc_CubeCompareSizeAndInt ( Mvc_Cube_t pC1,
Mvc_Cube_t pC2,
Mvc_Cube_t pMask 
)

Function*************************************************************

Synopsis [Compares the cubes (1) by size, (2) by integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file mvcCompare.c.

00089 {
00090     // compare the cubes by size
00091     if ( Mvc_CubeReadSize( pC1 ) < Mvc_CubeReadSize( pC2 ) )
00092         return 1;
00093     if ( Mvc_CubeReadSize( pC1 ) > Mvc_CubeReadSize( pC2 ) )
00094         return -1;
00095     // the cubes have the same size
00096 
00097     // compare the cubes as integers
00098     if ( Mvc_Cube1Words( pC1 ) )
00099     {
00100         if ( pC1->pData[0] < pC2->pData[0] )
00101             return -1;
00102         if ( pC1->pData[0] > pC2->pData[0] )
00103             return 1;
00104         return 0;
00105     }
00106     else if ( Mvc_Cube2Words( pC1 ) )
00107     {
00108         if ( pC1->pData[1] < pC2->pData[1] )
00109             return -1;
00110         if ( pC1->pData[1] > pC2->pData[1] )
00111             return 1;
00112         if ( pC1->pData[0] < pC2->pData[0] )
00113             return -1;
00114         if ( pC1->pData[0] > pC2->pData[0] )
00115             return 1;
00116         return 0;
00117     }
00118     else                            
00119     {
00120         int i = Mvc_CubeReadLast( pC1 );
00121         for(; i >= 0; i--)
00122         {
00123             if ( pC1->pData[i] < pC2->pData[i] )
00124                 return -1;
00125             if ( pC1->pData[i] > pC2->pData[i] )
00126                 return 1;
00127         }
00128         return 0;
00129     }
00130 }


Generated on Tue Jan 5 12:19:16 2010 for abc70930 by  doxygen 1.6.1