abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mvcCube.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mvcCube.c]
4 
5  PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
6 
7  Synopsis [Manipulating unate cubes.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 1.0. Started - February 1, 2003.]
14 
15  Revision [$Id: mvcCube.c,v 1.4 2003/04/03 06:31:49 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 []
35 
36  Description []
37 
38  SideEffects []
39 
40  SeeAlso []
41 
42 ***********************************************************************/
44 {
45  Mvc_Cube_t * pCube;
46 
47  assert( pCover->nWords >= 0 );
48  // allocate the cube
49 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
50  if ( pCover->nWords == 0 )
51  pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) );
52  else
53  pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) );
54 #else
55  switch( pCover->nWords )
56  {
57  case 0:
58  case 1:
59  pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan1 );
60  break;
61  case 2:
62  pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan2 );
63  break;
64  case 3:
65  case 4:
66  pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan4 );
67  break;
68  default:
69  pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) );
70  break;
71  }
72 #endif
73  // set the parameters charactering this cube
74  if ( pCover->nWords == 0 )
75  pCube->iLast = pCover->nWords;
76  else
77  pCube->iLast = pCover->nWords - 1;
78  pCube->nUnused = pCover->nUnused;
79  return pCube;
80 }
81 
82 
83 /**Function*************************************************************
84 
85  Synopsis []
86 
87  Description []
88 
89  SideEffects []
90 
91  SeeAlso []
92 
93 ***********************************************************************/
95 {
96  Mvc_Cube_t * pCubeCopy;
97  pCubeCopy = Mvc_CubeAlloc( pCover );
98  Mvc_CubeBitCopy( pCubeCopy, pCube );
99  return pCubeCopy;
100 }
101 
102 
103 /**Function*************************************************************
104 
105  Synopsis []
106 
107  Description []
108 
109  SideEffects []
110 
111  SeeAlso []
112 
113 ***********************************************************************/
114 void Mvc_CubeFree( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
115 {
116  if ( pCube == NULL )
117  return;
118 
119  // verify the parameters charactering this cube
120  assert( pCube->iLast == 0 || ((int)pCube->iLast) == pCover->nWords - 1 );
121  assert( ((int)pCube->nUnused) == pCover->nUnused );
122 
123  // deallocate the cube
124 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
125  ABC_FREE( pCube );
126 #else
127  switch( pCover->nWords )
128  {
129  case 0:
130  case 1:
131  Extra_MmFixedEntryRecycle( pCover->pMem->pMan1, (char *)pCube );
132  break;
133  case 2:
134  Extra_MmFixedEntryRecycle( pCover->pMem->pMan2, (char *)pCube );
135  break;
136  case 3:
137  case 4:
138  Extra_MmFixedEntryRecycle( pCover->pMem->pMan4, (char *)pCube );
139  break;
140  default:
141  ABC_FREE( pCube );
142  break;
143  }
144 #endif
145 }
146 
147 
148 /**Function*************************************************************
149 
150  Synopsis [Removes the don't-care variable from the cube.]
151 
152  Description []
153 
154  SideEffects []
155 
156  SeeAlso []
157 
158 ***********************************************************************/
160 {
161  unsigned Mask;
162  int i;
163  for ( i = Mvc_CubeReadLast(pCube); i >= 0; i-- )
164  {
165  // detect those variables that are different (not DCs)
166  Mask = (pCube->pData[i] ^ (pCube->pData[i] >> 1)) & BITS_DISJOINT;
167  // create the mask of all that are different
168  Mask |= (Mask << 1);
169  // remove other bits from the set
170  pCube->pData[i] &= Mask;
171  }
172 }
173 
174 ////////////////////////////////////////////////////////////////////////
175 /// END OF FILE ///
176 ////////////////////////////////////////////////////////////////////////
177 
178 
180 
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:94
int nWords
Definition: mvc.h:85
unsigned int Mvc_CubeWord_t
STRUCTURE DEFINITIONS ///.
Definition: mvc.h:55
Extra_MmFixed_t * pMan1
Definition: mvc.h:111
Extra_MmFixed_t * pMan4
Definition: mvc.h:113
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
ABC_NAMESPACE_IMPL_START Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define BITS_DISJOINT
Definition: mvc.h:44
int nUnused
Definition: mvc.h:86
unsigned iLast
Definition: mvc.h:66
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
unsigned nUnused
Definition: mvc.h:67
#define Mvc_CubeBitCopy(Cube1, Cube2)
Definition: mvc.h:393
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void Mvc_CubeBitRemoveDcs(Mvc_Cube_t *pCube)
Definition: mvcCube.c:159
Extra_MmFixed_t * pMan2
Definition: mvc.h:112
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Mvc_CubeReadLast(Cube)
Definition: mvc.h:123
#define assert(ex)
Definition: util_old.h:213
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
Mvc_Manager_t * pMem
Definition: mvc.h:93