abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
amapInt.h File Reference
#include "misc/extra/extra.h"
#include "aig/aig/aig.h"
#include "amap.h"

Go to the source code of this file.

Data Structures

struct  Amap_Man_t_
 
struct  Amap_Lib_t_
 
struct  Amap_Pin_t_
 
struct  Amap_Gat_t_
 
struct  Amap_Set_t_
 
struct  Amap_Nod_t_
 
struct  Amap_Cut_t_
 
struct  Amap_Mat_t_
 
struct  Amap_Obj_t_
 

Macros

#define AMAP_MAXINS   15
 INCLUDES ///. More...
 
#define AMAP_STRING_CONST0   "CONST0"
 
#define AMAP_STRING_CONST1   "CONST1"
 
#define Amap_ManForEachPi(p, pObj, i)   Vec_PtrForEachEntry( Amap_Obj_t *, p->vPis, pObj, i )
 MACRO DEFINITIONS ///. More...
 
#define Amap_ManForEachPo(p, pObj, i)   Vec_PtrForEachEntry( Amap_Obj_t *, p->vPos, pObj, i )
 
#define Amap_ManForEachObj(p, pObj, i)   Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
 
#define Amap_ManForEachNode(p, pObj, i)   Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Amap_ObjIsNode(pObj) ) {} else
 
#define Amap_LibForEachGate(pLib, pGate, i)   Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vGates, pGate, i )
 
#define Amap_GateForEachPin(pGate, pPin)   for ( pPin = pGate->Pins; pPin < pGate->Pins + pGate->nPins; pPin++ )
 
#define Amap_NodeForEachCut(pNode, pCut, i)
 
#define Amap_LibNodeForEachSet(pNod, pSet)   for ( pSet = pNod->pSets; pSet; pSet = pSet->pNext )
 
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
 
#define Amap_MatchForEachFanin(p, pM, pFanin, i)
 

Typedefs

typedef struct Amap_Pin_t_ Amap_Pin_t
 BASIC TYPES ///. More...
 
typedef struct Amap_Gat_t_ Amap_Gat_t
 
typedef struct Amap_Nod_t_ Amap_Nod_t
 
typedef struct Amap_Set_t_ Amap_Set_t
 
typedef struct Amap_Man_t_ Amap_Man_t
 
typedef struct Amap_Obj_t_ Amap_Obj_t
 
typedef struct Amap_Cut_t_ Amap_Cut_t
 
typedef struct Amap_Mat_t_ Amap_Mat_t
 

Enumerations

enum  Amap_Type_t {
  AMAP_OBJ_NONE, AMAP_OBJ_CONST1, AMAP_OBJ_PI, AMAP_OBJ_PO,
  AMAP_OBJ_AND, AMAP_OBJ_XOR, AMAP_OBJ_MUX, AMAP_OBJ_VOID
}
 

Functions

static Amap_Obj_tAmap_Regular (Amap_Obj_t *p)
 
static Amap_Obj_tAmap_Not (Amap_Obj_t *p)
 
static Amap_Obj_tAmap_NotCond (Amap_Obj_t *p, int c)
 
static int Amap_IsComplement (Amap_Obj_t *p)
 
static int Amap_ManPiNum (Amap_Man_t *p)
 
static int Amap_ManPoNum (Amap_Man_t *p)
 
static int Amap_ManAndNum (Amap_Man_t *p)
 
static int Amap_ManXorNum (Amap_Man_t *p)
 
static int Amap_ManMuxNum (Amap_Man_t *p)
 
static int Amap_ManObjNum (Amap_Man_t *p)
 
static int Amap_ManNodeNum (Amap_Man_t *p)
 
static Amap_Obj_tAmap_ManConst1 (Amap_Man_t *p)
 
static Amap_Obj_tAmap_ManPi (Amap_Man_t *p, int i)
 
static Amap_Obj_tAmap_ManPo (Amap_Man_t *p, int i)
 
static Amap_Obj_tAmap_ManObj (Amap_Man_t *p, int i)
 
static int Amap_ObjIsConst1 (Amap_Obj_t *pObj)
 
static int Amap_ObjIsPi (Amap_Obj_t *pObj)
 
static int Amap_ObjIsPo (Amap_Obj_t *pObj)
 
static int Amap_ObjIsAnd (Amap_Obj_t *pObj)
 
static int Amap_ObjIsXor (Amap_Obj_t *pObj)
 
static int Amap_ObjIsMux (Amap_Obj_t *pObj)
 
static int Amap_ObjIsNode (Amap_Obj_t *pObj)
 
static int Amap_ObjToLit (Amap_Obj_t *pObj)
 
static Amap_Obj_tAmap_ObjFanin0 (Amap_Man_t *p, Amap_Obj_t *pObj)
 
static Amap_Obj_tAmap_ObjFanin1 (Amap_Man_t *p, Amap_Obj_t *pObj)
 
static Amap_Obj_tAmap_ObjFanin2 (Amap_Man_t *p, Amap_Obj_t *pObj)
 
static int Amap_ObjFaninC0 (Amap_Obj_t *pObj)
 
static int Amap_ObjFaninC1 (Amap_Obj_t *pObj)
 
static int Amap_ObjFaninC2 (Amap_Obj_t *pObj)
 
static void * Amap_ObjCopy (Amap_Obj_t *pObj)
 
static int Amap_ObjLevel (Amap_Obj_t *pObj)
 
static void Amap_ObjSetLevel (Amap_Obj_t *pObj, int Level)
 
static void Amap_ObjSetCopy (Amap_Obj_t *pObj, void *pCopy)
 
static Amap_Obj_tAmap_ObjChoice (Amap_Man_t *p, Amap_Obj_t *pObj)
 
static void Amap_ObjSetChoice (Amap_Obj_t *pObj, Amap_Obj_t *pEqu)
 
static int Amap_ObjPhaseReal (Amap_Obj_t *pObj)
 
static int Amap_ObjRefsTotal (Amap_Obj_t *pObj)
 
static Amap_Gat_tAmap_LibGate (Amap_Lib_t *p, int i)
 
static Amap_Nod_tAmap_LibNod (Amap_Lib_t *p, int i)
 
static Amap_Cut_tAmap_ManCutNext (Amap_Cut_t *pCut)
 
static Amap_Cut_t ** Amap_ManCutNextP (Amap_Cut_t *pCut)
 
void Kit_DsdPrintFromTruth (unsigned *pTruth, int nVars)
 
Amap_Obj_tAmap_ManCreatePi (Amap_Man_t *p)
 FUNCTION DECLARATIONS ///. More...
 
Amap_Obj_tAmap_ManCreatePo (Amap_Man_t *p, Amap_Obj_t *pFan0)
 
Amap_Obj_tAmap_ManCreateAnd (Amap_Man_t *p, Amap_Obj_t *pFan0, Amap_Obj_t *pFan1)
 
Amap_Obj_tAmap_ManCreateXor (Amap_Man_t *p, Amap_Obj_t *pFan0, Amap_Obj_t *pFan1)
 
Amap_Obj_tAmap_ManCreateMux (Amap_Man_t *p, Amap_Obj_t *pFanC, Amap_Obj_t *pFan1, Amap_Obj_t *pFan0)
 
void Amap_ManCreateChoice (Amap_Man_t *p, Amap_Obj_t *pObj)
 
void Amap_ManCreate (Amap_Man_t *p, Aig_Man_t *pAig)
 
Amap_Lib_tAmap_LibAlloc ()
 DECLARATIONS ///. More...
 
int Amap_LibNumPinsMax (Amap_Lib_t *p)
 
void Amap_LibWrite (FILE *pFile, Amap_Lib_t *pLib, int fPrintDsd)
 
Vec_Ptr_tAmap_LibSelectGates (Amap_Lib_t *p, int fVerbose)
 
Amap_Man_tAmap_ManStart (int nNodes)
 DECLARATIONS ///. More...
 
void Amap_ManStop (Amap_Man_t *p)
 
void Amap_ManMap (Amap_Man_t *p)
 
void Amap_ManMerge (Amap_Man_t *p)
 
Vec_Ptr_tAmap_ManProduceMapped (Amap_Man_t *p)
 
int Amap_LibParseEquations (Amap_Lib_t *p, int fVerbose)
 
Amap_Lib_tAmap_LibReadBuffer (char *pBuffer, int fVerbose)
 
Amap_Lib_tAmap_LibReadFile (char *pFileName, int fVerbose)
 
short * Amap_LibTableFindNode (Amap_Lib_t *p, int iFan0, int iFan1, int fXor)
 
void Amap_LibCreateRules (Amap_Lib_t *p, int fVeryVerbose)
 
int Amap_LibFindNode (Amap_Lib_t *pLib, int iFan0, int iFan1, int fXor)
 
int Amap_LibFindMux (Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
 
int Amap_LibCreateVar (Amap_Lib_t *p)
 
int Amap_LibCreateNode (Amap_Lib_t *p, int iFan0, int iFan1, int fXor)
 
int Amap_LibCreateMux (Amap_Lib_t *p, int iFan0, int iFan1, int iFan2)
 
int ** Amap_LibLookupTableAlloc (Vec_Ptr_t *vVec, int fVerbose)
 

Macro Definition Documentation

#define Amap_GateForEachPin (   pGate,
  pPin 
)    for ( pPin = pGate->Pins; pPin < pGate->Pins + pGate->nPins; pPin++ )

Definition at line 296 of file amapInt.h.

#define Amap_LibForEachGate (   pLib,
  pGate,
 
)    Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vGates, pGate, i )

Definition at line 293 of file amapInt.h.

#define Amap_LibNodeForEachSet (   pNod,
  pSet 
)    for ( pSet = pNod->pSets; pSet; pSet = pSet->pNext )

Definition at line 305 of file amapInt.h.

#define Amap_ManForEachNode (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Amap_ObjIsNode(pObj) ) {} else

Definition at line 289 of file amapInt.h.

#define Amap_ManForEachObj (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else

Definition at line 286 of file amapInt.h.

#define Amap_ManForEachPi (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Amap_Obj_t *, p->vPis, pObj, i )

MACRO DEFINITIONS ///.

Definition at line 280 of file amapInt.h.

#define Amap_ManForEachPo (   p,
  pObj,
 
)    Vec_PtrForEachEntry( Amap_Obj_t *, p->vPos, pObj, i )

Definition at line 283 of file amapInt.h.

#define Amap_MatchForEachFanin (   p,
  pM,
  pFanin,
 
)
Value:
for ( i = 0; i < (int)(pM)->pCut->nFans && \
((pFanin = Amap_ManObj((p), Abc_Lit2Var((pM)->pCut->Fans[Abc_Lit2Var((pM)->pSet->Ins[i])]))), 1); \
i++ )
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264

Definition at line 316 of file amapInt.h.

#define Amap_MatchForEachFaninCompl (   p,
  pM,
  pFanin,
  fCompl,
 
)
Value:
for ( i = 0; i < (int)(pM)->pCut->nFans && \
((pFanin = Amap_ManObj((p), Abc_Lit2Var((pM)->pCut->Fans[Abc_Lit2Var((pM)->pSet->Ins[i])]))), 1) && \
((fCompl = Abc_LitIsCompl((pM)->pSet->Ins[i]) ^ Abc_LitIsCompl((pM)->pCut->Fans[Abc_Lit2Var((pM)->pSet->Ins[i])])), 1); \
i++ )
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264

Definition at line 309 of file amapInt.h.

#define AMAP_MAXINS   15

INCLUDES ///.

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

FileName [amapInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
amapInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 44 of file amapInt.h.

#define Amap_NodeForEachCut (   pNode,
  pCut,
 
)
Value:
for ( i = 0, pCut = (Amap_Cut_t *)pNode->pData; i < (int)pNode->nCuts; \
i++, pCut = Amap_ManCutNext(pCut) )
static Amap_Cut_t * Amap_ManCutNext(Amap_Cut_t *pCut)
Definition: amapInt.h:267

Definition at line 300 of file amapInt.h.

#define AMAP_STRING_CONST0   "CONST0"

Definition at line 46 of file amapInt.h.

#define AMAP_STRING_CONST1   "CONST1"

Definition at line 47 of file amapInt.h.

Typedef Documentation

typedef struct Amap_Cut_t_ Amap_Cut_t

Definition at line 72 of file amapInt.h.

typedef struct Amap_Gat_t_ Amap_Gat_t

Definition at line 66 of file amapInt.h.

typedef struct Amap_Man_t_ Amap_Man_t

Definition at line 70 of file amapInt.h.

typedef struct Amap_Mat_t_ Amap_Mat_t

Definition at line 73 of file amapInt.h.

typedef struct Amap_Nod_t_ Amap_Nod_t

Definition at line 67 of file amapInt.h.

typedef struct Amap_Obj_t_ Amap_Obj_t

Definition at line 71 of file amapInt.h.

typedef struct Amap_Pin_t_ Amap_Pin_t

BASIC TYPES ///.

Definition at line 65 of file amapInt.h.

typedef struct Amap_Set_t_ Amap_Set_t

Definition at line 68 of file amapInt.h.

Enumeration Type Documentation

Enumerator
AMAP_OBJ_NONE 
AMAP_OBJ_CONST1 
AMAP_OBJ_PI 
AMAP_OBJ_PO 
AMAP_OBJ_AND 
AMAP_OBJ_XOR 
AMAP_OBJ_MUX 
AMAP_OBJ_VOID 

Definition at line 50 of file amapInt.h.

50  {
51  AMAP_OBJ_NONE, // 0: non-existent object
52  AMAP_OBJ_CONST1, // 1: constant 1
53  AMAP_OBJ_PI, // 2: primary input
54  AMAP_OBJ_PO, // 3: primary output
55  AMAP_OBJ_AND, // 4: AND node
56  AMAP_OBJ_XOR, // 5: XOR node
57  AMAP_OBJ_MUX, // 6: MUX node
58  AMAP_OBJ_VOID // 7: unused object
59 } Amap_Type_t;
Amap_Type_t
Definition: amapInt.h:50

Function Documentation

static int Amap_IsComplement ( Amap_Obj_t p)
inlinestatic

Definition at line 224 of file amapInt.h.

224 { return (int )(((ABC_PTRUINT_T)p) & 01); }
Amap_Lib_t* Amap_LibAlloc ( )

DECLARATIONS ///.

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

FileName [amapLib.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Standard-cell library.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Allocs a library.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapLib.c.

46 {
47  Amap_Lib_t * p;
48  p = (Amap_Lib_t *)ABC_ALLOC( Amap_Lib_t, 1 );
49  memset( p, 0, sizeof(Amap_Lib_t) );
50  p->vGates = Vec_PtrAlloc( 100 );
51  p->pMemGates = Aig_MmFlexStart();
52  p->pMemSet = Aig_MmFlexStart();
53  return p;
54 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
int Amap_LibCreateMux ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  iFan2 
)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 244 of file amapUniq.c.

245 {
246  Amap_Nod_t * pNode;
247  pNode = Amap_LibCreateObj( p );
248  pNode->Type = AMAP_OBJ_MUX;
249  pNode->nSuppSize = p->pNodes[Abc_Lit2Var(iFan0)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan1)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan2)].nSuppSize;
250  pNode->iFan0 = iFan0;
251  pNode->iFan1 = iFan1;
252  pNode->iFan2 = iFan2;
253 if ( p->fVerbose )
254 printf( "Creating node %5d %c : iFan0 = %5d%c iFan1 = %5d%c iFan2 = %5d%c\n",
255 pNode->Id, 'm',
256 Abc_Lit2Var(iFan0), (Abc_LitIsCompl(iFan0)?'-':'+'),
257 Abc_Lit2Var(iFan1), (Abc_LitIsCompl(iFan1)?'-':'+'),
258 Abc_Lit2Var(iFan2), (Abc_LitIsCompl(iFan2)?'-':'+') );
259 
260  Vec_IntPush( p->vRules3, iFan0 );
261  Vec_IntPush( p->vRules3, iFan1 );
262  Vec_IntPush( p->vRules3, iFan2 );
263  Vec_IntPush( p->vRules3, pNode->Id );
264  return pNode->Id;
265 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
short iFan0
Definition: amapInt.h:177
short iFan2
Definition: amapInt.h:179
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned Type
Definition: amapInt.h:176
unsigned nSuppSize
Definition: amapInt.h:175
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Id
Definition: amapInt.h:174
short iFan1
Definition: amapInt.h:178
int Amap_LibCreateNode ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  fXor 
)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file amapUniq.c.

190 {
191  Amap_Nod_t * pNode;
192  int iFan;
193  if ( iFan0 < iFan1 )
194  {
195  iFan = iFan0;
196  iFan0 = iFan1;
197  iFan1 = iFan;
198  }
199  pNode = Amap_LibCreateObj( p );
200  pNode->Type = fXor? AMAP_OBJ_XOR : AMAP_OBJ_AND;
201  pNode->nSuppSize = p->pNodes[Abc_Lit2Var(iFan0)].nSuppSize + p->pNodes[Abc_Lit2Var(iFan1)].nSuppSize;
202  pNode->iFan0 = iFan0;
203  pNode->iFan1 = iFan1;
204 if ( p->fVerbose )
205 printf( "Creating node %5d %c : iFan0 = %5d%c iFan1 = %5d%c\n",
206 pNode->Id, (fXor?'x':' '),
207 Abc_Lit2Var(iFan0), (Abc_LitIsCompl(iFan0)?'-':'+'),
208 Abc_Lit2Var(iFan1), (Abc_LitIsCompl(iFan1)?'-':'+') );
209 
210  if ( fXor )
211  {
212  if ( iFan0 == iFan1 )
213  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
214  else
215  {
216  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
217  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan1), (pNode->Id << 16) | iFan0 );
218  }
219  }
220  else
221  {
222  if ( iFan0 == iFan1 )
223  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
224  else
225  {
226  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
227  Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan1), (pNode->Id << 16) | iFan0 );
228  }
229  }
230  return pNode->Id;
231 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
short iFan0
Definition: amapInt.h:177
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned Type
Definition: amapInt.h:176
unsigned nSuppSize
Definition: amapInt.h:175
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
static void Vec_IntPushOrderWithMask(Vec_Int_t *p, int Entry)
Definition: amapUniq.c:65
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Id
Definition: amapInt.h:174
short iFan1
Definition: amapInt.h:178
void Amap_LibCreateRules ( Amap_Lib_t pLib,
int  fVeryVerbose 
)

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

Synopsis [Creates rules for the given gate]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file amapRule.c.

427 {
428  Amap_Gat_t * pGate;
429  int i, nGates = 0;
430 // abctime clk = Abc_Clock();
431  pLib->fVerbose = fVeryVerbose;
432  pLib->vRules = Vec_PtrAlloc( 100 );
433  pLib->vRulesX = Vec_PtrAlloc( 100 );
434  pLib->vRules3 = Vec_IntAlloc( 100 );
435  Amap_LibCreateVar( pLib );
436  Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vSelect, pGate, i )
437  {
438  if ( pGate->nPins < 2 )
439  continue;
440  if ( pGate->pFunc == NULL )
441  {
442  printf( "Amap_LibCreateRules(): Skipping gate %s (%s).\n", pGate->pName, pGate->pForm );
443  continue;
444  }
445  Amap_CreateRulesForGate( pLib, pGate );
446  nGates++;
447  }
448  assert( Vec_PtrSize(pLib->vRules) == 2*pLib->nNodes );
449  assert( Vec_PtrSize(pLib->vRulesX) == 2*pLib->nNodes );
450  pLib->pRules = Amap_LibLookupTableAlloc( pLib->vRules, 0 );
451  pLib->pRulesX = Amap_LibLookupTableAlloc( pLib->vRulesX, 0 );
452  Vec_VecFree( (Vec_Vec_t *)pLib->vRules ); pLib->vRules = NULL;
453  Vec_VecFree( (Vec_Vec_t *)pLib->vRulesX ); pLib->vRulesX = NULL;
454 }
char * pForm
Definition: amapInt.h:157
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Amap_CreateRulesForGate(Amap_Lib_t *pLib, Amap_Gat_t *pGate)
Definition: amapRule.c:330
int Amap_LibCreateVar(Amap_Lib_t *p)
Definition: amapUniq.c:164
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int ** Amap_LibLookupTableAlloc(Vec_Ptr_t *vVec, int fVerbose)
Definition: amapUniq.c:278
unsigned * pFunc
Definition: amapInt.h:158
unsigned nPins
Definition: amapInt.h:161
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: amapInt.h:154
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Amap_LibCreateVar ( Amap_Lib_t p)

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

Synopsis [Creates a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file amapUniq.c.

165 {
166  Amap_Nod_t * pNode;
167  // start the manager
168  assert( p->pNodes == NULL );
169  p->nNodesAlloc = 256;
170  p->pNodes = ABC_ALLOC( Amap_Nod_t, p->nNodesAlloc );
171  // create the first node
172  pNode = Amap_LibCreateObj( p );
173  p->pNodes->Type = AMAP_OBJ_PI;
174  p->pNodes->nSuppSize = 1;
175  return 0;
176 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Amap_Nod_t * Amap_LibCreateObj(Amap_Lib_t *p)
Definition: amapUniq.c:135
#define assert(ex)
Definition: util_old.h:213
int Amap_LibFindMux ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  iFan2 
)

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

Synopsis [Checks if the three-argument rule exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file amapUniq.c.

110 {
111  int x;
112  for ( x = 0; x < Vec_IntSize(p->vRules3); x += 4 )
113  {
114  if ( Vec_IntEntry(p->vRules3, x) == iFan0 &&
115  Vec_IntEntry(p->vRules3, x+1) == iFan1 &&
116  Vec_IntEntry(p->vRules3, x+2) == iFan2 )
117  {
118  return Vec_IntEntry(p->vRules3, x+3);
119  }
120  }
121  return -1;
122 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int Amap_LibFindNode ( Amap_Lib_t pLib,
int  iFan0,
int  iFan1,
int  fXor 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file amapUniq.c.

91 {
92  if ( fXor )
93  return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRulesX, iFan0), iFan1 );
94  else
95  return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRules, iFan0), iFan1 );
96 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static ABC_NAMESPACE_IMPL_START int Vec_IntCheckWithMask(Vec_Int_t *p, int Entry)
DECLARATIONS ///.
Definition: amapUniq.c:45
static Amap_Gat_t* Amap_LibGate ( Amap_Lib_t p,
int  i 
)
inlinestatic

Definition at line 263 of file amapInt.h.

263 { return (Amap_Gat_t *)Vec_PtrEntry(p->vGates, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int** Amap_LibLookupTableAlloc ( Vec_Ptr_t vVec,
int  fVerbose 
)

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

Synopsis [Allocates triangular lookup table.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file amapUniq.c.

279 {
280  Vec_Int_t * vOne;
281  int ** pRes, * pBuffer;
282  int i, k, nTotal, nSize, nEntries, Value;
283  // count the total size
284  nEntries = nSize = Vec_PtrSize( vVec );
285  Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
286  nEntries += Vec_IntSize(vOne);
287  pBuffer = ABC_ALLOC( int, nSize * sizeof(void *) + nEntries );
288  pRes = (int **)pBuffer;
289  pRes[0] = pBuffer + nSize * sizeof(void *);
290  nTotal = 0;
291  Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
292  {
293  pRes[i] = pRes[0] + nTotal;
294  nTotal += Vec_IntSize(vOne) + 1;
295  if ( fVerbose )
296  printf( "%d : ", i );
297  Vec_IntForEachEntry( vOne, Value, k )
298  {
299  pRes[i][k] = Value;
300  if ( fVerbose )
301  printf( "%d(%d) ", Value&0xffff, Value>>16 );
302  }
303  if ( fVerbose )
304  printf( "\n" );
305  pRes[i][k] = 0;
306  }
307  assert( nTotal == nEntries );
308  return pRes;
309 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
static Amap_Nod_t* Amap_LibNod ( Amap_Lib_t p,
int  i 
)
inlinestatic

Definition at line 264 of file amapInt.h.

264 { return p->pNodes + i; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Amap_LibNumPinsMax ( Amap_Lib_t p)

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

Synopsis [Returns the largest gate size.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file amapLib.c.

104 {
105  Amap_Gat_t * pGate;
106  int i, Counter = 0;
107  Amap_LibForEachGate( p, pGate, i )
108  if ( Counter < (int)pGate->nPins )
109  Counter = pGate->nPins;
110  return Counter;
111 }
#define Amap_LibForEachGate(pLib, pGate, i)
Definition: amapInt.h:293
static Llb_Mgr_t * p
Definition: llb3Image.c:950
if(last==0)
Definition: sparse_int.h:34
static int Counter
int Amap_LibParseEquations ( Amap_Lib_t p,
int  fVerbose 
)

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

Synopsis [Parses equations for the gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 392 of file amapParse.c.

393 {
394 // extern int Kit_TruthSupportSize( unsigned * pTruth, int nVars );
395  Hop_Man_t * pMan;
396  Hop_Obj_t * pObj;
397  Vec_Ptr_t * vNames;
398  Vec_Int_t * vTruth;
399  Amap_Gat_t * pGate;
400  Amap_Pin_t * pPin;
401  unsigned * pTruth;
402  int i, nPinMax;
403  nPinMax = Amap_LibNumPinsMax(p);
404  if ( nPinMax > AMAP_MAXINS )
405  printf( "Gates with more than %d inputs will be ignored.\n", AMAP_MAXINS );
406  vTruth = Vec_IntAlloc( 1 << 16 );
407  vNames = Vec_PtrAlloc( 100 );
408  pMan = Hop_ManStart();
409  Hop_IthVar( pMan, nPinMax - 1 );
410  Vec_PtrForEachEntry( Amap_Gat_t *, p->vGates, pGate, i )
411  {
412  if ( pGate->nPins == 0 )
413  {
414  pGate->pFunc = (unsigned *)Aig_MmFlexEntryFetch( p->pMemGates, 4 );
415  if ( strcmp( pGate->pForm, AMAP_STRING_CONST0 ) == 0 )
416  pGate->pFunc[0] = 0;
417  else if ( strcmp( pGate->pForm, AMAP_STRING_CONST1 ) == 0 )
418  pGate->pFunc[0] = ~0;
419  else
420  {
421  printf( "Cannot parse formula \"%s\" of gate \"%s\" with no pins.\n", pGate->pForm, pGate->pName );
422  break;
423  }
424  continue;
425  }
426  if ( pGate->nPins > AMAP_MAXINS )
427  continue;
428  Vec_PtrClear( vNames );
429  Amap_GateForEachPin( pGate, pPin )
430  Vec_PtrPush( vNames, pPin->pName );
431  pObj = Amap_ParseFormula( stdout, pGate->pForm, vNames, pMan );
432  if ( pObj == NULL )
433  break;
434  pTruth = Hop_ManConvertAigToTruth( pMan, pObj, pGate->nPins, vTruth, 0 );
435  if ( Kit_TruthSupportSize(pTruth, pGate->nPins) < (int)pGate->nPins )
436  {
437  if ( fVerbose )
438  printf( "Skipping gate \"%s\" because its output \"%s\" does not depend on all input variables.\n", pGate->pName, pGate->pForm );
439  continue;
440  }
441  pGate->pFunc = (unsigned *)Aig_MmFlexEntryFetch( p->pMemGates, sizeof(unsigned)*Abc_TruthWordNum(pGate->nPins) );
442  memcpy( pGate->pFunc, pTruth, sizeof(unsigned)*Abc_TruthWordNum(pGate->nPins) );
443  }
444  Vec_PtrFree( vNames );
445  Vec_IntFree( vTruth );
446  Hop_ManStop( pMan );
447  return i == Vec_PtrSize(p->vGates);
448 }
int Amap_LibNumPinsMax(Amap_Lib_t *p)
Definition: amapLib.c:103
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
char * pForm
Definition: amapInt.h:157
#define Amap_GateForEachPin(pGate, pPin)
Definition: amapInt.h:296
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * memcpy()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
void Hop_ManStop(Hop_Man_t *p)
Definition: hopMan.c:84
#define AMAP_STRING_CONST0
Definition: amapInt.h:46
int strcmp()
Hop_Obj_t * Amap_ParseFormula(FILE *pOutput, char *pFormInit, Vec_Ptr_t *vVarNames, Hop_Man_t *pMan)
Definition: amapParse.c:106
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define AMAP_STRING_CONST1
Definition: amapInt.h:47
#define AMAP_MAXINS
INCLUDES ///.
Definition: amapInt.h:44
if(last==0)
Definition: sparse_int.h:34
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition: hopMan.c:45
unsigned * pFunc
Definition: amapInt.h:158
unsigned nPins
Definition: amapInt.h:161
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
Definition: hopTruth.c:143
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
char * pName
Definition: amapInt.h:154
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition: kitTruth.c:327
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Amap_Lib_t* Amap_LibReadBuffer ( char *  pBuffer,
int  fVerbose 
)

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

Synopsis [Reads the library from the input file.]

Description []

SideEffects []

SeeAlso []

Definition at line 446 of file amapRead.c.

447 {
448  Amap_Lib_t * pLib;
449  Vec_Ptr_t * vTokens;
450  Amap_RemoveComments( pBuffer, NULL, NULL );
451  vTokens = Amap_DeriveTokens( pBuffer );
452  pLib = Amap_ParseTokens( vTokens, fVerbose );
453  if ( pLib == NULL )
454  {
455  Vec_PtrFree( vTokens );
456  return NULL;
457  }
458  Vec_PtrFree( vTokens );
459  return pLib;
460 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Amap_Lib_t * Amap_ParseTokens(Vec_Ptr_t *vTokens, int fVerbose)
Definition: amapRead.c:326
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
Vec_Ptr_t * Amap_DeriveTokens(char *pBuffer)
Definition: amapRead.c:176
void Amap_RemoveComments(char *pBuffer, int *pnDots, int *pnLines)
Definition: amapRead.c:120
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Amap_Lib_t* Amap_LibReadFile ( char *  pFileName,
int  fVerbose 
)

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

Synopsis [Reads the library from the input file.]

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file amapRead.c.

474 {
475  Amap_Lib_t * pLib;
476  char * pBuffer;
477  pBuffer = Amap_LoadFile( pFileName );
478  if ( pBuffer == NULL )
479  return NULL;
480  pLib = Amap_LibReadBuffer( pBuffer, fVerbose );
481  if ( pLib )
482  pLib->pName = Abc_UtilStrsav( pFileName );
483  ABC_FREE( pBuffer );
484  return pLib;
485 }
char * Amap_LoadFile(char *pFileName)
FUNCTION DEFINITIONS ///.
Definition: amapRead.c:73
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Amap_Lib_t * Amap_LibReadBuffer(char *pBuffer, int fVerbose)
Definition: amapRead.c:446
Vec_Ptr_t* Amap_LibSelectGates ( Amap_Lib_t p,
int  fVerbose 
)

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

Synopsis [Selects gates useful for area-only mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file amapLib.c.

262 {
263  Vec_Ptr_t * vSelect;
264  Amap_Gat_t * pGate, * pGate2;
265  int i, k;//, clk = Abc_Clock();
266  p->pGate0 = Amap_LibFindGate( p, 0 );
267  p->pGate1 = Amap_LibFindGate( p, ~0 );
268  p->pGateBuf = Amap_LibFindGate( p, 0xAAAAAAAA );
269  p->pGateInv = Amap_LibFindGate( p, ~0xAAAAAAAA );
270  vSelect = Vec_PtrAlloc( 100 );
271  Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i )
272  {
273  if ( pGate->pFunc == NULL || pGate->pTwin != NULL )
274  continue;
275  Vec_PtrForEachEntryStop( Amap_Gat_t *, p->vSorted, pGate2, k, i )
276  {
277  if ( pGate2->pFunc == NULL || pGate2->pTwin != NULL )
278  continue;
279  if ( pGate2->nPins != pGate->nPins )
280  continue;
281  if ( !memcmp( pGate2->pFunc, pGate->pFunc, sizeof(unsigned) * Abc_TruthWordNum(pGate->nPins) ) )
282  break;
283  }
284  if ( k < i )
285  continue;
286  Vec_PtrPush( vSelect, pGate );
287  }
288  return vSelect;
289 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Amap_Gat_t * Amap_LibFindGate(Amap_Lib_t *p, unsigned uTruth)
Definition: amapLib.c:240
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
Amap_Gat_t * pTwin
Definition: amapInt.h:153
int memcmp()
unsigned * pFunc
Definition: amapInt.h:158
unsigned nPins
Definition: amapInt.h:161
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
short* Amap_LibTableFindNode ( Amap_Lib_t p,
int  iFan0,
int  iFan1,
int  fXor 
)
void Amap_LibWrite ( FILE *  pFile,
Amap_Lib_t pLib,
int  fPrintDsd 
)

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

Synopsis [Writes library.]

Description []

SideEffects []

SeeAlso []

Definition at line 179 of file amapLib.c.

180 {
181  Amap_Gat_t * pGate;
182  int i;
183  fprintf( pFile, "# The genlib library \"%s\".\n", pLib->pName );
184  Amap_LibForEachGate( pLib, pGate, i )
185  Amap_LibWriteGate( pFile, pGate, fPrintDsd );
186 }
#define Amap_LibForEachGate(pLib, pGate, i)
Definition: amapInt.h:293
void Amap_LibWriteGate(FILE *pFile, Amap_Gat_t *pGate, int fPrintDsd)
Definition: amapLib.c:150
static int Amap_ManAndNum ( Amap_Man_t p)
inlinestatic

Definition at line 228 of file amapInt.h.

228 { return p->nObjs[AMAP_OBJ_AND]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static Amap_Obj_t* Amap_ManConst1 ( Amap_Man_t p)
inlinestatic

Definition at line 234 of file amapInt.h.

234 { return p->pConst1; }
Amap_Obj_t * pConst1
Definition: amapInt.h:93
void Amap_ManCreate ( Amap_Man_t p,
Aig_Man_t pAig 
)

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

Synopsis [Starts the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 323 of file amapGraph.c.

324 {
325  Vec_Ptr_t * vNodes;
326  Amap_Obj_t * pChoices[4];
327  Aig_Obj_t * pObj, * pFanin, * pPrev, * pFan0, * pFan1, * pFanC;
328  int i, fChoices;
329  if ( pAig->pEquivs )
330  vNodes = Aig_ManDfsChoices( pAig );
331  else
332  vNodes = Aig_ManDfs( pAig, 1 );
333  p->pConst1 = Amap_ManCreateConst1( p );
334  // print warning about excessive memory usage
335  if ( p->pPars->fVerbose )
336  {
337  if ( 1.0 * Aig_ManObjNum(pAig) * sizeof(Amap_Obj_t) / (1<<30) > 0.1 )
338  printf( "Warning: Mapper allocates %.3f GB for subject graph with %d objects.\n",
339  1.0 * Aig_ManObjNum(pAig) * sizeof(Amap_Obj_t) / (1<<30), Aig_ManObjNum(pAig) );
340  }
341  // create PIs and remember them in the old nodes
342  Aig_ManCleanData(pAig);
343  Aig_ManConst1(pAig)->pData = Amap_ManConst1( p );
344  Aig_ManForEachCi( pAig, pObj, i )
345  pObj->pData = Amap_ManCreatePi( p );
346  // load the AIG into the mapper
347  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
348  {
349  fChoices = 0;
350  if ( p->fUseXor && Aig_ObjRecognizeExor(pObj, &pFan0, &pFan1 ) )
351  {
352  Amap_ManCreateXorChoices( p, Amap_AndToObj(pFan0), Amap_AndToObj(pFan1), pChoices );
353  fChoices = 1;
354  }
355  else if ( p->fUseMux && Aig_ObjIsMuxType(pObj) )
356  {
357  pFanC = Aig_ObjRecognizeMux( pObj, &pFan1, &pFan0 );
358  Amap_ManCreateMuxChoices( p, Amap_AndToObj(pFan0), Amap_AndToObj(pFan1), Amap_AndToObj(pFanC), pChoices );
359  fChoices = 1;
360  }
361  pObj->pData = Amap_ManCreateAnd( p, (Amap_Obj_t *)Aig_ObjChild0Copy(pObj), (Amap_Obj_t *)Aig_ObjChild1Copy(pObj) );
362  if ( fChoices )
363  {
364  p->nChoicesAdded++;
365  Amap_ObjSetChoice( (Amap_Obj_t *)pObj->pData, pChoices[0] );
366  Amap_ObjSetChoice( pChoices[0], pChoices[1] );
367  Amap_ObjSetChoice( pChoices[1], pChoices[2] );
368  Amap_ObjSetChoice( pChoices[2], pChoices[3] );
369  Amap_ManCreateChoice( p, (Amap_Obj_t *)pObj->pData );
370  }
371  if ( Aig_ObjIsChoice( pAig, pObj ) )
372  {
373 // assert( !fChoices );
374  p->nChoicesGiven++;
375  for ( pPrev = pObj, pFanin = Aig_ObjEquiv(pAig, pObj); pFanin; pPrev = pFanin, pFanin = Aig_ObjEquiv(pAig, pFanin) )
376  {
377  ((Amap_Obj_t *)pFanin->pData)->fRepr = 0;
379  (Amap_Obj_t *)pFanin->pData );
380  }
381  Amap_ManCreateChoice( p, (Amap_Obj_t *)pObj->pData );
382  }
383  }
384  Vec_PtrFree( vNodes );
385  // set the primary outputs without copying the phase
386  Aig_ManForEachCo( pAig, pObj, i )
387  pObj->pData = Amap_ManCreatePo( p, (Amap_Obj_t *)Aig_ObjChild0Copy(pObj) );
388  if ( p->pPars->fVerbose )
389  printf( "Performing mapping with %d given and %d created choices.\n",
390  p->nChoicesGiven, p->nChoicesAdded );
391 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Amap_Obj_t * Amap_ManGetLast_rec(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapGraph.c:305
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
void * pData
Definition: aig.h:87
Vec_Ptr_t * Aig_ManDfsChoices(Aig_Man_t *p)
Definition: aigDfs.c:391
Amap_Obj_t * pConst1
Definition: amapInt.h:93
static void Amap_ObjSetChoice(Amap_Obj_t *pObj, Amap_Obj_t *pEqu)
Definition: amapInt.h:259
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Amap_Obj_t * Amap_ManCreatePi(Amap_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition: amapGraph.c:88
Amap_Obj_t * Amap_ManCreatePo(Amap_Man_t *p, Amap_Obj_t *pFan0)
Definition: amapGraph.c:110
int fVerbose
Definition: amap.h:55
void * pData
Definition: amapInt.h:212
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pObj, Aig_Obj_t **ppObjT, Aig_Obj_t **ppObjE)
Definition: aigUtil.c:387
Amap_Obj_t * Amap_ManCreateConst1(Amap_Man_t *p)
Definition: amapGraph.c:67
if(last==0)
Definition: sparse_int.h:34
static Amap_Obj_t * Amap_ManConst1(Amap_Man_t *p)
Definition: amapInt.h:234
static Aig_Obj_t * Aig_ObjEquiv(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:328
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
int Aig_ObjRecognizeExor(Aig_Obj_t *pObj, Aig_Obj_t **ppFan0, Aig_Obj_t **ppFan1)
Definition: aigUtil.c:343
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition: aigDfs.c:145
Definition: aig.h:69
static Amap_Obj_t * Amap_AndToObj(Aig_Obj_t *pObj)
Definition: amapGraph.c:289
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
void Amap_ManCreateChoice(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapGraph.c:222
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
void Amap_ManCreateMuxChoices(Amap_Man_t *p, Amap_Obj_t *pFan0, Amap_Obj_t *pFan1, Amap_Obj_t *pFanC, Amap_Obj_t *pChoices[])
Definition: amapGraph.c:270
void Amap_ManCreateXorChoices(Amap_Man_t *p, Amap_Obj_t *pFan0, Amap_Obj_t *pFan1, Amap_Obj_t *pChoices[])
Definition: amapGraph.c:251
Amap_Par_t * pPars
Definition: amapInt.h:78
int Aig_ObjIsMuxType(Aig_Obj_t *pObj)
Definition: aigUtil.c:307
Amap_Obj_t * Amap_ManCreateAnd(Amap_Man_t *p, Amap_Obj_t *pFan0, Amap_Obj_t *pFan1)
Definition: amapGraph.c:137
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
static int Aig_ObjIsChoice(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:283
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Amap_Obj_t* Amap_ManCreateAnd ( Amap_Man_t p,
Amap_Obj_t pFan0,
Amap_Obj_t pFan1 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 137 of file amapGraph.c.

138 {
139  Amap_Obj_t * pObj;
140  pObj = Amap_ManSetupObj( p );
141  pObj->Type = AMAP_OBJ_AND;
142  pObj->Fan[0] = Amap_ObjToLit(pFan0); Amap_Regular(pFan0)->nRefs++;
143  pObj->Fan[1] = Amap_ObjToLit(pFan1); Amap_Regular(pFan1)->nRefs++;
144  assert( Abc_Lit2Var(pObj->Fan[0]) != Abc_Lit2Var(pObj->Fan[1]) );
145  pObj->fPhase = Amap_ObjPhaseReal(pFan0) & Amap_ObjPhaseReal(pFan1);
146  pObj->Level = 1 + Abc_MaxInt( Amap_Regular(pFan0)->Level, Amap_Regular(pFan1)->Level );
147  if ( p->nLevelMax < (int)pObj->Level )
148  p->nLevelMax = (int)pObj->Level;
149  assert( p->nLevelMax < 4094 ); // 2^12-2
150  p->nObjs[AMAP_OBJ_AND]++;
151  return pObj;
152 }
static int Amap_ObjPhaseReal(Amap_Obj_t *pObj)
Definition: amapInt.h:260
unsigned Level
Definition: amapInt.h:206
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
int nRefs
Definition: amapInt.h:208
static int Amap_ObjToLit(Amap_Obj_t *pObj)
Definition: amapInt.h:247
ABC_NAMESPACE_IMPL_START Amap_Obj_t * Amap_ManSetupObj(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapGraph.c:45
unsigned Type
Definition: amapInt.h:200
unsigned fPhase
Definition: amapInt.h:203
int Fan[3]
Definition: amapInt.h:210
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
int nLevelMax
Definition: amapInt.h:95
void Amap_ManCreateChoice ( Amap_Man_t p,
Amap_Obj_t pObj 
)

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

Synopsis [Creates the choice node.]

Description [Should be called after the equivalence class nodes are linked.]

SideEffects []

SeeAlso []

Definition at line 222 of file amapGraph.c.

223 {
224  Amap_Obj_t * pTemp;
225  // mark the node as a representative if its class
226 // assert( pObj->fRepr == 0 );
227  pObj->fRepr = 1;
228  // update the level of this node (needed for correct required time computation)
229  for ( pTemp = pObj; pTemp; pTemp = Amap_ObjChoice(p, pTemp) )
230  {
231  pObj->Level = Abc_MaxInt( pObj->Level, pTemp->Level );
232 // pTemp->nVisits++; pTemp->nVisitsCopy++;
233  }
234  // mark the largest level
235  if ( p->nLevelMax < (int)pObj->Level )
236  p->nLevelMax = (int)pObj->Level;
237  assert( p->nLevelMax < 4094 ); // 2^12-2
238 }
unsigned Level
Definition: amapInt.h:206
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
unsigned fRepr
Definition: amapInt.h:204
static Amap_Obj_t * Amap_ObjChoice(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:258
#define assert(ex)
Definition: util_old.h:213
int nLevelMax
Definition: amapInt.h:95
Amap_Obj_t* Amap_ManCreateMux ( Amap_Man_t p,
Amap_Obj_t pFan0,
Amap_Obj_t pFan1,
Amap_Obj_t pFanC 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file amapGraph.c.

193 {
194  Amap_Obj_t * pObj;
195  pObj = Amap_ManSetupObj( p );
196  pObj->Type = AMAP_OBJ_MUX;
197  pObj->Fan[0] = Amap_ObjToLit(pFan0); Amap_Regular(pFan0)->nRefs++;
198  pObj->Fan[1] = Amap_ObjToLit(pFan1); Amap_Regular(pFan1)->nRefs++;
199  pObj->Fan[2] = Amap_ObjToLit(pFanC); Amap_Regular(pFanC)->nRefs++;
200  pObj->fPhase = (Amap_ObjPhaseReal(pFan1) & Amap_ObjPhaseReal(pFanC)) |
201  (Amap_ObjPhaseReal(pFan0) & ~Amap_ObjPhaseReal(pFanC));
202  pObj->Level = Abc_MaxInt( Amap_Regular(pFan0)->Level, Amap_Regular(pFan1)->Level );
203  pObj->Level = 2 + Abc_MaxInt( pObj->Level, Amap_Regular(pFanC)->Level );
204  if ( p->nLevelMax < (int)pObj->Level )
205  p->nLevelMax = (int)pObj->Level;
206  assert( p->nLevelMax < 4094 ); // 2^12-2
207  p->nObjs[AMAP_OBJ_MUX]++;
208  return pObj;
209 }
static int Amap_ObjPhaseReal(Amap_Obj_t *pObj)
Definition: amapInt.h:260
unsigned Level
Definition: amapInt.h:206
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
int nRefs
Definition: amapInt.h:208
static int Amap_ObjToLit(Amap_Obj_t *pObj)
Definition: amapInt.h:247
ABC_NAMESPACE_IMPL_START Amap_Obj_t * Amap_ManSetupObj(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapGraph.c:45
unsigned Type
Definition: amapInt.h:200
unsigned fPhase
Definition: amapInt.h:203
int Fan[3]
Definition: amapInt.h:210
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
#define assert(ex)
Definition: util_old.h:213
int nLevelMax
Definition: amapInt.h:95
Amap_Obj_t* Amap_ManCreatePi ( Amap_Man_t p)

FUNCTION DECLARATIONS ///.

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

Synopsis [Creates primary input.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file amapGraph.c.

89 {
90  Amap_Obj_t * pObj;
91  pObj = Amap_ManSetupObj( p );
92  pObj->Type = AMAP_OBJ_PI;
93  pObj->IdPio = Vec_PtrSize( p->vPis );
94  Vec_PtrPush( p->vPis, pObj );
95  p->nObjs[AMAP_OBJ_PI]++;
96  return pObj;
97 }
unsigned IdPio
Definition: amapInt.h:202
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_NAMESPACE_IMPL_START Amap_Obj_t * Amap_ManSetupObj(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapGraph.c:45
Vec_Ptr_t * vPis
Definition: amapInt.h:86
unsigned Type
Definition: amapInt.h:200
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
Amap_Obj_t* Amap_ManCreatePo ( Amap_Man_t p,
Amap_Obj_t pFan0 
)

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

Synopsis [Creates primary output with the given driver.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file amapGraph.c.

111 {
112  Amap_Obj_t * pObj;
113  pObj = Amap_ManSetupObj( p );
114  pObj->IdPio = Vec_PtrSize( p->vPos );
115  Vec_PtrPush( p->vPos, pObj );
116  pObj->Type = AMAP_OBJ_PO;
117  pObj->Fan[0] = Amap_ObjToLit(pFan0); Amap_Regular(pFan0)->nRefs++;
118  pObj->Level = Amap_Regular(pFan0)->Level;
119  if ( p->nLevelMax < (int)pObj->Level )
120  p->nLevelMax = (int)pObj->Level;
121  assert( p->nLevelMax < 4094 ); // 2^12-2
122  p->nObjs[AMAP_OBJ_PO]++;
123  return pObj;
124 }
unsigned IdPio
Definition: amapInt.h:202
unsigned Level
Definition: amapInt.h:206
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
int nRefs
Definition: amapInt.h:208
static int Amap_ObjToLit(Amap_Obj_t *pObj)
Definition: amapInt.h:247
ABC_NAMESPACE_IMPL_START Amap_Obj_t * Amap_ManSetupObj(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapGraph.c:45
unsigned Type
Definition: amapInt.h:200
int Fan[3]
Definition: amapInt.h:210
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
#define assert(ex)
Definition: util_old.h:213
int nLevelMax
Definition: amapInt.h:95
Vec_Ptr_t * vPos
Definition: amapInt.h:87
Amap_Obj_t* Amap_ManCreateXor ( Amap_Man_t p,
Amap_Obj_t pFan0,
Amap_Obj_t pFan1 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file amapGraph.c.

166 {
167  Amap_Obj_t * pObj;
168  pObj = Amap_ManSetupObj( p );
169  pObj->Type = AMAP_OBJ_XOR;
170  pObj->Fan[0] = Amap_ObjToLit(pFan0); Amap_Regular(pFan0)->nRefs++;
171  pObj->Fan[1] = Amap_ObjToLit(pFan1); Amap_Regular(pFan1)->nRefs++;
172  pObj->fPhase = Amap_ObjPhaseReal(pFan0) ^ Amap_ObjPhaseReal(pFan1);
173  pObj->Level = 2 + Abc_MaxInt( Amap_Regular(pFan0)->Level, Amap_Regular(pFan1)->Level );
174  if ( p->nLevelMax < (int)pObj->Level )
175  p->nLevelMax = (int)pObj->Level;
176  assert( p->nLevelMax < 4094 ); // 2^12-2
177  p->nObjs[AMAP_OBJ_XOR]++;
178  return pObj;
179 }
static int Amap_ObjPhaseReal(Amap_Obj_t *pObj)
Definition: amapInt.h:260
unsigned Level
Definition: amapInt.h:206
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
int nRefs
Definition: amapInt.h:208
static int Amap_ObjToLit(Amap_Obj_t *pObj)
Definition: amapInt.h:247
ABC_NAMESPACE_IMPL_START Amap_Obj_t * Amap_ManSetupObj(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapGraph.c:45
unsigned Type
Definition: amapInt.h:200
unsigned fPhase
Definition: amapInt.h:203
int Fan[3]
Definition: amapInt.h:210
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
#define assert(ex)
Definition: util_old.h:213
int nLevelMax
Definition: amapInt.h:95
static Amap_Cut_t* Amap_ManCutNext ( Amap_Cut_t pCut)
inlinestatic

Definition at line 267 of file amapInt.h.

268 { return (Amap_Cut_t *)(((int *)pCut)+pCut->nFans+1); }
unsigned nFans
Definition: amapInt.h:187
static Amap_Cut_t** Amap_ManCutNextP ( Amap_Cut_t pCut)
inlinestatic

Definition at line 270 of file amapInt.h.

271 { return (Amap_Cut_t **)(((int *)pCut)+pCut->nFans+1); }
unsigned nFans
Definition: amapInt.h:187
void Amap_ManMap ( Amap_Man_t p)

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

Synopsis [Performs mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 593 of file amapMatch.c.

594 {
595  int i;
596  Amap_ManMerge( p );
597  for ( i = 0; i < p->pPars->nIterFlow; i++ )
598  Amap_ManMatch( p, 1, i>0 );
599  for ( i = 0; i < p->pPars->nIterArea; i++ )
600  Amap_ManMatch( p, 0, p->pPars->nIterFlow>0||i>0 );
601 /*
602  for ( i = 0; i < p->pPars->nIterFlow; i++ )
603  Amap_ManMatch( p, 1, 1 );
604  for ( i = 0; i < p->pPars->nIterArea; i++ )
605  Amap_ManMatch( p, 0, 1 );
606 */
607  Amap_ManCleanData( p );
608 }
void Amap_ManMerge(Amap_Man_t *p)
Definition: amapMerge.c:514
int nIterArea
Definition: amap.h:48
void Amap_ManCleanData(Amap_Man_t *p)
Definition: amapMatch.c:123
int nIterFlow
Definition: amap.h:47
Amap_Par_t * pPars
Definition: amapInt.h:78
void Amap_ManMatch(Amap_Man_t *p, int fFlow, int fRefs)
Definition: amapMatch.c:554
void Amap_ManMerge ( Amap_Man_t p)

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

Synopsis [Derives cuts for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file amapMerge.c.

515 {
516  Amap_Obj_t * pObj;
517  int i;
518  abctime clk = Abc_Clock();
519  p->pCutsPi = Amap_ManSetupPis( p );
520  Amap_ManForEachNode( p, pObj, i )
521  Amap_ManMergeNodeCuts( p, pObj );
522  if ( p->pPars->fVerbose )
523  {
524  printf( "AIG object is %d bytes. ", (int)sizeof(Amap_Obj_t) );
525  printf( "Internal AIG = %5.2f MB. Cuts = %5.2f MB. CutsMax = %d.\n",
526  1.0*Amap_ManObjNum(p)*sizeof(Amap_Obj_t)/(1<<20), 1.0*p->nBytesUsed/(1<<20), p->pPars->nCutsMax );
527  printf( "Node =%6d. Try =%9d. Try3 =%10d. Used =%7d. R =%6.2f. ",
528  Amap_ManNodeNum(p), p->nCutsTried, p->nCutsTried3, p->nCutsUsed,
529  1.0*p->nCutsUsed/Amap_ManNodeNum(p) );
530 ABC_PRT( "Time ", Abc_Clock() - clk );
531  }
532 }
void Amap_ManMergeNodeCuts(Amap_Man_t *p, Amap_Obj_t *pNode)
Definition: amapMerge.c:443
static abctime Abc_Clock()
Definition: abc_global.h:279
#define Amap_ManForEachNode(p, pObj, i)
Definition: amapInt.h:289
if(last==0)
Definition: sparse_int.h:34
static int Amap_ManNodeNum(Amap_Man_t *p)
Definition: amapInt.h:232
static int Amap_ManObjNum(Amap_Man_t *p)
Definition: amapInt.h:231
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManSetupPis(Amap_Man_t *p)
DECLARATIONS ///.
Definition: amapMerge.c:45
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_INT64_T abctime
Definition: abc_global.h:278
Amap_Cut_t * pCutsPi
Definition: amapInt.h:102
static int Amap_ManMuxNum ( Amap_Man_t p)
inlinestatic

Definition at line 230 of file amapInt.h.

230 { return p->nObjs[AMAP_OBJ_MUX]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static int Amap_ManNodeNum ( Amap_Man_t p)
inlinestatic

Definition at line 232 of file amapInt.h.

232 { return p->nObjs[AMAP_OBJ_AND] + p->nObjs[AMAP_OBJ_XOR] + p->nObjs[AMAP_OBJ_MUX]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static Amap_Obj_t* Amap_ManObj ( Amap_Man_t p,
int  i 
)
inlinestatic

Definition at line 237 of file amapInt.h.

237 { return (Amap_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
Vec_Ptr_t * vObjs
Definition: amapInt.h:88
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Amap_ManObjNum ( Amap_Man_t p)
inlinestatic

Definition at line 231 of file amapInt.h.

231 { return Vec_PtrSize(p->vObjs); }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * vObjs
Definition: amapInt.h:88
static Amap_Obj_t* Amap_ManPi ( Amap_Man_t p,
int  i 
)
inlinestatic

Definition at line 235 of file amapInt.h.

235 { return (Amap_Obj_t *)Vec_PtrEntry( p->vPis, i ); }
Vec_Ptr_t * vPis
Definition: amapInt.h:86
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Amap_ManPiNum ( Amap_Man_t p)
inlinestatic

Definition at line 226 of file amapInt.h.

226 { return p->nObjs[AMAP_OBJ_PI]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static Amap_Obj_t* Amap_ManPo ( Amap_Man_t p,
int  i 
)
inlinestatic

Definition at line 236 of file amapInt.h.

236 { return (Amap_Obj_t *)Vec_PtrEntry( p->vPos, i ); }
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vPos
Definition: amapInt.h:87
static int Amap_ManPoNum ( Amap_Man_t p)
inlinestatic

Definition at line 227 of file amapInt.h.

227 { return p->nObjs[AMAP_OBJ_PO]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
Vec_Ptr_t* Amap_ManProduceMapped ( Amap_Man_t p)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file amapOutput.c.

72 {
73  Vec_Ptr_t * vNodes;
74  Aig_MmFlex_t * pMem;
75  Amap_Obj_t * pObj, * pFanin;
76  Amap_Gat_t * pGate;
77  Amap_Out_t * pRes;
78  int i, k, iFanin, fCompl;
79  float TotalArea = 0.0;
80  pMem = Aig_MmFlexStart();
81  // create mapping object for each node used in the mapping
82  vNodes = Vec_PtrAlloc( 10 );
83  Amap_ManForEachObj( p, pObj, i )
84  {
85  if ( Amap_ObjIsPi(pObj) )
86  {
87  assert( pObj->fPolar == 0 );
88  pRes = Amap_OutputStructAlloc( pMem, NULL );
89  pRes->Type = -1;
90  pRes->nFans = 0;
91  // save this structure
92  pObj->iData = Vec_PtrSize( vNodes );
93  Vec_PtrPush( vNodes, pRes );
94  // create invertor if needed
95  if ( pObj->nFouts[1] ) // this PI is used in the neg polarity
96  {
97  pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGateInv );
98  pRes->pFans[0] = pObj->iData;
99  // save this structure
100  Vec_PtrPush( vNodes, pRes );
101  TotalArea += p->pLib->pGateInv->dArea;
102  }
103  continue;
104  }
105  if ( Amap_ObjIsNode(pObj) )
106  {
107  // skip the node that is not used in the mapping
108  if ( Amap_ObjRefsTotal(pObj) == 0 )
109  continue;
110  // get the gate
111  pGate = Amap_LibGate( p->pLib, pObj->Best.pSet->iGate );
112  assert( pGate->nPins == pObj->Best.pCut->nFans );
113  // allocate structure
114  pRes = Amap_OutputStructAlloc( pMem, pGate );
115  Amap_MatchForEachFaninCompl( p, &pObj->Best, pFanin, fCompl, k )
116  {
117  assert( Amap_ObjRefsTotal(pFanin) );
118  if ( (int)pFanin->fPolar == fCompl )
119  pRes->pFans[k] = pFanin->iData;
120  else
121  pRes->pFans[k] = pFanin->iData + 1;
122  }
123  // save this structure
124  pObj->iData = Vec_PtrSize( vNodes );
125  Vec_PtrPush( vNodes, pRes );
126  TotalArea += pGate->dArea;
127  // create invertor if needed
128  if ( pObj->nFouts[!pObj->fPolar] ) // needed in the opposite polarity
129  {
130  pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGateInv );
131  pRes->pFans[0] = pObj->iData;
132  // save this structure
133  Vec_PtrPush( vNodes, pRes );
134  TotalArea += p->pLib->pGateInv->dArea;
135  }
136  continue;
137  }
138  if ( Amap_ObjIsPo(pObj) )
139  {
140  assert( pObj->fPolar == 0 );
141  pFanin = Amap_ObjFanin0(p, pObj);
142  assert( Amap_ObjRefsTotal(pFanin) );
143  if ( Amap_ObjIsConst1(pFanin) )
144  { // create constant node
145  if ( Amap_ObjFaninC0(pObj) )
146  {
147  pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGate0 );
148  TotalArea += p->pLib->pGate0->dArea;
149  }
150  else
151  {
152  pRes = Amap_OutputStructAlloc( pMem, p->pLib->pGate1 );
153  TotalArea += p->pLib->pGate1->dArea;
154  }
155  // save this structure
156  iFanin = Vec_PtrSize( vNodes );
157  Vec_PtrPush( vNodes, pRes );
158  }
159  else
160  {
161  if ( (int)pFanin->fPolar == Amap_ObjFaninC0(pObj) )
162  iFanin = pFanin->iData;
163  else
164  iFanin = pFanin->iData + 1;
165  }
166  // create PO node
167  pRes = Amap_OutputStructAlloc( pMem, NULL );
168  pRes->Type = 1;
169  pRes->pFans[0] = iFanin;
170  // save this structure
171  Vec_PtrPush( vNodes, pRes );
172  }
173  }
174  // return memory manager in the last entry of the array
175  Vec_PtrPush( vNodes, pMem );
176  return vNodes;
177 }
static Amap_Gat_t * Amap_LibGate(Amap_Lib_t *p, int i)
Definition: amapInt.h:263
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int pFans[0]
Definition: amap.h:64
Amap_Mat_t Best
Definition: amapInt.h:218
static Amap_Obj_t * Amap_ObjFanin0(Amap_Man_t *p, Amap_Obj_t *pObj)
Definition: amapInt.h:248
int nFouts[2]
Definition: amapInt.h:217
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
Definition: amapInt.h:309
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Amap_ManForEachObj(p, pObj, i)
Definition: amapInt.h:286
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Amap_Out_t * Amap_OutputStructAlloc(Aig_MmFlex_t *pMem, Amap_Gat_t *pGate)
FUNCTION DEFINITIONS ///.
Definition: amapOutput.c:48
static int Amap_ObjIsPi(Amap_Obj_t *pObj)
Definition: amapInt.h:240
short nFans
Definition: amap.h:63
Amap_Cut_t * pCut
Definition: amapInt.h:192
static int Amap_ObjIsNode(Amap_Obj_t *pObj)
Definition: amapInt.h:245
static int Amap_ObjRefsTotal(Amap_Obj_t *pObj)
Definition: amapInt.h:261
static int Amap_ObjIsPo(Amap_Obj_t *pObj)
Definition: amapInt.h:241
Amap_Lib_t * pLib
Definition: amapInt.h:79
static int Amap_ObjIsConst1(Amap_Obj_t *pObj)
Definition: amapInt.h:239
unsigned nPins
Definition: amapInt.h:161
double dArea
Definition: amapInt.h:156
unsigned nFans
Definition: amapInt.h:187
short Type
Definition: amap.h:62
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
unsigned iGate
Definition: amapInt.h:167
#define assert(ex)
Definition: util_old.h:213
static int Amap_ObjFaninC0(Amap_Obj_t *pObj)
Definition: amapInt.h:251
unsigned fPolar
Definition: amapInt.h:205
Amap_Set_t * pSet
Definition: amapInt.h:193
int iData
Definition: amapInt.h:213
Amap_Man_t* Amap_ManStart ( int  nNodes)

DECLARATIONS ///.

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

FileName [amapMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis [Mapping manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Starts the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file amapMan.c.

46 {
47  Amap_Man_t * p;
48  // start the manager
49  p = ABC_ALLOC( Amap_Man_t, 1 );
50  memset( p, 0, sizeof(Amap_Man_t) );
51  p->fEpsilonInternal = (float)0.01;
52  // allocate arrays for nodes
53  p->vPis = Vec_PtrAlloc( 100 );
54  p->vPos = Vec_PtrAlloc( 100 );
55  p->vObjs = Vec_PtrAlloc( 100 );
56  p->vTemp = Vec_IntAlloc( 100 );
57  p->vCuts0 = Vec_PtrAlloc( 100 );
58  p->vCuts1 = Vec_PtrAlloc( 100 );
59  p->vCuts2 = Vec_PtrAlloc( 100 );
60  // prepare the memory manager
61  p->pMemObj = Aig_MmFixedStart( sizeof(Amap_Obj_t), nNodes );
65  return p;
66 }
char * memset()
Vec_Int_t * vTemp
Definition: amapInt.h:99
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_MmFlex_t * pMemCuts
Definition: amapInt.h:90
Vec_Ptr_t * vCuts0
Definition: amapInt.h:103
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition: aigMem.c:96
Aig_MmFlex_t * pMemCutBest
Definition: amapInt.h:91
Vec_Ptr_t * vObjs
Definition: amapInt.h:88
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t * vPis
Definition: amapInt.h:86
Aig_MmFixed_t * pMemObj
Definition: amapInt.h:89
Vec_Ptr_t * vCuts2
Definition: amapInt.h:105
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
Vec_Ptr_t * vCuts1
Definition: amapInt.h:104
Vec_Ptr_t * vPos
Definition: amapInt.h:87
float fEpsilonInternal
Definition: amapInt.h:81
void Amap_ManStop ( Amap_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file amapMan.c.

80 {
81  Vec_PtrFree( p->vPis );
82  Vec_PtrFree( p->vPos );
83  Vec_PtrFree( p->vObjs );
84  Vec_PtrFree( p->vCuts0 );
85  Vec_PtrFree( p->vCuts1 );
86  Vec_PtrFree( p->vCuts2 );
87  Vec_IntFree( p->vTemp );
88  Aig_MmFixedStop( p->pMemObj, 0 );
89  Aig_MmFlexStop( p->pMemCuts, 0 );
90  Aig_MmFlexStop( p->pMemCutBest, 0 );
91  Aig_MmFlexStop( p->pMemTemp, 0 );
92  ABC_FREE( p->pMatsTemp );
93  ABC_FREE( p->ppCutsTemp );
94  ABC_FREE( p->pCutsPi );
95  ABC_FREE( p );
96 }
Vec_Int_t * vTemp
Definition: amapInt.h:99
Aig_MmFlex_t * pMemCuts
Definition: amapInt.h:90
Vec_Ptr_t * vCuts0
Definition: amapInt.h:103
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
Aig_MmFlex_t * pMemCutBest
Definition: amapInt.h:91
Amap_Cut_t ** ppCutsTemp
Definition: amapInt.h:101
Vec_Ptr_t * vObjs
Definition: amapInt.h:88
Vec_Ptr_t * vPis
Definition: amapInt.h:86
Aig_MmFixed_t * pMemObj
Definition: amapInt.h:89
Vec_Ptr_t * vCuts2
Definition: amapInt.h:105
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition: aigMem.c:337
int * pMatsTemp
Definition: amapInt.h:100
Aig_MmFlex_t * pMemTemp
Definition: amapInt.h:92
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Ptr_t * vCuts1
Definition: amapInt.h:104
Amap_Cut_t * pCutsPi
Definition: amapInt.h:102
Vec_Ptr_t * vPos
Definition: amapInt.h:87
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Amap_ManXorNum ( Amap_Man_t p)
inlinestatic

Definition at line 229 of file amapInt.h.

229 { return p->nObjs[AMAP_OBJ_XOR]; }
int nObjs[AMAP_OBJ_VOID]
Definition: amapInt.h:94
static Amap_Obj_t* Amap_Not ( Amap_Obj_t p)
inlinestatic

Definition at line 222 of file amapInt.h.

222 { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
static Amap_Obj_t* Amap_NotCond ( Amap_Obj_t p,
int  c 
)
inlinestatic

Definition at line 223 of file amapInt.h.

223 { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
static Amap_Obj_t* Amap_ObjChoice ( Amap_Man_t p,
Amap_Obj_t pObj 
)
inlinestatic

Definition at line 258 of file amapInt.h.

258 { return pObj->Equiv? Amap_ManObj(p, pObj->Equiv) : NULL; }
int Equiv
Definition: amapInt.h:209
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static void* Amap_ObjCopy ( Amap_Obj_t pObj)
inlinestatic

Definition at line 254 of file amapInt.h.

254 { return pObj->pData; }
void * pData
Definition: amapInt.h:212
static Amap_Obj_t* Amap_ObjFanin0 ( Amap_Man_t p,
Amap_Obj_t pObj 
)
inlinestatic

Definition at line 248 of file amapInt.h.

248 { return Amap_ManObj(p, Abc_Lit2Var(pObj->Fan[0])); }
int Fan[3]
Definition: amapInt.h:210
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Amap_Obj_t* Amap_ObjFanin1 ( Amap_Man_t p,
Amap_Obj_t pObj 
)
inlinestatic

Definition at line 249 of file amapInt.h.

249 { return Amap_ManObj(p, Abc_Lit2Var(pObj->Fan[1])); }
int Fan[3]
Definition: amapInt.h:210
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Amap_Obj_t* Amap_ObjFanin2 ( Amap_Man_t p,
Amap_Obj_t pObj 
)
inlinestatic

Definition at line 250 of file amapInt.h.

250 { return Amap_ManObj(p, Abc_Lit2Var(pObj->Fan[2])); }
int Fan[3]
Definition: amapInt.h:210
static Amap_Obj_t * Amap_ManObj(Amap_Man_t *p, int i)
Definition: amapInt.h:237
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Amap_ObjFaninC0 ( Amap_Obj_t pObj)
inlinestatic

Definition at line 251 of file amapInt.h.

251 { return Abc_LitIsCompl(pObj->Fan[0]); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
int Fan[3]
Definition: amapInt.h:210
static int Amap_ObjFaninC1 ( Amap_Obj_t pObj)
inlinestatic

Definition at line 252 of file amapInt.h.

252 { return Abc_LitIsCompl(pObj->Fan[1]); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
int Fan[3]
Definition: amapInt.h:210
static int Amap_ObjFaninC2 ( Amap_Obj_t pObj)
inlinestatic

Definition at line 253 of file amapInt.h.

253 { return Abc_LitIsCompl(pObj->Fan[2]); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
int Fan[3]
Definition: amapInt.h:210
static int Amap_ObjIsAnd ( Amap_Obj_t pObj)
inlinestatic

Definition at line 242 of file amapInt.h.

242 { return pObj->Type == AMAP_OBJ_AND; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsConst1 ( Amap_Obj_t pObj)
inlinestatic

Definition at line 239 of file amapInt.h.

239 { return pObj->Type == AMAP_OBJ_CONST1; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsMux ( Amap_Obj_t pObj)
inlinestatic

Definition at line 244 of file amapInt.h.

244 { return pObj->Type == AMAP_OBJ_MUX; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsNode ( Amap_Obj_t pObj)
inlinestatic

Definition at line 245 of file amapInt.h.

245 { return pObj->Type == AMAP_OBJ_AND || pObj->Type == AMAP_OBJ_XOR || pObj->Type == AMAP_OBJ_MUX; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsPi ( Amap_Obj_t pObj)
inlinestatic

Definition at line 240 of file amapInt.h.

240 { return pObj->Type == AMAP_OBJ_PI; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsPo ( Amap_Obj_t pObj)
inlinestatic

Definition at line 241 of file amapInt.h.

241 { return pObj->Type == AMAP_OBJ_PO; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjIsXor ( Amap_Obj_t pObj)
inlinestatic

Definition at line 243 of file amapInt.h.

243 { return pObj->Type == AMAP_OBJ_XOR; }
unsigned Type
Definition: amapInt.h:200
static int Amap_ObjLevel ( Amap_Obj_t pObj)
inlinestatic

Definition at line 255 of file amapInt.h.

255 { return pObj->Level; }
unsigned Level
Definition: amapInt.h:206
static int Amap_ObjPhaseReal ( Amap_Obj_t pObj)
inlinestatic

Definition at line 260 of file amapInt.h.

260 { return Amap_Regular(pObj)->fPhase ^ Amap_IsComplement(pObj); }
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
static int Amap_IsComplement(Amap_Obj_t *p)
Definition: amapInt.h:224
unsigned fPhase
Definition: amapInt.h:203
static int Amap_ObjRefsTotal ( Amap_Obj_t pObj)
inlinestatic

Definition at line 261 of file amapInt.h.

261 { return pObj->nFouts[0] + pObj->nFouts[1]; }
int nFouts[2]
Definition: amapInt.h:217
static void Amap_ObjSetChoice ( Amap_Obj_t pObj,
Amap_Obj_t pEqu 
)
inlinestatic

Definition at line 259 of file amapInt.h.

259 { assert(pObj->Equiv==0); pObj->Equiv = pEqu->Id; }
unsigned Id
Definition: amapInt.h:201
int Equiv
Definition: amapInt.h:209
#define assert(ex)
Definition: util_old.h:213
static void Amap_ObjSetCopy ( Amap_Obj_t pObj,
void *  pCopy 
)
inlinestatic

Definition at line 257 of file amapInt.h.

257 { pObj->pData = pCopy; }
void * pData
Definition: amapInt.h:212
static void Amap_ObjSetLevel ( Amap_Obj_t pObj,
int  Level 
)
inlinestatic

Definition at line 256 of file amapInt.h.

256 { pObj->Level = Level; }
unsigned Level
Definition: amapInt.h:206
static int Amap_ObjToLit ( Amap_Obj_t pObj)
inlinestatic

Definition at line 247 of file amapInt.h.

247 { return Abc_Var2Lit( Amap_Regular(pObj)->Id, Amap_IsComplement(pObj) ); }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static Amap_Obj_t * Amap_Regular(Amap_Obj_t *p)
Definition: amapInt.h:221
static int Amap_IsComplement(Amap_Obj_t *p)
Definition: amapInt.h:224
static Amap_Obj_t* Amap_Regular ( Amap_Obj_t p)
inlinestatic

Definition at line 221 of file amapInt.h.

221 { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
void Kit_DsdPrintFromTruth ( unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 490 of file kitDsd.c.

491 {
492  Kit_DsdNtk_t * pTemp, * pTemp2;
493 // pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
494  pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
495 // Kit_DsdPrintExpanded( pTemp );
496  pTemp2 = Kit_DsdExpand( pTemp );
497  Kit_DsdPrint( stdout, pTemp2 );
498  Kit_DsdVerify( pTemp2, pTruth, nVars );
499  Kit_DsdNtkFree( pTemp2 );
500  Kit_DsdNtkFree( pTemp );
501 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350