ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cutCut.c
Go to the documentation of this file.
1
20
21#include "cutInt.h"
22
24
25
29
33
46{
47 Cut_Cut_t * pCut;
48 // cut allocation
49 pCut = (Cut_Cut_t *)Extra_MmFixedEntryFetch( p->pMmCuts );
50 memset( pCut, 0, sizeof(Cut_Cut_t) );
51 pCut->nVarsMax = p->pParams->nVarsMax;
52 pCut->fSimul = p->fSimul;
53 // statistics
54 p->nCutsAlloc++;
55 p->nCutsCur++;
56 if ( p->nCutsPeak < p->nCutsAlloc - p->nCutsDealloc )
57 p->nCutsPeak = p->nCutsAlloc - p->nCutsDealloc;
58 return pCut;
59}
60
73{
74 p->nCutsDealloc++;
75 p->nCutsCur--;
76 if ( pCut->nLeaves == 1 )
77 p->nCutsTriv--;
78 Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
79}
80
92int Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 )
93{
94 int i;
95 if ( pCut1->nLeaves < pCut2->nLeaves )
96 return -1;
97 if ( pCut1->nLeaves > pCut2->nLeaves )
98 return 1;
99 for ( i = 0; i < (int)pCut1->nLeaves; i++ )
100 {
101 if ( pCut1->pLeaves[i] < pCut2->pLeaves[i] )
102 return -1;
103 if ( pCut1->pLeaves[i] > pCut2->pLeaves[i] )
104 return 1;
105 }
106 return 0;
107}
108
121{
122 Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
123 Cut_Cut_t * pTemp, * pCopy;
124 if ( pList == NULL )
125 return NULL;
126 Cut_ListForEachCut( pList, pTemp )
127 {
128 pCopy = (Cut_Cut_t *)Extra_MmFixedEntryFetch( p->pMmCuts );
129 memcpy( pCopy, pTemp, (size_t)p->EntrySize );
130 *ppTail = pCopy;
131 ppTail = &pCopy->pNext;
132 }
133 *ppTail = NULL;
134 return pHead;
135}
136
149{
150 Cut_Cut_t * pCut, * pCut2;
151 Cut_ListForEachCutSafe( pList, pCut, pCut2 )
152 Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
153}
154
167{
168 int Counter = 0;
169 Cut_ListForEachCut( pList, pList )
170 Counter++;
171 return Counter;
172}
173
186{
187 Cut_Cut_t * pList = NULL, ** ppTail = &pList;
188 Cut_Cut_t * pCut;
189 while ( pList1 && pList2 )
190 {
191 if ( Cut_CutCompare(pList1, pList2) < 0 )
192 {
193 pCut = pList1;
194 pList1 = pList1->pNext;
195 }
196 else
197 {
198 pCut = pList2;
199 pList2 = pList2->pNext;
200 }
201 *ppTail = pCut;
202 ppTail = &pCut->pNext;
203 }
204 *ppTail = pList1? pList1: pList2;
205 return pList;
206}
207
220{
221 Cut_Cut_t * pCut;
222 int i = 0;
223 Cut_ListForEachCut( pList, pCut )
224 pCut->Num0 = i++;
225}
226
239{
240 Cut_Cut_t * pCut;
241 if ( p->pParams->fSeq )
242 Node <<= CUT_SHIFT;
243 pCut = Cut_CutAlloc( p );
244 pCut->nLeaves = 1;
245 pCut->pLeaves[0] = Node;
246 pCut->uSign = Cut_NodeSign( Node );
247 if ( p->pParams->fTruth )
248 {
249/*
250 if ( pCut->nVarsMax == 4 )
251 Cut_CutWriteTruth( pCut, p->uTruthVars[0] );
252 else
253 Extra_BitCopy( pCut->nLeaves, p->uTruths[0], (uint8*)Cut_CutReadTruth(pCut) );
254*/
255 unsigned * pTruth = Cut_CutReadTruth(pCut);
256 int i;
257 for ( i = 0; i < p->nTruthWords; i++ )
258 pTruth[i] = 0xAAAAAAAA;
259 }
260 p->nCutsTriv++;
261 return pCut;
262}
263
264
276void Cut_CutPrint( Cut_Cut_t * pCut, int fSeq )
277{
278 int i;
279 assert( pCut->nLeaves > 0 );
280 printf( "%d : {", pCut->nLeaves );
281 for ( i = 0; i < (int)pCut->nLeaves; i++ )
282 {
283 if ( fSeq )
284 {
285 printf( " %d", pCut->pLeaves[i] >> CUT_SHIFT );
286 if ( pCut->pLeaves[i] & CUT_MASK )
287 printf( "(%d)", pCut->pLeaves[i] & CUT_MASK );
288 }
289 else
290 printf( " %d", pCut->pLeaves[i] );
291 }
292 printf( " }" );
293// printf( "\nSign = " );
294// Extra_PrintBinary( stdout, &pCut->uSign, 32 );
295}
296
308void Cut_CutPrintList( Cut_Cut_t * pList, int fSeq )
309{
310 Cut_Cut_t * pCut;
311 for ( pCut = pList; pCut; pCut = pCut->pNext )
312 Cut_CutPrint( pCut, fSeq ), printf( "\n" );
313}
314
326void Cut_CutPrintMerge( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 )
327{
328 printf( "\n" );
329 printf( "%d : %5d %5d %5d %5d %5d\n",
330 pCut0->nLeaves,
331 pCut0->nLeaves > 0 ? pCut0->pLeaves[0] : -1,
332 pCut0->nLeaves > 1 ? pCut0->pLeaves[1] : -1,
333 pCut0->nLeaves > 2 ? pCut0->pLeaves[2] : -1,
334 pCut0->nLeaves > 3 ? pCut0->pLeaves[3] : -1,
335 pCut0->nLeaves > 4 ? pCut0->pLeaves[4] : -1
336 );
337 printf( "%d : %5d %5d %5d %5d %5d\n",
338 pCut1->nLeaves,
339 pCut1->nLeaves > 0 ? pCut1->pLeaves[0] : -1,
340 pCut1->nLeaves > 1 ? pCut1->pLeaves[1] : -1,
341 pCut1->nLeaves > 2 ? pCut1->pLeaves[2] : -1,
342 pCut1->nLeaves > 3 ? pCut1->pLeaves[3] : -1,
343 pCut1->nLeaves > 4 ? pCut1->pLeaves[4] : -1
344 );
345 if ( pCut == NULL )
346 printf( "Cannot merge\n" );
347 else
348 printf( "%d : %5d %5d %5d %5d %5d\n",
349 pCut->nLeaves,
350 pCut->nLeaves > 0 ? pCut->pLeaves[0] : -1,
351 pCut->nLeaves > 1 ? pCut->pLeaves[1] : -1,
352 pCut->nLeaves > 2 ? pCut->pLeaves[2] : -1,
353 pCut->nLeaves > 3 ? pCut->pLeaves[3] : -1,
354 pCut->nLeaves > 4 ? pCut->pLeaves[4] : -1
355 );
356}
357
361
362
364
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Cut_CutPrintList(Cut_Cut_t *pList, int fSeq)
Definition cutCut.c:308
void Cut_CutRecycleList(Cut_Man_t *p, Cut_Cut_t *pList)
Definition cutCut.c:148
Cut_Cut_t * Cut_CutDupList(Cut_Man_t *p, Cut_Cut_t *pList)
Definition cutCut.c:120
int Cut_CutCountList(Cut_Cut_t *pList)
Definition cutCut.c:166
void Cut_CutNumberList(Cut_Cut_t *pList)
Definition cutCut.c:219
void Cut_CutPrintMerge(Cut_Cut_t *pCut, Cut_Cut_t *pCut0, Cut_Cut_t *pCut1)
Definition cutCut.c:326
Cut_Cut_t * Cut_CutMergeLists(Cut_Cut_t *pList1, Cut_Cut_t *pList2)
Definition cutCut.c:185
ABC_NAMESPACE_IMPL_START Cut_Cut_t * Cut_CutAlloc(Cut_Man_t *p)
DECLARATIONS ///.
Definition cutCut.c:45
void Cut_CutPrint(Cut_Cut_t *pCut, int fSeq)
Definition cutCut.c:276
Cut_Cut_t * Cut_CutCreateTriv(Cut_Man_t *p, int Node)
Definition cutCut.c:238
int Cut_CutCompare(Cut_Cut_t *pCut1, Cut_Cut_t *pCut2)
Definition cutCut.c:92
void Cut_CutRecycle(Cut_Man_t *p, Cut_Cut_t *pCut)
Definition cutCut.c:72
#define Cut_ListForEachCut(pList, pCut)
Definition cutInt.h:104
#define Cut_ListForEachCutSafe(pList, pCut, pCut2)
Definition cutInt.h:112
#define CUT_MASK
Definition cut.h:42
#define CUT_SHIFT
Definition cut.h:41
struct Cut_ManStruct_t_ Cut_Man_t
BASIC TYPES ///.
Definition cut.h:48
struct Cut_CutStruct_t_ Cut_Cut_t
Definition cut.h:50
Cube * p
Definition exorList.c:222
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
unsigned nVarsMax
Definition cut.h:83
unsigned Num0
Definition cut.h:79
int pLeaves[0]
Definition cut.h:89
unsigned fSimul
Definition cut.h:81
unsigned uSign
Definition cut.h:85
unsigned nLeaves
Definition cut.h:84
Cut_Cut_t * pNext
Definition cut.h:88
#define assert(ex)
Definition util_old.h:213
char * memcpy()
char * memset()