ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwrMan.c
Go to the documentation of this file.
1
20
21#include "rwr.h"
22#include "base/main/main.h"
23#include "bool/dec/dec.h"
24
26
27
31
35
47Rwr_Man_t * Rwr_ManStart( int fPrecompute )
48{
49 Dec_Man_t * pManDec;
50 Rwr_Man_t * p;
51 abctime clk = Abc_Clock();
52clk = Abc_Clock();
53 p = ABC_ALLOC( Rwr_Man_t, 1 );
54 memset( p, 0, sizeof(Rwr_Man_t) );
55 p->nFuncs = (1<<16);
56 pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
57 p->puCanons = pManDec->puCanons;
58 p->pPhases = pManDec->pPhases;
59 p->pPerms = pManDec->pPerms;
60 p->pMap = pManDec->pMap;
61 // initialize practical NPN classes
62 p->pPractical = Rwr_ManGetPractical( p );
63 // create the table
64 p->pTable = ABC_ALLOC( Rwr_Node_t *, p->nFuncs );
65 memset( p->pTable, 0, sizeof(Rwr_Node_t *) * p->nFuncs );
66 // create the elementary nodes
67 p->pMmNode = Extra_MmFixedStart( sizeof(Rwr_Node_t) );
68 p->vForest = Vec_PtrAlloc( 100 );
69 Rwr_ManAddVar( p, 0x0000, fPrecompute ); // constant 0
70 Rwr_ManAddVar( p, 0xAAAA, fPrecompute ); // var A
71 Rwr_ManAddVar( p, 0xCCCC, fPrecompute ); // var B
72 Rwr_ManAddVar( p, 0xF0F0, fPrecompute ); // var C
73 Rwr_ManAddVar( p, 0xFF00, fPrecompute ); // var D
74 p->nClasses = 5;
75 // other stuff
76 p->nTravIds = 1;
77 p->pPerms4 = Extra_Permutations( 4 );
78 p->vLevNums = Vec_IntAlloc( 50 );
79 p->vFanins = Vec_PtrAlloc( 50 );
80 p->vFaninsCur = Vec_PtrAlloc( 50 );
81 p->vNodesTemp = Vec_PtrAlloc( 50 );
82 if ( fPrecompute )
83 { // precompute subgraphs
85// Rwr_ManPrint( p );
87 }
88 else
89 { // load saved subgraphs
91// Rwr_ManPrint( p );
93 }
94p->timeStart = Abc_Clock() - clk;
95 return p;
96}
97
110{
111 if ( p->vClasses )
112 {
113 Rwr_Node_t * pNode;
114 int i, k;
115 Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
116 Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
117 }
118 if ( p->vClasses ) Vec_VecFree( p->vClasses );
119 Vec_PtrFree( p->vNodesTemp );
120 Vec_PtrFree( p->vForest );
121 Vec_IntFree( p->vLevNums );
122 Vec_PtrFree( p->vFanins );
123 Vec_PtrFree( p->vFaninsCur );
124 Extra_MmFixedStop( p->pMmNode );
125 ABC_FREE( p->pMapInv );
126 ABC_FREE( p->pTable );
127 ABC_FREE( p->pPractical );
128 ABC_FREE( p->pPerms4 );
129 ABC_FREE( p );
130}
131
144{
145 int i, Counter = 0;
146 for ( i = 0; i < 222; i++ )
147 Counter += (p->nScores[i] > 0);
148
149 printf( "Rewriting statistics:\n" );
150 printf( "Total cuts tries = %8d.\n", p->nCutsGood );
151 printf( "Bad cuts found = %8d.\n", p->nCutsBad );
152 printf( "Total subgraphs = %8d.\n", p->nSubgraphs );
153 printf( "Used NPN classes = %8d.\n", Counter );
154 printf( "Nodes considered = %8d.\n", p->nNodesConsidered );
155 printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten );
156 printf( "Gain = %8d. (%6.2f %%).\n", p->nNodesBeg-p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg );
157 ABC_PRT( "Start ", p->timeStart );
158 ABC_PRT( "Cuts ", p->timeCut );
159 ABC_PRT( "Resynthesis ", p->timeRes );
160 ABC_PRT( " Mffc ", p->timeMffc );
161 ABC_PRT( " Eval ", p->timeEval );
162 ABC_PRT( "Update ", p->timeUpdate );
163 ABC_PRT( "TOTAL ", p->timeTotal );
164
165/*
166 printf( "The scores are:\n" );
167 for ( i = 0; i < 222; i++ )
168 if ( p->nScores[i] > 0 )
169 {
170 extern void Ivy_TruthDsdComputePrint( unsigned uTruth );
171 printf( "%3d = %8d canon = %5d ", i, p->nScores[i], p->pMapInv[i] );
172 Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[i] | ((unsigned)p->pMapInv[i] << 16) );
173 }
174*/
175 printf( "\n" );
176
177}
178
191{
192 FILE * pTable;
193 pTable = fopen( "stats.txt", "a+" );
194 fprintf( pTable, "%d ", p->nCutsGood );
195 fprintf( pTable, "%d ", p->nSubgraphs );
196 fprintf( pTable, "%d ", p->nNodesRewritten );
197 fprintf( pTable, "%d", p->nNodesGained );
198 fprintf( pTable, "\n" );
199 fclose( pTable );
200}
201
214{
215 return p->pGraph;
216}
217
230{
231 return p->vFanins;
232}
233
246{
247 return p->fCompl;
248}
249
262{
263 p->timeCut += Time;
264}
265
278{
279 p->timeUpdate += Time;
280}
281
294{
295 p->timeTotal += Time;
296}
297
298
311{
312 Rwr_Man_t * p;
313 p = Rwr_ManStart( 1 );
314 Rwr_ManStop( p );
315}
316
320
321
323
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadManDec()
Definition mainFrame.c:66
struct Dec_Man_t_ Dec_Man_t
Definition dec.h:79
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
Cube * p
Definition exorList.c:222
char ** Extra_Permutations(int n)
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
void Rwr_ManAddTimeUpdate(Rwr_Man_t *p, abctime Time)
Definition rwrMan.c:277
void Rwr_ManAddTimeCuts(Rwr_Man_t *p, abctime Time)
Definition rwrMan.c:261
void Rwr_ManAddTimeTotal(Rwr_Man_t *p, abctime Time)
Definition rwrMan.c:293
void Rwr_Precompute()
Definition rwrMan.c:310
int Rwr_ManReadCompl(Rwr_Man_t *p)
Definition rwrMan.c:245
void Rwr_ManPrintStats(Rwr_Man_t *p)
Definition rwrMan.c:143
ABC_NAMESPACE_IMPL_START Rwr_Man_t * Rwr_ManStart(int fPrecompute)
DECLARATIONS ///.
Definition rwrMan.c:47
void Rwr_ManPrintStatsFile(Rwr_Man_t *p)
Definition rwrMan.c:190
void Rwr_ManStop(Rwr_Man_t *p)
Definition rwrMan.c:109
void * Rwr_ManReadDecs(Rwr_Man_t *p)
Definition rwrMan.c:213
Vec_Ptr_t * Rwr_ManReadLeaves(Rwr_Man_t *p)
Definition rwrMan.c:229
Rwr_Node_t * Rwr_ManAddVar(Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
Definition rwrLib.c:253
char * Rwr_ManGetPractical(Rwr_Man_t *p)
Definition rwrUtil.c:640
void Rwr_ManPreprocess(Rwr_Man_t *p)
MACRO DEFINITIONS ///.
Definition rwrDec.c:49
struct Rwr_Man_t_ Rwr_Man_t
Definition rwr.h:47
void Rwr_ManWriteToArray(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition rwrUtil.c:426
void Rwr_ManPrecompute(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition rwrLib.c:48
struct Rwr_Node_t_ Rwr_Node_t
Definition rwr.h:48
void Rwr_ManLoadFromArray(Rwr_Man_t *p, int fVerbose)
Definition rwrUtil.c:472
char * pPerms
Definition dec.h:88
char * pPhases
Definition dec.h:87
unsigned char * pMap
Definition dec.h:89
unsigned short * puCanons
Definition dec.h:86
Rwr_Node_t * pNext
Definition rwr.h:112
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition vecVec.h:87