abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
absRpmOld.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [absRpmOld.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis [Old min-cut-based reparametrization.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: absRpmOld.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "abs.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Specialized duplication.]
37 
38  Description [Replaces registers by PIs/POs and PIs by registers.]
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Vec_Int_t * vPiOuts;
48  Gia_Man_t * pNew;
49  Gia_Obj_t * pObj;
50  int i;
51  vPiOuts = Vec_IntAlloc( Gia_ManPiNum(p) );
52  pNew = Gia_ManStart( Gia_ManObjNum(p) + 2 * Gia_ManPiNum(p) );
53  pNew->pName = Abc_UtilStrsav( p->pName );
54  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
55  Gia_ManFillValue( p );
56  Gia_ManConst0(p)->Value = 0;
57  Gia_ManForEachPi( p, pObj, i )
58  Vec_IntPush( vPiOuts, Gia_ManAppendCi(pNew) );
59  Gia_ManForEachRo( p, pObj, i )
60  pObj->Value = Gia_ManAppendCi( pNew );
61  Gia_ManForEachPi( p, pObj, i )
62  pObj->Value = Gia_ManAppendCi( pNew );
63  Gia_ManForEachAnd( p, pObj, i )
64  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
65  Gia_ManForEachPo( p, pObj, i )
66  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
67  Gia_ManForEachRi( p, pObj, i )
68  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
69  Gia_ManForEachPi( p, pObj, i )
70  Gia_ManAppendCo( pNew, Vec_IntEntry(vPiOuts, i) );
71  Gia_ManSetRegNum( pNew, Gia_ManPiNum(p) );
72  Vec_IntFree( vPiOuts );
73  return pNew;
74 }
75 
76 /**Function*************************************************************
77 
78  Synopsis [Reverses the above step.]
79 
80  Description []
81 
82  SideEffects []
83 
84  SeeAlso []
85 
86 ***********************************************************************/
88 {
89  if ( pObj->Value != ~0 )
90  return pObj->Value;
91  assert( Gia_ObjIsAnd(pObj) );
92  Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin0(pObj) );
93  Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin1(pObj) );
94  return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
95 }
96 
97 /**Function*************************************************************
98 
99  Synopsis [Reverses the above step.]
100 
101  Description []
102 
103  SideEffects []
104 
105  SeeAlso []
106 
107 ***********************************************************************/
108 Gia_Man_t * Gia_ManDupFf2In( Gia_Man_t * p, int nFlopsOld )
109 {
110  Gia_Man_t * pNew;
111  Gia_Obj_t * pObj;
112  int i;
113  pNew = Gia_ManStart( Gia_ManObjNum(p) );
114  pNew->pName = Abc_UtilStrsav( p->pName );
115  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
116  Gia_ManFillValue( p );
117  Gia_ManConst0(p)->Value = 0;
118  Gia_ManForEachRo( p, pObj, i )
119  pObj->Value = Gia_ManAppendCi( pNew );
120  for ( i = Gia_ManPiNum(p) - nFlopsOld; i < Gia_ManPiNum(p); i++ )
121  Gia_ManPi(p, i)->Value = Gia_ManAppendCi( pNew );
122  Gia_ManForEachPo( p, pObj, i )
123  Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin0(pObj) );
124  Gia_ManForEachPo( p, pObj, i )
125  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
126  Gia_ManSetRegNum( pNew, nFlopsOld );
127  return pNew;
128 }
129 
130 /**Function*************************************************************
131 
132  Synopsis [Reparameterized to get rid of useless primary inputs.]
133 
134  Description []
135 
136  SideEffects []
137 
138  SeeAlso []
139 
140 ***********************************************************************/
142 {
143 // extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
144  Aig_Man_t * pMan, * pTemp;
145  Gia_Man_t * pNew, * pTmp;
146  int nFlopsOld = Gia_ManRegNum(p);
147  if ( fVerbose )
148  {
149  printf( "Original AIG:\n" );
150  Gia_ManPrintStats( p, NULL );
151  }
152 
153  // perform input trimming
154  pNew = Gia_ManDupTrimmed( p, 1, 0, 0, -1 );
155  if ( fVerbose )
156  {
157  printf( "After PI trimming:\n" );
158  Gia_ManPrintStats( pNew, NULL );
159  }
160  // transform GIA
161  pNew = Gia_ManDupIn2Ff( pTmp = pNew );
162  Gia_ManStop( pTmp );
163  if ( fVerbose )
164  {
165  printf( "After PI-2-FF transformation:\n" );
166  Gia_ManPrintStats( pNew, NULL );
167  }
168 
169  // derive AIG
170  pMan = Gia_ManToAigSimple( pNew );
171  Gia_ManStop( pNew );
172  // perform min-reg retiming
173  pMan = Saig_ManRetimeMinArea( pTemp = pMan, 10, 0, 0, 1, 0 );
174  Aig_ManStop( pTemp );
175  // derive GIA
176  pNew = Gia_ManFromAigSimple( pMan );
177  Aig_ManStop( pMan );
178  if ( fVerbose )
179  {
180  printf( "After min-area retiming:\n" );
181  Gia_ManPrintStats( pNew, NULL );
182  }
183 
184  // transform back
185  pNew = Gia_ManDupFf2In( pTmp = pNew, nFlopsOld );
186  Gia_ManStop( pTmp );
187  if ( fVerbose )
188  {
189  printf( "After FF-2-PI tranformation:\n" );
190  Gia_ManPrintStats( pNew, NULL );
191  }
192  return pNew;
193 }
194 
195 ////////////////////////////////////////////////////////////////////////
196 /// END OF FILE ///
197 ////////////////////////////////////////////////////////////////////////
198 
199 
201 
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
Gia_Man_t * Gia_ManDupTrimmed(Gia_Man_t *p, int fTrimCis, int fTrimCos, int fDualOut, int OutValue)
Definition: giaDup.c:1638
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition: giaAig.c:367
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
Aig_Man_t * Saig_ManRetimeMinArea(Aig_Man_t *p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose)
Definition: saigRetMin.c:623
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * Abs_RpmPerformOld(Gia_Man_t *p, int fVerbose)
Definition: absRpmOld.c:141
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int Gia_ManDupFf2In_rec(Gia_Man_t *pNew, Gia_Obj_t *pObj)
Definition: absRpmOld.c:87
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
Definition: giaAig.c:171
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
Definition: gia.h:75
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_ManDupIn2Ff(Gia_Man_t *p)
DECLARATIONS ///.
Definition: absRpmOld.c:45
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int fVerbose
Definition: absRefJ.c:91
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
Gia_Man_t * Gia_ManDupFf2In(Gia_Man_t *p, int nFlopsOld)
Definition: absRpmOld.c:108
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387