ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mpmGates.c File Reference
#include "mpmInt.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "map/scl/sclSize.h"
#include "map/scl/sclTime.h"
Include dependency graph for mpmGates.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Vec_Wec_tMpm_ManFindDsdMatches (Mpm_Man_t *p, void *pScl)
 DECLARATIONS ///.
 
Vec_Ptr_tMpm_ManFindCells (Mio_Library_t *pMio, SC_Lib *pScl, Vec_Wec_t *vNpnConfigs)
 
Vec_Int_tMpm_ManFindMappedNodes (Mpm_Man_t *p)
 
Abc_Obj_tMpm_ManGetAbcNode (Abc_Ntk_t *pNtk, Vec_Int_t *vCopy, int iMigLit)
 
Abc_Ntk_tMpm_ManDeriveMappedAbcNtk (Mpm_Man_t *p, Mio_Library_t *pMio)
 
Abc_Ntk_tMpm_ManPerformCellMapping (Mig_Man_t *pMig, Mpm_Par_t *pPars, Mio_Library_t *pMio)
 
Abc_Ntk_tMpm_ManCellMapping (Gia_Man_t *pGia, Mpm_Par_t *pPars, void *pMio)
 

Function Documentation

◆ Mpm_ManCellMapping()

Abc_Ntk_t * Mpm_ManCellMapping ( Gia_Man_t * pGia,
Mpm_Par_t * pPars,
void * pMio )

Definition at line 281 of file mpmGates.c.

282{
283 Mig_Man_t * p;
284 Abc_Ntk_t * pNew;
285 assert( pMio != NULL );
286 assert( pPars->pLib->LutMax <= MPM_VAR_MAX );
287 assert( pPars->nNumCuts <= MPM_CUT_MAX );
288 if ( pPars->fUseGates )
289 {
290 pGia = Gia_ManDupMuxes( pGia, 2 );
291 p = Mig_ManCreate( pGia );
292 Gia_ManStop( pGia );
293 }
294 else
295 p = Mig_ManCreate( pGia );
296 pNew = Mpm_ManPerformCellMapping( p, pPars, (Mio_Library_t *)pMio );
297 Mig_ManStop( p );
298 return pNew;
299}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
Cube * p
Definition exorList.c:222
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
Definition giaMuxes.c:98
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mig_Man_t * Mig_ManCreate(void *pGia)
FUNCTION DECLARATIONS ///.
Definition mpmAbc.c:83
Abc_Ntk_t * Mpm_ManPerformCellMapping(Mig_Man_t *pMig, Mpm_Par_t *pPars, Mio_Library_t *pMio)
Definition mpmGates.c:264
#define MPM_CUT_MAX
INCLUDES ///.
Definition mpmInt.h:50
void Mig_ManStop(Mig_Man_t *p)
Definition mpmMig.c:56
struct Mig_Man_t_ Mig_Man_t
Definition mpmMig.h:60
#define MPM_VAR_MAX
INCLUDES ///.
Definition mpm.h:40
int LutMax
Definition mpm.h:50
int fUseGates
Definition mpm.h:63
int nNumCuts
Definition mpm.h:61
Mpm_LibLut_t * pLib
Definition mpm.h:59
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Mpm_ManDeriveMappedAbcNtk()

Abc_Ntk_t * Mpm_ManDeriveMappedAbcNtk ( Mpm_Man_t * p,
Mio_Library_t * pMio )

Definition at line 163 of file mpmGates.c.

