ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioReadBblif.c File Reference
#include "ioAbc.h"
#include "bool/dec/dec.h"
#include "misc/bbl/bblif.h"
Include dependency graph for ioReadBblif.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Abc_Ntk_tBbl_ManToAbc (Bbl_Man_t *p)
 DECLARATIONS ///.
 
void Bbl_ManDfs_rec (Bbl_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tBbl_ManDfs (Bbl_Man_t *p)
 
Abc_Ntk_tBbl_ManToAig (Bbl_Man_t *p)
 
void Bbl_ManVerify (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2)
 
void Bbl_ManTest (Abc_Ntk_t *pNtk)
 
Abc_Ntk_tIo_ReadBblif (char *pFileName, int fCheck)
 

Function Documentation

◆ Bbl_ManDfs()

Vec_Ptr_t * Bbl_ManDfs ( Bbl_Man_t * p)

Fnction*************************************************************

Synopsis [Collects internal nodes in the DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 128 of file ioReadBblif.c.

129{
130 Vec_Ptr_t * vNodes;
131 Bbl_Obj_t * pObj;
132 vNodes = Vec_PtrAlloc( 1000 );
133 Bbl_ManForEachObj( p, pObj )
134 if ( Bbl_ObjIsLut(pObj) )
135 Bbl_ManDfs_rec( pObj, vNodes );
136 return vNodes;
137}
int Bbl_ObjIsLut(Bbl_Obj_t *p)
Definition bblif.c:1095
struct Bbl_Obj_t_ Bbl_Obj_t
Definition bblif.h:216
#define Bbl_ManForEachObj(p, pObj)
Definition bblif.h:257
Cube * p
Definition exorList.c:222
void Bbl_ManDfs_rec(Bbl_Obj_t *pObj, Vec_Ptr_t *vNodes)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bbl_ManDfs_rec()

void Bbl_ManDfs_rec ( Bbl_Obj_t * pObj,
Vec_Ptr_t * vNodes )

Fnction*************************************************************

Synopsis [Collects internal nodes in the DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file ioReadBblif.c.

104{
105 extern void Bbl_ObjMark( Bbl_Obj_t * p );
106 extern int Bbl_ObjIsMarked( Bbl_Obj_t * p );
107 Bbl_Obj_t * pFanin;
108 if ( Bbl_ObjIsMarked(pObj) || Bbl_ObjIsInput(pObj) )
109 return;
110 Bbl_ObjForEachFanin( pObj, pFanin )
111 Bbl_ManDfs_rec( pFanin, vNodes );
112 assert( !Bbl_ObjIsMarked(pObj) ); // checks if acyclic
113 Bbl_ObjMark( pObj );
114 Vec_PtrPush( vNodes, pObj );
115}
int Bbl_ObjIsInput(Bbl_Obj_t *p)
Definition bblif.c:1093
int Bbl_ObjIsMarked(Bbl_Obj_t *p)
Definition bblif.c:1100
void Bbl_ObjMark(Bbl_Obj_t *p)
Definition bblif.c:1101
#define Bbl_ObjForEachFanin(pObj, pFanin)
Definition bblif.h:260
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bbl_ManTest()

void Bbl_ManTest ( Abc_Ntk_t * pNtk)

Fnction*************************************************************

Synopsis [Performs testing of the new manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 267 of file ioReadBblif.c.

268{
269 extern Bbl_Man_t * Bbl_ManFromAbc( Abc_Ntk_t * pNtk );
270
271 Abc_Ntk_t * pNtkNew;
272 Bbl_Man_t * p, * pNew;
273 char * pFileName = "test.bblif";
274 abctime clk, clk1, clk2, clk3, clk4, clk5;
275clk = Abc_Clock();
276 p = Bbl_ManFromAbc( pNtk );
278clk1 = Abc_Clock() - clk;
279//Bbl_ManDumpBlif( p, "test_bbl.blif" );
280
281 // write into file and back
282clk = Abc_Clock();
283 Bbl_ManDumpBinaryBlif( p, pFileName );
284clk2 = Abc_Clock() - clk;
285
286 // read from file
287clk = Abc_Clock();
288 pNew = Bbl_ManReadBinaryBlif( pFileName );
289 Bbl_ManStop( p ); p = pNew;
290clk3 = Abc_Clock() - clk;
291
292 // generate ABC network
293clk = Abc_Clock();
294 pNtkNew = Bbl_ManToAig( p );
295// pNtkNew = Bbl_ManToAbc( p );
296 Bbl_ManStop( p );
297clk4 = Abc_Clock() - clk;
298
299 // equivalence check
300clk = Abc_Clock();
301// Bbl_ManVerify( pNtk, pNtkNew );
302 Abc_NtkDelete( pNtkNew );
303clk5 = Abc_Clock() - clk;
304
305printf( "Runtime stats:\n" );
306ABC_PRT( "ABC to Man", clk1 );
307ABC_PRT( "Writing ", clk2 );
308ABC_PRT( "Reading ", clk3 );
309ABC_PRT( "Man to ABC", clk4 );
310ABC_PRT( "Verify ", clk5 );
311}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
void Bbl_ManPrintStats(Bbl_Man_t *p)
Definition bblif.c:749
Bbl_Man_t * Bbl_ManReadBinaryBlif(char *pFileName)
Definition bblif.c:712
void Bbl_ManDumpBinaryBlif(Bbl_Man_t *p, char *pFileName)
Definition bblif.c:691
void Bbl_ManStop(Bbl_Man_t *p)
Definition bblif.c:775
struct Bbl_Man_t_ Bbl_Man_t
Definition bblif.h:213
Abc_Ntk_t * Bbl_ManToAig(Bbl_Man_t *p)
ABC_NAMESPACE_IMPL_START Bbl_Man_t * Bbl_ManFromAbc(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Here is the call graph for this function:

◆ Bbl_ManToAbc()

DECLARATIONS ///.

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

FileName [ioReadBblif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to read AIG in the binary format.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] FUNCTION DEFINITIONS /// Fnction*************************************************************

Synopsis [Constructs ABC network from the manager.]

Description [The ABC network is started, as well as the array vCopy, which will map the new ID of each object in the BBLIF manager into the ponter ot the corresponding object in the ABC. For each internal node, determined by Bbl_ObjIsLut(), the SOP representation is created by retrieving the SOP representation of the BBLIF object. Finally, the objects are connected using fanin/fanout creation, and the dummy names are assigned because ABC requires each CI/CO to have a name.]

SideEffects []

SeeAlso []

Definition at line 55 of file ioReadBblif.c.

56{
57 Abc_Ntk_t * pNtk;
58 Abc_Obj_t * pObjNew = NULL;
59 Bbl_Obj_t * pObj, * pFanin;
60 Vec_Ptr_t * vCopy;
61 // start the network
64 // create objects
65 vCopy = Vec_PtrStart( 1000 );
66 Bbl_ManForEachObj( p, pObj )
67 {
68 if ( Bbl_ObjIsInput(pObj) )
69 pObjNew = Abc_NtkCreatePi( pNtk );
70 else if ( Bbl_ObjIsOutput(pObj) )
71 pObjNew = Abc_NtkCreatePo( pNtk );
72 else if ( Bbl_ObjIsLut(pObj) )
73 pObjNew = Abc_NtkCreateNode( pNtk );
74 else assert( 0 );
75 if ( Bbl_ObjIsLut(pObj) )
76 pObjNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, Bbl_ObjSop(p, pObj) );
77 Vec_PtrSetEntry( vCopy, Bbl_ObjId(pObj), pObjNew );
78 }
79 // connect objects
80 Bbl_ManForEachObj( p, pObj )
81 Bbl_ObjForEachFanin( pObj, pFanin )
82 Abc_ObjAddFanin( (Abc_Obj_t *)Vec_PtrEntry(vCopy, Bbl_ObjId(pObj)), (Abc_Obj_t *)Vec_PtrEntry(vCopy, Bbl_ObjId(pFanin)) );
83 // finalize
84 Vec_PtrFree( vCopy );
87 if ( !Abc_NtkCheck( pNtk ) )
88 printf( "Bbl_ManToAbc(): Network check has failed.\n" );
89 return pNtk;
90}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
char * Bbl_ManName(Bbl_Man_t *p)
Definition bblif.c:1115
int Bbl_ObjIsOutput(Bbl_Obj_t *p)
Definition bblif.c:1094
char * Bbl_ObjSop(Bbl_Man_t *pMan, Bbl_Obj_t *p)
Definition bblif.c:1099
int Bbl_ObjId(Bbl_Obj_t *p)
Definition bblif.c:1096
char * Extra_UtilStrsav(const char *s)
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
char * pName
Definition abc.h:158
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
Here is the call graph for this function:

◆ Bbl_ManToAig()

Abc_Ntk_t * Bbl_ManToAig ( Bbl_Man_t * p)

Fnction*************************************************************

Synopsis [Constructs AIG in ABC from the manager.]

Description [The ABC network is started, as well as the array vCopy, which will map the new ID of each object in the BBLIF manager into the ponter ot the corresponding AIG object in the ABC. For each internal node in a topological oder the AIG representation is created by factoring the SOP representation of the BBLIF object. Finally, the CO objects are created, and the dummy names are assigned because ABC requires each CI/CO to have a name.]

SideEffects []

SeeAlso []

Definition at line 156 of file ioReadBblif.c.

157{
158 extern int Bbl_ManFncSize( Bbl_Man_t * p );
159 extern int Bbl_ObjFncHandle( Bbl_Obj_t * p );
160 extern Abc_Obj_t * Dec_GraphToAig( Abc_Ntk_t * pNtk, Dec_Graph_t * pFForm, Vec_Ptr_t * vFaninAigs );
161 int fVerbose = 0;
162 Abc_Ntk_t * pNtk;
163 Abc_Obj_t * pObjNew = NULL;
164 Bbl_Obj_t * pObj, * pFanin;
165 Vec_Ptr_t * vCopy, * vNodes, * vFaninAigs;
166 Dec_Graph_t ** pFForms;
167 int i;
168 abctime clk;
169clk = Abc_Clock();
170 // map SOP handles into factored forms
171 pFForms = ABC_CALLOC( Dec_Graph_t *, Bbl_ManFncSize(p) );
172 Bbl_ManForEachObj( p, pObj )
173 if ( pFForms[Bbl_ObjFncHandle(pObj)] == NULL )
174 pFForms[Bbl_ObjFncHandle(pObj)] = Dec_Factor( Bbl_ObjSop(p, pObj) );
175if ( fVerbose )
176ABC_PRT( "Fct", Abc_Clock() - clk );
177 // start the network
180 vCopy = Vec_PtrStart( 1000 );
181 // create CIs
182 Bbl_ManForEachObj( p, pObj )
183 {
184 if ( !Bbl_ObjIsInput(pObj) )
185 continue;
186 Vec_PtrSetEntry( vCopy, Bbl_ObjId(pObj), Abc_NtkCreatePi(pNtk) );
187 }
188clk = Abc_Clock();
189 // create internal nodes
190 vNodes = Bbl_ManDfs( p );
191 vFaninAigs = Vec_PtrAlloc( 100 );
192 Vec_PtrForEachEntry( Bbl_Obj_t *, vNodes, pObj, i )
193 {
194 // collect fanin AIGs
195 Vec_PtrClear( vFaninAigs );
196 Bbl_ObjForEachFanin( pObj, pFanin )
197 Vec_PtrPush( vFaninAigs, Vec_PtrEntry( vCopy, Bbl_ObjId(pFanin) ) );
198 // create the new node
199 pObjNew = Dec_GraphToAig( pNtk, pFForms[Bbl_ObjFncHandle(pObj)], vFaninAigs );
200 Vec_PtrSetEntry( vCopy, Bbl_ObjId(pObj), pObjNew );
201 }
202 Vec_PtrFree( vFaninAigs );
203 Vec_PtrFree( vNodes );
204if ( fVerbose )
205ABC_PRT( "AIG", Abc_Clock() - clk );
206 // create COs
207 Bbl_ManForEachObj( p, pObj )
208 {
209 if ( !Bbl_ObjIsOutput(pObj) )
210 continue;
211 pObjNew = (Abc_Obj_t *)Vec_PtrEntry( vCopy, Bbl_ObjId(Bbl_ObjFaninFirst(pObj)) );
212 Abc_ObjAddFanin( Abc_NtkCreatePo(pNtk), pObjNew );
213 }
215 // clear factored forms
216 for ( i = Bbl_ManFncSize(p) - 1; i >= 0; i-- )
217 if ( pFForms[i] )
218 Dec_GraphFree( pFForms[i] );
219 ABC_FREE( pFForms );
220 // finalize
221clk = Abc_Clock();
222 Vec_PtrFree( vCopy );
225if ( fVerbose )
226ABC_PRT( "Nam", Abc_Clock() - clk );
227// if ( !Abc_NtkCheck( pNtk ) )
228// printf( "Bbl_ManToAig(): Network check has failed.\n" );
229 return pNtk;
230}
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
@ ABC_NTK_STRASH
Definition abc.h:58
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition abcAig.c:194
@ ABC_FUNC_AIG
Definition abc.h:67
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
int Bbl_ManFncSize(Bbl_Man_t *p)
Definition bblif.c:1131
Bbl_Obj_t * Bbl_ObjFaninFirst(Bbl_Obj_t *p)
Definition bblif.c:1181
int Bbl_ObjFncHandle(Bbl_Obj_t *p)
Definition bblif.c:1102
Abc_Obj_t * Dec_GraphToAig(Abc_Ntk_t *pNtk, Dec_Graph_t *pFForm, Vec_Ptr_t *vFaninAigs)
Definition decAbc.c:104
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition decFactor.c:58
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
Vec_Ptr_t * Bbl_ManDfs(Bbl_Man_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bbl_ManVerify()

void Bbl_ManVerify ( Abc_Ntk_t * pNtk1,
Abc_Ntk_t * pNtk2 )

Fnction*************************************************************

Synopsis [Verifies equivalence for two combinational networks.]

Description []

SideEffects []

SeeAlso []

Definition at line 243 of file ioReadBblif.c.

244{
245 extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
246 Abc_Ntk_t * pAig1, * pAig2;
247 pAig1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
248 pAig2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
249 Abc_NtkShortNames( pAig1 );
250 Abc_NtkShortNames( pAig2 );
251 Abc_NtkCecFraig( pAig1, pAig2, 0, 0 );
252 Abc_NtkDelete( pAig1 );
253 Abc_NtkDelete( pAig2 );
254}
void Abc_NtkCecFraig(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int nSeconds, int fVerbose)
Definition abcVerify.c:123
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition abcStrash.c:265
ABC_DLL void Abc_NtkShortNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:619
Here is the call graph for this function:

◆ Io_ReadBblif()

Abc_Ntk_t * Io_ReadBblif ( char * pFileName,
int fCheck )

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

Synopsis [Reads the AIG in the binary format.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file ioReadBblif.c.

325{
326 Bbl_Man_t * p;
327 Abc_Ntk_t * pNtkNew;
328 // read the file
329 p = Bbl_ManReadBinaryBlif( pFileName );
330 pNtkNew = Bbl_ManToAig( p );
331 Bbl_ManStop( p );
332 // check the result
333 if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
334 {
335 printf( "Io_ReadBaf: The network check has failed.\n" );
336 Abc_NtkDelete( pNtkNew );
337 return NULL;
338 }
339 return pNtkNew;
340}
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
Here is the call graph for this function:
Here is the caller graph for this function: