Commit 6d94b6b1 by Alan Mishchenko

Improvements to bit-blaster.

parent 27b1e49d
......@@ -229,7 +229,16 @@ void Wlc_BlastSubtract( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits )
pAdd0[b] = Gia_ManHashXor(pNew, top_bit, pAdd1[b]);
}
}
void Wlc_BlastMinus( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vRes )
{
int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
int i, invert = 0;
for ( i = 0; i < nNum; i++ )
{
pRes[i] = Gia_ManHashMux( pNew, invert, Abc_LitNot(pRes[i]), pRes[i] );
invert = Gia_ManHashOr( pNew, invert, pNum[i] );
}
}
void Wlc_BlastMultiplier( Gia_Man_t * pNew, int * pArg0, int * pArg1, int nBits, Vec_Int_t * vTemp, Vec_Int_t * vRes )
{
int i, j;
......@@ -292,9 +301,38 @@ void Wlc_BlastDivider( Gia_Man_t * pNew, int * pNum, int nNum, int * pDiv, int n
}
void Wlc_BlastDividerSigned( Gia_Man_t * pNew, int * pNum, int nNum, int * pDiv, int nDiv, int fQuo, Vec_Int_t * vRes )
{
int iDiffSign = Gia_ManHashXor( pNew, pNum[nNum-1], pDiv[nDiv-1] );
Wlc_BlastDivider( pNew, pNum, nNum-1, pDiv, nDiv-1, fQuo, vRes );
Vec_IntPush( vRes, iDiffSign );
Vec_Int_t * vNum = Vec_IntAlloc( nNum );
Vec_Int_t * vDiv = Vec_IntAlloc( nDiv );
Vec_Int_t * vRes00 = Vec_IntAlloc( nNum );
Vec_Int_t * vRes01 = Vec_IntAlloc( nNum );
Vec_Int_t * vRes10 = Vec_IntAlloc( nNum );
Vec_Int_t * vRes11 = Vec_IntAlloc( nNum );
Vec_Int_t * vRes2 = Vec_IntAlloc( nNum );
int k, iDiffSign = Gia_ManHashXor( pNew, pNum[nNum-1], pDiv[nDiv-1] );
Wlc_BlastMinus( pNew, pNum, nNum, vNum );
Wlc_BlastMinus( pNew, pDiv, nDiv, vDiv );
Wlc_BlastDivider( pNew, pNum, nNum, pDiv, nDiv, fQuo, vRes00 );
Wlc_BlastDivider( pNew, pNum, nNum, Vec_IntArray(vDiv), nDiv, fQuo, vRes01 );
Wlc_BlastDivider( pNew, Vec_IntArray(vNum), nNum, pDiv, nDiv, fQuo, vRes10 );
Wlc_BlastDivider( pNew, Vec_IntArray(vNum), nNum, Vec_IntArray(vDiv), nDiv, fQuo, vRes11 );
Vec_IntClear( vRes );
for ( k = 0; k < nNum; k++ )
{
int Data0 = Gia_ManHashMux( pNew, pDiv[nDiv-1], Vec_IntEntry(vRes01,k), Vec_IntEntry(vRes00,k) );
int Data1 = Gia_ManHashMux( pNew, pDiv[nDiv-1], Vec_IntEntry(vRes11,k), Vec_IntEntry(vRes10,k) );
Vec_IntPush( vRes, Gia_ManHashMux(pNew, pNum[nNum-1], Data1, Data0) );
}
Wlc_BlastMinus( pNew, Vec_IntArray(vRes), nNum, vRes2 );
for ( k = 0; k < nNum; k++ )
Vec_IntWriteEntry( vRes, k, Gia_ManHashMux(pNew, fQuo ? iDiffSign : pNum[nNum-1], Vec_IntEntry(vRes2,k), Vec_IntEntry(vRes,k)) );
Vec_IntFree( vNum );
Vec_IntFree( vDiv );
Vec_IntFree( vRes00 );
Vec_IntFree( vRes01 );
Vec_IntFree( vRes10 );
Vec_IntFree( vRes11 );
Vec_IntFree( vRes2 );
assert( Vec_IntSize(vRes) == nNum );
}
void Wlc_BlastZeroCondition( Gia_Man_t * pNew, int * pDiv, int nDiv, Vec_Int_t * vRes )
{
......@@ -302,16 +340,6 @@ void Wlc_BlastZeroCondition( Gia_Man_t * pNew, int * pDiv, int nDiv, Vec_Int_t *
Vec_IntForEachEntry( vRes, Entry, i )
Vec_IntWriteEntry( vRes, i, Gia_ManHashAnd(pNew, iLit, Entry) );
}
void Wlc_BlastMinus( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vRes )
{
int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
int i, invert = 0;
for ( i = 0; i < nNum; i++ )
{
pRes[i] = Gia_ManHashMux( pNew, invert, Abc_LitNot(pRes[i]), pRes[i] );
invert = Gia_ManHashOr( pNew, invert, pNum[i] );
}
}
void Wlc_BlastTable( Gia_Man_t * pNew, word * pTable, int * pFans, int nFans, int nOuts, Vec_Int_t * vRes )
{
extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
......
......@@ -96,6 +96,31 @@ void Wlc_WriteTables( FILE * pFile, Wlc_Ntk_t * p )
SeeAlso []
***********************************************************************/
void Wlc_WriteAddPos( Wlc_Ntk_t * p )
{
Wlc_Obj_t * pObj;
int i;
Vec_IntClear( &p->vPos );
Wlc_NtkForEachObj( p, pObj, i )
if ( pObj->Type != WLC_OBJ_PI && pObj->Type != WLC_OBJ_MUX )
{
pObj->fIsPo = 1;
Vec_IntPush( &p->vPos, Wlc_ObjId(p, pObj) );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Wlc_WriteVerIntVec( FILE * pFile, Wlc_Ntk_t * p, Vec_Int_t * vVec, int Start )
{
char * pName;
......@@ -156,16 +181,27 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
fprintf( pFile, "output " );
else
fprintf( pFile, " " );
if ( Wlc_ObjIsCi(pObj) )
fprintf( pFile, "wire %s %s", Range, pName );
else if ( pObj->Type == WLC_OBJ_TABLE )
if ( Wlc_ObjIsCi(pObj) || pObj->fIsPo )
{
fprintf( pFile, "wire %s %s ;\n", Range, pName );
if ( Wlc_ObjIsCi(pObj) )
continue;
Range[0] = 0;
}
if ( pObj->fIsPo )
fprintf( pFile, " assign " );
else if ( pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3 )
fprintf( pFile, "reg " );
else
fprintf( pFile, "wire " );
if ( pObj->Type == WLC_OBJ_TABLE )
{
// wire [3:0] s4972; table0 s4972_Index(s4971, s4972);
fprintf( pFile, "wire %s %s ; table%d s%d_Index(%s, %s)", Range, pName, Wlc_ObjTableId(pObj), i, pName0, pName );
fprintf( pFile, "%s %s ; table%d s%d_Index(%s, %s)", Range, pName, Wlc_ObjTableId(pObj), i, pName0, pName );
}
else if ( pObj->Type == WLC_OBJ_CONST )
{
fprintf( pFile, "wire %s %-16s = %d\'%sh", Range, pName, Wlc_ObjRange(pObj), pObj->Signed ? "s":"" );
fprintf( pFile, "%s %-16s = %d\'%sh", Range, pName, Wlc_ObjRange(pObj), pObj->Signed ? "s":"" );
Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pObj), (Wlc_ObjRange(pObj) + 3) / 4 );
}
else if ( pObj->Type == WLC_OBJ_ROTATE_R || pObj->Type == WLC_OBJ_ROTATE_L )
......@@ -184,7 +220,7 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
}
else if ( pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3 )
{
fprintf( pFile, "reg %s ;\n", pName );
fprintf( pFile, "%s ;\n", pName );
fprintf( pFile, " " );
fprintf( pFile, "always @( " );
Wlc_ObjForEachFanin( pObj, iFanin, k )
......@@ -208,11 +244,13 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
}
else
{
fprintf( pFile, "wire %s %-16s = ", Range, Wlc_ObjName(p, i) );
fprintf( pFile, "%s %-16s = ", Range, Wlc_ObjName(p, i) );
if ( pObj->Type == WLC_OBJ_BUF )
fprintf( pFile, "%s", pName0 );
else if ( pObj->Type == WLC_OBJ_MUX )
fprintf( pFile, "%s ? %s : %s", pName0, Wlc_ObjName(p, Wlc_ObjFaninId2(pObj)), Wlc_ObjName(p, Wlc_ObjFaninId1(pObj)) );
else if ( pObj->Type == WLC_OBJ_ARI_MINUS )
fprintf( pFile, "-%s", pName0 );
else if ( pObj->Type == WLC_OBJ_BIT_NOT )
fprintf( pFile, "~%s", pName0 );
else if ( pObj->Type == WLC_OBJ_LOGIC_NOT )
......@@ -293,8 +331,6 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
assert( i == Wlc_ObjCiId(pObj) );
if ( pObj->Type == WLC_OBJ_PI )
continue;
// CPL_FF#9 I_32890_reg ( .q ( E_42304 ) , .qbar ( ) , .d ( E_42305 ) , .clk ( E_65040 ) ,
// .arst ( E_65037 ) , .arstval ( E_62126 ) );
fprintf( pFile, " " );
fprintf( pFile, "CPL_FF" );
if ( Wlc_ObjRange(pObj) > 1 )
......@@ -322,6 +358,7 @@ void Wlc_WriteVer( Wlc_Ntk_t * p, char * pFileName )
fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", p->pName, Extra_TimeStamp() );
fprintf( pFile, "\n" );
Wlc_WriteTables( pFile, p );
// Wlc_WriteAddPos( p );
Wlc_WriteVerInt( pFile, p );
fprintf( pFile, "\n" );
fclose( pFile );
......
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