1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/**CFile****************************************************************
FileName [absIter.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Abstraction package.]
Synopsis [Iterative improvement of abstraction.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: absIter.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abs.h"
#include "sat/bmc/bmc.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static inline int Gia_ObjIsInGla( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Vec_IntEntry(p->vGateClasses, Gia_ObjId(p, pObj)); }
static inline void Gia_ObjAddToGla( Gia_Man_t * p, Gia_Obj_t * pObj ) { Vec_IntWriteEntry(p->vGateClasses, Gia_ObjId(p, pObj), 1); }
static inline void Gia_ObjRemFromGla( Gia_Man_t * p, Gia_Obj_t * pObj ) { Vec_IntWriteEntry(p->vGateClasses, Gia_ObjId(p, pObj), 0); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Gia_IterTryImprove( Gia_Man_t * p, int nTimeOut, int iFrame0 )
{
Gia_Man_t * pAbs = Gia_ManDupAbsGates( p, p->vGateClasses );
Aig_Man_t * pAig = Gia_ManToAigSimple( pAbs );
int nStart = 0;
int nFrames = iFrame0 ? iFrame0 + 1 : 10000000;
int nNodeDelta = 2000;
int nBTLimit = 0;
int nBTLimitAll = 0;
int fVerbose = 0;
int RetValue, iFrame;
RetValue = Saig_BmcPerform( pAig, nStart, nFrames, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fVerbose, 0, &iFrame, 1 );
assert( RetValue == 0 || RetValue == -1 );
Aig_ManStop( pAig );
Gia_ManStop( pAbs );
return iFrame;
}
Gia_Man_t * Gia_ManShrinkGla( Gia_Man_t * p, int nFrameMax, int nTimeOut, int fUsePdr, int fUseSat, int fUseBdd, int fVerbose )
{
Gia_Obj_t * pObj;
int i, iFrame0, iFrame;
int nTotal = 0, nRemoved = 0;
Vec_Int_t * vGScopy;
abctime clk, clkTotal = Abc_Clock();
assert( Gia_ManPoNum(p) == 1 );
assert( p->vGateClasses != NULL );
vGScopy = Vec_IntDup( p->vGateClasses );
if ( nFrameMax == 0 )
iFrame0 = Gia_IterTryImprove( p, 0, 0 );
else
iFrame0 = nFrameMax - 1;
while ( 1 )
{
int fChanges = 0;
Gia_ManForEachObj1( p, pObj, i )
{
if ( pObj->fMark0 )
continue;
if ( !Gia_ObjIsInGla(p, pObj) )
continue;
if ( pObj == Gia_ObjFanin0( Gia_ManPo(p, 0) ) )
continue;
if ( Gia_ObjIsAnd(pObj) )
{
if ( Gia_ObjIsInGla(p, Gia_ObjFanin0(pObj)) && Gia_ObjIsInGla(p, Gia_ObjFanin1(pObj)) )
continue;
}
if ( Gia_ObjIsRo(p, pObj) )
{
if ( Gia_ObjIsInGla(p, Gia_ObjFanin0(Gia_ObjRoToRi(p, pObj))) )
continue;
}
clk = Abc_Clock();
printf( "%5d : ", nTotal );
printf( "Obj =%7d ", i );
Gia_ObjRemFromGla( p, pObj );
iFrame = Gia_IterTryImprove( p, nTimeOut, iFrame0 );
if ( nFrameMax )
assert( iFrame <= nFrameMax );
else
assert( iFrame <= iFrame0 );
printf( "Frame =%6d ", iFrame );
if ( iFrame < iFrame0 )
{
pObj->fMark0 = 1;
Gia_ObjAddToGla( p, pObj );
printf( " " );
}
else
{
fChanges = 1;
nRemoved++;
printf( "Removing " );
Vec_IntWriteEntry( vGScopy, Gia_ObjId(p, pObj), 0 );
}
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
nTotal++;
// update the classes
Vec_IntFreeP( &p->vGateClasses );
p->vGateClasses = Vec_IntDup(vGScopy);
}
if ( !fChanges )
break;
}
Gia_ManCleanMark0(p);
Vec_IntFree( vGScopy );
printf( "Tried = %d. ", nTotal );
printf( "Removed = %d. (%.2f %%) ", nRemoved, 100.0 * nRemoved / Vec_IntCountPositive(p->vGateClasses) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
return NULL;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
|