Commit 7a4a63d0 by Alan Mishchenko

Several improvements to CBA data-structure.

parent ff1fd41a
......@@ -803,6 +803,10 @@ SOURCE=.\src\base\cba\cbaNtk.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaOper.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaPrs.h
# End Source File
# Begin Source File
......
......@@ -165,11 +165,12 @@ int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, int fBuffers, Ve
iRes = Abc_LitNot( pLits[0] );
else assert( 0 );
}
else
else if ( nLits == 2 )
{
assert( nLits == 2 );
if ( Type == CBA_BOX_AND )
iRes = Gia_ManHashAnd( pNew, pLits[0], pLits[1] );
else if ( Type == CBA_BOX_NAND )
iRes = Abc_LitNot( Gia_ManHashAnd( pNew, pLits[0], pLits[1] ) );
else if ( Type == CBA_BOX_OR )
iRes = Gia_ManHashOr( pNew, pLits[0], pLits[1] );
else if ( Type == CBA_BOX_NOR )
......@@ -180,9 +181,30 @@ int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, int fBuffers, Ve
iRes = Abc_LitNot( Gia_ManHashXor( pNew, pLits[0], pLits[1] ) );
else if ( Type == CBA_BOX_SHARP )
iRes = Gia_ManHashAnd( pNew, pLits[0], Abc_LitNot(pLits[1]) );
else if ( Type == CBA_BOX_SHARPL )
iRes = Gia_ManHashAnd( pNew, Abc_LitNot(pLits[0]), pLits[1] );
else assert( 0 );
}
//printf("%d input\n", nLits );
else if ( nLits == 3 )
{
if ( Type == CBA_BOX_MUX )
iRes = Gia_ManHashMux( pNew, pLits[0], pLits[1], pLits[2] );
else if ( Type == CBA_BOX_MAJ )
iRes = Gia_ManHashMaj( pNew, pLits[0], pLits[1], pLits[2] );
else if ( Type == CBA_BOX_ADD )
{
int iRes0 = Gia_ManHashAnd( pNew, pLits[1], pLits[2] );
int iRes1 = Gia_ManHashOr( pNew, pLits[1], pLits[2] );
assert( Cba_BoxBoNum(p, iBox) == 2 );
if ( Cba_BoxBo(p, iBox, 0) == i ) // sum
iRes = Gia_ManHashXor( pNew, pLits[0], Gia_ManHashAnd(pNew, Abc_LitNot(iRes0), iRes1) );
else if ( Cba_BoxBo(p, iBox, 1) == i ) // cout
iRes = Gia_ManHashOr( pNew, iRes0, Gia_ManHashAnd(pNew, pLits[0], iRes1) );
else assert( 0 );
}
else assert( 0 );
}
else assert( 0 );
}
}
}
......
......@@ -32,6 +32,67 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
Synopsis [Replaces fanin iOld by iNew in all fanouts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cba_NtkUpdateFanout( Cba_Ntk_t * p, int iOld, int iNew )
{
int iCo;
assert( Cba_ObjIsCi(p, iOld) );
assert( Cba_ObjIsCi(p, iNew) );
Cba_ObjForEachFanout( p, iOld, iCo )
{
assert( Cba_ObjFanin(p, iCo) == iOld );
Cba_ObjCleanFanin( p, iCo );
Cba_ObjSetFanin( p, iCo, iNew );
}
Cba_ObjSetFanout( p, iNew, Cba_ObjFanout(p, iOld) );
Cba_ObjSetFanout( p, iOld, 0 );
}
/**Function*************************************************************
Synopsis [Derives fanout.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cba_NtkDeriveFanout( Cba_Ntk_t * p )
{
int iCi, iCo;
assert( !Cba_NtkHasFanouts(p) );
Cba_NtkStartFanouts( p );
Cba_NtkForEachCo( p, iCo )
{
assert( !Cba_ObjNextFanout(p, iCo) );
iCi = Cba_ObjFanin(p, iCo);
if ( Cba_ObjFanout(p, iCi) )
Cba_ObjSetNextFanout( p, Cba_ObjFanout(p, iCi), iCo );
Cba_ObjSetFanout( p, iCi, iCo );
}
Cba_NtkForEachCo( p, iCo )
if ( !Cba_ObjNextFanout(p, iCo) )
Cba_ObjSetFanout( p, Cba_ObjFanin(p, iCo), iCo );
}
void Cba_ManDeriveFanout( Cba_Man_t * p )
{
Cba_Ntk_t * pNtk; int i;
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkDeriveFanout( pNtk );
}
/**Function*************************************************************
Synopsis [Assigns word-level names.]
Description []
......
......@@ -55,6 +55,10 @@ struct Prs_Ntk_t_
int iModuleName;
unsigned fMapped : 1;
unsigned fSlices : 1;
unsigned fHasC0s : 1;
unsigned fHasC1s : 1;
unsigned fHasCXs : 1;
unsigned fHasCZs : 1;
Abc_Nam_t * pStrs;
// interface
Vec_Int_t vOrder; // order of signals
......
......@@ -222,6 +222,16 @@ static inline int Prs_ManReadCube( Prs_Man_t * p )
static inline void Prs_ManSaveCover( Prs_Man_t * p )
{
int iToken;
if ( Vec_StrSize(&p->vCover) == 0 )
p->pNtk->fHasC0s = 1;
else if ( Vec_StrSize(&p->vCover) == 2 )
{
if ( Vec_StrEntryLast(&p->vCover) == '0' )
p->pNtk->fHasC0s = 1;
else if ( Vec_StrEntryLast(&p->vCover) == '1' )
p->pNtk->fHasC1s = 1;
else assert( 0 );
}
assert( Vec_StrSize(&p->vCover) > 0 );
Vec_StrPush( &p->vCover, '\0' );
//iToken = Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL );
......
......@@ -326,19 +326,39 @@ static inline int Prs_ManReadConstant( Prs_Man_t * p )
{
p->pCur++;
while ( Prs_CharIsDigitB(*p->pCur) )
{
if ( *p->pCur == '0' )
p->pNtk->fHasC0s = 1;
else if ( *p->pCur == '1' )
p->pNtk->fHasC1s = 1;
else if ( *p->pCur == 'x' )
p->pNtk->fHasCXs = 1;
else if ( *p->pCur == 'z' )
p->pNtk->fHasCZs = 1;
p->pCur++;
}
}
else if ( Prs_ManIsChar(p, 'h') )
{
p->pCur++;
p->pNtk->fHasC0s = 1;
while ( Prs_CharIsDigitH(*p->pCur) )
{
if ( *p->pCur != '0' )
p->pNtk->fHasC1s = 1;
p->pCur++;
}
}
else if ( Prs_ManIsChar(p, 'd') )
{
p->pCur++;
p->pNtk->fHasC0s = 1;
while ( Prs_ManIsDigit(p) )
{
if ( *p->pCur != '0' )
p->pNtk->fHasC1s = 1;
p->pCur++;
}
}
else return Prs_ManErrorSet(p, "Cannot read radix of constant.", 0);
return Abc_NamStrFindOrAddLim( p->pStrs, pStart, p->pCur, NULL );
......
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