abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclUtil.c File Reference
#include "sclSize.h"
#include "map/mio/mio.h"
#include "base/main/main.h"

Go to the source code of this file.

Macros

#define ABC_SCL_MAX_SIZE   64
 

Functions

ABC_NAMESPACE_IMPL_START void Abc_SclMioGates2SclGates (SC_Lib *pLib, Abc_Ntk_t *p)
 DECLARATIONS ///. More...
 
void Abc_SclSclGates2MioGates (SC_Lib *pLib, Abc_Ntk_t *p)
 
void Abc_SclManPrintGateSizes (SC_Lib *pLib, Abc_Ntk_t *p, Vec_Int_t *vGates)
 
void Abc_SclPrintGateSizes (SC_Lib *pLib, Abc_Ntk_t *p)
 
SC_CellAbc_SclFindMaxAreaCell (SC_Cell *pRepr)
 
Vec_Int_tAbc_SclFindMinAreas (SC_Lib *pLib, int fUseMax)
 
void Abc_SclMinsizePerform (SC_Lib *pLib, Abc_Ntk_t *p, int fUseMax, int fVerbose)
 
int Abc_SclCountMinSize (SC_Lib *pLib, Abc_Ntk_t *p, int fUseMax)
 
void Abc_SclReadTimingConstr (Abc_Frame_t *pAbc, char *pFileName, int fVerbose)
 
Vec_Int_tAbc_SclExtractBarBufs (Abc_Ntk_t *pNtk)
 
void Abc_SclInsertBarBufs (Abc_Ntk_t *pNtk, Vec_Int_t *vBufs)
 

Macro Definition Documentation

#define ABC_SCL_MAX_SIZE   64

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

Synopsis [Reports percentage of gates of each size.]

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file sclUtil.c.

Function Documentation

int Abc_SclCountMinSize ( SC_Lib pLib,
Abc_Ntk_t p,
int  fUseMax 
)

Definition at line 203 of file sclUtil.c.

204 {
205  Vec_Int_t * vMinCells;
206  Abc_Obj_t * pObj;
207  int i, gateId, Counter = 0;
208  vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
209  Abc_NtkForEachNode1( p, pObj, i )
210  {
211  gateId = Vec_IntEntry( p->vGates, i );
212  Counter += ( gateId == Vec_IntEntry(vMinCells, gateId) );
213  }
214  Vec_IntFree( vMinCells );
215  return Counter;
216 }
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Abc_SclFindMinAreas(SC_Lib *pLib, int fUseMax)
Definition: sclUtil.c:170
Vec_Int_t * vGates
Definition: abc.h:207
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Counter
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Int_t* Abc_SclExtractBarBufs ( Abc_Ntk_t pNtk)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 267 of file sclUtil.c.

268 {
269  Vec_Int_t * vBufs;
270  Mio_Gate_t * pBuffer;
271  Abc_Obj_t * pObj; int i;
272  pBuffer = Mio_LibraryReadBuf( (Mio_Library_t *)pNtk->pManFunc );
273  if ( pBuffer == NULL )
274  {
275  printf( "Cannot find buffer in the current library. Quitting.\n" );
276  return NULL;
277  }
278  vBufs = Vec_IntAlloc( 100 );
279  Abc_NtkForEachBarBuf( pNtk, pObj, i )
280  {
281  assert( pObj->pData == NULL );
282  pObj->pData = pBuffer;
283  Vec_IntPush( vBufs, i );
284  }
285  return vBufs;
286 }
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition: mioApi.c:47
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void * pManFunc
Definition: abc.h:191
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachBarBuf(pNtk, pNode, i)
Definition: abc.h:479
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
SC_Cell* Abc_SclFindMaxAreaCell ( SC_Cell pRepr)

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

Synopsis [Downsizes each gate to its minimium size.]

Description []

SideEffects []

SeeAlso []

Definition at line 157 of file sclUtil.c.

158 {
159  SC_Cell * pCell, * pBest = pRepr;
160  float AreaBest = pRepr->area;
161  int i;
162  SC_RingForEachCell( pRepr, pCell, i )
163  if ( AreaBest < pCell->area )
164  {
165  AreaBest = pCell->area;
166  pBest = pCell;
167  }
168  return pBest;
169 }
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
float area
Definition: sclLib.h:188
if(last==0)
Definition: sparse_int.h:34
Vec_Int_t* Abc_SclFindMinAreas ( SC_Lib pLib,
int  fUseMax 
)

Definition at line 170 of file sclUtil.c.

