summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-01-17 20:27:23 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2015-01-17 20:27:23 -0800
commit17610c039f79e30679b7950e7d91de166b34d2fa (patch)
tree3e9885c0fad76b1ca8f122323683fb11b87d290f
parent42cc56576b0ab244f0834fc8d80a3ced406576bd (diff)
downloadabc-17610c039f79e30679b7950e7d91de166b34d2fa.tar.gz
abc-17610c039f79e30679b7950e7d91de166b34d2fa.tar.bz2
abc-17610c039f79e30679b7950e7d91de166b34d2fa.zip
Organizing commands for barbuf-aware flow.
-rw-r--r--src/aig/gia/giaFx.c28
-rw-r--r--src/base/cba/cba.h49
-rw-r--r--src/base/cba/cbaBlast.c242
-rw-r--r--src/base/cba/cbaBuild.c22
-rw-r--r--src/base/cba/cbaCom.c4
-rw-r--r--src/base/cba/cbaNtk.c19
-rw-r--r--src/base/cba/cbaPrs.h18
-rw-r--r--src/base/cba/cbaReadBlif.c6
-rw-r--r--src/base/cba/cbaReadVer.c65
-rw-r--r--src/base/cba/cbaSimple.c15
-rw-r--r--src/base/cba/cbaWriteBlif.c34
-rw-r--r--src/base/cba/cbaWriteVer.c65
12 files changed, 411 insertions, 156 deletions
diff --git a/src/aig/gia/giaFx.c b/src/aig/gia/giaFx.c
index 9879b636..9985e51d 100644
--- a/src/aig/gia/giaFx.c
+++ b/src/aig/gia/giaFx.c
@@ -96,6 +96,20 @@ int Gia_ManSopToAig( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
iSum = Abc_LitNot(iSum);
return iSum;
}
+int Gia_ManFactorGraph( Gia_Man_t * p, Dec_Graph_t * pFForm, Vec_Int_t * vLeaves )
+{
+ Dec_Node_t * pFFNode;
+ int i, Lit;
+ // assign fanins
+ Dec_GraphForEachLeaf( pFForm, pFFNode, i )
+ {
+ assert( Vec_IntEntry(vLeaves, i) >= 0 );
+ pFFNode->iFunc = Vec_IntEntry(vLeaves, i);
+ }
+ // perform strashing
+ Lit = Gia_ManGraphToAig( p, pFForm );
+ return Lit;
+}
int Gia_ManFactorNode( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
{
if ( Kit_PlaGetVarNum(pSop) == 0 )
@@ -103,18 +117,8 @@ int Gia_ManFactorNode( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
assert( Kit_PlaGetVarNum(pSop) == Vec_IntSize(vLeaves) );
if ( Kit_PlaGetVarNum(pSop) > 2 && Kit_PlaGetCubeNum(pSop) > 1 )
{
- Dec_Graph_t * pFForm;
- Dec_Node_t * pFFNode;
- int i, Lit;
- pFForm = Dec_Factor( pSop );
- // assign fanins
- Dec_GraphForEachLeaf( pFForm, pFFNode, i )
- {
- assert( Vec_IntEntry(vLeaves, i) >= 0 );
- pFFNode->iFunc = Vec_IntEntry(vLeaves, i);
- }
- // perform strashing
- Lit = Gia_ManGraphToAig( p, pFForm );
+ Dec_Graph_t * pFForm = Dec_Factor( pSop );
+ int Lit = Gia_ManFactorGraph( p, pFForm, vLeaves );
Dec_GraphFree( pFForm );
return Lit;
}
diff --git a/src/base/cba/cba.h b/src/base/cba/cba.h
index fa2abc9f..cdf5cf29 100644
--- a/src/base/cba/cba.h
+++ b/src/base/cba/cba.h
@@ -21,7 +21,6 @@
#ifndef ABC__base__cba__cba_h
#define ABC__base__cba__cba_h
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -66,17 +65,15 @@ typedef enum {
CBA_NODE_BUF, // 3: buffer
CBA_NODE_INV, // 4: inverter
CBA_NODE_AND, // 5: AND
- CBA_NODE_AND00, // 6: AND00
- CBA_NODE_AND01, // 7: AND01
- CBA_NODE_AND10, // 8: AND10
- CBA_NODE_NAND, // 9: NAND
- CBA_NODE_OR, // 10: OR
- CBA_NODE_NOR, // 11: NOR
- CBA_NODE_XOR, // 12: XOR
- CBA_NODE_XNOR, // 13 XNOR
- CBA_NODE_MUX, // 14: MUX
- CBA_NODE_MAJ, // 15: MAJ
- CBA_NODE_UNKNOWN // 16: unknown
+ CBA_NODE_NAND, // 6: NAND
+ CBA_NODE_OR, // 7: OR
+ CBA_NODE_NOR, // 8: NOR
+ CBA_NODE_XOR, // 9: XOR
+ CBA_NODE_XNOR, // 10 XNOR
+ CBA_NODE_SHARP, // 11: SHARP
+ CBA_NODE_MUX, // 12: MUX
+ CBA_NODE_MAJ, // 13: MAJ
+ CBA_NODE_UNKNOWN // 14: unknown
} Cba_NodeType_t;
@@ -100,6 +97,8 @@ struct Cba_Man_t_
Vec_Int_t * vBuf2RootObj;
Vec_Int_t * vBuf2LeafNtk;
Vec_Int_t * vBuf2LeafObj;
+ void * pMioLib;
+ void ** ppGraphs;
};
// network
@@ -123,7 +122,6 @@ struct Cba_Ntk_t_
Vec_Int_t vInstIds; // instance names (used by parser to store instance name as NameId)
Vec_Int_t vFanins; // fanins (used by parser to store fanin/fanout/range as NameId) (node: handle; CO/BI fanin0)
// attributes
- Vec_Int_t vBoxes; // box objects
Vec_Int_t vNameIds; // original names as NameId
Vec_Int_t vRanges; // ranges as NameId
};
@@ -145,9 +143,8 @@ static inline char * Cba_NtkName( Cba_Ntk_t * p ) { r
static inline int Cba_NtkObjNum( Cba_Ntk_t * p ) { return Vec_IntSize(&p->vFanins); }
static inline int Cba_NtkPiNum( Cba_Ntk_t * p ) { return Vec_IntSize(&p->vInputs); }
static inline int Cba_NtkPoNum( Cba_Ntk_t * p ) { return Vec_IntSize(&p->vOutputs); }
-static inline int Cba_NtkBoxNum( Cba_Ntk_t * p ) { return Vec_IntSize(&p->vBoxes); }
-static inline int Cba_NtkBoxNumCount( Cba_Ntk_t * p ) { return Vec_IntCountEntry(&p->vTypes, CBA_OBJ_BOX); }
static inline int Cba_NtkNodeNum( Cba_Ntk_t * p ) { return Vec_IntCountEntry(&p->vTypes, CBA_OBJ_NODE); }
+static inline int Cba_NtkBoxNum( Cba_Ntk_t * p ) { return Vec_IntCountEntry(&p->vTypes, CBA_OBJ_BOX); }
static inline int Cba_NtkPi( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vInputs, i); }
static inline int Cba_NtkPo( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vOutputs, i); }
@@ -218,7 +215,6 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { r
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
-
#define Cba_ManForEachNtk( p, pNtk, i ) \
for ( i = 1; (i <= Cba_ManNtkNum(p)) && (((pNtk) = Cba_ManNtk(p, i)), 1); i++ )
@@ -230,8 +226,8 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { r
#define Cba_NtkForEachObjType( p, Type, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1); i++ )
-#define Cba_NtkForEachBox( p, iObj, i ) \
- for ( i = 0; (i < Cba_NtkBoxNum(p)) && (((iObj) = Vec_IntEntry(&p->vBoxes, i)), 1); i++ )
+#define Cba_NtkForEachBox( p, i ) \
+ for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_BOX ) {} else
#define Cba_NtkForEachNode( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( Cba_ObjType(p, i) != CBA_OBJ_NODE ) {} else
@@ -337,8 +333,6 @@ static inline Cba_Man_t * Cba_ManClone( Cba_Man_t * pOld )
pNtkNew = Cba_NtkAlloc( p, Cba_NtkName(pNtk) );
Cba_ManFetchArray( p, &pNtkNew->vInputs, Cba_NtkPiNum(pNtk) );
Cba_ManFetchArray( p, &pNtkNew->vOutputs, Cba_NtkPoNum(pNtk) );
- Cba_ManFetchArray( p, &pNtkNew->vBoxes, Cba_NtkBoxNumCount(pNtk) );
- Vec_IntShrink( &pNtkNew->vBoxes, 0 );
}
assert( Cba_ManNtkNum(p) == Cba_ManNtkNum(pOld) );
return p;
@@ -398,9 +392,7 @@ static inline Cba_NodeType_t Ptr_SopToType( char * pSop )
if ( !strcmp(pSop, "1 1\n") ) return CBA_NODE_BUF;
if ( !strcmp(pSop, "0 1\n") ) return CBA_NODE_INV;
if ( !strcmp(pSop, "11 1\n") ) return CBA_NODE_AND;
- if ( !strcmp(pSop, "00 1\n") ) return CBA_NODE_AND00;
- if ( !strcmp(pSop, "01 1\n") ) return CBA_NODE_AND01;
- if ( !strcmp(pSop, "10 1\n") ) return CBA_NODE_AND10;
+ if ( !strcmp(pSop, "00 1\n") ) return CBA_NODE_NOR;
if ( !strcmp(pSop, "00 0\n") ) return CBA_NODE_OR;
if ( !strcmp(pSop, "-1 1\n1- 1\n") ) return CBA_NODE_OR;
if ( !strcmp(pSop, "1- 1\n-1 1\n") ) return CBA_NODE_OR;
@@ -408,6 +400,7 @@ static inline Cba_NodeType_t Ptr_SopToType( char * pSop )
if ( !strcmp(pSop, "10 1\n01 1\n") ) return CBA_NODE_XOR;
if ( !strcmp(pSop, "11 1\n00 1\n") ) return CBA_NODE_XNOR;
if ( !strcmp(pSop, "00 1\n11 1\n") ) return CBA_NODE_XNOR;
+ if ( !strcmp(pSop, "10 1\n") ) return CBA_NODE_SHARP;
assert( 0 );
return CBA_NODE_NONE;
}
@@ -418,9 +411,6 @@ static inline char * Ptr_TypeToName( Cba_NodeType_t Type )
if ( Type == CBA_NODE_BUF ) return "buf";
if ( Type == CBA_NODE_INV ) return "not";
if ( Type == CBA_NODE_AND ) return "and";
- if ( Type == CBA_NODE_AND00 ) return "and00";
- if ( Type == CBA_NODE_AND01 ) return "and01";
- if ( Type == CBA_NODE_AND10 ) return "and10";
if ( Type == CBA_NODE_NAND ) return "nand";
if ( Type == CBA_NODE_OR ) return "or";
if ( Type == CBA_NODE_NOR ) return "nor";
@@ -428,6 +418,7 @@ static inline char * Ptr_TypeToName( Cba_NodeType_t Type )
if ( Type == CBA_NODE_XNOR ) return "xnor";
if ( Type == CBA_NODE_MUX ) return "mux";
if ( Type == CBA_NODE_MAJ ) return "maj";
+ if ( Type == CBA_NODE_SHARP ) return "sharp";
assert( 0 );
return "???";
}
@@ -438,14 +429,12 @@ static inline char * Ptr_TypeToSop( Cba_NodeType_t Type )
if ( Type == CBA_NODE_BUF ) return "1 1\n";
if ( Type == CBA_NODE_INV ) return "0 1\n";
if ( Type == CBA_NODE_AND ) return "11 1\n";
- if ( Type == CBA_NODE_AND00 ) return "00 1\n";
- if ( Type == CBA_NODE_AND01 ) return "01 1\n";
- if ( Type == CBA_NODE_AND10 ) return "10 1\n";
if ( Type == CBA_NODE_NAND ) return "11 0\n";
if ( Type == CBA_NODE_OR ) return "00 0\n";
if ( Type == CBA_NODE_NOR ) return "00 1\n";
if ( Type == CBA_NODE_XOR ) return "01 1\n10 1\n";
if ( Type == CBA_NODE_XNOR ) return "00 1\n11 1\n";
+ if ( Type == CBA_NODE_SHARP ) return "10 1\n";
if ( Type == CBA_NODE_MUX ) return "11- 1\n0-1 1\n";
if ( Type == CBA_NODE_MAJ ) return "11- 1\n1-1 1\n-11 1\n";
assert( 0 );
@@ -462,7 +451,7 @@ extern Cba_Man_t * Cba_ManBuild( Cba_Man_t * p );
/*=== cbaReadBlif.c =========================================================*/
extern Cba_Man_t * Cba_PrsReadBlif( char * pFileName );
/*=== cbaReadVer.c ==========================================================*/
-extern Cba_Man_t * Cba_PrsReadVerilog( char * pFileName );
+extern Cba_Man_t * Cba_PrsReadVerilog( char * pFileName, int fBinary );
/*=== cbaWriteBlif.c ========================================================*/
extern void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * p );
extern void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p );
diff --git a/src/base/cba/cbaBlast.c b/src/base/cba/cbaBlast.c
index 808f3035..45ced7d2 100644
--- a/src/base/cba/cbaBlast.c
+++ b/src/base/cba/cbaBlast.c
@@ -20,6 +20,8 @@
#include "cba.h"
#include "base/abc/abc.h"
+#include "map/mio/mio.h"
+#include "bool/dec/dec.h"
ABC_NAMESPACE_IMPL_START
@@ -42,6 +44,44 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
+void Cba_ManPrepareGates( Cba_Man_t * p )
+{
+ int i;
+ if ( p->pMioLib == NULL )
+ return;
+ assert( p->ppGraphs == NULL );
+ p->ppGraphs = ABC_ALLOC( Dec_Graph_t *, Abc_NamObjNumMax(p->pFuncs) );
+ p->ppGraphs[0] = NULL;
+ for ( i = 1; i < Abc_NamObjNumMax(p->pFuncs); i++ )
+ {
+ char * pGateName = Abc_NamStr( p->pFuncs, i );
+ Mio_Gate_t * pGate = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pMioLib, pGateName, NULL );
+ char * pSop = Mio_GateReadSop( pGate );
+ p->ppGraphs[i] = Dec_Factor( pSop );
+ }
+}
+void Cba_ManUndoGates( Cba_Man_t * p )
+{
+ int i;
+ if ( p->pMioLib == NULL )
+ return;
+ for ( i = 1; i < Abc_NamObjNumMax(p->pFuncs); i++ )
+ Dec_GraphFree( p->ppGraphs[i] );
+ ABC_FREE( p->ppGraphs );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int Cba_ManAddBarbuf( Gia_Man_t * pNew, int iRes, Cba_Man_t * p, int iLNtk, int iLObj, int iRNtk, int iRObj, Vec_Int_t * vMap )
{
int iBufLit, iIdLit;
@@ -86,6 +126,17 @@ int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, int fBuffers, Ve
if ( fBuffers )
iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pHost), iObj, vMap );
}
+ else if ( Cba_ObjIsNode(p, i) && p->pDesign->ppGraphs )
+ {
+ extern int Gia_ManFactorGraph( Gia_Man_t * p, Dec_Graph_t * pFForm, Vec_Int_t * vLeaves );
+ Dec_Graph_t * pGraph = (Dec_Graph_t *)p->pDesign->ppGraphs[Cba_ObjFuncId(p, i)];
+ int k, pLits[32], * pFanins = Cba_ObjFaninArray(p, i);
+ Vec_Int_t Leaves = { pFanins[0], pFanins[0], pLits };
+ assert( pFanins[0] < 32 );
+ for ( k = 0; k < pFanins[0]; k++ )
+ pLits[k] = Cba_ManExtract_rec( pNew, p, pFanins[k+1], fBuffers, vMap );
+ return Gia_ManFactorGraph( pNew, pGraph, &Leaves );
+ }
else if ( Cba_ObjIsNode(p, i) )
{
int * pFanins = Cba_ObjFaninArray(p, i);
@@ -115,10 +166,14 @@ int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, int fBuffers, Ve
iRes = Gia_ManHashAnd( pNew, pLits[0], pLits[1] );
else if ( Type == CBA_NODE_OR )
iRes = Gia_ManHashOr( pNew, pLits[0], pLits[1] );
+ else if ( Type == CBA_NODE_NOR )
+ iRes = Abc_LitNot( Gia_ManHashOr( pNew, pLits[0], pLits[1] ) );
else if ( Type == CBA_NODE_XOR )
iRes = Gia_ManHashXor( pNew, pLits[0], pLits[1] );
else if ( Type == CBA_NODE_XNOR )
iRes = Abc_LitNot( Gia_ManHashXor( pNew, pLits[0], pLits[1] ) );
+ else if ( Type == CBA_NODE_SHARP )
+ iRes = Gia_ManHashAnd( pNew, pLits[0], Abc_LitNot(pLits[1]) );
else assert( 0 );
}
}
@@ -155,8 +210,10 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
Gia_ManHashAlloc( pNew );
pNew->vBarBufs = Vec_IntAlloc( 10000 );
vMap = Vec_IntStartFull( 10000 );
+ Cba_ManPrepareGates( p );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ManExtract_rec( pNew, pRoot, iObj, fBuffers, vMap );
+ Cba_ManUndoGates( p );
Vec_IntFreeP( &vMap );
Gia_ManHashStop( pNew );
@@ -187,8 +244,8 @@ Vec_Int_t * Cba_ManCountGia( Cba_Man_t * p, Gia_Man_t * pGia, int fAlwaysAdd )
{
Cba_Ntk_t * pNtk;
Gia_Obj_t * pObj;
- int i, k, iBox, Count = 0;
- Vec_Int_t * vNtkSizes = Vec_IntStart( Cba_ManNtkNum(p) + 1 );
+ int i, iBox, Count = 0;
+ Vec_Int_t * vNtkSizes = Vec_IntStart( Cba_ManNtkNum(p) + 1 );
Vec_Int_t * vDrivenCos = Vec_IntStart( Cba_ManNtkNum(p) + 1 );
assert( Vec_IntSize(p->vBuf2LeafNtk) == Gia_ManBufNum(pGia) );
// assing for each GIA node, the network it belongs to and count nodes for all networks
@@ -222,7 +279,7 @@ Vec_Int_t * Cba_ManCountGia( Cba_Man_t * p, Gia_Man_t * pGia, int fAlwaysAdd )
Cba_ManForEachNtk( p, pNtk, i )
{
Count = Cba_NtkPiNum(pNtk) + 2 * Cba_NtkPoNum(pNtk) - (fAlwaysAdd ? 0 : Vec_IntEntry(vDrivenCos, i));
- Cba_NtkForEachBox( pNtk, iBox, k )
+ Cba_NtkForEachBox( pNtk, iBox )
Count += Cba_ObjBoxSize(pNtk, iBox) + Cba_ObjBoxBiNum(pNtk, iBox);
Vec_IntAddToEntry( vNtkSizes, i, Count );
}
@@ -249,21 +306,21 @@ void Cba_ManRemapBarbufs( Cba_Man_t * pNew, Cba_Man_t * p )
Vec_IntWriteEntry( pNew->vBuf2RootObj, i, Cba_NtkCopy(pNtk, Entry) );
}
}
-void Cba_NtkCreateAndConnectBuffer( Gia_Man_t * pGia, Gia_Obj_t * pObj, Cba_Ntk_t * pNtk, int iTerm )
+void Cba_NtkCreateAndConnectBuffer( Gia_Man_t * pGia, Gia_Obj_t * pObj, Cba_Ntk_t * p, int iTerm )
{
- Vec_IntWriteEntry( &pNtk->vTypes, pNtk->nObjs, CBA_OBJ_NODE );
- if ( !pGia || !Gia_ObjFaninId0p(pGia, pObj) )
+ Vec_IntWriteEntry( &p->vTypes, p->nObjs, CBA_OBJ_NODE );
+ if ( pGia && Gia_ObjFaninId0p(pGia, pObj) > 0 )
{
- Vec_IntWriteEntry( &pNtk->vFuncs, pNtk->nObjs, pGia && Gia_ObjFaninC0(pObj) ? CBA_NODE_C1 : CBA_NODE_C0 );
- Vec_IntWriteEntry( &pNtk->vFanins, pNtk->nObjs, Cba_ManHandleBuffer(pNtk->pDesign, -1) );
+ Vec_IntWriteEntry( &p->vFuncs, p->nObjs, Gia_ObjFaninC0(pObj) ? CBA_NODE_INV : CBA_NODE_BUF );
+ Vec_IntWriteEntry( &p->vFanins, p->nObjs, Cba_ManHandleBuffer(p->pDesign, Gia_ObjFanin0(pObj)->Value) );
}
else
{
- Vec_IntWriteEntry( &pNtk->vFuncs, pNtk->nObjs, Gia_ObjFaninC0(pObj) ? CBA_NODE_INV : CBA_NODE_BUF );
- Vec_IntWriteEntry( &pNtk->vFanins, pNtk->nObjs, Cba_ManHandleBuffer(pNtk->pDesign, Gia_ObjFanin0(pObj)->Value) );
+ Vec_IntWriteEntry( &p->vFuncs, p->nObjs, pGia && Gia_ObjFaninC0(pObj) ? CBA_NODE_C1 : CBA_NODE_C0 );
+ Vec_IntWriteEntry( &p->vFanins, p->nObjs, Cba_ManHandleBuffer(p->pDesign, -1) );
}
- Vec_IntWriteEntry( &pNtk->vNameIds, pNtk->nObjs, Cba_ObjNameId(pNtk, iTerm) );
- Vec_IntWriteEntry( &pNtk->vFanins, iTerm, pNtk->nObjs++ );
+ Vec_IntWriteEntry( &p->vNameIds, p->nObjs, Cba_ObjNameId(p, iTerm) );
+ Vec_IntWriteEntry( &p->vFanins, iTerm, p->nObjs++ );
}
void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
{
@@ -288,17 +345,22 @@ void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
}
else
{
+ int iLit0 = Gia_ObjFanin0(pObj)->Value;
+ int iLit1 = Gia_ObjFanin1(pObj)->Value;
Cba_NodeType_t Type;
pNtk = Cba_ManNtk( p, pObj->Value );
if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
- Type = CBA_NODE_AND00;
- else if ( Gia_ObjFaninC0(pObj) )
- Type = CBA_NODE_AND01;
+ Type = CBA_NODE_NOR;
else if ( Gia_ObjFaninC1(pObj) )
- Type = CBA_NODE_AND10;
+ Type = CBA_NODE_SHARP;
+ else if ( Gia_ObjFaninC0(pObj) )
+ {
+ Type = CBA_NODE_SHARP;
+ ABC_SWAP( int, iLit0, iLit1 );
+ }
else
Type = CBA_NODE_AND;
- Vec_IntFillTwo( vTemp, 2, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
+ Vec_IntFillTwo( vTemp, 2, iLit0, iLit1 );
Vec_IntWriteEntry( &pNtk->vTypes, pNtk->nObjs, CBA_OBJ_NODE );
Vec_IntWriteEntry( &pNtk->vFuncs, pNtk->nObjs, Type );
Vec_IntWriteEntry( &pNtk->vFanins, pNtk->nObjs, Cba_ManHandleArray(p, vTemp) );
@@ -311,7 +373,7 @@ void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
// create constant 0 drivers for COs without barbufs
Cba_ManForEachNtk( p, pNtk, i )
{
- Cba_NtkForEachBox( pNtk, iBox, k )
+ Cba_NtkForEachBox( pNtk, iBox )
Cba_BoxForEachBi( pNtk, iBox, iTerm, j )
if ( Cba_ObjFanin0(pNtk, iTerm) == -1 )
Cba_NtkCreateAndConnectBuffer( NULL, NULL, pNtk, iTerm );
@@ -333,7 +395,6 @@ Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
Cba_NtkInsertGia( pNew, pGia );
Vec_IntFree( vNtkSizes );
return pNew;
-
}
/**Function*************************************************************
@@ -368,10 +429,149 @@ Cba_Man_t * Cba_ManBlastTest( Cba_Man_t * p )
SeeAlso []
***********************************************************************/
+static inline int Abc_NodeIsSeriousGate( Abc_Obj_t * p )
+{
+ return Abc_ObjIsNode(p) && (Abc_ObjFaninNum(p) > 0);
+}
+Vec_Int_t * Cba_ManCountAbc( Cba_Man_t * p, Abc_Ntk_t * pNtk, int fAlwaysAdd )
+{
+ Cba_Ntk_t * pCbaNtk;
+ Abc_Obj_t * pObj, * pFanin;
+ int i, k, iBox, Count = 0;
+ Vec_Int_t * vNtkSizes = Vec_IntStart( Cba_ManNtkNum(p) + 1 );
+ Vec_Int_t * vDrivenCos = Vec_IntStart( Cba_ManNtkNum(p) + 1 );
+ assert( Vec_IntSize(p->vBuf2LeafNtk) == pNtk->nBarBufs2 );
+ // assing for each GIA node, the network it belongs to and count nodes for all networks
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ pObj->iTemp = 1;
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ if ( Abc_ObjIsBarBuf(pObj) )
+ {
+ if ( Abc_NodeIsSeriousGate(Abc_ObjFanin0(pObj)) )
+ Vec_IntAddToEntry( vDrivenCos, Abc_ObjFanin0(pObj)->iTemp, 1 );
+ pObj->iTemp = Vec_IntEntry( p->vBuf2LeafNtk, Count++ );
+ }
+ else if ( Abc_NodeIsSeriousGate(pObj) )
+ {
+ pObj->iTemp = Abc_ObjFanin0(pObj)->iTemp;
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ assert( pObj->iTemp == pFanin->iTemp );
+ Vec_IntAddToEntry( vNtkSizes, pObj->iTemp, 1 );
+ }
+ }
+ assert( Count == pNtk->nBarBufs2 );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ assert( Abc_ObjFanin0(pObj)->iTemp == 1 );
+ pObj->iTemp = Abc_ObjFanin0(pObj)->iTemp;
+ if ( Abc_NodeIsSeriousGate(Abc_ObjFanin0(pObj)) )
+ Vec_IntAddToEntry( vDrivenCos, pObj->iTemp, 1 );
+ }
+ // for each network, count the total number of COs
+ Cba_ManForEachNtk( p, pCbaNtk, i )
+ {
+ Count = Cba_NtkPiNum(pCbaNtk) + 2 * Cba_NtkPoNum(pCbaNtk) - (fAlwaysAdd ? 0 : Vec_IntEntry(vDrivenCos, i));
+ Cba_NtkForEachBox( pCbaNtk, iBox )
+ Count += Cba_ObjBoxSize(pCbaNtk, iBox) + Cba_ObjBoxBiNum(pCbaNtk, iBox);
+ Vec_IntAddToEntry( vNtkSizes, i, Count );
+ }
+ Vec_IntFree( vDrivenCos );
+ return vNtkSizes;
+}
+void Cba_NtkCreateOrConnectFanin( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin, Cba_Ntk_t * p, int iTerm )
+{
+ if ( pNtk && Abc_NodeIsSeriousGate(pFanin) )
+ {
+ Vec_IntWriteEntry( &p->vNameIds, pFanin->iTemp, Cba_ObjNameId(p, iTerm) );
+ Vec_IntWriteEntry( &p->vFanins, iTerm, pFanin->iTemp );
+ }
+ else
+ {
+ assert( !pFanin || Abc_NodeIsConst0(pFanin) || Abc_NodeIsConst1(pFanin) );
+ Vec_IntWriteEntry( &p->vTypes, p->nObjs, CBA_OBJ_NODE );
+ Vec_IntWriteEntry( &p->vFuncs, p->nObjs, pNtk && Abc_NodeIsConst1(pFanin) ? 2 : 1 ); // assuming elem gates are added first
+ Vec_IntWriteEntry( &p->vFanins, p->nObjs, Cba_ManHandleBuffer(p->pDesign, -1) );
+ Vec_IntWriteEntry( &p->vNameIds, p->nObjs, Cba_ObjNameId(p, iTerm) );
+ Vec_IntWriteEntry( &p->vFanins, iTerm, p->nObjs++ );
+ }
+}
+void Cba_NtkPrepareLibrary( Cba_Man_t * p, Mio_Library_t * pLib )
+{
+ Mio_Gate_t * pGate;
+ Mio_Gate_t * pGate0 = Mio_LibraryReadConst0( pLib );
+ Mio_Gate_t * pGate1 = Mio_LibraryReadConst1( pLib );
+ assert( Abc_NamObjNumMax(p->pFuncs) == 1 );
+ Abc_NamStrFindOrAdd( p->pFuncs, Mio_GateReadName(pGate0), NULL );
+ Abc_NamStrFindOrAdd( p->pFuncs, Mio_GateReadName(pGate1), NULL );
+ assert( Abc_NamObjNumMax(p->pFuncs) == 3 );
+ Mio_LibraryForEachGate( pLib, pGate )
+ if ( pGate != pGate0 && pGate != pGate1 )
+ Abc_NamStrFindOrAdd( p->pFuncs, Mio_GateReadName(pGate), NULL );
+ assert( Abc_NamObjNumMax(p->pFuncs) > 1 );
+}
+void Cba_NtkInsertNtk( Cba_Man_t * p, Abc_Ntk_t * pNtk )
+{
+ Cba_Ntk_t * pCbaNtk, * pRoot = Cba_ManRoot( p );
+ Vec_Int_t * vTemp = Vec_IntAlloc( 100 );
+ int i, j, k, iBox, iTerm, Count = 0;
+ Abc_Obj_t * pObj, * pFanin;
+ assert( Abc_NtkHasMapping(pNtk) );
+ Cba_NtkPrepareLibrary( p, (Mio_Library_t *)pNtk->pManFunc );
+
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ pObj->iTemp = Cba_NtkPi( pRoot, i );
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ if ( Abc_ObjIsBarBuf(pObj) )
+ {
+ pCbaNtk = Cba_ManNtk( p, Vec_IntEntry(p->vBuf2RootNtk, Count) );
+ iTerm = Vec_IntEntry( p->vBuf2RootObj, Count );
+ assert( Cba_ObjIsCo(pCbaNtk, iTerm) );
+ Cba_NtkCreateOrConnectFanin( pNtk, Abc_ObjFanin0(pObj), pCbaNtk, iTerm );
+ // prepare leaf
+ pObj->iTemp = Vec_IntEntry( p->vBuf2LeafObj, Count++ );
+ }
+ else if ( Abc_NodeIsSeriousGate(pObj) )
+ {
+ Vec_IntClear( vTemp );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Vec_IntPush( vTemp, pFanin->iTemp );
+ pCbaNtk = Cba_ManNtk( p, pObj->iTemp );
+ Vec_IntWriteEntry( &pCbaNtk->vTypes, pCbaNtk->nObjs, CBA_OBJ_NODE );
+ Vec_IntWriteEntry( &pCbaNtk->vFuncs, pCbaNtk->nObjs, Abc_NamStrFind(p->pFuncs, Mio_GateReadName((Mio_Gate_t *)pObj->pData)) );
+ Vec_IntWriteEntry( &pCbaNtk->vFanins, pCbaNtk->nObjs, Cba_ManHandleArray(p, vTemp) );
+ pObj->iTemp = pCbaNtk->nObjs++;
+ }
+ }
+ assert( Count == pNtk->nBarBufs2 );
+ Vec_IntFree( vTemp );
+
+ // create constant 0 drivers for COs without barbufs
+ Cba_ManForEachNtk( p, pCbaNtk, i )
+ {
+ Cba_NtkForEachBox( pCbaNtk, iBox )
+ Cba_BoxForEachBi( pCbaNtk, iBox, iTerm, j )
+ if ( Cba_ObjFanin0(pCbaNtk, iTerm) == -1 )
+ Cba_NtkCreateOrConnectFanin( NULL, NULL, pCbaNtk, iTerm );
+ Cba_NtkForEachPo( pCbaNtk, iTerm, k )
+ if ( pCbaNtk != pRoot && Cba_ObjFanin0(pCbaNtk, iTerm) == -1 )
+ Cba_NtkCreateOrConnectFanin( NULL, NULL, pCbaNtk, iTerm );
+ }
+ // create node and connect POs
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ Cba_NtkCreateOrConnectFanin( pNtk, Abc_ObjFanin0(pObj), pRoot, Cba_NtkPo(pRoot, i) );
+ Cba_ManForEachNtk( p, pCbaNtk, i )
+ assert( Cba_NtkObjNum(pCbaNtk) == pCbaNtk->nObjs );
+}
void * Cba_ManInsertAbc( Cba_Man_t * p, void * pAbc )
{
- Abc_Ntk_t * pNtk = pAbc;
- Cba_Man_t * pNew = NULL;
+ Abc_Ntk_t * pNtk = (Abc_Ntk_t *)pAbc;
+ Vec_Int_t * vNtkSizes = Cba_ManCountAbc( p, pNtk, 0 );
+ Cba_Man_t * pNew = Cba_ManDupStart( p, vNtkSizes );
+ Cba_ManRemapBarbufs( pNew, p );
+ Cba_NtkInsertNtk( pNew, pNtk );
+ Vec_IntFree( vNtkSizes );
return pNew;
}
diff --git a/src/base/cba/cbaBuild.c b/src/base/cba/cbaBuild.c
index ddacc409..86d60983 100644
--- a/src/base/cba/cbaBuild.c
+++ b/src/base/cba/cbaBuild.c
@@ -73,12 +73,9 @@ void Cba_BoxRemap( Cba_Ntk_t * pNtk, int iBox, Vec_Int_t * vMap )
}
void Cba_NtkRemapBoxes( Cba_Ntk_t * pNtk, Vec_Int_t * vMap )
{
- int Type, iBox;
- Cba_NtkForEachObjType( pNtk, Type, iBox )
- if ( Type == CBA_OBJ_BOX )
- Cba_BoxRemap( pNtk, iBox, vMap );
- Vec_IntForEachEntry( vMap, Type, iBox )
- assert( Type == -1 );
+ int iBox;
+ Cba_NtkForEachBox( pNtk, iBox )
+ Cba_BoxRemap( pNtk, iBox, vMap );
}
// create maps of NameId and boxes
void Cba_NtkFindNonDriven( Cba_Ntk_t * pNtk, Vec_Int_t * vMap, int nObjCount, Vec_Int_t * vNonDriven )
@@ -164,7 +161,7 @@ int Cba_NtkCreateMap( Cba_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vBoxes, Ve
nObjCount += Vec_IntSize(vNonDriven) + Cba_NtkPoNum(pNtk);
return nObjCount;
}
-Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vNonDriven, Vec_Int_t * vTemp, int nObjCount )
+Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vBoxes, Vec_Int_t * vNonDriven, Vec_Int_t * vTemp, int nObjCount )
{
Vec_Int_t * vFanins;
Cba_Ntk_t * pNtkNew, * pNtkBox;
@@ -202,7 +199,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
else if ( Type == CBA_OBJ_BOX )
{
- ObjId = Vec_IntEntry( &pNtkNew->vBoxes, nBoxes++ );
+ ObjId = Vec_IntEntry( vBoxes, nBoxes++ );
pNtkBox = Cba_ObjBoxModel( pNtk, iObj );
// collect fanins
Vec_IntFill( vTemp, Cba_NtkPiNum(pNtkBox), -1 );
@@ -243,7 +240,7 @@ Cba_Ntk_t * Cba_NtkBuild( Cba_Man_t * pNew, Cba_Ntk_t * pNtk, Vec_Int_t * vMap,
}
}
}
- assert( nBoxes == Vec_IntSize(&pNtkNew->vBoxes) );
+ assert( nBoxes == Vec_IntSize(vBoxes) );
// add constants for nondriven nodes
Vec_IntForEachEntry( vNonDriven, NameId, i )
{
@@ -309,6 +306,7 @@ Cba_Man_t * Cba_ManBuild( Cba_Man_t * p )
{
Cba_Man_t * pNew = Cba_ManClone( p );
Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(p->pNames) + 1 );
+ Vec_Int_t * vBoxes = Vec_IntAlloc( 1000 );
Vec_Int_t * vNonDr = Vec_IntAlloc( 1000 );
Vec_Int_t * vTemp = Vec_IntAlloc( 1000 );
Cba_Ntk_t * pNtk;
@@ -317,11 +315,13 @@ Cba_Man_t * Cba_ManBuild( Cba_Man_t * p )
Cba_ManForEachNtk( p, pNtk, i )
{
Cba_NtkRemapBoxes( pNtk, vMap );
- nObjs = Cba_NtkCreateMap( pNtk, vMap, &Cba_ManNtk(pNew, i)->vBoxes, vNonDr );
- Cba_NtkBuild( pNew, pNtk, vMap, vNonDr, vTemp, nObjs );
+ nObjs = Cba_NtkCreateMap( pNtk, vMap, vBoxes, vNonDr );
+ Cba_NtkBuild( pNew, pNtk, vMap, vBoxes, vNonDr, vTemp, nObjs );
Cba_NtkCleanMap( pNtk, vMap );
}
+ assert( Vec_IntCountEntry(vMap, -1) == Vec_IntSize(vMap) );
Vec_IntFree( vMap );
+ Vec_IntFree( vBoxes );
Vec_IntFree( vNonDr );
Vec_IntFree( vTemp );
return pNew;
diff --git a/src/base/cba/cbaCom.c b/src/base/cba/cbaCom.c
index 329f1b0a..73e69f5f 100644
--- a/src/base/cba/cbaCom.c
+++ b/src/base/cba/cbaCom.c
@@ -149,7 +149,7 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
else if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) )
p = Cba_PrsReadBlif( pFileName );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
- p = Cba_PrsReadVerilog( pFileName );
+ p = Cba_PrsReadVerilog( pFileName, 1 );
else assert( 0 );
p = Cba_ManBuild( pTemp = p );
Cba_ManFree( pTemp );
@@ -465,7 +465,7 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !strcmp( Extra_FileNameExtension(FileName), "blif" ) )
p = Cba_PrsReadBlif( FileName );
else if ( !strcmp( Extra_FileNameExtension(FileName), "v" ) )
- p = Cba_PrsReadVerilog( FileName );
+ p = Cba_PrsReadVerilog( FileName, 1 );
else assert( 0 );
p = Cba_ManBuild( pTemp = p );
Cba_ManFree( pTemp );
diff --git a/src/base/cba/cbaNtk.c b/src/base/cba/cbaNtk.c
index af48f227..257d39bb 100644
--- a/src/base/cba/cbaNtk.c
+++ b/src/base/cba/cbaNtk.c
@@ -43,11 +43,11 @@ ABC_NAMESPACE_IMPL_START
***********************************************************************/
void Cba_ManAssignInternNamesNtk( Cba_Ntk_t * p )
{
- int i, Type, NameId;
+ int i, NameId;
int nDigits = Abc_Base10Log( Cba_NtkObjNum(p) );
- Cba_NtkForEachObjType( p, Type, i )
+ Cba_NtkForEachNode( p, i )
{
- if ( Type == CBA_OBJ_NODE && Cba_ObjNameId(p, i) == -1 )
+ if ( Cba_ObjNameId(p, i) == -1 )
{
char Buffer[100];
sprintf( Buffer, "%s%0*d", "_n_", nDigits, i );
@@ -109,28 +109,25 @@ void Cba_ObjDupStart( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int iObj )
Vec_IntWriteEntry( &pNew->vNameIds, pNew->nObjs, Cba_ObjNameId(p, iObj) );
if ( Cba_ObjIsBox(p, iObj) )
Cba_NtkSetHost( Cba_ObjBoxModel(pNew, pNew->nObjs), Cba_NtkId(pNew), pNew->nObjs );
- if ( Cba_ObjIsBox(p, iObj) )
- Vec_IntPush( &pNew->vBoxes, pNew->nObjs );
Cba_NtkSetCopy( p, iObj, pNew->nObjs++ );
}
void Cba_NtkDupStart( Cba_Ntk_t * pNew, Cba_Ntk_t * p )
{
- int i, k, iObj, iTerm;
- assert( Vec_IntSize(&pNew->vBoxes) == 0 );
+ int i, iObj, iTerm;
pNew->nObjs = 0;
Cba_NtkForEachPi( p, iObj, i )
Cba_ObjDupStart( pNew, p, iObj );
Cba_NtkForEachPo( p, iObj, i )
Cba_ObjDupStart( pNew, p, iObj );
- Cba_NtkForEachBox( p, iObj, i )
+ Cba_NtkForEachBox( p, iObj )
{
- Cba_BoxForEachBi( p, iObj, iTerm, k )
+ Cba_BoxForEachBi( p, iObj, iTerm, i )
Cba_ObjDupStart( pNew, p, iTerm );
Cba_ObjDupStart( pNew, p, iObj );
- Cba_BoxForEachBo( p, iObj, iTerm, k )
+ Cba_BoxForEachBo( p, iObj, iTerm, i )
Cba_ObjDupStart( pNew, p, iTerm );
// connect box outputs to boxes
- Cba_BoxForEachBo( p, iObj, iTerm, k )
+ Cba_BoxForEachBo( p, iObj, iTerm, i )
Vec_IntWriteEntry( &pNew->vFanins, Cba_NtkCopy(p, iTerm), Cba_NtkCopy(p, Cba_ObjFanin0(p, iTerm)) );
}
assert( Cba_NtkBoxNum(p) == Cba_NtkBoxNum(pNew) );
diff --git a/src/base/cba/cbaPrs.h b/src/base/cba/cbaPrs.h
index 12a2c065..222a7534 100644
--- a/src/base/cba/cbaPrs.h
+++ b/src/base/cba/cbaPrs.h
@@ -197,17 +197,15 @@ static inline void Cba_PrsFree( Cba_Prs_t * p )
}
static inline void Cba_PrsRemapBoxModels( Cba_Man_t * p )
{
- Cba_Ntk_t * pNtk;
- int i, Type, iObj;
+ Cba_Ntk_t * pNtk; int i, iBox;
Cba_ManForEachNtk( p, pNtk, i )
- Cba_NtkForEachObjType( pNtk, Type, iObj )
- if ( Type == CBA_OBJ_BOX )
- {
- char * pName = Abc_NamStr( p->pNames, Cba_ObjFuncId(pNtk, iObj) );
- int iModelId = Abc_NamStrFind( p->pModels, pName );
- assert( iModelId > 0 );
- Vec_IntWriteEntry( &pNtk->vFuncs, iObj, iModelId );
- }
+ Cba_NtkForEachBox( pNtk, iBox )
+ {
+ char * pName = Abc_NamStr( p->pNames, Cba_ObjFuncId(pNtk, iBox) );
+ int iModelId = Abc_NamStrFind( p->pModels, pName );
+ assert( iModelId > 0 );
+ Vec_IntWriteEntry( &pNtk->vFuncs, iBox, iModelId );
+ }
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/cba/cbaReadBlif.c b/src/base/cba/cbaReadBlif.c
index 83ec12f5..fa552990 100644
--- a/src/base/cba/cbaReadBlif.c
+++ b/src/base/cba/cbaReadBlif.c
@@ -62,11 +62,11 @@ static inline void Cba_PrsAddBlifDirectives( Cba_Prs_t * p )
{
int i;
for ( i = 1; s_BlifTypes[i]; i++ )
- Abc_NamStrFindOrAdd( p->pDesign->pNames, (char *)s_BlifTypes[i], NULL );
+ Abc_NamStrFindOrAdd( p->pDesign->pNames, (char *)s_BlifTypes[i], NULL );
assert( Abc_NamObjNumMax(p->pDesign->pNames) == i );
for ( i = 1; i < CBA_NODE_UNKNOWN; i++ )
- Abc_NamStrFindOrAdd( p->pDesign->pFuncs, Ptr_TypeToSop(i), NULL );
- assert( Abc_NamObjNumMax(p->pDesign->pFuncs) == i-1 );
+ Abc_NamStrFindOrAdd( p->pDesign->pFuncs, Ptr_TypeToSop(i), NULL );
+ assert( Abc_NamObjNumMax(p->pDesign->pFuncs) == i );
}
diff --git a/src/base/cba/cbaReadVer.c b/src/base/cba/cbaReadVer.c
index 714830ab..6eeb104f 100644
--- a/src/base/cba/cbaReadVer.c
+++ b/src/base/cba/cbaReadVer.c
@@ -708,7 +708,57 @@ void Cba_PrsPrintModules( Cba_Prs_t * p )
SeeAlso []
***********************************************************************/
-Cba_Man_t * Cba_PrsReadVerilog( char * pFileName )
+void Cba_PrsSkipRangesNtk( Cba_Ntk_t * p )
+{
+ Vec_Int_t * vFanins;
+ int FormId, NameId, RangeId;
+ int i, k, s, Count = 0;
+ Vec_Int_t * vSigs[4] = { &p->vInouts, &p->vInputs, &p->vOutputs, &p->vWires };
+ for ( s = 0; s < 4; s++ )
+ {
+ k = 0;
+ Vec_IntForEachEntryDouble( vSigs[s], NameId, RangeId, i )
+ Vec_IntWriteEntry( vSigs[s], k++, NameId ), Count += RangeId > 0;
+ Vec_IntShrink( vSigs[s], k );
+ }
+ Cba_NtkForEachNode( p, i )
+ {
+ k = 0;
+ vFanins = Cba_ObjFaninVec( p, i );
+ Vec_IntForEachEntryDouble( vFanins, NameId, RangeId, s )
+ Vec_IntWriteEntry( vFanins, k++, NameId ), Count += RangeId > 0;
+ Cba_ObjFaninArray(p, i)[0] = k;
+ }
+ Cba_NtkForEachBox( p, i )
+ {
+ k = 0;
+ vFanins = Cba_ObjFaninVec( p, i );
+ Vec_IntForEachEntryTriple( vFanins, FormId, NameId, RangeId, s )
+ Vec_IntWriteEntry( vFanins, k++, FormId ), Vec_IntWriteEntry( vFanins, k++, NameId ), Count += RangeId > 0;
+ Cba_ObjFaninArray(p, i)[0] = k;
+ }
+ if ( Count )
+ printf( "Network %s has %d non-trivial ranges.\n", Cba_NtkName(p), Count );
+}
+void Cba_PrsSkipRanges( Cba_Man_t * p )
+{
+ Cba_Ntk_t * pNtk; int i;
+ Cba_ManForEachNtk( p, pNtk, i )
+ Cba_PrsSkipRangesNtk( pNtk );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Cba_Man_t * Cba_PrsReadVerilog( char * pFileName, int fBinary )
{
Cba_Man_t * pDesign = NULL;
Cba_Prs_t * p = Cba_PrsAlloc( pFileName );
@@ -716,11 +766,14 @@ Cba_Man_t * Cba_PrsReadVerilog( char * pFileName )
return NULL;
Cba_PrsAddVerilogDirectives( p );
Cba_PrsReadDesign( p );
- Cba_PrsPrintModules( p );
+ //Cba_PrsPrintModules( p );
if ( Cba_PrsErrorPrint(p) )
ABC_SWAP( Cba_Man_t *, pDesign, p->pDesign );
Cba_PrsFree( p );
Cba_PrsRemapBoxModels( pDesign );
+ // transform to binary ranges
+ if ( fBinary )
+ Cba_PrsSkipRanges( pDesign );
return pDesign;
}
@@ -728,16 +781,16 @@ void Cba_PrsReadVerilogTest( char * pFileName )
{
abctime clk = Abc_Clock();
extern void Cba_PrsWriteVerilog( char * pFileName, Cba_Man_t * p );
- Cba_Man_t * p = Cba_PrsReadVerilog( "c/hie/dump/1/netlist_1.v" );
-// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/me/me_wide.v" );
-// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/ray/ray_wide.v" );
+ Cba_Man_t * p = Cba_PrsReadVerilog( "c/hie/dump/24/netlist_0.v", 0 );
+// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/me/me_wide.v", 0 );
+// Cba_Man_t * p = Cba_PrsReadVerilog( "aga/ray/ray_wide.v", 0 );
if ( !p ) return;
printf( "Finished reading %d networks. ", Cba_ManNtkNum(p) );
printf( "NameIDs = %d. ", Abc_NamObjNumMax(p->pNames) );
printf( "Memory = %.2f MB. ", 1.0*Cba_ManMemory(p)/(1<<20) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
// Abc_NamPrint( p->pDesign->pNames );
- Cba_PrsWriteVerilog( "c/hie/dump/1/netlist_1_out.v", p );
+ Cba_PrsWriteVerilog( "c/hie/dump/24/netlist_0_out.v", p );
// Cba_PrsWriteVerilog( "aga/me/me_wide_out.v", p );
// Cba_PrsWriteVerilog( "aga/ray/ray_wide_out.v", p );
Cba_ManFree( p );
diff --git a/src/base/cba/cbaSimple.c b/src/base/cba/cbaSimple.c
index 7fe6cb0a..702fa2b0 100644
--- a/src/base/cba/cbaSimple.c
+++ b/src/base/cba/cbaSimple.c
@@ -481,11 +481,10 @@ Vec_Ptr_t * Ptr_CbaDeriveNode( Cba_Ntk_t * pNtk, int iObj )
}
Vec_Ptr_t * Ptr_CbaDeriveNodes( Cba_Ntk_t * pNtk )
{
- int Type, iObj;
+ int i;
Vec_Ptr_t * vNodes = Vec_PtrAlloc( Cba_NtkNodeNum(pNtk) );
- Cba_NtkForEachObjType( pNtk, Type, iObj )
- if ( Type == CBA_OBJ_NODE )
- Vec_PtrPush( vNodes, Ptr_CbaDeriveNode(pNtk, iObj) );
+ Cba_NtkForEachNode( pNtk, i )
+ Vec_PtrPush( vNodes, Ptr_CbaDeriveNode(pNtk, i) );
assert( Ptr_CheckArray(vNodes) );
return vNodes;
}
@@ -515,11 +514,10 @@ Vec_Ptr_t * Ptr_CbaDeriveBox( Cba_Ntk_t * pNtk, int iObj )
}
Vec_Ptr_t * Ptr_CbaDeriveBoxes( Cba_Ntk_t * pNtk )
{
- int Type, iObj;
+ int i;
Vec_Ptr_t * vBoxes = Vec_PtrAlloc( Cba_NtkBoxNum(pNtk) );
- Cba_NtkForEachObjType( pNtk, Type, iObj )
- if ( Type == CBA_OBJ_BOX )
- Vec_PtrPush( vBoxes, Ptr_CbaDeriveBox(pNtk, iObj) );
+ Cba_NtkForEachBox( pNtk, i )
+ Vec_PtrPush( vBoxes, Ptr_CbaDeriveBox(pNtk, i) );
assert( Ptr_CheckArray(vBoxes) );
return vBoxes;
}
@@ -620,7 +618,6 @@ void Cba_PrsReadModule( Cba_Man_t * p, Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_I
Cba_ManAllocArray( p, &pNtk->vFuncs, Vec_PtrSize(vNodes) + Vec_PtrSize(vBoxes) );
Cba_ManAllocArray( p, &pNtk->vInstIds, Vec_PtrSize(vNodes) + Vec_PtrSize(vBoxes) );
Cba_ManAllocArray( p, &pNtk->vFanins, Vec_PtrSize(vNodes) + Vec_PtrSize(vBoxes) );
- Cba_ManAllocArray( p, &pNtk->vBoxes, Vec_PtrSize(vBoxes) );
Cba_PrsReadList( p, vInputs, &pNtk->vInputs, -1, -1 );
Cba_PrsReadList( p, vOutputs, &pNtk->vOutputs, -1, -1 );
diff --git a/src/base/cba/cbaWriteBlif.c b/src/base/cba/cbaWriteBlif.c
index 656ae8c0..7e227d2d 100644
--- a/src/base/cba/cbaWriteBlif.c
+++ b/src/base/cba/cbaWriteBlif.c
@@ -20,6 +20,8 @@
#include "cba.h"
#include "cbaPrs.h"
+#include "map/mio/mio.h"
+#include "base/main/main.h"
ABC_NAMESPACE_IMPL_START
@@ -131,6 +133,14 @@ void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * p )
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;
@@ -157,10 +167,20 @@ void Cba_ManWriteBlifLines( FILE * pFile, Cba_Ntk_t * p )
{
if ( Type == CBA_OBJ_NODE ) // .names/assign/box2 (no formal/actual binding)
{
- fprintf( pFile, ".names" );
- Cba_ManWriteBlifArray( pFile, p, Cba_ObjFaninVec(p, i), i );
- //fprintf( pFile, "%s", Cba_NtkFuncStr(p, Cba_ObjFuncId(p, i)) );
- fprintf( pFile, "%s", Ptr_TypeToSop( Cba_ObjFuncId(p, i) ) );
+ if ( Abc_NamObjNumMax(p->pDesign->pFuncs) > 1 ) // mapped
+ {
+ char * pGateName = Abc_NamStr( p->pDesign->pFuncs, Cba_ObjFuncId(p, i) );
+ Mio_Gate_t * pGate = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pDesign->pMioLib, pGateName, NULL );
+ fprintf( pFile, ".gate" );
+ Cba_ManWriteBlifGate( pFile, p, pGate, Cba_ObjFaninVec(p, i), i );
+ }
+ else
+ {
+ fprintf( pFile, ".names" );
+ Cba_ManWriteBlifArray( pFile, p, Cba_ObjFaninVec(p, i), i );
+ //fprintf( pFile, "%s", Cba_NtkFuncStr(p, Cba_ObjFuncId(p, i)) );
+ fprintf( pFile, "%s", Ptr_TypeToSop( Cba_ObjFuncId(p, i) ) );
+ }
}
else if ( Type == CBA_OBJ_BOX ) // .names/assign/box2 (no formal/actual binding)
{
@@ -201,6 +221,12 @@ void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p )
FILE * pFile;
Cba_Ntk_t * pNtk;
int i;
+ // check the library
+ if ( Abc_NamObjNumMax(p->pFuncs) > 1 && p->pMioLib != Abc_FrameReadLibGen() )
+ {
+ printf( "Genlib library used in the mapped design is not longer a current library.\n" );
+ return;
+ }
pFile = fopen( pFileName, "wb" );
if ( pFile == NULL )
{
diff --git a/src/base/cba/cbaWriteVer.c b/src/base/cba/cbaWriteVer.c
index d928da4b..e2769239 100644
--- a/src/base/cba/cbaWriteVer.c
+++ b/src/base/cba/cbaWriteVer.c
@@ -116,14 +116,13 @@ void Cba_PrsWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p )
}
void Cba_PrsWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p )
{
- int Type, i;
- Cba_NtkForEachObjType( p, Type, i )
- if ( Type == CBA_OBJ_BOX ) // .subckt/.gate/box (formal/actual binding)
- {
- fprintf( pFile, " %s %s (", Cba_NtkName(Cba_ObjBoxModel(p, i)), Cba_ObjInstStr(p, i) );
- Cba_PrsWriteVerilogArray3( pFile, p, Cba_ObjFaninVec(p, i) );
- fprintf( pFile, ");\n" );
- }
+ int i;
+ Cba_NtkForEachBox( p, i ) // .subckt/.gate/box (formal/actual binding)
+ {
+ fprintf( pFile, " %s %s (", Cba_NtkName(Cba_ObjBoxModel(p, i)), Cba_ObjInstStr(p, i) );
+ Cba_PrsWriteVerilogArray3( pFile, p, Cba_ObjFaninVec(p, i) );
+ fprintf( pFile, ");\n" );
+ }
}
void Cba_PrsWriteVerilogSignals( FILE * pFile, Cba_Ntk_t * p, int SigType )
{
@@ -259,40 +258,32 @@ void Cba_ManWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, int iObj, Vec_Int_t
}
void Cba_ManWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p )
{
- int Type, Func, i;
- Cba_NtkForEachObjType( p, Type, i )
- if ( Type == CBA_OBJ_NODE ) // .names/assign/box2 (no formal/actual binding)
+ int Func, i;
+ Cba_NtkForEachNode( p, i ) // .names/assign/box2 (no formal/actual binding)
+ {
+ Func = Cba_ObjFuncId(p, i);
+ if ( Func >= CBA_NODE_BUF && Func <= CBA_NODE_XNOR )
{
- Func = Cba_ObjFuncId(p, i);
- if ( Func >= CBA_NODE_BUF && Func <= CBA_NODE_XNOR )
- {
- fprintf( pFile, " %s (", Ptr_TypeToName(Func) );
- Cba_ManWriteVerilogArray2( pFile, p, i, Cba_ObjFaninVec(p, i) );
- fprintf( pFile, ");\n" );
- }
-// else if ( Func == CBA_NODE_MUX )
-// Cba_PrsWriteVerilogMux( pFile, p, Cba_ObjFaninVec(p, i) );
- else
- {
- //char * pName = Cba_NtkStr(p, Func);
- assert( 0 );
- }
+ fprintf( pFile, " %s (", Ptr_TypeToName(Func) );
+ Cba_ManWriteVerilogArray2( pFile, p, i, Cba_ObjFaninVec(p, i) );
+ fprintf( pFile, ");\n" );
}
+ else assert( 0 );
+ }
}
void Cba_ManWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p )
{
- int i, k, iTerm, Type;
- Cba_NtkForEachObjType( p, Type, i )
- if ( Type == CBA_OBJ_BOX ) // .subckt/.gate/box (formal/actual binding)
- {
- Cba_Ntk_t * pModel = Cba_ObjBoxModel( p, i );
- fprintf( pFile, " %s %s (", Cba_NtkName(pModel), Vec_IntSize(&p->vInstIds) ? Cba_ObjInstStr(p, i) : "" );
- Cba_NtkForEachPi( pModel, iTerm, k )
- fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_ObjBoxBi(p, i, k)) );
- Cba_NtkForEachPo( pModel, iTerm, k )
- fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_ObjBoxBo(p, i, k)) );
- fprintf( pFile, "\n" );
- }
+ int i, k, iTerm;
+ Cba_NtkForEachBox( p, i ) // .subckt/.gate/box (formal/actual binding)
+ {
+ Cba_Ntk_t * pModel = Cba_ObjBoxModel( p, i );
+ fprintf( pFile, " %s %s (", Cba_NtkName(pModel), Vec_IntSize(&p->vInstIds) ? Cba_ObjInstStr(p, i) : "" );
+ Cba_NtkForEachPi( pModel, iTerm, k )
+ fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_ObjBoxBi(p, i, k)) );
+ Cba_NtkForEachPo( pModel, iTerm, k )
+ fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_ObjBoxBo(p, i, k)) );
+ fprintf( pFile, "\n" );
+ }
}
void Cba_ManWriteVerilogSignals( FILE * pFile, Cba_Ntk_t * p, int SigType, int fNoRange )
{