ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sclUtil.c File Reference
#include "sclSize.h"
#include "map/mio/mio.h"
#include "base/main/main.h"
Include dependency graph for sclUtil.c:

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 ///.
 
void Abc_SclSclGates2MioGates (SC_Lib *pLib, Abc_Ntk_t *p)
 
void Abc_SclTransferGates (Abc_Ntk_t *pOld, Abc_Ntk_t *pNew)
 
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

◆ ABC_SCL_MAX_SIZE

#define ABC_SCL_MAX_SIZE   64

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

Synopsis [Reports percentage of gates of each size.]

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file sclUtil.c.

Function Documentation

◆ Abc_SclCountMinSize()

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

Definition at line 222 of file sclUtil.c.

223{
224 Vec_Int_t * vMinCells;
225 Abc_Obj_t * pObj;
226 int i, gateId, Counter = 0;
227 vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
229 {
230 gateId = Vec_IntEntry( p->vGates, i );
231 Counter += ( gateId == Vec_IntEntry(vMinCells, gateId) );
232 }
233 Vec_IntFree( vMinCells );
234 return Counter;
235}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachNodeNotBarBuf1(pNtk, pNode, i)
Definition abc.h:473
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
Vec_Int_t * Abc_SclFindMinAreas(SC_Lib *pLib, int fUseMax)
Definition sclUtil.c:189
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclExtractBarBufs()

Vec_Int_t * Abc_SclExtractBarBufs ( Abc_Ntk_t * pNtk)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file sclUtil.c.

288{
289 Vec_Int_t * vBufs;
290 Mio_Gate_t * pBuffer;
291 Abc_Obj_t * pObj; int i;
292 pBuffer = Mio_LibraryReadBuf( (Mio_Library_t *)pNtk->pManFunc );
293 if ( pBuffer == NULL )
294 {
295 printf( "Cannot find buffer in the current library. Quitting.\n" );
296 return NULL;
297 }
298 vBufs = Vec_IntAlloc( 100 );
299 Abc_NtkForEachBarBuf( pNtk, pObj, i )
300 {
301 assert( pObj->pData == NULL );
302 pObj->pData = pBuffer;
303 Vec_IntPush( vBufs, i );
304 }
305 return vBufs;
306}
#define Abc_NtkForEachBarBuf(pNtk, pNode, i)
Definition abc.h:482
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition mioApi.c:49
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Abc_SclFindMaxAreaCell()

SC_Cell * Abc_SclFindMaxAreaCell ( SC_Cell * pRepr)

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

Synopsis [Downsizes each gate to its minimium size.]

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file sclUtil.c.

177{
178 SC_Cell * pCell, * pBest = pRepr;
179 float AreaBest = pRepr->area;
180 int i;
181 SC_RingForEachCell( pRepr, pCell, i )
182 if ( AreaBest < pCell->area )
183 {
184 AreaBest = pCell->area;
185 pBest = pCell;
186 }
187 return pBest;
188}
#define SC_RingForEachCell(pRing, pCell, i)
Definition sclLib.h:277
struct SC_Cell_ SC_Cell
Definition sclLib.h:127
float area
Definition sclLib.h:207
Here is the caller graph for this function:

◆ Abc_SclFindMinAreas()

Vec_Int_t * Abc_SclFindMinAreas ( SC_Lib * pLib,
int fUseMax )

Definition at line 189 of file sclUtil.c.

190{
191 Vec_Int_t * vMinCells;
192 SC_Cell * pCell, * pRepr = NULL, * pBest = NULL;
193 int i, k;
194 // map each gate in the library into its min/max-size prototype
195 vMinCells = Vec_IntStartFull( Vec_PtrSize(&pLib->vCells) );
196 SC_LibForEachCellClass( pLib, pRepr, i )
197 {
198 pBest = fUseMax ? Abc_SclFindMaxAreaCell(pRepr) : pRepr;
199 SC_RingForEachCell( pRepr, pCell, k )
200 Vec_IntWriteEntry( vMinCells, pCell->Id, pBest->Id );
201 }
202 return vMinCells;
203}
#define SC_LibForEachCellClass(p, pCell, i)
Definition sclLib.h:270
SC_Cell * Abc_SclFindMaxAreaCell(SC_Cell *pRepr)
Definition sclUtil.c:176
int Id
Definition sclLib.h:203
Vec_Ptr_t vCells
Definition sclLib.h:236
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclInsertBarBufs()

