ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
amapOutput.c
Go to the documentation of this file.
1
20
21#include "amapInt.h"
22
24
25
29
30static inline char * Amap_OuputStrsav( Aig_MmFlex_t * p, char * pStr )
31{ return pStr ? strcpy(Aig_MmFlexEntryFetch(p, strlen(pStr)+1), pStr) : NULL; }
32
36
49{
50 Amap_Out_t * pRes;
51 int nFans = pGate? pGate->nPins : 1;
52 pRes = (Amap_Out_t *)Aig_MmFlexEntryFetch( pMem, sizeof(Amap_Out_t)+sizeof(int)*nFans );
53 memset( pRes, 0, sizeof(Amap_Out_t) );
54 memset( pRes->pFans, 0xff, sizeof(int)*nFans );
55 pRes->pName = pGate? Amap_OuputStrsav( pMem, pGate->pName ) : NULL;
56 pRes->nFans = nFans;
57 return pRes;
58}
59
72{
73 Vec_Ptr_t * vNodes;
74 Aig_MmFlex_t * pMem;
75 Amap_Obj_t * pObj, * pFanin;
76 Amap_Gat_t * pGate;
77 Amap_Out_t * pRes;
78 int i, k, iFanin, fCompl;
79 float TotalArea = 0.0;
80 pMem = Aig_MmFlexStart();
81 // create mapping object for each node used in the mapping
82 vNodes = Vec_PtrAlloc( 10 );
83 Amap_ManForEachObj( p, pObj, i )
84 {
85 if ( Amap_ObjIsPi(pObj) )
86 {
87 assert( pObj->fPolar == 0 );
88 pRes = Amap_OutputStructAlloc( pMem, NULL );
89 pRes->Type = -1;
90 pRes->nFans = 0;
91 // save this structure
92 pObj->iData = Vec_PtrSize( vNodes );
93 Vec_PtrPush( vNodes, pRes );
94 // create invertor if needed
95 if ( pObj->nFouts[1] ) // this PI is used in the neg polarity
96 {
97 pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGateInv );
98 pRes->pFans[0] = pObj->iData;
99 // save this structure
100 Vec_PtrPush( vNodes, pRes );
101 TotalArea += p->pLib->pGateInv->dArea;
102 }
103 continue;
104 }
105 if ( Amap_ObjIsNode(pObj) )
106 {
107 // skip the node that is not used in the mapping
108 if ( Amap_ObjRefsTotal(pObj) == 0 )
109 continue;
110 // get the gate
111 pGate = Amap_LibGate( p->pLib, pObj->Best.pSet->iGate );
112 assert( pGate->nPins == pObj->Best.pCut->nFans );
113 // allocate structure
114 pRes = Amap_OutputStructAlloc( pMem, pGate );
115 Amap_MatchForEachFaninCompl( p, &pObj->Best, pFanin, fCompl, k )
116 {
117 assert( Amap_ObjRefsTotal(pFanin) );
118 if ( (int)pFanin->fPolar == fCompl )
119 pRes->pFans[k] = pFanin->iData;
120 else
121 pRes->pFans[k] = pFanin->iData + 1;
122 }
123 // save this structure
124 pObj->iData = Vec_PtrSize( vNodes );
125 Vec_PtrPush( vNodes, pRes );
126 TotalArea += pGate->dArea;
127 // create invertor if needed
128 if ( pObj->nFouts[!pObj->fPolar] ) // needed in the opposite polarity
129 {
130 pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGateInv );
131 pRes->pFans[0] = pObj->iData;
132 // save this structure
133 Vec_PtrPush( vNodes, pRes );
134 TotalArea += p->pLib->pGateInv->dArea;
135 }
136 continue;
137 }
138 if ( Amap_ObjIsPo(pObj) )
139 {
140 assert( pObj->fPolar == 0 );
141 pFanin = Amap_ObjFanin0(p, pObj);
142 assert( Amap_ObjRefsTotal(pFanin) );
143 if ( Amap_ObjIsConst1(pFanin) )
144 { // create constant node
145 if ( Amap_ObjFaninC0(pObj) )
146 {
147 pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGate0 );
148 TotalArea += p->pLib->pGate0->dArea;
149 }
150 else
151 {
152 pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGate1 );
153 TotalArea += p->pLib->pGate1->dArea;
154 }
155 // save this structure
156 iFanin = Vec_PtrSize( vNodes );
157 Vec_PtrPush( vNodes, pRes );
158 }
159 else
160 {
161 if ( (int)pFanin->fPolar == Amap_ObjFaninC0(pObj) )
162 iFanin = pFanin->iData;
163 else
164 iFanin = pFanin->iData + 1;
165 }
166 // create PO node
167 pRes = Amap_OutputStructAlloc( pMem, NULL );
168 pRes->Type = 1;
169 pRes->pFans[0] = iFanin;
170 // save this structure
171 Vec_PtrPush( vNodes, pRes );
172 }
173 }
174 // return memory manager in the last entry of the array
175 Vec_PtrPush( vNodes, pMem );
176 return vNodes;
177}
178
179
183
184
186
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition aigMem.c:366
struct Aig_MmFlex_t_ Aig_MmFlex_t
Definition aig.h:53
Aig_MmFlex_t * Aig_MmFlexStart()
Definition aigMem.c:305
struct Amap_Obj_t_ Amap_Obj_t
Definition amapInt.h:71
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
Definition amapInt.h:310
struct Amap_Man_t_ Amap_Man_t
Definition amapInt.h:70
#define Amap_ManForEachObj(p, pObj, i)
Definition amapInt.h:287
struct Amap_Gat_t_ Amap_Gat_t
Definition amapInt.h:66
Vec_Ptr_t * Amap_ManProduceMapped(Amap_Man_t *p)
Definition amapOutput.c:71
Amap_Out_t * Amap_OutputStructAlloc(Aig_MmFlex_t *pMem, Amap_Gat_t *pGate)
FUNCTION DEFINITIONS ///.
Definition amapOutput.c:48
struct Amap_Out_t_ Amap_Out_t
Definition amap.h:58
Cube * p
Definition exorList.c:222
unsigned nFans
Definition amapInt.h:188
double dArea
Definition amapInt.h:157
unsigned nPins
Definition amapInt.h:162
char * pName
Definition amapInt.h:155
Amap_Set_t * pSet
Definition amapInt.h:194
Amap_Cut_t * pCut
Definition amapInt.h:193
unsigned fPolar
Definition amapInt.h:206
int nFouts[2]
Definition amapInt.h:218
Amap_Mat_t Best
Definition amapInt.h:219
int pFans[0]
Definition amap.h:64
short Type
Definition amap.h:62
char * pName
Definition amap.h:61
short nFans
Definition amap.h:63
unsigned iGate
Definition amapInt.h:168
#define assert(ex)
Definition util_old.h:213
char * memset()
int strlen()
char * strcpy()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42