ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwrLib.c File Reference
#include "rwr.h"
Include dependency graph for rwrLib.c:

Go to the source code of this file.

Functions

void Rwr_ManPrecompute (Rwr_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
Rwr_Node_tRwr_ManAddNode (Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1, int fExor, int Level, int Volume)
 
Rwr_Node_tRwr_ManAddVar (Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
 
void Rwr_Trav_rec (Rwr_Man_t *p, Rwr_Node_t *pNode, int *pVolume)
 
int Rwr_ManNodeVolume (Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
 
void Rwr_ManIncTravId (Rwr_Man_t *p)
 

Function Documentation

◆ Rwr_ManAddNode()

Rwr_Node_t * Rwr_ManAddNode ( Rwr_Man_t * p,
Rwr_Node_t * p0,
Rwr_Node_t * p1,
int fExor,
int Level,
int Volume )

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file rwrLib.c.

207{
208 Rwr_Node_t * pNew;
209 unsigned uTruth;
210 // compute truth table, leve, volume
211 p->nConsidered++;
212 if ( fExor )
213 uTruth = (p0->uTruth ^ p1->uTruth);
214 else
215 uTruth = (Rwr_IsComplement(p0)? ~Rwr_Regular(p0)->uTruth : Rwr_Regular(p0)->uTruth) &
216 (Rwr_IsComplement(p1)? ~Rwr_Regular(p1)->uTruth : Rwr_Regular(p1)->uTruth) & 0xFFFF;
217 // create the new node
218 pNew = (Rwr_Node_t *)Extra_MmFixedEntryFetch( p->pMmNode );
219 pNew->Id = p->vForest->nSize;
220 pNew->TravId = 0;
221 pNew->uTruth = uTruth;
222 pNew->Level = Level;
223 pNew->Volume = Volume;
224 pNew->fUsed = 0;
225 pNew->fExor = fExor;
226 pNew->p0 = p0;
227 pNew->p1 = p1;
228 pNew->pNext = NULL;
229 Vec_PtrPush( p->vForest, pNew );
230 // do not add if the node is not essential
231 if ( uTruth != p->puCanons[uTruth] )
232 return pNew;
233
234 // add to the list
235 p->nAdded++;
236 if ( p->pTable[uTruth] == NULL )
237 p->nClasses++;
238 Rwr_ListAddToTail( p->pTable + uTruth, pNew );
239 return pNew;
240}
Cube * p
Definition exorList.c:222
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
struct Rwr_Node_t_ Rwr_Node_t
Definition rwr.h:48
void Rwr_ListAddToTail(Rwr_Node_t **ppList, Rwr_Node_t *pNode)
Definition rwrUtil.c:619
Rwr_Node_t * p1
Definition rwr.h:111
int Id
Definition rwr.h:100
unsigned fUsed
Definition rwr.h:108
unsigned Volume
Definition rwr.h:106
Rwr_Node_t * p0
Definition rwr.h:110
unsigned fExor
Definition rwr.h:109
unsigned Level
Definition rwr.h:107
Rwr_Node_t * pNext
Definition rwr.h:112
int TravId
Definition rwr.h:101
unsigned uTruth
Definition rwr.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManAddVar()

Rwr_Node_t * Rwr_ManAddVar ( Rwr_Man_t * p,
unsigned uTruth,
int fPrecompute )

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file rwrLib.c.

254{
255 Rwr_Node_t * pNew;
256 pNew = (Rwr_Node_t *)Extra_MmFixedEntryFetch( p->pMmNode );
257 pNew->Id = p->vForest->nSize;
258 pNew->TravId = 0;
259 pNew->uTruth = uTruth;
260 pNew->Level = 0;
261 pNew->Volume = 0;
262 pNew->fUsed = 1;
263 pNew->fExor = 0;
264 pNew->p0 = NULL;
265 pNew->p1 = NULL;
266 pNew->pNext = NULL;
267 Vec_PtrPush( p->vForest, pNew );
268 if ( fPrecompute )
269 Rwr_ListAddToTail( p->pTable + uTruth, pNew );
270 return pNew;
271}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManIncTravId()

void Rwr_ManIncTravId ( Rwr_Man_t * p)

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file rwrLib.c.

351{
352 Rwr_Node_t * pNode;
353 int i;
354 if ( p->nTravIds++ < 0x8FFFFFFF )
355 return;
356 Vec_PtrForEachEntry( Rwr_Node_t *, p->vForest, pNode, i )
357 pNode->TravId = 0;
358 p->nTravIds = 1;
359}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Rwr_ManNodeVolume()

int Rwr_ManNodeVolume ( Rwr_Man_t * p,
Rwr_Node_t * p0,
Rwr_Node_t * p1 )

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file rwrLib.c.

331{
332 int Volume = 0;
334 Rwr_Trav_rec( p, p0, &Volume );
335 Rwr_Trav_rec( p, p1, &Volume );
336 return Volume;
337}
void Rwr_Trav_rec(Rwr_Man_t *p, Rwr_Node_t *pNode, int *pVolume)
Definition rwrLib.c:307
void Rwr_ManIncTravId(Rwr_Man_t *p)
Definition rwrLib.c:350
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManPrecompute()

void Rwr_ManPrecompute ( Rwr_Man_t * p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Precomputes the forest in the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file rwrLib.c.

49{
50 Rwr_Node_t * p0, * p1;
51 int i, k, Level, Volume;
52 int LevelOld = -1;
53 int nNodes;
54
55 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 1 )
56 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p1, k, 1 )
57 {
58 if ( LevelOld < (int)p0->Level )
59 {
60 LevelOld = p0->Level;
61 printf( "Starting level %d (at %d nodes).\n", LevelOld+1, i );
62 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
63 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
64 }
65
66 if ( k == i )
67 break;
68// if ( p0->Level + p1->Level > 6 ) // hard
69// break;
70
71 if ( p0->Level + p1->Level > 5 ) // easy
72 break;
73
74// if ( p0->Level + p1->Level > 6 || (p0->Level == 3 && p1->Level == 3) )
75// break;
76
77 // compute the level and volume of the new nodes
78 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
79 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
80 // try four different AND nodes
81 Rwr_ManTryNode( p, p0 , p1 , 0, Level, Volume );
82 Rwr_ManTryNode( p, Rwr_Not(p0), p1 , 0, Level, Volume );
83 Rwr_ManTryNode( p, p0 , Rwr_Not(p1), 0, Level, Volume );
84 Rwr_ManTryNode( p, Rwr_Not(p0), Rwr_Not(p1), 0, Level, Volume );
85 // try EXOR
86 Rwr_ManTryNode( p, p0 , p1 , 1, Level, Volume + 1 );
87 // report the progress
88 if ( p->nConsidered % 50000000 == 0 )
89 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
90 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
91 // quit after some time
92 if ( p->vForest->nSize == RWR_LIMIT + 5 )
93 {
94 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
95 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
96 goto save;
97 }
98 }
99save :
100
101 // mark the relevant ones
103 k = 5;
104 nNodes = 0;
105 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
106 if ( p0->uTruth == p->puCanons[p0->uTruth] )
107 {
108 Rwr_MarkUsed_rec( p, p0 );
109 nNodes++;
110 }
111
112 // compact the array by throwing away non-canonical
113 k = 5;
114 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
115 if ( p0->fUsed )
116 {
117 p->vForest->pArray[k] = p0;
118 p0->Id = k++;
119 }
120 p->vForest->nSize = k;
121 printf( "Total canonical = %4d. Total used = %5d.\n", nNodes, p->vForest->nSize );
122}
int Rwr_ManNodeVolume(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
Definition rwrLib.c:330
#define RWR_LIMIT
INCLUDES ///.
Definition rwr.h:45
if(last==0)
Definition sparse_int.h:34
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_Trav_rec()

void Rwr_Trav_rec ( Rwr_Man_t * p,
Rwr_Node_t * pNode,
int * pVolume )

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file rwrLib.c.

308{
309 if ( pNode->fUsed || pNode->TravId == p->nTravIds )
310 return;
311 pNode->TravId = p->nTravIds;
312 (*pVolume)++;
313 if ( pNode->fExor )
314 (*pVolume)++;
315 Rwr_Trav_rec( p, Rwr_Regular(pNode->p0), pVolume );
316 Rwr_Trav_rec( p, Rwr_Regular(pNode->p1), pVolume );
317}
Here is the call graph for this function:
Here is the caller graph for this function: