Commit f6a7f695 by Alan Mishchenko

Improvements to Cba data-structure.

parent bab71101
......@@ -38,9 +38,9 @@ static int Bac_CommandClp ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Bac_CommandCec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Bac_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
static inline Bac_Man_t * Bac_AbcGetMan( Abc_Frame_t * pAbc ) { return (Bac_Man_t *)pAbc->pAbcCba; }
static inline void Bac_AbcFreeMan( Abc_Frame_t * pAbc ) { if ( pAbc->pAbcCba ) Bac_ManFree(Bac_AbcGetMan(pAbc)); }
static inline void Bac_AbcUpdateMan( Abc_Frame_t * pAbc, Bac_Man_t * p ) { Bac_AbcFreeMan(pAbc); pAbc->pAbcCba = p; }
static inline Bac_Man_t * Bac_AbcGetMan( Abc_Frame_t * pAbc ) { return (Bac_Man_t *)pAbc->pAbcBac; }
static inline void Bac_AbcFreeMan( Abc_Frame_t * pAbc ) { if ( pAbc->pAbcBac ) Bac_ManFree(Bac_AbcGetMan(pAbc)); }
static inline void Bac_AbcUpdateMan( Abc_Frame_t * pAbc, Bac_Man_t * p ) { Bac_AbcFreeMan(pAbc); pAbc->pAbcBac = p; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......
......@@ -4,9 +4,9 @@
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Verilog parser.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Parses several flavors of word-level Verilog.]
Synopsis []
Author [Alan Mishchenko]
......
/**CFile****************************************************************
FileName [cba.c]
FileName [cbaBlast.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Verilog parser.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Parses several flavors of word-level Verilog.]
Synopsis [Collapsing word-level design.]
Author [Alan Mishchenko]
......@@ -14,11 +14,15 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cbaBlast.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
#include "cba.h"
#include "base/abc/abc.h"
#include "map/mio/mio.h"
#include "bool/dec/dec.h"
#include "base/main/mainInt.h"
ABC_NAMESPACE_IMPL_START
......@@ -41,7 +45,31 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
Gia_Man_t * Cba_ManBlast( Cba_Man_t * p, int fBarBufs, int fVerbose )
{
return NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
{
return NULL;
}
Cba_Man_t * Cba_ManInsertAbc( Cba_Man_t * p, void * pAbc )
{
Abc_Ntk_t * pNtk = (Abc_Ntk_t *)pAbc;
return (Cba_Man_t *)pNtk;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
/**CFile****************************************************************
FileName [cba.c]
FileName [cbaCba.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Verilog parser.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Parses several flavors of word-level Verilog.]
Synopsis [Reading binary representation.]
Author [Alan Mishchenko]
......@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cbaCba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
......@@ -41,7 +41,13 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
Cba_Man_t * Cba_ManReadCba( char * pFileName )
{
return NULL;
}
void Cba_ManWriteCba( char * pFileName, Cba_Man_t * p )
{
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
/**CFile****************************************************************
FileName [cba.c]
FileName [cbaNtk.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Verilog parser.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Parses several flavors of word-level Verilog.]
Synopsis [Network manipulation.]
Author [Alan Mishchenko]
......@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - July 21, 2015.]
Revision [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
Revision [$Id: cbaNtk.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
......
......@@ -60,6 +60,7 @@ struct Prs_Ntk_t_
unsigned fHasCXs : 1;
unsigned fHasCZs : 1;
Abc_Nam_t * pStrs;
Abc_Nam_t * pSops;
// interface
Vec_Int_t vOrder; // order of signals
// signal names
......@@ -89,6 +90,7 @@ struct Prs_Man_t_
char * pLimit; // end of file
char * pCur; // current position
Abc_Nam_t * pStrs; // string manager
Abc_Nam_t * pSops; // cover manager
Prs_Ntk_t * pNtk; // current network
Vec_Ptr_t * vNtks; // input networks
// temporary data
......@@ -107,6 +109,7 @@ struct Prs_Man_t_
static inline Prs_Ntk_t * Prs_ManNtk( Vec_Ptr_t * vPrs, int i ) { return i >= 0 && i < Vec_PtrSize(vPrs) ? (Prs_Ntk_t *)Vec_PtrEntry(vPrs, i) : NULL; }
static inline Prs_Ntk_t * Prs_ManRoot( Vec_Ptr_t * vPrs ) { return Prs_ManNtk(vPrs, 0); }
static inline Abc_Nam_t * Prs_ManNameMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pStrs; }
static inline Abc_Nam_t * Prs_ManFuncMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pSops; }
static inline int Prs_NtkId( Prs_Ntk_t * p ) { return p->iModuleName; }
static inline int Prs_NtkPioNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vInouts); }
......@@ -115,6 +118,7 @@ static inline int Prs_NtkPoNum( Prs_Ntk_t * p ) { return
static inline int Prs_NtkBoxNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vObjs); }
static inline int Prs_NtkObjNum( Prs_Ntk_t * p ) { return Prs_NtkPioNum(p) + Prs_NtkPiNum(p) + Prs_NtkPoNum(p) + Prs_NtkBoxNum(p); }
static inline char * Prs_NtkStr( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pStrs, h); }
static inline char * Prs_NtkSop( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pSops, h); }
static inline char * Prs_NtkName( Prs_Ntk_t * p ) { return Prs_NtkStr(p, Prs_NtkId(p)); }
static inline int Prs_NtkSigName( Prs_Ntk_t * p, int i ) { if (!p->fSlices) return i; assert(Abc_Lit2Att2(i) == CBA_PRS_NAME); return Abc_Lit2Var2(i); }
......@@ -182,6 +186,7 @@ static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
p->pNtk->iModuleName = iName;
p->pNtk->fSlices = fSlices;
p->pNtk->pStrs = Abc_NamRef( p->pStrs );
p->pNtk->pSops = Abc_NamRef( p->pSops );
Vec_PtrPush( p->vNtks, p->pNtk );
}
static inline void Prs_ManFinalizeNtk( Prs_Man_t * p )
......@@ -264,14 +269,17 @@ static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
p->pLimit = pLimit;
p->pCur = pBuffer;
p->pStrs = Abc_NamStart( 1000, 24 );
p->pSops = Abc_NamStart( 100, 24 );
p->vNtks = Vec_PtrAlloc( 100 );
Abc_NamStrFindOrAdd( p->pSops, " 0\n", NULL );
Abc_NamStrFindOrAdd( p->pSops, " 1\n", NULL );
return p;
}
static inline void Prs_NtkFree( Prs_Ntk_t * p )
{
if ( p->pStrs )
Abc_NamDeref( p->pStrs );
if ( p->pStrs ) Abc_NamDeref( p->pStrs );
if ( p->pSops ) Abc_NamDeref( p->pSops );
Vec_IntErase( &p->vOrder );
Vec_IntErase( &p->vInouts );
Vec_IntErase( &p->vInputs );
......@@ -298,10 +306,9 @@ static inline void Prs_ManVecFree( Vec_Ptr_t * vPrs )
static inline void Prs_ManFree( Prs_Man_t * p )
{
if ( p->pStrs )
Abc_NamDeref( p->pStrs );
if ( p->vNtks )
Prs_ManVecFree( p->vNtks );
if ( p->pStrs ) Abc_NamDeref( p->pStrs );
if ( p->pSops ) Abc_NamDeref( p->pSops );
if ( p->vNtks ) Prs_ManVecFree( p->vNtks );
// temporary
Vec_StrErase( &p->vCover );
Vec_IntErase( &p->vTemp );
......
......@@ -234,8 +234,8 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
}
assert( Vec_StrSize(&p->vCover) > 0 );
Vec_StrPush( &p->vCover, '\0' );
//iToken = Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL );
iToken = Ptr_SopToType( Vec_StrArray(&p->vCover) );
// iToken = Ptr_SopToType( Vec_StrArray(&p->vCover) );
iToken = Abc_NamStrFindOrAdd( p->pSops, Vec_StrArray(&p->vCover), NULL );
Vec_StrClear( &p->vCover );
// set the cover to the module of this box
assert( Prs_BoxNtk(p->pNtk, Prs_NtkBoxNum(p->pNtk)-1) == 1 ); // default const 0
......@@ -433,17 +433,211 @@ void Prs_ManReadBlifTest()
abctime clk = Abc_Clock();
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs );
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "aga/ray/ray_hie_oper.blif" );
Vec_Ptr_t * vPrs = Prs_ManReadBlif( "c/hie/dump/1/netlist_1_out8.blif" );
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "c/hie/dump/1/netlist_1_out8.blif" );
Vec_Ptr_t * vPrs = Prs_ManReadBlif( "add2.blif" );
if ( !vPrs ) return;
printf( "Finished reading %d networks. ", Vec_PtrSize(vPrs) );
printf( "NameIDs = %d. ", Abc_NamObjNumMax(Prs_ManNameMan(vPrs)) );
printf( "Memory = %.2f MB. ", 1.0*Prs_ManMemory(vPrs)/(1<<20) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
// Abc_NamPrint( p->pStrs );
Prs_ManWriteBlif( "c/hie/dump/1/netlist_1_out8_out.blif", vPrs );
Prs_ManWriteBlif( "add2_out.blif", vPrs );
Prs_ManVecFree( vPrs );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Prs_CreateBlifFindFon( Cba_Ntk_t * p, int NameId )
{
int iFon = Cba_NtkGetMap( p, NameId );
if ( iFon )
return iFon;
printf( "Network \"%s\": Signal \"%s\" is not driven.\n", Cba_NtkName(p), Cba_NtkStr(p, NameId) );
return 0;
}
void Prs_CreateBlifPio( Cba_Ntk_t * p, Prs_Ntk_t * pNtk )
{
int i, NameId, iObj, iFon;
Cba_NtkCleanObjFuncs( p );
Cba_NtkCleanObjNames( p );
Cba_NtkCleanFonNames( p );
// create inputs
Prs_NtkForEachPi( pNtk, NameId, i )
{
iObj = Cba_ObjAlloc( p, CBA_OBJ_PI, 0, 1 );
Cba_ObjSetName( p, iObj, NameId );
iFon = Cba_ObjFon0(p, iObj);
Cba_FonSetName( p, iFon, NameId );
Cba_NtkSetMap( p, NameId, iFon );
Vec_IntPush( &p->vOrder, iObj );
}
// create outputs
Prs_NtkForEachPo( pNtk, NameId, i )
{
iObj = Cba_ObjAlloc( p, CBA_OBJ_PO, 1, 0 );
Cba_ObjSetName( p, iObj, NameId );
Vec_IntPush( &p->vOrder, iObj );
}
}
int Prs_CreateBlifNtk( Cba_Ntk_t * p, Prs_Ntk_t * pNtk )
{
Vec_Int_t * vBox;
int i, k, iObj, iTerm, iFon, FormId, ActId;
// map inputs
Cba_NtkCleanMap( p );
Cba_NtkForEachPi( p, iObj, i )
Cba_NtkSetMap( p, Cba_ObjName(p, iObj), Cba_ObjFon0(p, iObj) );
// create objects
Prs_NtkForEachBox( pNtk, vBox, i )
{
int FuncId = Prs_BoxNtk(pNtk, i);
assert( Prs_BoxIONum(pNtk, i) > 0 );
assert( Vec_IntSize(vBox) % 2 == 0 );
if ( FuncId == -1 ) // latch
{
iObj = Cba_ObjAlloc( p, CBA_BOX_DFFRS, 4, 1 );
Cba_NtkSetMap( p, Vec_IntEntry(vBox, 3), Cba_ObjFon0(p, iObj) ); // latch output
Cba_ObjSetFunc( p, iObj, Prs_BoxName(pNtk, i)+1 ); // init + 1
}
else if ( Prs_BoxIsNode(pNtk, i) ) // node
{
iObj = Cba_ObjAlloc( p, CBA_BOX_NODE, Prs_BoxIONum(pNtk, i)-1, 1 );
Cba_FonSetName( p, Cba_ObjFon0(p, iObj), Vec_IntEntryLast(vBox) ); // node output
Cba_NtkSetMap( p, Vec_IntEntryLast(vBox), Cba_ObjFon0(p, iObj) );
Cba_ObjSetFunc( p, iObj, FuncId );
}
else // box
{
Cba_Ntk_t * pBox = Cba_ManNtkFind( p->pDesign, Prs_NtkStr(pNtk, FuncId) );
iObj = Cba_ObjAlloc( p, CBA_OBJ_BOX, Cba_NtkPiNum(pBox), Cba_NtkPoNum(pBox) );
Cba_ObjSetFunc( p, iObj, Cba_NtkId(pBox) );
// mark PO objects
Cba_NtkCleanMap2( p );
Cba_NtkForEachPo( pBox, iTerm, k )
Cba_NtkSetMap2( p, Cba_ObjName(pBox, iTerm), k+1 );
// map box fons
Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
if ( Cba_NtkGetMap2(p, FormId) )
{
iFon = Cba_ObjFon(p, iObj, Cba_NtkGetMap2(p, FormId)-1);
Cba_FonSetName( p, iFon, ActId );
Cba_NtkSetMap( p, ActId, iFon );
}
}
}
// connect objects
Prs_NtkForEachBox( pNtk, vBox, i )
{
iObj = Cba_NtkPiNum(p) + Cba_NtkPoNum(p) + i + 1;
if ( Prs_BoxNtk(pNtk, i) == -1 ) // latch
{
assert( Cba_ObjType(p, iObj) == CBA_BOX_DFFRS );
iFon = Prs_CreateBlifFindFon( p, Vec_IntEntry(vBox, 1) ); // latch input
if ( iFon )
Cba_ObjSetFinFon( p, iObj, 0, iFon );
}
else if ( Prs_BoxIsNode(pNtk, i) ) // node
{
assert( Cba_ObjType(p, iObj) == CBA_BOX_NODE );
Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
{
if ( k == 2 * Cba_ObjFinNum(p, iObj) ) // stop at node output
break;
iFon = Prs_CreateBlifFindFon( p, ActId );
if ( iFon )
Cba_ObjSetFinFon( p, iObj, k/2, iFon );
}
}
else // box
{
// mark PI objects
Cba_Ntk_t * pBox = Cba_ObjNtk(p, iObj);
assert( Cba_NtkPiNum(pBox) == Cba_ObjFinNum(p, iObj) );
assert( Cba_NtkPoNum(pBox) == Cba_ObjFonNum(p, iObj) );
Cba_NtkCleanMap2( p );
Cba_NtkForEachPi( pBox, iTerm, k )
Cba_NtkSetMap2( p, Cba_ObjName(pBox, iTerm), k+1 );
// connect box fins
Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
if ( Cba_NtkGetMap2(p, FormId) )
{
iFon = Prs_CreateBlifFindFon( p, ActId );
if ( iFon )
Cba_ObjSetFinFon( p, iObj, Cba_NtkGetMap2(p, FormId)-1, iFon );
}
}
}
// connect outputs
Cba_NtkForEachPo( p, iObj, i )
{
iFon = Prs_CreateBlifFindFon( p, Cba_ObjName(p, iObj) );
if ( iFon )
Cba_ObjSetFinFon( p, iObj, 0, iFon );
}
return 0;
}
Cba_Man_t * Prs_ManBuildCbaBlif( char * pFileName, Vec_Ptr_t * vDes )
{
Prs_Ntk_t * pPrsNtk; int i, fError = 0;
Prs_Ntk_t * pPrsRoot = Prs_ManRoot(vDes);
// start the manager
Abc_Nam_t * pStrs = Abc_NamRef(pPrsRoot->pStrs);
Abc_Nam_t * pCons = Abc_NamRef(pPrsRoot->pSops);
Abc_Nam_t * pMods = Abc_NamStart( 100, 24 );
Cba_Man_t * p = Cba_ManAlloc( pFileName, Vec_PtrSize(vDes), pStrs, pCons, pMods );
// initialize networks
Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pPrsNtk, i )
{
Cba_Ntk_t * pNtk = Cba_NtkAlloc( p, Prs_NtkId(pPrsNtk), Prs_NtkPiNum(pPrsNtk), Prs_NtkPoNum(pPrsNtk), Prs_NtkObjNum(pPrsNtk), 100, 100 );
Prs_CreateBlifPio( pNtk, pPrsNtk );
Cba_NtkAdd( p, pNtk );
}
// create networks
Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pPrsNtk, i )
{
printf( "Elaboration module \"%s\"...\n", Prs_NtkName(pPrsNtk), vDes );
fError = Prs_CreateBlifNtk( Cba_ManNtk(p, i+1), pPrsNtk );
if ( fError )
break;
}
if ( fError )
printf( "Quitting because of errors.\n" );
else
Cba_ManPrepareSeq( p );
return p;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t * Cba_ManReadBlif( char * pFileName )
{
Cba_Man_t * p = NULL;
Vec_Ptr_t * vDes = Prs_ManReadBlif( pFileName );
if ( vDes && Vec_PtrSize(vDes) )
p = Prs_ManBuildCbaBlif( pFileName, vDes );
if ( vDes )
Prs_ManVecFree( vDes );
return p;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -865,6 +865,32 @@ void Prs_ManReadVerilogTest( char * pFileName )
Prs_ManVecFree( vPrs );
}
Cba_Man_t * Prs_ManBuildCbaVerilog( char * pFileName, Vec_Ptr_t * vDes )
{
return NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cba_Man_t * Cba_ManReadVerilog( char * pFileName )
{
Cba_Man_t * p = NULL;
Vec_Ptr_t * vDes = Prs_ManReadVerilog( pFileName );
if ( vDes && Vec_PtrSize(vDes) )
p = Prs_ManBuildCbaVerilog( pFileName, vDes );
if ( vDes )
Prs_ManVecFree( vDes );
return p;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -72,7 +72,7 @@ static void Prs_ManWriteBlifLines( FILE * pFile, Prs_Ntk_t * p )
fprintf( pFile, ".names" );
Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
fprintf( pFile, " %s", Prs_NtkStr(p, ActId) );
fprintf( pFile, "\n%s", Prs_NtkStr(p, NtkId) );
fprintf( pFile, "\n%s", Prs_NtkSop(p, NtkId) );
}
else // box
{
......@@ -116,8 +116,6 @@ void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs )
}
#if 0
/**Function*************************************************************
Synopsis [Write elaborated design.]
......@@ -129,76 +127,59 @@ void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs )
SeeAlso []
***********************************************************************/
void Cba_ManWriteBlifGate( FILE * pFile, Cba_Ntk_t * p, Mio_Gate_t * pGate, Vec_Int_t * vFanins, int iObj )
{
int iFanin, i;
Vec_IntForEachEntry( vFanins, iFanin, i )
fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, i), Cba_ObjNameStr(p, iFanin) );
fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iObj) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifArray( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins, int iObj )
{
int iFanin, i;
Vec_IntForEachEntry( vFanins, iFanin, i )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iFanin) );
if ( iObj >= 0 )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iObj) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifArray2( FILE * pFile, Cba_Ntk_t * p, int iObj )
{
int iTerm, i;
Cba_Ntk_t * pModel = Cba_BoxNtk( p, iObj );
Cba_NtkForEachPi( pModel, iTerm, i )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBi(p, iObj, i)) );
Cba_NtkForEachPo( pModel, iTerm, i )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBo(p, iObj, i)) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifLines( FILE * pFile, Cba_Ntk_t * p )
{
int i, k, iTerm;
Cba_NtkForEachBox( p, i )
int k, iObj, iFin, iFon;
Cba_NtkForEachBox( p, iObj )
{
if ( Cba_ObjIsBoxUser(p, i) )
if ( Cba_ObjIsBoxUser(p, iObj) )
{
Cba_Ntk_t * pNtk = Cba_ObjNtk( p, iObj );
fprintf( pFile, ".subckt" );
fprintf( pFile, " %s", Cba_NtkName(Cba_BoxNtk(p, i)) );
Cba_ManWriteBlifArray2( pFile, p, i );
fprintf( pFile, " %s", Cba_NtkName(pNtk) );
Cba_ObjForEachFinFon( p, iObj, iFin, iFon, k )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pNtk, Cba_NtkPi(pNtk, k)), Cba_FonNameStr(p, iFon) );
Cba_ObjForEachFon( p, iObj, iFon, k )
fprintf( pFile, " %s=%s", Cba_ObjNameStr(pNtk, Cba_NtkPo(pNtk, k)), Cba_FonNameStr(p, iFon) );
fprintf( pFile, "\n" );
}
else if ( Cba_ObjIsGate(p, i) )
else if ( Cba_ObjIsGate(p, iObj) )
{
char * pGateName = Abc_NamStr(p->pDesign->pMods, Cba_BoxNtkId(p, i));
char * pGateName = Abc_NamStr(p->pDesign->pMods, Cba_ObjNtkId( p, iObj ));
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, pGateName, NULL );
fprintf( pFile, ".gate %s", pGateName );
Cba_BoxForEachBi( p, i, iTerm, k )
fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, k), Cba_ObjNameStr(p, iTerm) );
Cba_BoxForEachBo( p, i, iTerm, k )
fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iTerm) );
Cba_ObjForEachFinFon( p, iObj, iFin, iFon, k )
fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, k), Cba_FonNameStr(p, iFon) );
Cba_ObjForEachFon( p, iObj, iFon, k )
fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_FonNameStr(p, iFon) );
fprintf( pFile, "\n" );
}
else
{
fprintf( pFile, ".names" );
Cba_BoxForEachBi( p, i, iTerm, k )
fprintf( pFile, " %s", Cba_ObjNameStr(p, Cba_ObjFanin(p, iTerm)) );
Cba_BoxForEachBo( p, i, iTerm, k )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iTerm) );
fprintf( pFile, "\n%s", Ptr_TypeToSop(Cba_ObjType(p, i)) );
Cba_ObjForEachFinFon( p, iObj, iFin, iFon, k )
fprintf( pFile, " %s", Cba_FonNameStr(p, iFon) );
fprintf( pFile, " %s", Cba_FonNameStr(p, Cba_ObjFon0(p, iObj)) );
fprintf( pFile, "\n%s", Cba_NtkSop(p, Cba_ObjFunc(p, iObj)) );
}
}
}
void Cba_ManWriteBlifArray( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vObjs )
{
int iObj, i;
Vec_IntForEachEntry( vObjs, iObj, i )
fprintf( pFile, " %s", Cba_ObjNameStr(p, iObj) );
fprintf( pFile, "\n" );
}
void Cba_ManWriteBlifNtk( FILE * pFile, Cba_Ntk_t * p )
{
assert( Vec_IntSize(&p->vFanin) == Cba_NtkObjNum(p) );
// write header
fprintf( pFile, ".model %s\n", Cba_NtkName(p) );
fprintf( pFile, ".inputs" );
Cba_ManWriteBlifArray( pFile, p, &p->vInputs, -1 );
Cba_ManWriteBlifArray( pFile, p, &p->vInputs );
fprintf( pFile, ".outputs" );
Cba_ManWriteBlifArray( pFile, p, &p->vOutputs, -1 );
Cba_ManWriteBlifArray( pFile, p, &p->vOutputs );
// write objects
Cba_ManWriteBlifLines( pFile, p );
fprintf( pFile, ".end\n\n" );
......@@ -221,13 +202,12 @@ void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p )
return;
}
fprintf( pFile, "# Design \"%s\" written via CBA package in ABC on %s\n\n", Cba_ManName(p), Extra_TimeStamp() );
Cba_ManAssignInternWordNames( p );
// Cba_ManAssignInternWordNames( p );
Cba_ManForEachNtk( p, pNtk, i )
Cba_ManWriteBlifNtk( pFile, pNtk );
fclose( pFile );
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -127,6 +127,7 @@ struct Abc_Frame_t_
void * pAbc85Best;
void * pAbc85Delay;
void * pAbcWlc;
void * pAbcBac;
void * pAbcCba;
void * pAbcPla;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment