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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
Map_Man_t
Abc_NtkToMap (Abc_Ntk_t *pNtk, double DelayTarget, int fRecovery, float *pSwitching, int fVerbose)
 DECLARATIONS ///. More...
 
static Abc_Ntk_tAbc_NtkFromMap (Map_Man_t *pMan, Abc_Ntk_t *pNtk)
 
static Abc_Obj_tAbc_NodeFromMap_rec (Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, int fPhase)
 
static Abc_Obj_tAbc_NodeFromMapPhase_rec (Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, int fPhase)
 
static Abc_Ntk_tAbc_NtkFromMapSuperChoice (Map_Man_t *pMan, Abc_Ntk_t *pNtk)
 
static void Abc_NodeSuperChoice (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
 
static void Abc_NodeFromMapCutPhase (Abc_Ntk_t *pNtkNew, Map_Cut_t *pCut, int fPhase)
 
static Abc_Obj_tAbc_NodeFromMapSuperChoice_rec (Abc_Ntk_t *pNtkNew, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
 
Abc_Ntk_tAbc_NtkMap (Abc_Ntk_t *pNtk, double DelayTarget, double AreaMulti, double DelayMulti, float LogFan, float Slew, float Gain, int nGatesMin, int fRecovery, int fSwitching, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 
Map_Time_tAbc_NtkMapCopyCiArrival (Abc_Ntk_t *pNtk, Abc_Time_t *ppTimes)
 
Map_Time_tAbc_NtkMapCopyCoRequired (Abc_Ntk_t *pNtk, Abc_Time_t *ppTimes)
 
Abc_Obj_tAbc_NodeFromMapSuper_rec (Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
 
Abc_Ntk_tAbc_NtkSuperChoice (Abc_Ntk_t *pNtk)
 
Abc_Obj_tAbc_NtkFetchTwinNode (Abc_Obj_t *pNode)
 
Vec_Int_tAbc_NtkWriteMiniMapping (Abc_Ntk_t *pNtk)
 
void Abc_NtkPrintMiniMapping (int *pArray)
 
int * Abc_NtkOutputMiniMapping (void *pAbc0)
 
void Abc_NtkTestMiniMapping (Abc_Ntk_t *p)
 
void Abc_NtkSetCiArrivalTime (void *pAbc0, int iCi, float Rise, float Fall)
 
void Abc_NtkSetCoRequiredTime (void *pAbc0, int iCo, float Rise, float Fall)
 

Function Documentation

Abc_Obj_t * Abc_NodeFromMap_rec ( Abc_Ntk_t pNtkNew,
Map_Node_t pNodeMap,
int  fPhase 
)
static

Definition at line 385 of file abcMap.c.

386 {
387  Abc_Obj_t * pNodeNew, * pNodeInv;
388 
389  // check the case of constant node
390  if ( Map_NodeIsConst(pNodeMap) )
391  {
392  pNodeNew = fPhase? Abc_NtkCreateNodeConst1(pNtkNew) : Abc_NtkCreateNodeConst0(pNtkNew);
393  if ( pNodeNew->pData == NULL )
394  printf( "Error creating mapped network: Library does not have a constant %d gate.\n", fPhase );
395  return pNodeNew;
396  }
397 
398  // check if the phase is already implemented
399  pNodeNew = (Abc_Obj_t *)Map_NodeReadData( pNodeMap, fPhase );
400  if ( pNodeNew )
401  return pNodeNew;
402 
403  // implement the node if the best cut is assigned
404  if ( Map_NodeReadCutBest(pNodeMap, fPhase) != NULL )
405  return Abc_NodeFromMapPhase_rec( pNtkNew, pNodeMap, fPhase );
406 
407  // if the cut is not assigned, implement the node
408  assert( Map_NodeReadCutBest(pNodeMap, !fPhase) != NULL || Map_NodeIsConst(pNodeMap) );
409  pNodeNew = Abc_NodeFromMapPhase_rec( pNtkNew, pNodeMap, !fPhase );
410 
411  // add the inverter
412  pNodeInv = Abc_NtkCreateNode( pNtkNew );
413  Abc_ObjAddFanin( pNodeInv, pNodeNew );
415 
416  // set the inverter
417  Map_NodeSetData( pNodeMap, fPhase, (char *)pNodeInv );
418  return pNodeInv;
419 }
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
void Map_NodeSetData(Map_Node_t *p, int fPhase, char *pData)
Definition: mapperCreate.c:96
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
int Map_NodeIsConst(Map_Node_t *p)
Definition: mapperCreate.c:112
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
char * Map_NodeReadData(Map_Node_t *p, int fPhase)
Definition: mapperCreate.c:89
static Abc_Obj_t * Abc_NodeFromMapPhase_rec(Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, int fPhase)
Definition: abcMap.c:348
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
Map_Cut_t * Map_NodeReadCutBest(Map_Node_t *p, int fPhase)
Definition: mapperCreate.c:93
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition: mioApi.c:48
void Abc_NodeFromMapCutPhase ( Abc_Ntk_t pNtkNew,
Map_Cut_t pCut,
int  fPhase 
)
static

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

Synopsis [Constructs the nodes corrresponding to one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file abcMap.c.

644 {
645  Abc_Obj_t * pNodePIs[10];
646  Map_Node_t ** ppLeaves;
647  Map_Super_t * pSuperBest;
648  unsigned uPhaseBest;
649  int i, fInvPin, nLeaves;
650 
651  pSuperBest = Map_CutReadSuperBest( pCut, fPhase );
652  if ( pSuperBest == NULL )
653  return;
654 
655  // get the information about the best cut
656  uPhaseBest = Map_CutReadPhaseBest( pCut, fPhase );
657  nLeaves = Map_CutReadLeavesNum( pCut );
658  ppLeaves = Map_CutReadLeaves( pCut );
659 
660  // collect the PI nodes
661  for ( i = 0; i < nLeaves; i++ )
662  {
663  fInvPin = ((uPhaseBest & (1 << i)) > 0);
664  pNodePIs[i] = (Abc_Obj_t *)Map_NodeReadData( ppLeaves[i], !fInvPin );
665  assert( pNodePIs[i] != NULL );
666  }
667 
668  // implement the supergate
669  Abc_NodeFromMapSuperChoice_rec( pNtkNew, pSuperBest, pNodePIs, nLeaves );
670 }
static Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec(Abc_Ntk_t *pNtkNew, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
Definition: abcMap.c:684
Map_Super_t * Map_CutReadSuperBest(Map_Cut_t *p, int fPhase)
Definition: mapperCreate.c:129
int Map_CutReadLeavesNum(Map_Cut_t *p)
Definition: mapperCreate.c:132
Map_Node_t ** Map_CutReadLeaves(Map_Cut_t *p)
Definition: mapperCreate.c:133
char * Map_NodeReadData(Map_Node_t *p, int fPhase)
Definition: mapperCreate.c:89
#define assert(ex)
Definition: util_old.h:213
unsigned Map_CutReadPhaseBest(Map_Cut_t *p, int fPhase)
Definition: mapperCreate.c:134
Abc_Obj_t * Abc_NodeFromMapPhase_rec ( Abc_Ntk_t pNtkNew,
Map_Node_t pNodeMap,
int  fPhase 
)
static

Definition at line 348 of file abcMap.c.

349 {
350  Abc_Obj_t * pNodePIs[10];
351  Abc_Obj_t * pNodeNew;
352  Map_Node_t ** ppLeaves;
353  Map_Cut_t * pCutBest;
354  Map_Super_t * pSuperBest;
355  unsigned uPhaseBest;
356  int i, fInvPin, nLeaves;
357 
358  // make sure the node can be implemented in this phase
359  assert( Map_NodeReadCutBest(pNodeMap, fPhase) != NULL || Map_NodeIsConst(pNodeMap) );
360  // check if the phase is already implemented
361  pNodeNew = (Abc_Obj_t *)Map_NodeReadData( pNodeMap, fPhase );
362  if ( pNodeNew )
363  return pNodeNew;
364 
365  // get the information about the best cut
366  pCutBest = Map_NodeReadCutBest( pNodeMap, fPhase );
367  pSuperBest = Map_CutReadSuperBest( pCutBest, fPhase );
368  uPhaseBest = Map_CutReadPhaseBest( pCutBest, fPhase );
369  nLeaves = Map_CutReadLeavesNum( pCutBest );
370  ppLeaves = Map_CutReadLeaves( pCutBest );
371 
372  // collect the PI nodes
373  for ( i = 0; i < nLeaves; i++ )
374  {
375  fInvPin = ((uPhaseBest & (1 << i)) > 0);
376  pNodePIs[i] = Abc_NodeFromMap_rec( pNtkNew, ppLeaves[i], !fInvPin );
377  assert( pNodePIs[i] != NULL );
378  }
379 
380  // implement the supergate
381  pNodeNew = Abc_NodeFromMapSuper_rec( pNtkNew, pNodeMap, pSuperBest, pNodePIs, nLeaves );
382  Map_NodeSetData( pNodeMap, fPhase, (char *)pNodeNew );
383  return pNodeNew;
384 }
void Map_NodeSetData(Map_Node_t *p, int fPhase, char *pData)
Definition: mapperCreate.c:96
Abc_Obj_t * Abc_NodeFromMapSuper_rec(Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
Definition: abcMap.c:304
int Map_NodeIsConst(Map_Node_t *p)
Definition: mapperCreate.c:112
Map_Super_t * Map_CutReadSuperBest(Map_Cut_t *p, int fPhase)
Definition: mapperCreate.c:129
int Map_CutReadLeavesNum(Map_Cut_t *p)
Definition: mapperCreate.c:132
Map_Node_t ** Map_CutReadLeaves(Map_Cut_t *p)
Definition: mapperCreate.c:133
char * Map_NodeReadData(Map_Node_t *p, int fPhase)
Definition: mapperCreate.c:89
#define assert(ex)
Definition: util_old.h:213
unsigned Map_CutReadPhaseBest(Map_Cut_t *p, int fPhase)
Definition: mapperCreate.c:134
Map_Cut_t * Map_NodeReadCutBest(Map_Node_t *p, int fPhase)
Definition: mapperCreate.c:93
static Abc_Obj_t * Abc_NodeFromMap_rec(Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, int fPhase)
Definition: abcMap.c:385
Abc_Obj_t* Abc_NodeFromMapSuper_rec ( Abc_Ntk_t pNtkNew,
Map_Node_t pNodeMap,
Map_Super_t pSuper,
Abc_Obj_t pNodePis[],
int  nNodePis 
)

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

Synopsis [Creates the mapped network.]

Description []

SideEffects []

SeeAlso []

Definition at line 304 of file abcMap.c.

305 {
307  Mio_Gate_t * pRoot;
308  Map_Super_t ** ppFanins;
309  Abc_Obj_t * pNodeNew, * pNodeFanin;
310  int nFanins, Number, i;
311 
312  // get the parameters of the supergate
313  pRoot = Map_SuperReadRoot(pSuper);
314  if ( pRoot == NULL )
315  {
316  Number = Map_SuperReadNum(pSuper);
317  if ( Number < nNodePis )
318  {
319  return pNodePis[Number];
320  }
321  else
322  {
323 // assert( 0 );
324  /* It might happen that a super gate with 5 inputs is constructed that
325  * actually depends only on the first four variables; i.e the fifth is a
326  * don't care -- in that case we connect constant node for the fifth
327  * (since the cut only has 4 variables). An interesting question is what
328  * if the first variable (and not the fifth one is the redundant one;
329  * can that happen?) */
330  return Abc_NtkCreateNodeConst0(pNtkNew);
331  }
332  }
333  pRoot = Mio_LibraryReadGateByName( pLib, Mio_GateReadName(pRoot), NULL );
334 
335  // get information about the fanins of the supergate
336  nFanins = Map_SuperReadFaninNum( pSuper );
337  ppFanins = Map_SuperReadFanins( pSuper );
338  // create a new node with these fanins
339  pNodeNew = Abc_NtkCreateNode( pNtkNew );
340  for ( i = 0; i < nFanins; i++ )
341  {
342  pNodeFanin = Abc_NodeFromMapSuper_rec( pNtkNew, pNodeMap, ppFanins[i], pNodePis, nNodePis );
343  Abc_ObjAddFanin( pNodeNew, pNodeFanin );
344  }
345  pNodeNew->pData = pRoot;
346  return pNodeNew;
347 }
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition: mioApi.c:99
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
Map_Super_t ** Map_SuperReadFanins(Map_Super_t *p)
Definition: mapperCreate.c:153
Abc_Obj_t * Abc_NodeFromMapSuper_rec(Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
Definition: abcMap.c:304
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
int Map_SuperReadFaninNum(Map_Super_t *p)
Definition: mapperCreate.c:154
Mio_Gate_t * Map_SuperReadRoot(Map_Super_t *p)
Definition: mapperCreate.c:151
int Map_SuperReadNum(Map_Super_t *p)
Definition: mapperCreate.c:152
void * pData
Definition: abc.h:145
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec ( Abc_Ntk_t pNtkNew,
Map_Super_t pSuper,
Abc_Obj_t pNodePis[],
int  nNodePis 
)
static

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

Synopsis [Constructs the nodes corrresponding to one supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 684 of file abcMap.c.

685 {
687  Mio_Gate_t * pRoot;
688  Map_Super_t ** ppFanins;
689  Abc_Obj_t * pNodeNew, * pNodeFanin;
690  int nFanins, Number, i;
691 
692  // get the parameters of the supergate
693  pRoot = Map_SuperReadRoot(pSuper);
694  if ( pRoot == NULL )
695  {
696  Number = Map_SuperReadNum(pSuper);
697  if ( Number < nNodePis )
698  {
699  return pNodePis[Number];
700  }
701  else
702  {
703 // assert( 0 );
704  /* It might happen that a super gate with 5 inputs is constructed that
705  * actually depends only on the first four variables; i.e the fifth is a
706  * don't care -- in that case we connect constant node for the fifth
707  * (since the cut only has 4 variables). An interesting question is what
708  * if the first variable (and not the fifth one is the redundant one;
709  * can that happen?) */
710  return Abc_NtkCreateNodeConst0(pNtkNew);
711  }
712  }
713  pRoot = Mio_LibraryReadGateByName( pLib, Mio_GateReadName(pRoot), NULL );
714 
715  // get information about the fanins of the supergate
716  nFanins = Map_SuperReadFaninNum( pSuper );
717  ppFanins = Map_SuperReadFanins( pSuper );
718  // create a new node with these fanins
719  pNodeNew = Abc_NtkCreateNode( pNtkNew );
720  for ( i = 0; i < nFanins; i++ )
721  {
722  pNodeFanin = Abc_NodeFromMapSuperChoice_rec( pNtkNew, ppFanins[i], pNodePis, nNodePis );
723  Abc_ObjAddFanin( pNodeNew, pNodeFanin );
724  }
725  pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Mio_GateReadSop(pRoot) );
726  return pNodeNew;
727 }
static Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec(Abc_Ntk_t *pNtkNew, Map_Super_t *pSuper, Abc_Obj_t *pNodePis[], int nNodePis)
Definition: abcMap.c:684
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition: mioApi.c:99
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
Map_Super_t ** Map_SuperReadFanins(Map_Super_t *p)
Definition: mapperCreate.c:153
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition: abcObj.c:604
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
int Map_SuperReadFaninNum(Map_Super_t *p)
Definition: mapperCreate.c:154
Mio_Gate_t * Map_SuperReadRoot(Map_Super_t *p)
Definition: mapperCreate.c:151
int Map_SuperReadNum(Map_Super_t *p)
Definition: mapperCreate.c:152
void * pData
Definition: abc.h:145
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition: mioApi.c:153
void Abc_NodeSuperChoice ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNode 
)
static

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

Synopsis [Creates the mapped network.]

Description []

SideEffects []

SeeAlso []

Definition at line 618 of file abcMap.c.

619 {
620  Map_Node_t * pMapNode = (Map_Node_t *)pNode->pNext;
621  Map_Cut_t * pCuts, * pTemp;
622 
623  pCuts = Map_NodeReadCuts(pMapNode);
624  for ( pTemp = Map_CutReadNext(pCuts); pTemp; pTemp = Map_CutReadNext(pTemp) )
625  {
626  Abc_NodeFromMapCutPhase( pNtkNew, pTemp, 0 );
627  Abc_NodeFromMapCutPhase( pNtkNew, pTemp, 1 );
628  }
629 }
Map_Cut_t * Map_NodeReadCuts(Map_Node_t *p)
Definition: mapperCreate.c:92
Map_Cut_t * Map_CutReadNext(Map_Cut_t *p)
Definition: mapperCreate.c:137
static void Abc_NodeFromMapCutPhase(Abc_Ntk_t *pNtkNew, Map_Cut_t *pCut, int fPhase)
Definition: abcMap.c:643
Abc_Obj_t * pNext
Definition: abc.h:131
Abc_Obj_t* Abc_NtkFetchTwinNode ( Abc_Obj_t pNode)

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

Synopsis [Returns the twin node if it exists.]

Description []

SideEffects []

SeeAlso []

Definition at line 740 of file abcMap.c.

741 {
742  Abc_Obj_t * pNode2;
743  Mio_Gate_t * pGate = (Mio_Gate_t *)pNode->pData;
744  assert( Abc_NtkHasMapping(pNode->pNtk) );
745  if ( pGate == NULL || Mio_GateReadTwin(pGate) == NULL )
746  return NULL;
747  // assuming the twin node is following next
748  if ( (int)Abc_ObjId(pNode) == Abc_NtkObjNumMax(pNode->pNtk) - 1 )
749  return NULL;
750  pNode2 = Abc_NtkObj( pNode->pNtk, Abc_ObjId(pNode) + 1 );
751  if ( pNode2 == NULL || !Abc_ObjIsNode(pNode2) || Abc_ObjFaninNum(pNode) != Abc_ObjFaninNum(pNode2) )
752  return NULL;
753  if ( Mio_GateReadTwin(pGate) != (Mio_Gate_t *)pNode2->pData )
754  return NULL;
755  return pNode2;
756 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Mio_Gate_t * Mio_GateReadTwin(Mio_Gate_t *pGate)
Definition: mioApi.c:150
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
Abc_Ntk_t * Abc_NtkFromMap ( Map_Man_t pMan,
Abc_Ntk_t pNtk 
)
static

Definition at line 420 of file abcMap.c.

421 {
422  Abc_Ntk_t * pNtkNew;
423  Map_Node_t * pNodeMap;
424  Abc_Obj_t * pNode, * pNodeNew;
425  int i, nDupGates;
426  assert( Map_ManReadBufNum(pMan) == pNtk->nBarBufs );
427  // create the new network
428  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_MAP );
429  // make the mapper point to the new network
430  Map_ManCleanData( pMan );
431  Abc_NtkForEachCi( pNtk, pNode, i )
432  {
433  if ( i >= Abc_NtkCiNum(pNtk) - pNtk->nBarBufs )
434  break;
435  Map_NodeSetData( Map_ManReadInputs(pMan)[i], 1, (char *)pNode->pCopy );
436  }
437  Abc_NtkForEachCi( pNtk, pNode, i )
438  {
439  if ( i < Abc_NtkCiNum(pNtk) - pNtk->nBarBufs )
440  continue;
441  Map_NodeSetData( Map_ManReadBufs(pMan)[i - (Abc_NtkCiNum(pNtk) - pNtk->nBarBufs)], 1, (char *)pNode->pCopy );
442  }
443  // assign the mapping of the required phase to the POs
444  Abc_NtkForEachCo( pNtk, pNode, i )
445  {
446  if ( i < Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
447  continue;
448  pNodeMap = Map_ManReadBufDriver( pMan, i - (Abc_NtkCoNum(pNtk) - pNtk->nBarBufs) );
449  pNodeNew = Abc_NodeFromMap_rec( pNtkNew, Map_Regular(pNodeMap), !Map_IsComplement(pNodeMap) );
450  assert( !Abc_ObjIsComplement(pNodeNew) );
451  Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
452  }
453  Abc_NtkForEachCo( pNtk, pNode, i )
454  {
455  if ( i >= Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
456  break;
457  pNodeMap = Map_ManReadOutputs(pMan)[i];
458  pNodeNew = Abc_NodeFromMap_rec( pNtkNew, Map_Regular(pNodeMap), !Map_IsComplement(pNodeMap) );
459  assert( !Abc_ObjIsComplement(pNodeNew) );
460  Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
461  }
462  // decouple the PO driver nodes to reduce the number of levels
463  nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
464 // if ( nDupGates && Map_ManReadVerbose(pMan) )
465 // printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates );
466  return pNtkNew;
467 }
Map_Node_t ** Map_ManReadBufs(Map_Man_t *p)
Definition: mapperCreate.c:54
void Map_NodeSetData(Map_Node_t *p, int fPhase, char *pData)
Definition: mapperCreate.c:96
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
Map_Node_t ** Map_ManReadInputs(Map_Man_t *p)
Definition: mapperCreate.c:52
int Map_ManReadBufNum(Map_Man_t *p)
Definition: mapperCreate.c:51
#define Map_Regular(p)
Definition: mapper.h:68
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Map_Node_t ** Map_ManReadOutputs(Map_Man_t *p)
Definition: mapperCreate.c:53
int nBarBufs
Definition: abc.h:174
#define assert(ex)
Definition: util_old.h:213
Map_Node_t * Map_ManReadBufDriver(Map_Man_t *p, int i)
Definition: mapperCreate.c:55
void Map_ManCleanData(Map_Man_t *p)
Definition: mapperUtils.c:652
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static Abc_Obj_t * Abc_NodeFromMap_rec(Abc_Ntk_t *pNtkNew, Map_Node_t *pNodeMap, int fPhase)
Definition: abcMap.c:385
Abc_Ntk_t * Abc_NtkFromMapSuperChoice ( Map_Man_t pMan,
Abc_Ntk_t pNtk 
)
static

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

Synopsis [Creates the mapped network.]

Description []

SideEffects []

SeeAlso []

Definition at line 545 of file abcMap.c.

546 {
547  extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
548  ProgressBar * pProgress;
549  Abc_Ntk_t * pNtkNew, * pNtkNew2;
550  Abc_Obj_t * pNode;
551  int i;
552 
553  // save the pointer to the mapped nodes
554  Abc_NtkForEachCi( pNtk, pNode, i )
555  pNode->pNext = pNode->pCopy;
556  Abc_NtkForEachPo( pNtk, pNode, i )
557  pNode->pNext = pNode->pCopy;
558  Abc_NtkForEachNode( pNtk, pNode, i )
559  pNode->pNext = pNode->pCopy;
560 
561  // duplicate the network
562  pNtkNew2 = Abc_NtkDup( pNtk );
563  pNtkNew = Abc_NtkMulti( pNtkNew2, 0, 20, 0, 0, 1, 0 );
564  if ( !Abc_NtkBddToSop( pNtkNew, 0 ) )
565  {
566  printf( "Abc_NtkFromMapSuperChoice(): Converting to SOPs has failed.\n" );
567  return NULL;
568  }
569 
570  // set the old network to point to the new network
571  Abc_NtkForEachCi( pNtk, pNode, i )
572  pNode->pCopy = pNode->pCopy->pCopy;
573  Abc_NtkForEachPo( pNtk, pNode, i )
574  pNode->pCopy = pNode->pCopy->pCopy;
575  Abc_NtkForEachNode( pNtk, pNode, i )
576  pNode->pCopy = pNode->pCopy->pCopy;
577  Abc_NtkDelete( pNtkNew2 );
578 
579  // set the pointers from the mapper to the new nodes
580  Abc_NtkForEachCi( pNtk, pNode, i )
581  {
582  Map_NodeSetData( Map_ManReadInputs(pMan)[i], 0, (char *)Abc_NtkCreateNodeInv(pNtkNew,pNode->pCopy) );
583  Map_NodeSetData( Map_ManReadInputs(pMan)[i], 1, (char *)pNode->pCopy );
584  }
585  Abc_NtkForEachNode( pNtk, pNode, i )
586  {
587 // if ( Abc_NodeIsConst(pNode) )
588 // continue;
589  Map_NodeSetData( (Map_Node_t *)pNode->pNext, 0, (char *)Abc_NtkCreateNodeInv(pNtkNew,pNode->pCopy) );
590  Map_NodeSetData( (Map_Node_t *)pNode->pNext, 1, (char *)pNode->pCopy );
591  }
592 
593  // assign the mapping of the required phase to the POs
594  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
595  Abc_NtkForEachNode( pNtk, pNode, i )
596  {
597  Extra_ProgressBarUpdate( pProgress, i, NULL );
598 // if ( Abc_NodeIsConst(pNode) )
599 // continue;
600  Abc_NodeSuperChoice( pNtkNew, pNode );
601  }
602  Extra_ProgressBarStop( pProgress );
603  return pNtkNew;
604 }
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
Abc_Ntk_t * Abc_NtkMulti(Abc_Ntk_t *pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor)
FUNCTION DEFINITIONS ///.
Definition: abcMulti.c:59
static void Abc_NodeSuperChoice(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
Definition: abcMap.c:618
void Map_NodeSetData(Map_Node_t *p, int fPhase, char *pData)
Definition: mapperCreate.c:96
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
DECLARATIONS ///.
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
Map_Node_t ** Map_ManReadInputs(Map_Man_t *p)
Definition: mapperCreate.c:52
if(last==0)
Definition: sparse_int.h:34
void Extra_ProgressBarStop(ProgressBar *p)
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
Abc_Ntk_t * pCopy
Definition: abc.h:204
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
Abc_Ntk_t* Abc_NtkMap ( Abc_Ntk_t pNtk,
double  DelayTarget,
double  AreaMulti,
double  DelayMulti,
float  LogFan,
float  Slew,
float  Gain,
int  nGatesMin,
int  fRecovery,
int  fSwitching,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Interface with the mapping package.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file abcMap.c.

60 {
61  static int fUseMulti = 0;
62  int fShowSwitching = 1;
63  Abc_Ntk_t * pNtkNew;
64  Map_Man_t * pMan;
65  Vec_Int_t * vSwitching = NULL;
66  float * pSwitching = NULL;
67  abctime clk, clkTotal = Abc_Clock();
69 
70  assert( Abc_NtkIsStrash(pNtk) );
71  // derive library from SCL
72  // if the library is created here, it will be deleted when pSuperLib is deleted in Map_SuperLibFree()
74  {
75  pLib = Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin, fVerbose );
76  if ( Abc_FrameReadLibGen() )
78  // remove supergate library
80  Abc_FrameSetLibSuper( NULL );
81  }
82  // quit if there is no library
83  if ( pLib == NULL )
84  {
85  printf( "The current library is not available.\n" );
86  return 0;
87  }
88  if ( AreaMulti != 0.0 )
89  fUseMulti = 1, printf( "The cell areas are multiplied by the factor: <num_fanins> ^ (%.2f).\n", AreaMulti );
90  if ( DelayMulti != 0.0 )
91  fUseMulti = 1, printf( "The cell delays are multiplied by the factor: <num_fanins> ^ (%.2f).\n", DelayMulti );
92 
93  // penalize large gates by increasing their area
94  if ( AreaMulti != 0.0 )
95  Mio_LibraryMultiArea( pLib, AreaMulti );
96  if ( DelayMulti != 0.0 )
97  Mio_LibraryMultiDelay( pLib, DelayMulti );
98 
99  // derive the supergate library
100  if ( fUseMulti || Abc_FrameReadLibSuper() == NULL )
101  {
102  if ( fVerbose )
103  printf( "Converting \"%s\" into supergate library \"%s\".\n",
105  // compute supergate library to be used for mapping
106  Map_SuperLibDeriveFromGenlib( pLib, fVerbose );
107  }
108 
109  // return the library to normal
110  if ( AreaMulti != 0.0 )
112  if ( DelayMulti != 0.0 )
114 
115  // print a warning about choice nodes
116  if ( fVerbose && Abc_NtkGetChoiceNum( pNtk ) )
117  printf( "Performing mapping with choices.\n" );
118 
119  // compute switching activity
120  fShowSwitching |= fSwitching;
121  if ( fShowSwitching )
122  {
123  extern Vec_Int_t * Sim_NtkComputeSwitching( Abc_Ntk_t * pNtk, int nPatterns );
124  vSwitching = Sim_NtkComputeSwitching( pNtk, 4096 );
125  pSwitching = (float *)vSwitching->pArray;
126  }
127 
128  // perform the mapping
129  pMan = Abc_NtkToMap( pNtk, DelayTarget, fRecovery, pSwitching, fVerbose );
130  if ( pSwitching ) Vec_IntFree( vSwitching );
131  if ( pMan == NULL )
132  return NULL;
133 clk = Abc_Clock();
134  Map_ManSetSwitching( pMan, fSwitching );
135  if ( LogFan != 0 )
136  Map_ManCreateNodeDelays( pMan, LogFan );
137  if ( !Map_Mapping( pMan ) )
138  {
139  Map_ManFree( pMan );
140  return NULL;
141  }
142 // Map_ManPrintStatsToFile( pNtk->pSpec, Map_ManReadAreaFinal(pMan), Map_ManReadRequiredGlo(pMan), Abc_Clock()-clk );
143 
144  // reconstruct the network after mapping
145  pNtkNew = Abc_NtkFromMap( pMan, pNtk );
146  Map_ManFree( pMan );
147  if ( pNtkNew == NULL )
148  return NULL;
149 
150  if ( pNtk->pExdc )
151  pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
152 if ( fVerbose )
153 {
154 ABC_PRT( "Total runtime", Abc_Clock() - clkTotal );
155 }
156 
157  // make sure that everything is okay
158  if ( !Abc_NtkCheck( pNtkNew ) )
159  {
160  printf( "Abc_NtkMap: The network check has failed.\n" );
161  Abc_NtkDelete( pNtkNew );
162  return NULL;
163  }
164  return pNtkNew;
165 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition: mainFrame.c:84
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
static ABC_NAMESPACE_IMPL_START Map_Man_t * Abc_NtkToMap(Abc_Ntk_t *pNtk, double DelayTarget, int fRecovery, float *pSwitching, int fVerbose)
DECLARATIONS ///.
Definition: abcMap.c:218
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
void Mio_LibraryMultiDelay(Mio_Library_t *pLib, double Multi)
Definition: mioUtils.c:841
Abc_Ntk_t * pExdc
Definition: abc.h:201
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Abc_SclHasDelayInfo(void *pScl)
Definition: sclLibUtil.c:292
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioApi.c:43
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Mio_Library_t * Abc_SclDeriveGenlib(void *pScl, float Slew, float Gain, int nGatesMin, int fVerbose)
Definition: sclLibUtil.c:818
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
int Map_SuperLibDeriveFromGenlib(Mio_Library_t *pLib, int fVerbose)
Definition: mapperLib.c:199
void Mio_LibraryMultiArea(Mio_Library_t *pLib, double Multi)
Definition: mioUtils.c:829
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
void Map_ManSetSwitching(Map_Man_t *p, int fSwitching)
Definition: mapperCreate.c:75
Vec_Int_t * Sim_NtkComputeSwitching(Abc_Ntk_t *pNtk, int nPatterns)
FUNCTION DEFINITIONS ///.
Definition: simSwitch.c:52
void Mio_LibraryTransferDelays(Mio_Library_t *pLibD, Mio_Library_t *pLibS)
Definition: mioUtils.c:872
static Abc_Ntk_t * Abc_NtkFromMap(Map_Man_t *pMan, Abc_Ntk_t *pNtk)
Definition: abcMap.c:420
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition: mapper.h:40
void Map_ManCreateNodeDelays(Map_Man_t *p, int LogFan)
Definition: mapperCreate.c:284
ABC_DLL void * Abc_FrameReadLibScl()
Definition: mainFrame.c:59
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Map_ManFree(Map_Man_t *pMan)
Definition: mapperCreate.c:248
int Map_Mapping(Map_Man_t *p)
DECLARATIONS ///.
Definition: mapperCore.c:50
#define assert(ex)
Definition: util_old.h:213
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
Map_Time_t* Abc_NtkMapCopyCiArrival ( Abc_Ntk_t pNtk,
Abc_Time_t ppTimes 
)

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

Synopsis [Load the network into manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file abcMap.c.

179 {
180  Map_Time_t * p;
181  int i;
182  p = ABC_CALLOC( Map_Time_t, Abc_NtkCiNum(pNtk) );
183  for ( i = 0; i < Abc_NtkCiNum(pNtk); i++ )
184  {
185  p->Fall = ppTimes[i].Fall;
186  p->Rise = ppTimes[i].Rise;
187  p->Worst = Abc_MaxFloat( p->Fall, p->Rise );
188  }
189  ABC_FREE( ppTimes );
190  return p;
191 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
float Fall
Definition: abc.h:125
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
float Rise
Definition: abc.h:124
Map_Time_t* Abc_NtkMapCopyCoRequired ( Abc_Ntk_t pNtk,
Abc_Time_t ppTimes 
)

Definition at line 192 of file abcMap.c.

193 {
194  Map_Time_t * p;
195  int i;
196  p = ABC_CALLOC( Map_Time_t, Abc_NtkCoNum(pNtk) );
197  for ( i = 0; i < Abc_NtkCoNum(pNtk); i++ )
198  {
199  p->Fall = ppTimes[i].Fall;
200  p->Rise = ppTimes[i].Rise;
201  p->Worst = Abc_MaxFloat( p->Fall, p->Rise );
202  }
203  ABC_FREE( ppTimes );
204  return p;
205 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
float Fall
Definition: abc.h:125
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
float Rise
Definition: abc.h:124
int* Abc_NtkOutputMiniMapping ( void *  pAbc0)

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

Synopsis [This procedure outputs an array representing mini-mapped network.]

Description []

SideEffects []

SeeAlso []

Definition at line 875 of file abcMap.c.

876 {
877  Abc_Frame_t * pAbc = (Abc_Frame_t *)pAbc0;
878  Abc_Ntk_t * pNtk;
879  Vec_Int_t * vMapping;
880  int * pArray;
881  if ( pAbc == NULL )
882  printf( "ABC framework is not initialized by calling Abc_Start()\n" );
883  pNtk = Abc_FrameReadNtk( pAbc );
884  if ( pNtk == NULL )
885  printf( "Current network in ABC framework is not defined.\n" );
886  if ( !Abc_NtkHasMapping(pNtk) )
887  printf( "Current network in ABC framework is not mapped.\n" );
888  // derive mini-mapping
889  vMapping = Abc_NtkWriteMiniMapping( pNtk );
890  pArray = Vec_IntArray( vMapping );
891  ABC_FREE( vMapping );
892  // print mini-mapping (optional)
893 // Abc_NtkPrintMiniMapping( pArray );
894  // return the array representation of mini-mapping
895  return pArray;
896 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * Abc_NtkWriteMiniMapping(Abc_Ntk_t *pNtk)
Definition: abcMap.c:770
void Abc_NtkPrintMiniMapping ( int *  pArray)

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

Synopsis [Prints mapped network represented in mini-mapped format.]

Description []

SideEffects []

SeeAlso []

Definition at line 834 of file abcMap.c.

835 {
836  int nCis, nCos, nNodes, nFlops;
837  int i, k, nLeaves, Pos = 4;
838  char * pBuffer, * pName;
839  nCis = pArray[0];
840  nCos = pArray[1];
841  nNodes = pArray[2];
842  nFlops = pArray[3];
843  printf( "Mapped network has %d CIs, %d COs, %d gates, and %d flops.\n", nCis, nCos, nNodes, nFlops );
844  printf( "The first %d object IDs (from 0 to %d) are reserved for the CIs.\n", nCis, nCis - 1 );
845  for ( i = 0; i < nNodes; i++ )
846  {
847  printf( "Node %d has fanins {", nCis + i );
848  nLeaves = pArray[Pos++];
849  for ( k = 0; k < nLeaves; k++ )
850  printf( " %d", pArray[Pos++] );
851  printf( " }\n" );
852  }
853  for ( i = 0; i < nCos; i++ )
854  printf( "CO %d is driven by node %d\n", i, pArray[Pos++] );
855  pBuffer = (char *)(pArray + Pos);
856  for ( i = 0; i < nNodes; i++ )
857  {
858  pName = pBuffer;
859  pBuffer += strlen(pName) + 1;
860  printf( "Node %d has gate \"%s\"\n", nCis + i, pName );
861  }
862 }
ush Pos
Definition: deflate.h:88
int strlen()
void Abc_NtkSetCiArrivalTime ( void *  pAbc0,
int  iCi,
float  Rise,
float  Fall 
)

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

Synopsis [These APIs set arriva/required times of CIs/COs.]

Description []

SideEffects []

SeeAlso []

Definition at line 929 of file abcMap.c.

930 {
931  Abc_Frame_t * pAbc = (Abc_Frame_t *)pAbc0;
932  Abc_Ntk_t * pNtk;
933  Abc_Obj_t * pNode;
934  if ( pAbc == NULL )
935  printf( "ABC framework is not initialized by calling Abc_Start()\n" );
936  pNtk = Abc_FrameReadNtk( pAbc );
937  if ( pNtk == NULL )
938  printf( "Current network in ABC framework is not defined.\n" );
939  if ( iCi < 0 || iCi >= Abc_NtkCiNum(pNtk) )
940  printf( "CI index is not valid.\n" );
941  pNode = Abc_NtkCi( pNtk, iCi );
942  Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pNode), Rise, Fall );
943 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
ABC_DLL void Abc_NtkTimeSetArrival(Abc_Ntk_t *pNtk, int ObjId, float Rise, float Fall)
Definition: abcTiming.c:185
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
void Abc_NtkSetCoRequiredTime ( void *  pAbc0,
int  iCo,
float  Rise,
float  Fall 
)

Definition at line 944 of file abcMap.c.

945 {
946  Abc_Frame_t * pAbc = (Abc_Frame_t *)pAbc0;
947  Abc_Ntk_t * pNtk;
948  Abc_Obj_t * pNode;
949  if ( pAbc == NULL )
950  printf( "ABC framework is not initialized by calling Abc_Start()\n" );
951  pNtk = Abc_FrameReadNtk( pAbc );
952  if ( pNtk == NULL )
953  printf( "Current network in ABC framework is not defined.\n" );
954  if ( iCo < 0 || iCo >= Abc_NtkCoNum(pNtk) )
955  printf( "CO index is not valid.\n" );
956  pNode = Abc_NtkCo( pNtk, iCo );
957  Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pNode), Rise, Fall );
958 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
ABC_DLL void Abc_NtkTimeSetRequired(Abc_Ntk_t *pNtk, int ObjId, float Rise, float Fall)
Definition: abcTiming.c:200
Abc_Ntk_t* Abc_NtkSuperChoice ( Abc_Ntk_t pNtk)

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

Synopsis [Interface with the mapping package.]

Description []

SideEffects []

SeeAlso []

Definition at line 480 of file abcMap.c.

481 {
482  Abc_Ntk_t * pNtkNew;
483 
484  Map_Man_t * pMan;
485 
486  assert( Abc_NtkIsStrash(pNtk) );
487 
488  // check that the library is available
489  if ( Abc_FrameReadLibGen() == NULL )
490  {
491  printf( "The current library is not available.\n" );
492  return 0;
493  }
494 
495  // derive the supergate library
496  if ( Abc_FrameReadLibSuper() == NULL && Abc_FrameReadLibGen() )
497  {
498 // printf( "A simple supergate library is derived from gate library \"%s\".\n",
499 // Mio_LibraryReadName((Mio_Library_t *)Abc_FrameReadLibGen()) );
501  }
502 
503  // print a warning about choice nodes
504  if ( Abc_NtkGetChoiceNum( pNtk ) )
505  printf( "Performing mapping with choices.\n" );
506 
507  // perform the mapping
508  pMan = Abc_NtkToMap( pNtk, -1, 1, NULL, 0 );
509  if ( pMan == NULL )
510  return NULL;
511  if ( !Map_Mapping( pMan ) )
512  {
513  Map_ManFree( pMan );
514  return NULL;
515  }
516 
517  // reconstruct the network after mapping
518  pNtkNew = Abc_NtkFromMapSuperChoice( pMan, pNtk );
519  if ( pNtkNew == NULL )
520  return NULL;
521  Map_ManFree( pMan );
522 
523  // make sure that everything is okay
524  if ( !Abc_NtkCheck( pNtkNew ) )
525  {
526  printf( "Abc_NtkMap: The network check has failed.\n" );
527  Abc_NtkDelete( pNtkNew );
528  return NULL;
529  }
530  return pNtkNew;
531 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static ABC_NAMESPACE_IMPL_START Map_Man_t * Abc_NtkToMap(Abc_Ntk_t *pNtk, double DelayTarget, int fRecovery, float *pSwitching, int fVerbose)
DECLARATIONS ///.
Definition: abcMap.c:218
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static Abc_Ntk_t * Abc_NtkFromMapSuperChoice(Map_Man_t *pMan, Abc_Ntk_t *pNtk)
Definition: abcMap.c:545
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
int Map_SuperLibDeriveFromGenlib(Mio_Library_t *pLib, int fVerbose)
Definition: mapperLib.c:199
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition: mapper.h:40
void Map_ManFree(Map_Man_t *pMan)
Definition: mapperCreate.c:248
int Map_Mapping(Map_Man_t *p)
DECLARATIONS ///.
Definition: mapperCore.c:50
#define assert(ex)
Definition: util_old.h:213
void Abc_NtkTestMiniMapping ( Abc_Ntk_t p)

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

Synopsis [Test for mini-mapped format.]

Description []

SideEffects []

SeeAlso []

Definition at line 909 of file abcMap.c.

910 {
911  Vec_Int_t * vMapping;
912  vMapping = Abc_NtkWriteMiniMapping( p );
914  printf( "Array has size %d ints.\n", Vec_IntSize(vMapping) );
915  Vec_IntFree( vMapping );
916 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * Abc_NtkWriteMiniMapping(Abc_Ntk_t *pNtk)
Definition: abcMap.c:770
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Abc_NtkPrintMiniMapping(int *pArray)
Definition: abcMap.c:834
Map_Man_t * Abc_NtkToMap ( Abc_Ntk_t pNtk,
double  DelayTarget,
int  fRecovery,
float *  pSwitching,
int  fVerbose 
)
static

DECLARATIONS ///.

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

FileName [abcMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Interface with the SC mapping package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Load the network into manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 218 of file abcMap.c.

219 {
220  Map_Man_t * pMan;
221  Map_Node_t * pNodeMap;
222  Vec_Ptr_t * vNodes;
223  Abc_Obj_t * pNode, * pFanin, * pPrev;
224  int i;
225 
226  assert( Abc_NtkIsStrash(pNtk) );
227 
228  // start the mapping manager and set its parameters
229  pMan = Map_ManCreate( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) - pNtk->nBarBufs, Abc_NtkPoNum(pNtk) + Abc_NtkLatchNum(pNtk) - pNtk->nBarBufs, fVerbose );
230  if ( pMan == NULL )
231  return NULL;
232  Map_ManSetAreaRecovery( pMan, fRecovery );
234  Map_ManSetDelayTarget( pMan, (float)DelayTarget );
237 
238  // create PIs and remember them in the old nodes
239  Abc_NtkCleanCopy( pNtk );
241  Abc_NtkForEachCi( pNtk, pNode, i )
242  {
243  if ( i == Abc_NtkCiNum(pNtk) - pNtk->nBarBufs )
244  break;
245  pNodeMap = Map_ManReadInputs(pMan)[i];
246  pNode->pCopy = (Abc_Obj_t *)pNodeMap;
247  if ( pSwitching )
248  Map_NodeSetSwitching( pNodeMap, pSwitching[pNode->Id] );
249  }
250 
251  // load the AIG into the mapper
252  vNodes = Abc_AigDfsMap( pNtk );
253  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
254  {
255  if ( Abc_ObjIsLatch(pNode) )
256  {
257  pFanin = Abc_ObjFanin0(pNode);
258  pNodeMap = Map_NodeBuf( pMan, Map_NotCond( Abc_ObjFanin0(pFanin)->pCopy, (int)Abc_ObjFaninC0(pFanin) ) );
259  Abc_ObjFanout0(pNode)->pCopy = (Abc_Obj_t *)pNodeMap;
260  continue;
261  }
262  assert( Abc_ObjIsNode(pNode) );
263  // add the node to the mapper
264  pNodeMap = Map_NodeAnd( pMan,
265  Map_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) ),
266  Map_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) ) );
267  assert( pNode->pCopy == NULL );
268  // remember the node
269  pNode->pCopy = (Abc_Obj_t *)pNodeMap;
270  if ( pSwitching )
271  Map_NodeSetSwitching( pNodeMap, pSwitching[pNode->Id] );
272  // set up the choice node
273  if ( Abc_AigNodeIsChoice( pNode ) )
274  for ( pPrev = pNode, pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pPrev = pFanin, pFanin = (Abc_Obj_t *)pFanin->pData )
275  {
276  Map_NodeSetNextE( (Map_Node_t *)pPrev->pCopy, (Map_Node_t *)pFanin->pCopy );
277  Map_NodeSetRepr( (Map_Node_t *)pFanin->pCopy, (Map_Node_t *)pNode->pCopy );
278  }
279  }
280  assert( Map_ManReadBufNum(pMan) == pNtk->nBarBufs );
281  Vec_PtrFree( vNodes );
282 
283  // set the primary outputs in the required phase
284  Abc_NtkForEachCo( pNtk, pNode, i )
285  {
286  if ( i == Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
287  break;
288  Map_ManReadOutputs(pMan)[i] = Map_NotCond( (Map_Node_t *)Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) );
289  }
290  return pMan;
291 }
#define Map_NotCond(p, c)
Definition: mapper.h:70
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Map_Node_t * Map_ManReadConst1(Map_Man_t *p)
Definition: mapperCreate.c:56
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
Map_Man_t * Map_ManCreate(int nInputs, int nOutputs, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: mapperCreate.c:184
ABC_DLL Vec_Ptr_t * Abc_AigDfsMap(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1054
Map_Time_t * Abc_NtkMapCopyCoRequired(Abc_Ntk_t *pNtk, Abc_Time_t *ppTimes)
Definition: abcMap.c:192
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
void Map_ManSetOutputNames(Map_Man_t *p, char **ppNames)
Definition: mapperCreate.c:63
ABC_DLL char ** Abc_NtkCollectCioNames(Abc_Ntk_t *pNtk, int fCollectCos)
Definition: abcNames.c:278
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Map_ManSetInputArrivals(Map_Man_t *p, Map_Time_t *pArrivals)
Definition: mapperCreate.c:66
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
void Map_NodeSetRepr(Map_Node_t *p, Map_Node_t *pRepr)
Definition: mapperCreate.c:98
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
void Map_ManSetDelayTarget(Map_Man_t *p, float DelayTarget)
Definition: mapperCreate.c:65
Abc_Obj_t * pCopy
Definition: abc.h:148
Map_Node_t ** Map_ManReadInputs(Map_Man_t *p)
Definition: mapperCreate.c:52
void Map_ManSetOutputRequireds(Map_Man_t *p, Map_Time_t *pArrivals)
Definition: mapperCreate.c:67
int Map_ManReadBufNum(Map_Man_t *p)
Definition: mapperCreate.c:51
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition: mapper.h:40
ABC_DLL Abc_Time_t * Abc_NtkGetCiArrivalTimes(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:619
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
Map_Time_t * Abc_NtkMapCopyCiArrival(Abc_Ntk_t *pNtk, Abc_Time_t *ppTimes)
Definition: abcMap.c:178
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
Map_Node_t ** Map_ManReadOutputs(Map_Man_t *p)
Definition: mapperCreate.c:53
int nBarBufs
Definition: abc.h:174
Map_Node_t * Map_NodeAnd(Map_Man_t *p, Map_Node_t *p1, Map_Node_t *p2)
Definition: mapperCreate.c:447
int Id
Definition: abc.h:132
void Map_ManSetAreaRecovery(Map_Man_t *p, int fAreaRecovery)
Definition: mapperCreate.c:64
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
Map_Node_t * Map_NodeBuf(Map_Man_t *p, Map_Node_t *p1)
Definition: mapperCreate.c:552
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
void Map_NodeSetSwitching(Map_Node_t *p, float Switching)
Definition: mapperCreate.c:99
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Map_NodeSetNextE(Map_Node_t *p, Map_Node_t *pNextE)
Definition: mapperCreate.c:97
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
ABC_DLL Abc_Time_t * Abc_NtkGetCoRequiredTimes(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:632
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Int_t* Abc_NtkWriteMiniMapping ( Abc_Ntk_t pNtk)

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

Synopsis [Dumps mapped network in the mini-mapped format.]

Description []

SideEffects []

SeeAlso []

Definition at line 770 of file abcMap.c.

771 {
772  Vec_Ptr_t * vNodes;
773  Vec_Int_t * vMapping;
774  Vec_Str_t * vGates;
775  Abc_Obj_t * pObj, * pFanin;
776  int i, k, nNodes, nFanins, nExtra, * pArray;
777  assert( Abc_NtkHasMapping(pNtk) );
778  // collect nodes in the DFS order
779  vNodes = Abc_NtkDfs( pNtk, 0 );
780  // assign unique numbers
781  nNodes = nFanins = 0;
782  Abc_NtkForEachCi( pNtk, pObj, i )
783  pObj->iTemp = nNodes++;
784  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
785  pObj->iTemp = nNodes++, nFanins += Abc_ObjFaninNum(pObj);
786  // allocate attay to store mapping (4 counters + fanins for each node + PO drivers + gate names)
787  vMapping = Vec_IntAlloc( 4 + Abc_NtkNodeNum(pNtk) + nFanins + Abc_NtkCoNum(pNtk) + 10000 );
788  // write the numbers of CI/CO/Node/FF
789  Vec_IntPush( vMapping, Abc_NtkCiNum(pNtk) );
790  Vec_IntPush( vMapping, Abc_NtkCoNum(pNtk) );
791  Vec_IntPush( vMapping, Abc_NtkNodeNum(pNtk) );
792  Vec_IntPush( vMapping, Abc_NtkLatchNum(pNtk) );
793  // write the nodes
794  vGates = Vec_StrAlloc( 10000 );
795  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
796  {
797  Vec_IntPush( vMapping, Abc_ObjFaninNum(pObj) );
798  Abc_ObjForEachFanin( pObj, pFanin, k )
799  Vec_IntPush( vMapping, pFanin->iTemp );
800  // remember this gate (to be added to the mapping later)
801  Vec_StrPrintStr( vGates, Mio_GateReadName((Mio_Gate_t *)pObj->pData) );
802  Vec_StrPush( vGates, '\0' );
803  }
804  // write the COs literals
805  Abc_NtkForEachCo( pNtk, pObj, i )
806  Vec_IntPush( vMapping, Abc_ObjFanin0(pObj)->iTemp );
807  // finish off the array
808  nExtra = 4 - Vec_StrSize(vGates) % 4;
809  for ( i = 0; i < nExtra; i++ )
810  Vec_StrPush( vGates, '\0' );
811  // add gates to the array
812  assert( Vec_StrSize(vGates) % 4 == 0 );
813  nExtra = Vec_StrSize(vGates) / 4;
814  pArray = (int *)Vec_StrArray(vGates);
815  for ( i = 0; i < nExtra; i++ )
816  Vec_IntPush( vMapping, pArray[i] );
817  // cleanup and return
818  Vec_PtrFree( vNodes );
819  Vec_StrFree( vGates );
820  return vMapping;
821 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
static void Vec_StrPrintStr(Vec_Str_t *p, const char *pStr)
Definition: vecStr.h:627
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223