abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteBblif.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [ioWriteBblif.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Command processing package.]
8 
9  Synopsis [Procedures to write AIG in the binary format.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: ioWriteBblif.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "ioAbc.h"
22 #include "misc/bbl/bblif.h"
23 
25 
26 
27 // For description of Binary BLIF format, refer to "abc/src/aig/bbl/bblif.h"
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// DECLARATIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 ////////////////////////////////////////////////////////////////////////
34 /// FUNCTION DEFINITIONS ///
35 ////////////////////////////////////////////////////////////////////////
36 
37 /**Fnction*************************************************************
38 
39  Synopsis [Construct manager from the ABC network.]
40 
41  Description [In the ABC network each object has a unique integer ID.
42  This ID is used when we construct objects of the BBLIF manager
43  corresponding to each object of the ABC network. The objects can be
44  added to the manager in any order (although below they are added in the
45  topological order), but by the time fanin/fanout connections are created,
46  corresponding objects are already constructed. In the end the checking
47  procedure is called.]
48 
49  SideEffects []
50 
51  SeeAlso []
52 
53 ***********************************************************************/
55 {
56  Bbl_Man_t * p;
57  Vec_Ptr_t * vNodes;
58  Abc_Obj_t * pObj, * pFanin;
59  int i, k;
60  assert( Abc_NtkIsSopLogic(pNtk) );
61  // start the data manager
62  p = Bbl_ManStart( Abc_NtkName(pNtk) );
63  // collect internal nodes to be added
64  vNodes = Abc_NtkDfs( pNtk, 0 );
65  // create combinational inputs
66  Abc_NtkForEachCi( pNtk, pObj, i )
67  Bbl_ManCreateObject( p, BBL_OBJ_CI, Abc_ObjId(pObj), 0, NULL );
68  // create internal nodes
69  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
70  Bbl_ManCreateObject( p, BBL_OBJ_NODE, Abc_ObjId(pObj), Abc_ObjFaninNum(pObj), (char *)pObj->pData );
71  // create combinational outputs
72  Abc_NtkForEachCo( pNtk, pObj, i )
73  Bbl_ManCreateObject( p, BBL_OBJ_CO, Abc_ObjId(pObj), 1, NULL );
74  // create fanin/fanout connections for internal nodes
75  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
76  Abc_ObjForEachFanin( pObj, pFanin, k )
77  Bbl_ManAddFanin( p, Abc_ObjId(pObj), Abc_ObjId(pFanin) );
78  // create fanin/fanout connections for combinational outputs
79  Abc_NtkForEachCo( pNtk, pObj, i )
80  Abc_ObjForEachFanin( pObj, pFanin, k )
81  Bbl_ManAddFanin( p, Abc_ObjId(pObj), Abc_ObjId(pFanin) );
82  Vec_PtrFree( vNodes );
83  // sanity check
84  Bbl_ManCheck( p );
85  return p;
86 }
87 
88 /**Function*************************************************************
89 
90  Synopsis [Writes the AIG in the binary format.]
91 
92  Description []
93 
94  SideEffects []
95 
96  SeeAlso []
97 
98 ***********************************************************************/
99 void Io_WriteBblif( Abc_Ntk_t * pNtk, char * pFileName )
100 {
101  Bbl_Man_t * p;
102  p = Bbl_ManFromAbc( pNtk );
103 //Bbl_ManPrintStats( p );
104 //Bbl_ManDumpBlif( p, "test_bbl.blif" );
105  Bbl_ManDumpBinaryBlif( p, pFileName );
106  Bbl_ManStop( p );
107 }
108 
109 
110 ////////////////////////////////////////////////////////////////////////
111 /// END OF FILE ///
112 ////////////////////////////////////////////////////////////////////////
113 
114 
116 
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Bbl_ManAddFanin(Bbl_Man_t *p, int ObjId, int FaninId)
Definition: bblif.c:1023
Bbl_Man_t * Bbl_ManStart(char *pName)
MACRO DEFINITIONS ///.
Definition: bblif.c:806
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Io_WriteBblif(Abc_Ntk_t *pNtk, char *pFileName)
Definition: ioWriteBblif.c:99
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:264
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
ABC_NAMESPACE_IMPL_START Bbl_Man_t * Bbl_ManFromAbc(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBblif.c:54
int Bbl_ManCheck(Bbl_Man_t *p)
Definition: bblif.c:1062
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#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
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Bbl_ManDumpBinaryBlif(Bbl_Man_t *p, char *pFileName)
Definition: bblif.c:691
void Bbl_ManStop(Bbl_Man_t *p)
Definition: bblif.c:775
void Bbl_ManCreateObject(Bbl_Man_t *p, Bbl_Type_t Type, int ObjId, int nFanins, char *pSop)
Definition: bblif.c:988
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223