171 {
172  Vec_Int_t * vMinCells;
173  SC_Cell * pCell, * pRepr = NULL, * pBest = NULL;
174  int i, k;
175  // map each gate in the library into its min/max-size prototype
176  vMinCells = Vec_IntStartFull( Vec_PtrSize(pLib->vCells) );
177  SC_LibForEachCellClass( pLib, pRepr, i )
178  {
179  pBest = fUseMax ? Abc_SclFindMaxAreaCell(pRepr) : pRepr;
180  SC_RingForEachCell( pRepr, pCell, k )
181  Vec_IntWriteEntry( vMinCells, pCell->Id, pBest->Id );
182  }
183  return vMinCells;
184 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
SC_Cell * Abc_SclFindMaxAreaCell(SC_Cell *pRepr)
Definition: sclUtil.c:157
Vec_Ptr_t * vCells
Definition: sclLib.h:215
void Abc_SclInsertBarBufs ( Abc_Ntk_t pNtk,
Vec_Int_t vBufs 
)

Definition at line 287 of file sclUtil.c.

288 {
289  Abc_Obj_t * pObj; int i;
290  Abc_NtkForEachObjVec( vBufs, pNtk, pObj, i )
291  pObj->pData = NULL;
292 }
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition: abc.h:452
void Abc_SclManPrintGateSizes ( SC_Lib pLib,
Abc_Ntk_t p,
Vec_Int_t vGates 
)

Definition at line 109 of file sclUtil.c.

110 {
111  Abc_Obj_t * pObj;
112  SC_Cell * pCell;
113  int i, nGates = 0, Counters[ABC_SCL_MAX_SIZE] = {0};
114  double TotArea = 0, Areas[ABC_SCL_MAX_SIZE] = {0};
115  Abc_NtkForEachNode1( p, pObj, i )
116  {
117  pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
118  assert( pCell->Order < ABC_SCL_MAX_SIZE );
119  Counters[pCell->Order]++;
120  Areas[pCell->Order] += pCell->area;
121  TotArea += pCell->area;
122  nGates++;
123  }
124  printf( "Total gates = %d. Total area = %.1f\n", nGates, TotArea );
125  for ( i = 0; i < ABC_SCL_MAX_SIZE; i++ )
126  {
127  if ( Counters[i] == 0 )
128  continue;
129  printf( "Cell size = %d. ", i );
130  printf( "Count = %6d ", Counters[i] );
131  printf( "(%5.1f %%) ", 100.0 * Counters[i] / nGates );
132  printf( "Area = %12.1f ", Areas[i] );
133  printf( "(%5.1f %%) ", 100.0 * Areas[i] / TotArea );
134  printf( "\n" );
135  }
136 }
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
#define ABC_SCL_MAX_SIZE
Definition: sclUtil.c:108
int Order
Definition: sclLib.h:198
float area
Definition: sclLib.h:188
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
#define assert(ex)
Definition: util_old.h:213
void Abc_SclMinsizePerform ( SC_Lib pLib,
Abc_Ntk_t p,
int  fUseMax,
int  fVerbose 
)

Definition at line 185 of file sclUtil.c.

186 {
187  Vec_Int_t * vMinCells;
188  Abc_Obj_t * pObj;
189  int i, gateId;
190  vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
191  Abc_SclMioGates2SclGates( pLib, p );
192  Abc_NtkForEachNode1( p, pObj, i )
193  {
194  gateId = Vec_IntEntry( p->vGates, i );
195  assert( gateId >= 0 && gateId < Vec_PtrSize(pLib->vCells) );
196  gateId = Vec_IntEntry( vMinCells, gateId );
197  assert( gateId >= 0 && gateId < Vec_PtrSize(pLib->vCells) );
198  Vec_IntWriteEntry( p->vGates, i, gateId );
199  }
200  Abc_SclSclGates2MioGates( pLib, p );
201  Vec_IntFree( vMinCells );
202 }
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
Definition: sclUtil.c:73
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Abc_SclFindMinAreas(SC_Lib *pLib, int fUseMax)
Definition: sclUtil.c:170
Vec_Int_t * vGates
Definition: abc.h:207
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
ABC_NAMESPACE_IMPL_START void Abc_SclMioGates2SclGates(SC_Lib *pLib, Abc_Ntk_t *p)
DECLARATIONS ///.
Definition: sclUtil.c:47
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Ptr_t * vCells
Definition: sclLib.h:215
ABC_NAMESPACE_IMPL_START void Abc_SclMioGates2SclGates ( SC_Lib pLib,
Abc_Ntk_t p 
)

DECLARATIONS ///.

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

FileName [sclUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Standard-cell library representation.]

Synopsis [Various utilities.]

Author [Alan Mishchenko, Niklas Een]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 24, 2012.]

Revision [

Id:
sclUtil.c,v 1.0 2012/08/24 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Converts pNode->pData gates into array of SC_Lit gate IDs and back.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file sclUtil.c.

48 {
49  Abc_Obj_t * pObj;
50  int i, gateId, bufferId;
51  // find buffer
52  if ( Mio_LibraryReadBuf((Mio_Library_t *)p->pManFunc) == NULL )
53  {
54  printf( "Cannot find buffer in the current library. Quitting.\n" );
55  return;
56  }
58  assert( bufferId >= 0 );
59  // remap cells
60  assert( p->vGates == NULL );
62  Abc_NtkForEachNode1( p, pObj, i )
63  {
64  if ( Abc_ObjIsBarBuf(pObj) )
65  gateId = bufferId;
66  else
67  gateId = Abc_SclCellFind( pLib, Mio_GateReadName((Mio_Gate_t *)pObj->pData) );
68  assert( gateId >= 0 );
69  Vec_IntWriteEntry( p->vGates, i, gateId );
70  }
71  p->pSCLib = pLib;
72 }
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition: mioApi.c:47
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
void * pSCLib
Definition: abc.h:206
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
Vec_Int_t * vGates
Definition: abc.h:207
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:79
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
void Abc_SclPrintGateSizes ( SC_Lib pLib,
Abc_Ntk_t p 
)

Definition at line 137 of file sclUtil.c.

138 {
139  Abc_SclMioGates2SclGates( pLib, p );
140  Abc_SclManPrintGateSizes( pLib, p, p->vGates );
141  Abc_SclSclGates2MioGates( pLib, p );
142  Vec_IntFreeP( &p->vGates );
143  p->pSCLib = NULL;
144 }
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
Definition: sclUtil.c:73
void * pSCLib
Definition: abc.h:206
Vec_Int_t * vGates
Definition: abc.h:207
ABC_NAMESPACE_IMPL_START void Abc_SclMioGates2SclGates(SC_Lib *pLib, Abc_Ntk_t *p)
DECLARATIONS ///.
Definition: sclUtil.c:47
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
void Abc_SclManPrintGateSizes(SC_Lib *pLib, Abc_Ntk_t *p, Vec_Int_t *vGates)
Definition: sclUtil.c:109
void Abc_SclReadTimingConstr ( Abc_Frame_t pAbc,
char *  pFileName,
int  fVerbose 
)

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

Synopsis [Reads timing constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file sclUtil.c.

230 {
231  char Buffer[1000], * pToken;
232  FILE * pFile = fopen( pFileName, "rb" );
233  while ( fgets( Buffer, 1000, pFile ) )
234  {
235  pToken = strtok( Buffer, " \t\r\n" );
236  if ( pToken == NULL )
237  continue;
238  if ( !strcmp(pToken, "set_driving_cell") )
239  {
240  Abc_FrameSetDrivingCell( Abc_UtilStrsav(strtok(NULL, " \t\r\n")) );
241  if ( fVerbose )
242  printf( "Setting driving cell to be \"%s\".\n", Abc_FrameReadDrivingCell() );
243  }
244  else if ( !strcmp(pToken, "set_load") )
245  {
246  Abc_FrameSetMaxLoad( atof(strtok(NULL, " \t\r\n")) );
247  if ( fVerbose )
248  printf( "Setting driving cell to be %f.\n", Abc_FrameReadMaxLoad() );
249  }
250  else
251  printf( "Unrecognized token \"%s\".\n", pToken );
252  }
253  fclose( pFile );
254 }
ABC_DLL float Abc_FrameReadMaxLoad()
Definition: mainFrame.c:98
ABC_DLL char * Abc_FrameReadDrivingCell()
Definition: mainFrame.c:97
char * strtok()
int strcmp()
ABC_DLL void Abc_FrameSetMaxLoad(float Load)
Definition: mainFrame.c:100
double atof()
ABC_DLL void Abc_FrameSetDrivingCell(char *pName)
Definition: mainFrame.c:99
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Abc_SclSclGates2MioGates ( SC_Lib pLib,
Abc_Ntk_t p 
)

Definition at line 73 of file sclUtil.c.

74 {
75  Abc_Obj_t * pObj;
76  SC_Cell * pCell;
77  int i, Counter = 0, CounterAll = 0;
78  assert( p->vGates != NULL );
79  Abc_NtkForEachNode1( p, pObj, i )
80  {
81  pCell = Abc_SclObjCell(pObj);
82  assert( pCell->n_inputs == Abc_ObjFaninNum(pObj) );
83  if ( Abc_ObjIsBarBuf(pObj) )
84  pObj->pData = NULL;
85  else
86  pObj->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pManFunc, pCell->pName, NULL );
87  Counter += (pObj->pData == NULL);
88  assert( pObj->fMarkA == 0 && pObj->fMarkB == 0 );
89  CounterAll++;
90  }
91  if ( Counter )
92  printf( "Could not find %d (out of %d) gates in the current library.\n", Counter, CounterAll );
93  Vec_IntFreeP( &p->vGates );
94  p->pSCLib = NULL;
95 }
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition: mioApi.c:99
void * pSCLib
Definition: abc.h:206
unsigned fMarkA
Definition: abc.h:134
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
Vec_Int_t * vGates
Definition: abc.h:207
void * pManFunc
Definition: abc.h:191
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
char * pName
Definition: sclLib.h:183
static int Counter
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
unsigned fMarkB
Definition: abc.h:135
int n_inputs
Definition: sclLib.h:192
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static SC_Cell * Abc_SclObjCell(Abc_Obj_t *p)
Definition: sclSize.h:110