void Abc_SclInsertBarBufs ( Abc_Ntk_t * pNtk,
Vec_Int_t * vBufs )

Definition at line 307 of file sclUtil.c.

308{
309 Abc_Obj_t * pObj; int i;
310 Abc_NtkForEachObjVec( vBufs, pNtk, pObj, i )
311 pObj->pData = NULL;
312}
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition abc.h:455

◆ Abc_SclManPrintGateSizes()

void Abc_SclManPrintGateSizes ( SC_Lib * pLib,
Abc_Ntk_t * p,
Vec_Int_t * vGates )

Definition at line 128 of file sclUtil.c.

129{
130 Abc_Obj_t * pObj;
131 SC_Cell * pCell;
132 int i, nGates = 0, Counters[ABC_SCL_MAX_SIZE] = {0};
133 double TotArea = 0, Areas[ABC_SCL_MAX_SIZE] = {0};
135 {
136 pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
137 assert( pCell->Order < ABC_SCL_MAX_SIZE );
138 Counters[pCell->Order]++;
139 Areas[pCell->Order] += pCell->area;
140 TotArea += pCell->area;
141 nGates++;
142 }
143 printf( "Total gates = %d. Total area = %.1f\n", nGates, TotArea );
144 for ( i = 0; i < ABC_SCL_MAX_SIZE; i++ )
145 {
146 if ( Counters[i] == 0 )
147 continue;
148 printf( "Cell size = %d. ", i );
149 printf( "Count = %6d ", Counters[i] );
150 printf( "(%5.1f %%) ", 100.0 * Counters[i] / nGates );
151 printf( "Area = %12.1f ", Areas[i] );
152 printf( "(%5.1f %%) ", 100.0 * Areas[i] / TotArea );
153 printf( "\n" );
154 }
155}
#define ABC_SCL_MAX_SIZE
Definition sclUtil.c:127
int Order
Definition sclLib.h:219
Here is the caller graph for this function:

◆ Abc_SclMinsizePerform()

void Abc_SclMinsizePerform ( SC_Lib * pLib,
Abc_Ntk_t * p,
int fUseMax,
int fVerbose )

Definition at line 204 of file sclUtil.c.

205{
206 Vec_Int_t * vMinCells;
207 Abc_Obj_t * pObj;
208 int i, gateId;
209 vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
212 {
213 gateId = Vec_IntEntry( p->vGates, i );
214 assert( gateId >= 0 && gateId < Vec_PtrSize(&pLib->vCells) );
215 gateId = Vec_IntEntry( vMinCells, gateId );
216 assert( gateId >= 0 && gateId < Vec_PtrSize(&pLib->vCells) );
217 Vec_IntWriteEntry( p->vGates, i, gateId );
218 }
220 Vec_IntFree( vMinCells );
221}
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
Definition sclUtil.c:70
ABC_NAMESPACE_IMPL_START void Abc_SclMioGates2SclGates(SC_Lib *pLib, Abc_Ntk_t *p)
DECLARATIONS ///.
Definition sclUtil.c:47
Here is the call graph for this function:

◆ Abc_SclMioGates2SclGates()

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 }
57 bufferId = Abc_SclCellFind( pLib, Mio_GateReadName(Mio_LibraryReadBuf((Mio_Library_t *)p->pManFunc)) );
58 assert( bufferId >= 0 );
59 // remap cells
60 assert( p->vGates == NULL );
61 p->vGates = Vec_IntStartFull( Abc_NtkObjNumMax(p) );
63 {
64 gateId = Abc_SclCellFind( pLib, Mio_GateReadName((Mio_Gate_t *)pObj->pData) );
65 assert( gateId >= 0 );
66 Vec_IntWriteEntry( p->vGates, i, gateId );
67 }
68 p->pSCLib = pLib;
69}
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition sclLibUtil.c:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclPrintGateSizes()

void Abc_SclPrintGateSizes ( SC_Lib * pLib,
Abc_Ntk_t * p )

Definition at line 156 of file sclUtil.c.