164{
165 Abc_Ntk_t * pNtk;
166 Vec_Ptr_t * vNpnGatesMio;
167 Vec_Int_t * vNodes, * vCopy, * vClass;
168 Abc_Obj_t * pObj, * pFanin;
169 Mig_Obj_t * pNode;
170 Mpm_Cut_t * pCutBest;
171 int i, k, iNode, iMigLit, fCompl, Config;
172
173 // find mapping of SCL cells into MIO cells
174 vNpnGatesMio = Mpm_ManFindCells( pMio, (SC_Lib *)p->pPars->pScl, p->vNpnConfigs );
175 if ( vNpnGatesMio == NULL )
176 {
177 printf( "Genlib library does not match SCL library.\n" );
178 return NULL;
179 }
180
181 // create mapping for each phase of each node
182 vCopy = Vec_IntStartFull( 2 * Mig_ManObjNum(p->pMig) );
183
184 // get internal nodes
185 vNodes = Mpm_ManFindMappedNodes( p );
186
187 // start the network
189 pNtk->pName = Extra_UtilStrsav( p->pMig->pName );
190 pNtk->pManFunc = pMio;
191
192 // create primary inputs
193 Mig_ManForEachCi( p->pMig, pNode, i )
194 {
195 pObj = Abc_NtkCreatePi(pNtk);
196 Vec_IntWriteEntry( vCopy, Abc_Var2Lit( Mig_ObjId(pNode), 0 ), Abc_ObjId(pObj) );
197 }
199
200 // create constant nodes
201 Mig_ManForEachCo( p->pMig, pNode, i )
202 if ( Mig_ObjFaninLit(pNode, 0) == 0 )
203 {
204 pObj = Abc_NtkCreateNodeConst0(pNtk);
205 Vec_IntWriteEntry( vCopy, Abc_Var2Lit( 0, 0 ), Abc_ObjId(pObj) );
206 break;
207 }
208 Mig_ManForEachCo( p->pMig, pNode, i )
209 if ( Mig_ObjFaninLit(pNode, 0) == 1 )
210 {
211 pObj = Abc_NtkCreateNodeConst1(pNtk);
212 Vec_IntWriteEntry( vCopy, Abc_Var2Lit( 0, 1 ), Abc_ObjId(pObj) );
213 break;
214 }
215
216 // create internal nodes
217 Vec_IntForEachEntry( vNodes, iNode, i )
218 {
219 pCutBest = Mpm_ObjCutBestP( p, Mig_ManObj(p->pMig, iNode) );
220 vClass = Vec_WecEntry( p->vNpnConfigs, Abc_Lit2Var(pCutBest->iFunc) );
221 Config = Vec_IntEntry( vClass, 0 );
222 pObj = Abc_NtkCreateNode( pNtk );
223 pObj->pData = Vec_PtrEntry( vNpnGatesMio, Abc_Lit2Var(pCutBest->iFunc) );
224 assert( pObj->pData != NULL );
225 fCompl = pCutBest->fCompl ^ Abc_LitIsCompl(pCutBest->iFunc) ^ ((Config >> 16) & 1);
226 Config &= 0xFFFF;
227 for ( k = 0; k < (int)pCutBest->nLeaves; k++ )
228 {
229 assert( (Config >> 6) < 720 );
230 iMigLit = pCutBest->pLeaves[ (int)(p->Perm6[Config >> 6][k]) ];
231 pFanin = Mpm_ManGetAbcNode( pNtk, vCopy, Abc_LitNotCond(iMigLit, (Config >> k) & 1) );
232 Abc_ObjAddFanin( pObj, pFanin );
233 }
234 Vec_IntWriteEntry( vCopy, Abc_Var2Lit(iNode, fCompl), Abc_ObjId(pObj) );
235 }
236
237 // create primary outputs
238 Mig_ManForEachCo( p->pMig, pNode, i )
239 {
240 pObj = Abc_NtkCreatePo(pNtk);
241 pFanin = Mpm_ManGetAbcNode( pNtk, vCopy, Mig_ObjFaninLit(pNode, 0) );
242 Abc_ObjAddFanin( pObj, pFanin );
243 }
245
246 // clean up
247 Vec_PtrFree( vNpnGatesMio );
248 Vec_IntFree( vNodes );
249 Vec_IntFree( vCopy );
250 return pNtk;
251}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
@ ABC_FUNC_MAP
Definition abc.h:68
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
char * Extra_UtilStrsav(const char *s)
Vec_Int_t * Mpm_ManFindMappedNodes(Mpm_Man_t *p)
Definition mpmGates.c:141
Abc_Obj_t * Mpm_ManGetAbcNode(Abc_Ntk_t *pNtk, Vec_Int_t *vCopy, int iMigLit)
Definition mpmGates.c:151
Vec_Ptr_t * Mpm_ManFindCells(Mio_Library_t *pMio, SC_Lib *pScl, Vec_Wec_t *vNpnConfigs)
Definition mpmGates.c:104
struct Mpm_Cut_t_ Mpm_Cut_t
BASIC TYPES ///.
Definition mpmInt.h:61
struct Mig_Obj_t_ Mig_Obj_t
Definition mpmMig.h:54
#define Mig_ManForEachCi(p, pObj, i)
Definition mpmMig.h:327
#define Mig_ManForEachCo(p, pObj, i)
Definition mpmMig.h:329
struct SC_Lib_ SC_Lib
Definition sclLib.h:128
char * pName
Definition abc.h:158
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
unsigned fCompl
Definition mpmInt.h:66
unsigned nLeaves
Definition mpmInt.h:68
int pLeaves[1]
Definition mpmInt.h:69
unsigned iFunc
Definition mpmInt.h:65
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManFindCells()

