abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mvcOpAlg.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mvcOperAlg.c]
4 
5  PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
6 
7  Synopsis [Miscellaneous operations on covers.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 1.0. Started - February 1, 2003.]
14 
15  Revision [$Id: mvcOpAlg.c,v 1.4 2003/04/26 20:41:36 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "mvc.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 /**Function*************************************************************
33 
34  Synopsis [Multiplies two disjoint-support covers.]
35 
36  Description []
37 
38  SideEffects []
39 
40  SeeAlso []
41 
42 ***********************************************************************/
44 {
45  Mvc_Cover_t * pCover;
46  Mvc_Cube_t * pCube1, * pCube2, * pCube;
47  int CompResult;
48 
49  // covers should be the same base
50  assert( pCover1->nBits == pCover2->nBits );
51  // make sure that supports do not overlap
52  Mvc_CoverAllocateMask( pCover1 );
53  Mvc_CoverAllocateMask( pCover2 );
54  Mvc_CoverSupport( pCover1, pCover1->pMask );
55  Mvc_CoverSupport( pCover2, pCover2->pMask );
56  // check if the cubes are bit-wise disjoint
57  Mvc_CubeBitDisjoint( CompResult, pCover1->pMask, pCover2->pMask );
58  if ( !CompResult )
59  printf( "Mvc_CoverMultiply(): Cover supports are not disjoint!\n" );
60 
61  // iterate through the cubes
62  pCover = Mvc_CoverClone( pCover1 );
63  Mvc_CoverForEachCube( pCover1, pCube1 )
64  Mvc_CoverForEachCube( pCover2, pCube2 )
65  {
66  // create the product cube
67  pCube = Mvc_CubeAlloc( pCover );
68  // set the product cube equal to the product of the two cubes
69  Mvc_CubeBitOr( pCube, pCube1, pCube2 );
70  // add the cube to the cover
71  Mvc_CoverAddCubeTail( pCover, pCube );
72  }
73  return pCover;
74 }
75 
76 
77 /**Function*************************************************************
78 
79  Synopsis [Subtracts the second cover from the first.]
80 
81  Description []
82 
83  SideEffects []
84 
85  SeeAlso []
86 
87 ***********************************************************************/
89 {
90  Mvc_Cover_t * pCover;
91  Mvc_Cube_t * pCube1, * pCube2, * pCube;
92  int fFound;
93  int CompResult;
94 
95  // covers should be the same base
96  assert( pCover1->nBits == pCover2->nBits );
97 
98  // iterate through the cubes
99  pCover = Mvc_CoverClone( pCover1 );
100  Mvc_CoverForEachCube( pCover1, pCube1 )
101  {
102  fFound = 0;
103  Mvc_CoverForEachCube( pCover2, pCube2 )
104  {
105  Mvc_CubeBitEqual( CompResult, pCube1, pCube2 );
106  if ( CompResult )
107  {
108  fFound = 1;
109  break;
110  }
111  }
112  if ( !fFound )
113  {
114  // create the copy of the cube
115  pCube = Mvc_CubeDup( pCover, pCube1 );
116  // add the cube copy to the cover
117  Mvc_CoverAddCubeTail( pCover, pCube );
118  }
119  }
120  return pCover;
121 }
122 
123 /**Function*************************************************************
124 
125  Synopsis []
126 
127  Description []
128 
129  SideEffects []
130 
131  SeeAlso []
132 
133 ***********************************************************************/
135 {
136  Mvc_Cube_t * pCube1, * pCube2;
137  int fFound;
138  int CompResult;
139 
140  // covers should be the same base
141  assert( pCover1->nBits == pCover2->nBits );
142  // iterate through the cubes
143  Mvc_CoverForEachCube( pCover1, pCube1 )
144  {
145  fFound = 0;
146  Mvc_CoverForEachCube( pCover2, pCube2 )
147  {
148  Mvc_CubeBitEqual( CompResult, pCube1, pCube2 );
149  if ( CompResult )
150  {
151  fFound = 1;
152  break;
153  }
154  }
155  if ( !fFound )
156  return 0;
157  }
158  return 1;
159 }
160 
161 
162 ////////////////////////////////////////////////////////////////////////
163 /// END OF FILE ///
164 ////////////////////////////////////////////////////////////////////////
165 
166 
168 
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
int Mvc_CoverAlgebraicEqual(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
Definition: mvcOpAlg.c:134
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:94
#define Mvc_CubeBitEqual(Res, Cube1, Cube2)
Definition: mvc.h:417
Mvc_Cover_t * Mvc_CoverAlgebraicSubtract(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
Definition: mvcOpAlg.c:88
#define Mvc_CubeBitDisjoint(Res, Cube1, Cube2)
Definition: mvc.h:433
#define Mvc_CubeBitOr(CubeR, Cube1, Cube2)
Definition: mvc.h:397
void Mvc_CoverSupport(Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
FUNCTION DEFINITIONS ///.
Definition: mvcUtils.c:58
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
Mvc_Cube_t * pMask
Definition: mvc.h:92
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Definition: mvcCover.c:79
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
ABC_NAMESPACE_IMPL_START Mvc_Cover_t * Mvc_CoverAlgebraicMultiply(Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
DECLARATIONS ///.
Definition: mvcOpAlg.c:43
int nBits
Definition: mvc.h:87
#define assert(ex)
Definition: util_old.h:213
void Mvc_CoverAllocateMask(Mvc_Cover_t *pCover)
Definition: mvcCover.c:168