abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
amapOutput.c File Reference
#include "amapInt.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START char * 
Amap_OuputStrsav (Aig_MmFlex_t *p, char *pStr)
 DECLARATIONS ///. More...
 
Amap_Out_tAmap_OutputStructAlloc (Aig_MmFlex_t *pMem, Amap_Gat_t *pGate)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Ptr_tAmap_ManProduceMapped (Amap_Man_t *p)
 

Function Documentation

Vec_Ptr_t* Amap_ManProduceMapped ( Amap_Man_t p)

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

Synopsis [Returns mapped network as an array of structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file amapOutput.c.

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 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int pFans[0]
Definition: amap.h:64
Amap_Mat_t Best
Definition: amapInt.h:218
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
int nFouts[2]
Definition: amapInt.h:217
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
Definition: amapInt.h:309
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Amap_ManForEachObj(p, pObj, i)
Definition: amapInt.h:286
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Amap_Out_t * Amap_OutputStructAlloc(Aig_MmFlex_t *pMem, Amap_Gat_t *pGate)
FUNCTION DEFINITIONS ///.
Definition: amapOutput.c:48
static int Amap_ObjIsPi(Amap_Obj_t *pObj)
Definition: amapInt.h:240
short nFans
Definition: amap.h:63
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Amap_ObjIsNode(Amap_Obj_t *pObj)
Definition: amapInt.h:245
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
static int Amap_ObjIsPo(Amap_Obj_t *pObj)
Definition: amapInt.h:241
Amap_Lib_t * pLib
Definition: amapInt.h:79
static int Amap_ObjIsConst1(Amap_Obj_t *pObj)
Definition: amapInt.h:239
unsigned nPins
Definition: amapInt.h:161
double dArea
Definition: amapInt.h:156
unsigned nFans
Definition: amapInt.h:187
short Type
Definition: amap.h:62
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
unsigned fPolar
Definition: amapInt.h:205
Amap_Set_t * pSet
Definition: amapInt.h:193
int iData
Definition: amapInt.h:213
static ABC_NAMESPACE_IMPL_START char* Amap_OuputStrsav ( Aig_MmFlex_t p,
char *  pStr 
)
inlinestatic

DECLARATIONS ///.

CFile****************************************************************

FileName [amapOutput.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Core mapping procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
amapOutput.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file amapOutput.c.

31 { return pStr ? strcpy(Aig_MmFlexEntryFetch(p, strlen(pStr)+1), pStr) : NULL; }
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * strcpy()
int strlen()
Amap_Out_t* Amap_OutputStructAlloc ( Aig_MmFlex_t pMem,
Amap_Gat_t pGate 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates structure for storing one gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file amapOutput.c.

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 }
char * memset()
int pFans[0]
Definition: amap.h:64
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
static ABC_NAMESPACE_IMPL_START char * Amap_OuputStrsav(Aig_MmFlex_t *p, char *pStr)
DECLARATIONS ///.
Definition: amapOutput.c:30
char * pName
Definition: amap.h:61
short nFans
Definition: amap.h:63
unsigned nPins
Definition: amapInt.h:161
char * pName
Definition: amapInt.h:154