Vec_Ptr_t * Mpm_ManFindCells ( Mio_Library_t * pMio,
SC_Lib * pScl,
Vec_Wec_t * vNpnConfigs )

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

Synopsis [Find mapping of DSD classes into Genlib library cells.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file mpmGates.c.

105{
106 Vec_Ptr_t * vNpnGatesMio;
107 Vec_Int_t * vClass;
108 Mio_Gate_t * pMioGate;
109 SC_Cell * pCell;
110 int Config, iClass;
111 vNpnGatesMio = Vec_PtrStart( Vec_WecSize(vNpnConfigs) );
112 Vec_WecForEachLevel( vNpnConfigs, vClass, iClass )
113 {
114 if ( Vec_IntSize(vClass) == 0 )
115 continue;
116 Config = Vec_IntEntry(vClass, 0);
117 pCell = SC_LibCell( pScl, (Config >> 17) );
118 pMioGate = Mio_LibraryReadGateByName( pMio, pCell->pName, NULL );
119 if ( pMioGate == NULL )
120 {
121 Vec_PtrFree( vNpnGatesMio );
122 return NULL;
123 }
124 assert( pMioGate != NULL );
125 Vec_PtrWriteEntry( vNpnGatesMio, iClass, pMioGate );
126 }
127 return vNpnGatesMio;
128}
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
struct SC_Cell_ SC_Cell
Definition sclLib.h:127
char * pName
Definition sclLib.h:202
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManFindDsdMatches()

ABC_NAMESPACE_IMPL_START Vec_Wec_t * Mpm_ManFindDsdMatches ( Mpm_Man_t * p,
void * pScl )

DECLARATIONS ///.

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

FileName [mpmGates.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Configurable technology mapper.]

Synopsis [Standard-cell mapping.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 1, 2013.]

Revision [

Id
mpmGates.c,v 1.00 2013/06/01 00:00:00 alanmi Exp

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

Synopsis [Finds matches fore each DSD class.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file mpmGates.c.

50{
51 int fVerbose = p->pPars->fVeryVerbose;
52 SC_Lib * pLib = (SC_Lib *)pScl;
53 Vec_Wec_t * vClasses;
54 Vec_Int_t * vClass;
55 SC_Cell * pRepr;
56 int i, Config, iClass;
57 word Truth;
58 vClasses = Vec_WecStart( 600 );
59 SC_LibForEachCellClass( pLib, pRepr, i )
60 {
61 if ( pRepr->n_inputs > 6 || pRepr->n_outputs > 1 )
62 {
63 if ( fVerbose )
64 printf( "Skipping cell %s with %d inputs and %d outputs\n", pRepr->pName, pRepr->n_inputs, pRepr->n_outputs );
65 continue;
66 }
67 Truth = *Vec_WrdArray( &SC_CellPin(pRepr, pRepr->n_inputs)->vFunc );
68 Config = Mpm_CutCheckDsd6( p, Truth );
69 if ( Config == -1 )
70 {
71 if ( fVerbose )
72 printf( "Skipping cell %s with non-DSD function\n", pRepr->pName );
73 continue;
74 }
75 iClass = Config >> 17;
76 Config = (pRepr->Id << 17) | (Config & 0x1FFFF);
77 // write gate and NPN config for this DSD class
78 vClass = Vec_WecEntry( vClasses, iClass );
79 Vec_IntPush( vClass, Config );
80 if ( !fVerbose )
81 continue;
82
83 printf( "Gate %5d %-30s : ", pRepr->Id, pRepr->pName );
84 printf( "Class %3d ", iClass );
85 printf( "Area %10.3f ", pRepr->area );
86 Extra_PrintBinary( stdout, (unsigned *)&Config, 17 );
87 printf( " " );
88 Kit_DsdPrintFromTruth( (unsigned *)&Truth, pRepr->n_inputs ); printf( "\n" );
89 }
90 return vClasses;
91}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
int Mpm_CutCheckDsd6(Mpm_Man_t *p, word t)
Definition mpmDsd.c:905
#define SC_LibForEachCellClass(p, pCell, i)
Definition sclLib.h:270
float area
Definition sclLib.h:207
int n_outputs
Definition sclLib.h:214
int n_inputs
Definition sclLib.h:213
int Id
Definition sclLib.h:203
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManFindMappedNodes()

Vec_Int_t * Mpm_ManFindMappedNodes ( Mpm_Man_t * p)

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

Synopsis [Derive mapped network as an ABC network.]

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file mpmGates.c.

142{
143 Vec_Int_t * vNodes;
144 Mig_Obj_t * pObj;
145 vNodes = Vec_IntAlloc( 1000 );
146 Mig_ManForEachObj( p->pMig, pObj )
147 if ( Mig_ObjIsNode(pObj) && Mpm_ObjMapRef(p, pObj) )
148 Vec_IntPush( vNodes, Mig_ObjId(pObj) );
149 return vNodes;
150}
#define Mig_ManForEachObj(p, pObj)
MACRO DEFINITIONS ///.
Definition mpmMig.h:304
Here is the caller graph for this function:

◆ Mpm_ManGetAbcNode()

Abc_Obj_t * Mpm_ManGetAbcNode ( Abc_Ntk_t * pNtk,
Vec_Int_t * vCopy,
int iMigLit )

Definition at line 151 of file mpmGates.c.

152{
153 Abc_Obj_t * pObj;
154 int iObjId = Vec_IntEntry( vCopy, iMigLit );
155 if ( iObjId >= 0 )
156 return Abc_NtkObj( pNtk, iObjId );
157 iObjId = Vec_IntEntry( vCopy, Abc_LitNot(iMigLit) );
158 assert( iObjId >= 0 );
159 pObj = Abc_NtkCreateNodeInv( pNtk, Abc_NtkObj(pNtk, iObjId) );
160 Vec_IntWriteEntry( vCopy, iMigLit, Abc_ObjId(pObj) );
161 return pObj;
162}
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:674
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mpm_ManPerformCellMapping()

Abc_Ntk_t * Mpm_ManPerformCellMapping ( Mig_Man_t * pMig,
Mpm_Par_t * pPars,
Mio_Library_t * pMio )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file mpmGates.c.

265{
266 Abc_Ntk_t * pNew;
267 Mpm_Man_t * p;
268 assert( pPars->fMap4Gates );
269 p = Mpm_ManStart( pMig, pPars );
270 if ( p->pPars->fVerbose )
272 p->vNpnConfigs = Mpm_ManFindDsdMatches( p, p->pPars->pScl );
273 Mpm_ManPrepare( p );
274 Mpm_ManPerform( p );
275 if ( p->pPars->fVerbose )
277 pNew = Mpm_ManDeriveMappedAbcNtk( p, pMio );
278 Mpm_ManStop( p );
279 return pNew;
280}
ABC_NAMESPACE_IMPL_START Vec_Wec_t * Mpm_ManFindDsdMatches(Mpm_Man_t *p, void *pScl)
DECLARATIONS ///.
Definition mpmGates.c:49
Abc_Ntk_t * Mpm_ManDeriveMappedAbcNtk(Mpm_Man_t *p, Mio_Library_t *pMio)
Definition mpmGates.c:163
void Mpm_ManPrintStatsInit(Mpm_Man_t *p)
Definition mpmMan.c:166
struct Mpm_Man_t_ Mpm_Man_t
Definition mpmInt.h:94
Mpm_Man_t * Mpm_ManStart(Mig_Man_t *pMig, Mpm_Par_t *pPars)
DECLARATIONS ///.
Definition mpmMan.c:45
void Mpm_ManPrintStats(Mpm_Man_t *p)
Definition mpmMan.c:173
void Mpm_ManPerform(Mpm_Man_t *p)
Definition mpmMap.c:833
void Mpm_ManPrepare(Mpm_Man_t *p)
Definition mpmMap.c:794
void Mpm_ManStop(Mpm_Man_t *p)
Definition mpmMan.c:111
int fMap4Gates
Definition mpm.h:71
Here is the call graph for this function:
Here is the caller graph for this function: