abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcMini.c File Reference
#include "base/abc/abc.h"
#include "base/main/main.h"
#include "aig/miniaig/miniaig.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Abc_Obj_t
Abc_NodeFanin0Copy (Abc_Ntk_t *pNtk, Vec_Int_t *vCopies, Mini_Aig_t *p, int Id)
 DECLARATIONS ///. More...
 
Abc_Obj_tAbc_NodeFanin1Copy (Abc_Ntk_t *pNtk, Vec_Int_t *vCopies, Mini_Aig_t *p, int Id)
 
Abc_Ntk_tAbc_NtkFromMiniAig (Mini_Aig_t *p)
 
int Abc_NodeFanin0Copy2 (Abc_Obj_t *pObj)
 
int Abc_NodeFanin1Copy2 (Abc_Obj_t *pObj)
 
Mini_Aig_tAbc_NtkToMiniAig (Abc_Ntk_t *pNtk)
 
void Abc_NtkInputMiniAig (Abc_Frame_t *pAbc, void *p)
 
void * Abc_NtkOutputMiniAig (Abc_Frame_t *pAbc)
 
void Abc_NtkMiniAigTest (Abc_Ntk_t *pNtk)
 

Function Documentation

ABC_NAMESPACE_IMPL_START Abc_Obj_t* Abc_NodeFanin0Copy ( Abc_Ntk_t pNtk,
Vec_Int_t vCopies,
Mini_Aig_t p,
int  Id 
)

DECLARATIONS ///.

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

FileName [abcMini.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Interface to the minimalistic AIG package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Converts the network from the AIG manager into ABC.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file abcMini.c.

49 {
50  int Lit = Mini_AigNodeFanin0( p, Id );
51  int AbcLit = Abc_LitNotCond( Vec_IntEntry(vCopies, Abc_Lit2Var(Lit)), Abc_LitIsCompl(Lit) );
52  return Abc_ObjFromLit( pNtk, AbcLit );
53 }
static Abc_Obj_t * Abc_ObjFromLit(Abc_Ntk_t *p, int iLit)
Definition: abc.h:390
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Mini_AigNodeFanin0(Mini_Aig_t *p, int Id)
Definition: miniaig.h:89
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Abc_NodeFanin0Copy2 ( Abc_Obj_t pObj)

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

Synopsis [Converts the network from ABC into the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file abcMini.c.

116 {
117  return Abc_LitNotCond( Abc_ObjFanin0(pObj)->iTemp, Abc_ObjFaninC0(pObj) );
118 }
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Abc_Obj_t* Abc_NodeFanin1Copy ( Abc_Ntk_t pNtk,
Vec_Int_t vCopies,
Mini_Aig_t p,
int  Id 
)

Definition at line 54 of file abcMini.c.

55 {
56  int Lit = Mini_AigNodeFanin1( p, Id );
57  int AbcLit = Abc_LitNotCond( Vec_IntEntry(vCopies, Abc_Lit2Var(Lit)), Abc_LitIsCompl(Lit) );
58  return Abc_ObjFromLit( pNtk, AbcLit );
59 }
static Abc_Obj_t * Abc_ObjFromLit(Abc_Ntk_t *p, int iLit)
Definition: abc.h:390
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Mini_AigNodeFanin1(Mini_Aig_t *p, int Id)
Definition: miniaig.h:94
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Abc_NodeFanin1Copy2 ( Abc_Obj_t pObj)

Definition at line 119 of file abcMini.c.

120 {
121  return Abc_LitNotCond( Abc_ObjFanin1(pObj)->iTemp, Abc_ObjFaninC1(pObj) );
122 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Abc_Ntk_t* Abc_NtkFromMiniAig ( Mini_Aig_t p)

Definition at line 60 of file abcMini.c.

61 {
62  Abc_Ntk_t * pNtk;
63  Abc_Obj_t * pObj;
64  Vec_Int_t * vCopies;
65  int i, nNodes;
66  // get the number of nodes
67  nNodes = Mini_AigNodeNum(p);
68  // create ABC network
70  pNtk->pName = Abc_UtilStrsav( "MiniAig" );
71  // create mapping from MiniAIG objects into ABC objects
72  vCopies = Vec_IntAlloc( nNodes );
74  // iterate through the objects
75  for ( i = 1; i < nNodes; i++ )
76  {
77  if ( Mini_AigNodeIsPi( p, i ) )
78  pObj = Abc_NtkCreatePi(pNtk);
79  else if ( Mini_AigNodeIsPo( p, i ) )
80  Abc_ObjAddFanin( (pObj = Abc_NtkCreatePo(pNtk)), Abc_NodeFanin0Copy(pNtk, vCopies, p, i) );
81  else if ( Mini_AigNodeIsAnd( p, i ) )
82  pObj = Abc_AigAnd((Abc_Aig_t *)pNtk->pManFunc, Abc_NodeFanin0Copy(pNtk, vCopies, p, i), Abc_NodeFanin1Copy(pNtk, vCopies, p, i));
83  else assert( 0 );
84  Vec_IntPush( vCopies, Abc_ObjToLit(pObj) );
85  }
86  assert( Vec_IntSize(vCopies) == nNodes );
87  Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
88  Vec_IntFree( vCopies );
89  Abc_NtkAddDummyPiNames( pNtk );
90  Abc_NtkAddDummyPoNames( pNtk );
91  if ( !Abc_NtkCheck( pNtk ) )
92  fprintf( stdout, "Abc_NtkFromMini(): Network check has failed.\n" );
93  // add latches
94  if ( Mini_AigRegNum(p) > 0 )
95  {
96  extern Abc_Ntk_t * Abc_NtkRestrashWithLatches( Abc_Ntk_t * pNtk, int nLatches );
97  Abc_Ntk_t * pTemp;
98  pNtk = Abc_NtkRestrashWithLatches( pTemp = pNtk, Mini_AigRegNum(p) );
99  Abc_NtkDelete( pTemp );
100  }
101  return pNtk;
102 }
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Mini_AigNodeIsPi(Mini_Aig_t *p, int Id)
Definition: miniaig.h:116
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Mini_AigRegNum(Mini_Aig_t *p)
Definition: miniaig.h:121
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static int Mini_AigNodeIsPo(Mini_Aig_t *p, int Id)
Definition: miniaig.h:117
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:398
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition: abcAig.c:194
static int Mini_AigNodeIsAnd(Mini_Aig_t *p, int Id)
Definition: miniaig.h:118
Abc_Ntk_t * Abc_NtkRestrashWithLatches(Abc_Ntk_t *pNtk, int nLatches)
Definition: abcNtk.c:528
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NodeFanin0Copy(Abc_Ntk_t *pNtk, Vec_Int_t *vCopies, Mini_Aig_t *p, int Id)
DECLARATIONS ///.
Definition: abcMini.c:48
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Mini_AigNodeNum(Mini_Aig_t *p)
Definition: miniaig.h:114
Abc_Obj_t * Abc_NodeFanin1Copy(Abc_Ntk_t *pNtk, Vec_Int_t *vCopies, Mini_Aig_t *p, int Id)
Definition: abcMini.c:54
static int Abc_ObjToLit(Abc_Obj_t *p)
Definition: abc.h:391
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
void Abc_NtkInputMiniAig ( Abc_Frame_t pAbc,
void *  p 
)

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

Synopsis [Procedures to update internal ABC network using AIG node array.]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file abcMini.c.

160 {
161  Abc_Ntk_t * pNtk;
162  if ( pAbc == NULL )
163  printf( "ABC framework is not initialized by calling Abc_Start()\n" );
164  pNtk = Abc_NtkFromMiniAig( (Mini_Aig_t *)p );
165  Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
166 // Abc_NtkDelete( pNtk );
167 }
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:493
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Abc_Ntk_t * Abc_NtkFromMiniAig(Mini_Aig_t *p)
Definition: abcMini.c:60
void Abc_NtkMiniAigTest ( Abc_Ntk_t pNtk)

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

Synopsis [Testing the above code.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file abcMini.c.

192 {
193  Abc_Ntk_t * pNtkNew;
194  Mini_Aig_t * p;
195  p = Abc_NtkToMiniAig( pNtk );
196  pNtkNew = Abc_NtkFromMiniAig( p );
197  Mini_AigStop( p );
198  Abc_NtkPrintStats( pNtkNew, 0, 0, 0, 0, 0, 0, 0, 0 );
199  Abc_NtkDelete( pNtkNew );
200 
201  // test dumping
202  p = Abc_NtkToMiniAig( pNtk );
203  Mini_AigDump( p, "miniaig.data" );
204  Mini_AigPrintStats( p );
205  Mini_AigStop( p );
206 
207  p = Mini_AigLoad( "miniaig.data" );
208  Mini_AigPrintStats( p );
209  Mini_AigStop( p );
210 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static Mini_Aig_t * Mini_AigLoad(char *pFileName)
Definition: miniaig.h:176
static void Mini_AigStop(Mini_Aig_t *p)
Definition: miniaig.h:140
ABC_DLL void Abc_NtkPrintStats(Abc_Ntk_t *pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch, int fSkipBuf)
Definition: abcPrint.c:207
static void Mini_AigPrintStats(Mini_Aig_t *p)
Definition: miniaig.h:145
Mini_Aig_t * Abc_NtkToMiniAig(Abc_Ntk_t *pNtk)
Definition: abcMini.c:123
static void Mini_AigDump(Mini_Aig_t *p, char *pFileName)
Definition: miniaig.h:161
Abc_Ntk_t * Abc_NtkFromMiniAig(Mini_Aig_t *p)
Definition: abcMini.c:60
void* Abc_NtkOutputMiniAig ( Abc_Frame_t pAbc)

Definition at line 168 of file abcMini.c.

169 {
170  Abc_Ntk_t * pNtk;
171  if ( pAbc == NULL )
172  printf( "ABC framework is not initialized by calling Abc_Start()\n" );
173  pNtk = Abc_FrameReadNtk( pAbc );
174  if ( pNtk == NULL )
175  printf( "Current network in ABC framework is not defined.\n" );
176  return Abc_NtkToMiniAig( pNtk );
177 }
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
Mini_Aig_t * Abc_NtkToMiniAig(Abc_Ntk_t *pNtk)
Definition: abcMini.c:123
Mini_Aig_t* Abc_NtkToMiniAig ( Abc_Ntk_t pNtk)

Definition at line 123 of file abcMini.c.

124 {
125  Mini_Aig_t * p;
126  Abc_Obj_t * pObj;
127  int i;
128  assert( Abc_NtkIsStrash(pNtk) );
129  // create the manager
130  p = Mini_AigStart();
131  // create mapping from MiniAIG into ABC objects
132  Abc_NtkCleanCopy( pNtk );
134  // create primary inputs
135  Abc_NtkForEachCi( pNtk, pObj, i )
136  pObj->iTemp = Mini_AigCreatePi(p);
137  // create internal nodes
138  Abc_NtkForEachNode( pNtk, pObj, i )
139  pObj->iTemp = Mini_AigAnd( p, Abc_NodeFanin0Copy2(pObj), Abc_NodeFanin1Copy2(pObj) );
140  // create primary outputs
141  Abc_NtkForEachCo( pNtk, pObj, i )
142  pObj->iTemp = Mini_AigCreatePo( p, Abc_NodeFanin0Copy2(pObj) );
143  // set registers
145  return p;
146 }
int iTemp
Definition: abc.h:149
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static void Mini_AigSetRegNum(Mini_Aig_t *p, int n)
Definition: miniaig.h:122
static int Mini_AigLitConst1()
Definition: miniaig.h:109
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static Mini_Aig_t * Mini_AigStart()
Definition: miniaig.h:131
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Mini_AigCreatePo(Mini_Aig_t *p, int Lit0)
Definition: miniaig.h:206
static int Mini_AigCreatePi(Mini_Aig_t *p)
Definition: miniaig.h:200
int Abc_NodeFanin0Copy2(Abc_Obj_t *pObj)
Definition: abcMini.c:115
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Mini_AigAnd(Mini_Aig_t *p, int Lit0, int Lit1)
Definition: miniaig.h:215
int Abc_NodeFanin1Copy2(Abc_Obj_t *pObj)
Definition: abcMini.c:119
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213