157{
159 Abc_SclManPrintGateSizes( pLib, p, p->vGates );
161 Vec_IntFreeP( &p->vGates );
162 p->pSCLib = NULL;
163}
void Abc_SclManPrintGateSizes(SC_Lib *pLib, Abc_Ntk_t *p, Vec_Int_t *vGates)
Definition sclUtil.c:128
Here is the call graph for this function:

◆ Abc_SclReadTimingConstr()

void Abc_SclReadTimingConstr ( Abc_Frame_t * pAbc,
char * pFileName,
int fVerbose )

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

Synopsis [Reads timing constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file sclUtil.c.

249{
250 char Buffer[1000], * pToken;
251 FILE * pFile = fopen( pFileName, "rb" );
252 while ( fgets( Buffer, 1000, pFile ) )
253 {
254 pToken = strtok( Buffer, " \t\r\n" );
255 if ( pToken == NULL )
256 continue;
257 if ( !strcmp(pToken, "set_driving_cell") )
258// if ( !strcmp(pToken, "default_input_cell") )
259 {
260 Abc_FrameSetDrivingCell( Abc_UtilStrsav(strtok(NULL, " \t\r\n")) );
261 if ( fVerbose )
262 printf( "Setting driving cell to be \"%s\".\n", Abc_FrameReadDrivingCell() );
263 }
264 else if ( !strcmp(pToken, "set_load") )
265// else if ( !strcmp(pToken, "default_output_load") )
266 {
267 Abc_FrameSetMaxLoad( atof(strtok(NULL, " \t\r\n")) );
268 if ( fVerbose )
269 printf( "Setting output load to be %f.\n", Abc_FrameReadMaxLoad() );
270 }
271 else printf( "Unrecognized token \"%s\".\n", pToken );
272 }
273 fclose( pFile );
274}
ABC_DLL float Abc_FrameReadMaxLoad()
Definition mainFrame.c:117
ABC_DLL char * Abc_FrameReadDrivingCell()
Definition mainFrame.c:116
ABC_DLL void Abc_FrameSetDrivingCell(char *pName)
Definition mainFrame.c:118
ABC_DLL void Abc_FrameSetMaxLoad(float Load)
Definition mainFrame.c:119
int strcmp()
char * strtok()
double atof()
Here is the call graph for this function:

◆ Abc_SclSclGates2MioGates()

void Abc_SclSclGates2MioGates ( SC_Lib * pLib,
Abc_Ntk_t * p )

Definition at line 70 of file sclUtil.c.

71{
72 Abc_Obj_t * pObj;
73 SC_Cell * pCell;
74 int i, Counter = 0, CounterAll = 0;
75 assert( p->vGates != NULL );
77 {
78 pCell = Abc_SclObjCell(pObj);
79 assert( pCell->n_inputs == Abc_ObjFaninNum(pObj) );
80 pObj->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pManFunc, pCell->pName, NULL );
81 Counter += (pObj->pData == NULL);
82 assert( pObj->fMarkA == 0 && pObj->fMarkB == 0 );
83 CounterAll++;
84 }
85 if ( Counter )
86 printf( "Could not find %d (out of %d) gates in the current library.\n", Counter, CounterAll );
87 Vec_IntFreeP( &p->vGates );
88 p->pSCLib = NULL;
89}
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
unsigned fMarkB
Definition abc.h:135
unsigned fMarkA
Definition abc.h:134
char * pName
Definition sclLib.h:202
int n_inputs
Definition sclLib.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclTransferGates()

void Abc_SclTransferGates ( Abc_Ntk_t * pOld,
Abc_Ntk_t * pNew )

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

Synopsis [Transfer gate sizes from AIG without barbufs.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file sclUtil.c.

103{
104 Abc_Obj_t * pObj; int i;
105 assert( pOld->nBarBufs2 > 0 );
106 assert( pNew->nBarBufs2 == 0 );
107 Abc_NtkForEachNodeNotBarBuf( pOld, pObj, i )
108 {
109 if ( pObj->pCopy == NULL )
110 continue;
111 assert( Abc_ObjNtk(pObj->pCopy) == pNew );
112 pObj->pData = pObj->pCopy->pData;
113 }
114}
#define Abc_NtkForEachNodeNotBarBuf(pNtk, pNode, i)
Definition abc.h:467
int nBarBufs2
Definition abc.h:175
Abc_Obj_t * pCopy
Definition abc.h:148
Here is the caller graph for this function: