abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mvcCompare.c File Reference
#include "mvc.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Mvc_CubeCompareInt (Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
 DECLARATIONS ///. More...
 
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

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

DECLARATIONS ///.

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

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file mvcCompare.c.

44 {
45  if ( Mvc_Cube1Words(pC1) )
46  {
47  if ( pC1->pData[0] < pC2->pData[0] )
48  return -1;
49  if ( pC1->pData[0] > pC2->pData[0] )
50  return 1;
51  return 0;
52  }
53  else if ( Mvc_Cube2Words(pC1) )
54  {
55  if ( pC1->pData[1] < pC2->pData[1] )
56  return -1;
57  if ( pC1->pData[1] > pC2->pData[1] )
58  return 1;
59  if ( pC1->pData[0] < pC2->pData[0] )
60  return -1;
61  if ( pC1->pData[0] > pC2->pData[0] )
62  return 1;
63  return 0;
64  }
65  else
66  {
67  int i = Mvc_CubeReadLast(pC1);
68  for(; i >= 0; i--)
69  {
70  if ( pC1->pData[i] < pC2->pData[i] )
71  return -1;
72  if ( pC1->pData[i] > pC2->pData[i] )
73  return 1;
74  }
75  return 0;
76  }
77 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_Cube2Words(Cube)
Definition: mvc.h:132
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define Mvc_Cube1Words(Cube)
Definition: mvc.h:131
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 265 of file mvcCompare.c.

266 {
267  unsigned uBits1, uBits2;
268 
269  if ( Mvc_Cube1Words(pC1) )
270  {
271  // compare the cubes outside the mask
272  uBits1 = pC1->pData[0] & ~(pMask->pData[0]);
273  uBits2 = pC2->pData[0] & ~(pMask->pData[0]);
274  if ( uBits1 < uBits2 )
275  return -1;
276  if ( uBits1 > uBits2 )
277  return 1;
278 
279  // compare the cubes under the mask
280  uBits1 = pC1->pData[0] & pMask->pData[0];
281  uBits2 = pC2->pData[0] & pMask->pData[0];
282  if ( uBits1 < uBits2 )
283  return -1;
284  if ( uBits1 > uBits2 )
285  return 1;
286  // cubes are equal
287  // should never happen
288  assert( 0 );
289  return 0;
290  }
291  else if ( Mvc_Cube2Words(pC1) )
292  {
293  // compare the cubes outside the mask
294  uBits1 = pC1->pData[1] & ~(pMask->pData[1]);
295  uBits2 = pC2->pData[1] & ~(pMask->pData[1]);
296  if ( uBits1 < uBits2 )
297  return -1;
298  if ( uBits1 > uBits2 )
299  return 1;
300 
301  uBits1 = pC1->pData[0] & ~(pMask->pData[0]);
302  uBits2 = pC2->pData[0] & ~(pMask->pData[0]);
303  if ( uBits1 < uBits2 )
304  return -1;
305  if ( uBits1 > uBits2 )
306  return 1;
307 
308  // compare the cubes under the mask
309  uBits1 = pC1->pData[1] & pMask->pData[1];
310  uBits2 = pC2->pData[1] & pMask->pData[1];
311  if ( uBits1 < uBits2 )
312  return -1;
313  if ( uBits1 > uBits2 )
314  return 1;
315 
316  uBits1 = pC1->pData[0] & pMask->pData[0];
317  uBits2 = pC2->pData[0] & pMask->pData[0];
318  if ( uBits1 < uBits2 )
319  return -1;
320  if ( uBits1 > uBits2 )
321  return 1;
322 
323  // cubes are equal
324  // should never happen
325  assert( 0 );
326  return 0;
327  }
328  else
329  {
330  int i;
331 
332  // compare the cubes outside the mask
333  for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- )
334  {
335  uBits1 = pC1->pData[i] & ~(pMask->pData[i]);
336  uBits2 = pC2->pData[i] & ~(pMask->pData[i]);
337  if ( uBits1 < uBits2 )
338  return -1;
339  if ( uBits1 > uBits2 )
340  return 1;
341  }
342  // compare the cubes under the mask
343  for( i = Mvc_CubeReadLast(pC1); i >= 0; i-- )
344  {
345  uBits1 = pC1->pData[i] & pMask->pData[i];
346  uBits2 = pC2->pData[i] & pMask->pData[i];
347  if ( uBits1 < uBits2 )
348  return -1;
349  if ( uBits1 > uBits2 )
350  return 1;
351  }
352 /*
353  {
354  Mvc_Cover_t * pCover;
355  pCover = Mvc_CoverAlloc( NULL, 96 );
356  Mvc_CubePrint( pCover, pC1 );
357  Mvc_CubePrint( pCover, pC2 );
358  Mvc_CubePrint( pCover, pMask );
359  }
360 */
361  // cubes are equal
362  // should never happen
363  assert( 0 );
364  return 0;
365  }
366 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_Cube2Words(Cube)
Definition: mvc.h:132
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define assert(ex)
Definition: util_old.h:213
#define Mvc_Cube1Words(Cube)
Definition: mvc.h:131
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 205 of file mvcCompare.c.

206 {
207  unsigned uBits1, uBits2;
208 
209  // compare the cubes under the mask
210  if ( Mvc_Cube1Words(pC1) )
211  {
212  uBits1 = pC1->pData[0] | pMask->pData[0];
213  uBits2 = pC2->pData[0] | pMask->pData[0];
214  if ( uBits1 < uBits2 )
215  return -1;
216  if ( uBits1 > uBits2 )
217  return 1;
218  // cubes are equal
219  return 0;
220  }
221  else if ( Mvc_Cube2Words(pC1) )
222  {
223  uBits1 = pC1->pData[1] | pMask->pData[1];
224  uBits2 = pC2->pData[1] | pMask->pData[1];
225  if ( uBits1 < uBits2 )
226  return -1;
227  if ( uBits1 > uBits2 )
228  return 1;
229  uBits1 = pC1->pData[0] | pMask->pData[0];
230  uBits2 = pC2->pData[0] | pMask->pData[0];
231  if ( uBits1 < uBits2 )
232  return -1;
233  if ( uBits1 > uBits2 )
234  return 1;
235  return 0;
236  }
237  else
238  {
239  int i = Mvc_CubeReadLast(pC1);
240  for(; i >= 0; i--)
241  {
242  uBits1 = pC1->pData[i] | pMask->pData[i];
243  uBits2 = pC2->pData[i] | pMask->pData[i];
244  if ( uBits1 < uBits2 )
245  return -1;
246  if ( uBits1 > uBits2 )
247  return 1;
248  }
249  return 0;
250  }
251 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_Cube2Words(Cube)
Definition: mvc.h:132
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define Mvc_Cube1Words(Cube)
Definition: mvc.h:131
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 146 of file mvcCompare.c.

147 {
148  unsigned uBits1, uBits2;
149 
150  // compare the cubes under the mask
151  if ( Mvc_Cube1Words(pC1) )
152  {
153  uBits1 = pC1->pData[0] & pMask->pData[0];
154  uBits2 = pC2->pData[0] & pMask->pData[0];
155  if ( uBits1 < uBits2 )
156  return -1;
157  if ( uBits1 > uBits2 )
158  return 1;
159  // cubes are equal
160  return 0;
161  }
162  else if ( Mvc_Cube2Words(pC1) )
163  {
164  uBits1 = pC1->pData[1] & pMask->pData[1];
165  uBits2 = pC2->pData[1] & pMask->pData[1];
166  if ( uBits1 < uBits2 )
167  return -1;
168  if ( uBits1 > uBits2 )
169  return 1;
170  uBits1 = pC1->pData[0] & pMask->pData[0];
171  uBits2 = pC2->pData[0] & pMask->pData[0];
172  if ( uBits1 < uBits2 )
173  return -1;
174  if ( uBits1 > uBits2 )
175  return 1;
176  return 0;
177  }
178  else
179  {
180  int i = Mvc_CubeReadLast(pC1);
181  for(; i >= 0; i--)
182  {
183  uBits1 = pC1->pData[i] & pMask->pData[i];
184  uBits2 = pC2->pData[i] & pMask->pData[i];
185  if ( uBits1 < uBits2 )
186  return -1;
187  if ( uBits1 > uBits2 )
188  return 1;
189  }
190  return 0;
191  }
192 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_Cube2Words(Cube)
Definition: mvc.h:132
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define Mvc_Cube1Words(Cube)
Definition: mvc.h:131
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 91 of file mvcCompare.c.

92 {
93  // compare the cubes by size
94  if ( Mvc_CubeReadSize( pC1 ) < Mvc_CubeReadSize( pC2 ) )
95  return 1;
96  if ( Mvc_CubeReadSize( pC1 ) > Mvc_CubeReadSize( pC2 ) )
97  return -1;
98  // the cubes have the same size
99 
100  // compare the cubes as integers
101  if ( Mvc_Cube1Words( pC1 ) )
102  {
103  if ( pC1->pData[0] < pC2->pData[0] )
104  return -1;
105  if ( pC1->pData[0] > pC2->pData[0] )
106  return 1;
107  return 0;
108  }
109  else if ( Mvc_Cube2Words( pC1 ) )
110  {
111  if ( pC1->pData[1] < pC2->pData[1] )
112  return -1;
113  if ( pC1->pData[1] > pC2->pData[1] )
114  return 1;
115  if ( pC1->pData[0] < pC2->pData[0] )
116  return -1;
117  if ( pC1->pData[0] > pC2->pData[0] )
118  return 1;
119  return 0;
120  }
121  else
122  {
123  int i = Mvc_CubeReadLast( pC1 );
124  for(; i >= 0; i--)
125  {
126  if ( pC1->pData[i] < pC2->pData[i] )
127  return -1;
128  if ( pC1->pData[i] > pC2->pData[i] )
129  return 1;
130  }
131  return 0;
132  }
133 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_Cube2Words(Cube)
Definition: mvc.h:132
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define Mvc_Cube1Words(Cube)
Definition: mvc.h:131
#define Mvc_CubeReadSize(Cube)
Definition: mvc.h:124