Commit f23ea8e3 by Alan Mishchenko

Updates to NDR format (flops, memories, signed mult, etc).

parent 89c981c6
...@@ -138,8 +138,8 @@ typedef enum { ...@@ -138,8 +138,8 @@ typedef enum {
ABC_OPER_LATCH, // 86 ABC_OPER_LATCH, // 86
ABC_OPER_LATCHRS, // 87 ABC_OPER_LATCHRS, // 87
ABC_OPER_DFF, // 88 ABC_OPER_DFF, // 88
ABC_OPER_DFFCPL, // 89 ABC_OPER_DFFRSE, // 89
ABC_OPER_DFFRS, // 90 ABC_OPER_DFFLAST, // 90
ABC_OPER_SLICE, // 91 ABC_OPER_SLICE, // 91
ABC_OPER_CONCAT, // 92 ABC_OPER_CONCAT, // 92
......
...@@ -237,7 +237,7 @@ static inline void Acb_NtkFreeObjCnfs( Acb_Ntk_t * p ) { V ...@@ -237,7 +237,7 @@ static inline void Acb_NtkFreeObjCnfs( Acb_Ntk_t * p ) { V
static inline Acb_ObjType_t Acb_ObjType( Acb_Ntk_t * p, int i ) { assert(i>0); return (Acb_ObjType_t)(int)(unsigned char)Vec_StrEntry(&p->vObjType, i); } static inline Acb_ObjType_t Acb_ObjType( Acb_Ntk_t * p, int i ) { assert(i>0); return (Acb_ObjType_t)(int)(unsigned char)Vec_StrEntry(&p->vObjType, i); }
static inline void Acb_ObjCleanType( Acb_Ntk_t * p, int i ) { assert(i>0); Vec_StrWriteEntry( &p->vObjType, i, (char)ABC_OPER_NONE ); } static inline void Acb_ObjCleanType( Acb_Ntk_t * p, int i ) { assert(i>0); Vec_StrWriteEntry( &p->vObjType, i, (char)ABC_OPER_NONE ); }
static inline int Acb_TypeIsSeq( Acb_ObjType_t Type ) { return Type >= ABC_OPER_RAM && Type <= ABC_OPER_DFFRS; } static inline int Acb_TypeIsSeq( Acb_ObjType_t Type ) { return Type >= ABC_OPER_RAM && Type <= ABC_OPER_DFFLAST; }
static inline int Acb_TypeIsUnary( Acb_ObjType_t Type ) { return Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_BIT_INV || Type == ABC_OPER_LOGIC_NOT || Type == ABC_OPER_ARI_MIN || Type == ABC_OPER_ARI_SQRT || Type == ABC_OPER_ARI_ABS || (Type >= ABC_OPER_RED_AND && Type <= ABC_OPER_RED_NXOR); } static inline int Acb_TypeIsUnary( Acb_ObjType_t Type ) { return Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_BIT_INV || Type == ABC_OPER_LOGIC_NOT || Type == ABC_OPER_ARI_MIN || Type == ABC_OPER_ARI_SQRT || Type == ABC_OPER_ARI_ABS || (Type >= ABC_OPER_RED_AND && Type <= ABC_OPER_RED_NXOR); }
static inline int Acb_TypeIsMux( Acb_ObjType_t Type ) { return Type == ABC_OPER_BIT_MUX || Type == ABC_OPER_SEL_NMUX || Type == ABC_OPER_SEL_SEL || Type == ABC_OPER_SEL_PSEL; } static inline int Acb_TypeIsMux( Acb_ObjType_t Type ) { return Type == ABC_OPER_BIT_MUX || Type == ABC_OPER_SEL_NMUX || Type == ABC_OPER_SEL_SEL || Type == ABC_OPER_SEL_PSEL; }
......
...@@ -44,10 +44,10 @@ ABC_NAMESPACE_HEADER_START ...@@ -44,10 +44,10 @@ ABC_NAMESPACE_HEADER_START
typedef enum { typedef enum {
WLC_OBJ_NONE = 0, // 00: unknown WLC_OBJ_NONE = 0, // 00: unknown
WLC_OBJ_PI, // 01: primary input WLC_OBJ_PI, // 01: primary input
WLC_OBJ_PO, // 02: primary output (unused) WLC_OBJ_PO, // 02: primary output
WLC_OBJ_FO, // 03: flop output WLC_OBJ_FO, // 03: flop output
WLC_OBJ_FI, // 04: flop input (unused) WLC_OBJ_FI, // 04: flop input (unused)
WLC_OBJ_FF, // 05: flop (unused) WLC_OBJ_FF, // 05: flop
WLC_OBJ_CONST, // 06: constant WLC_OBJ_CONST, // 06: constant
WLC_OBJ_BUF, // 07: buffer WLC_OBJ_BUF, // 07: buffer
WLC_OBJ_MUX, // 08: multiplexer WLC_OBJ_MUX, // 08: multiplexer
...@@ -98,7 +98,8 @@ typedef enum { ...@@ -98,7 +98,8 @@ typedef enum {
WLC_OBJ_TABLE, // 53: bit table WLC_OBJ_TABLE, // 53: bit table
WLC_OBJ_READ, // 54: read port WLC_OBJ_READ, // 54: read port
WLC_OBJ_WRITE, // 55: write port WLC_OBJ_WRITE, // 55: write port
WLC_OBJ_NUMBER // 56: unused WLC_OBJ_ARI_ADDSUB, // 56: adder-subtractor
WLC_OBJ_NUMBER // 57: unused
} Wlc_ObjType_t; } Wlc_ObjType_t;
// when adding new types, remember to update table Wlc_Names in "wlcNtk.c" // when adding new types, remember to update table Wlc_Names in "wlcNtk.c"
...@@ -142,6 +143,8 @@ struct Wlc_Ntk_t_ ...@@ -142,6 +143,8 @@ struct Wlc_Ntk_t_
int nObjs[WLC_OBJ_NUMBER]; // counter of objects of each type int nObjs[WLC_OBJ_NUMBER]; // counter of objects of each type
int nAnds[WLC_OBJ_NUMBER]; // counter of AND gates after blasting int nAnds[WLC_OBJ_NUMBER]; // counter of AND gates after blasting
int fSmtLib; // the network comes from an SMT-LIB file int fSmtLib; // the network comes from an SMT-LIB file
int fMemPorts; // the network contains memory ports
int fEasyFfs; // the network contains simple flops
int nAssert; // the number of asserts int nAssert; // the number of asserts
// memory for objects // memory for objects
Wlc_Obj_t * pObjs; Wlc_Obj_t * pObjs;
......
...@@ -1642,7 +1642,7 @@ usage: ...@@ -1642,7 +1642,7 @@ usage:
int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
extern void Wlc_NtkSimulateTest( Wlc_Ntk_t * p ); extern void Wlc_NtkSimulateTest( Wlc_Ntk_t * p );
Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc); //Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
int c, fVerbose = 0; int c, fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
...@@ -1658,11 +1658,12 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -1658,11 +1658,12 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage; goto usage;
} }
} }
if ( pNtk == NULL ) // if ( pNtk == NULL )
{ // {
Abc_Print( 1, "Abc_CommandTest(): There is no current design.\n" ); // Abc_Print( 1, "Abc_CommandTest(): There is no current design.\n" );
return 0; // return 0;
} // }
// transform // transform
//pNtk = Wlc_NtkUifNodePairs( pNtk, NULL ); //pNtk = Wlc_NtkUifNodePairs( pNtk, NULL );
//pNtk = Wlc_NtkAbstractNodes( pNtk, NULL ); //pNtk = Wlc_NtkAbstractNodes( pNtk, NULL );
...@@ -1671,9 +1672,9 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -1671,9 +1672,9 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
//Wlc_NtkSimulateTest( (Wlc_Ntk_t *)pAbc->pAbcWlc ); //Wlc_NtkSimulateTest( (Wlc_Ntk_t *)pAbc->pAbcWlc );
//pNtk = Wlc_NtkDupSingleNodes( pNtk ); //pNtk = Wlc_NtkDupSingleNodes( pNtk );
//Wlc_AbcUpdateNtk( pAbc, pNtk ); //Wlc_AbcUpdateNtk( pAbc, pNtk );
//Wlc_ReadNdrTest( pNtk ); Ndr_ModuleTestMemory();
pNtk = Wlc_NtkMemAbstractTest( pNtk ); //pNtk = Wlc_NtkMemAbstractTest( pNtk );
Wlc_AbcUpdateNtk( pAbc, pNtk ); //Wlc_AbcUpdateNtk( pAbc, pNtk );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: %%test [-vh]\n" ); Abc_Print( -2, "usage: %%test [-vh]\n" );
......
...@@ -366,6 +366,8 @@ Wlc_Ntk_t * Wlc_NtkAbstractMemory( Wlc_Ntk_t * p, Vec_Int_t * vMemObjs, Vec_Int_ ...@@ -366,6 +366,8 @@ Wlc_Ntk_t * Wlc_NtkAbstractMemory( Wlc_Ntk_t * p, Vec_Int_t * vMemObjs, Vec_Int_
Wlc_NtkCleanCopy( p ); Wlc_NtkCleanCopy( p );
pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc + 1000 ); pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc + 1000 );
pNew->fSmtLib = p->fSmtLib; pNew->fSmtLib = p->fSmtLib;
pNew->fMemPorts = p->fMemPorts;
pNew->fEasyFfs = p->fEasyFfs;
pNew->vInits = Vec_IntAlloc( 100 ); pNew->vInits = Vec_IntAlloc( 100 );
// duplicate PIs // duplicate PIs
......
...@@ -91,6 +91,12 @@ int Ndr_TypeNdr2Wlc( int Type ) ...@@ -91,6 +91,12 @@ int Ndr_TypeNdr2Wlc( int Type )
if ( Type == ABC_OPER_ARI_MIN ) return WLC_OBJ_ARI_MINUS; // 50: arithmetic minus if ( Type == ABC_OPER_ARI_MIN ) return WLC_OBJ_ARI_MINUS; // 50: arithmetic minus
if ( Type == ABC_OPER_ARI_SQRT ) return WLC_OBJ_ARI_SQRT; // 51: integer square root if ( Type == ABC_OPER_ARI_SQRT ) return WLC_OBJ_ARI_SQRT; // 51: integer square root
if ( Type == ABC_OPER_ARI_SQUARE ) return WLC_OBJ_ARI_SQUARE; // 52: integer square if ( Type == ABC_OPER_ARI_SQUARE ) return WLC_OBJ_ARI_SQUARE; // 52: integer square
if ( Type == ABC_OPER_ARI_ADDSUB ) return WLC_OBJ_ARI_ADDSUB; // 56: adder-subtractor
if ( Type == ABC_OPER_ARI_SMUL ) return WLC_OBJ_ARI_MULTI; // 45: signed multiplier
if ( Type == ABC_OPER_DFF ) return WLC_OBJ_FO; // 03: flop
if ( Type == ABC_OPER_DFFRSE ) return WLC_OBJ_FF; // 05: flop
if ( Type == ABC_OPER_RAMR ) return WLC_OBJ_READ; // 54: read port
if ( Type == ABC_OPER_RAMW ) return WLC_OBJ_WRITE; // 55: write port
return -1; return -1;
} }
int Ndr_TypeWlc2Ndr( int Type ) int Ndr_TypeWlc2Ndr( int Type )
...@@ -142,6 +148,12 @@ int Ndr_TypeWlc2Ndr( int Type ) ...@@ -142,6 +148,12 @@ int Ndr_TypeWlc2Ndr( int Type )
if ( Type == WLC_OBJ_ARI_MINUS ) return ABC_OPER_ARI_MIN; // 50: arithmetic minus if ( Type == WLC_OBJ_ARI_MINUS ) return ABC_OPER_ARI_MIN; // 50: arithmetic minus
if ( Type == WLC_OBJ_ARI_SQRT ) return ABC_OPER_ARI_SQRT; // 51: integer square root if ( Type == WLC_OBJ_ARI_SQRT ) return ABC_OPER_ARI_SQRT; // 51: integer square root
if ( Type == WLC_OBJ_ARI_SQUARE ) return ABC_OPER_ARI_SQUARE; // 52: integer square if ( Type == WLC_OBJ_ARI_SQUARE ) return ABC_OPER_ARI_SQUARE; // 52: integer square
if ( Type == WLC_OBJ_ARI_ADDSUB ) return ABC_OPER_ARI_ADDSUB; // 56: adder-subtractor
if ( Type == WLC_OBJ_ARI_MULTI ) return ABC_OPER_ARI_SMUL; // 45: signed multiplier
if ( Type == WLC_OBJ_FO ) return ABC_OPER_DFF; // 03: flop
if ( Type == WLC_OBJ_FF ) return ABC_OPER_DFFRSE; // 05: flop
if ( Type == WLC_OBJ_READ ) return ABC_OPER_RAMR; // 54: read port
if ( Type == WLC_OBJ_WRITE ) return ABC_OPER_RAMW; // 55: write port
return -1; return -1;
} }
...@@ -337,6 +349,7 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) ...@@ -337,6 +349,7 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
int Mod = 2, i, k, Obj, * pArray, nDigits, fFound, NameId, NameIdMax; int Mod = 2, i, k, Obj, * pArray, nDigits, fFound, NameId, NameIdMax;
Wlc_Ntk_t * pTemp, * pNtk = Wlc_NtkAlloc( "top", Ndr_DataObjNum(p, Mod)+1 ); Wlc_Ntk_t * pTemp, * pNtk = Wlc_NtkAlloc( "top", Ndr_DataObjNum(p, Mod)+1 );
Wlc_NtkCheckIntegrity( pData ); Wlc_NtkCheckIntegrity( pData );
Vec_IntClear( &pNtk->vFfs );
//pNtk->pSpec = Abc_UtilStrsav( pFileName ); //pNtk->pSpec = Abc_UtilStrsav( pFileName );
// construct network and save name IDs // construct network and save name IDs
Wlc_NtkCleanNameId( pNtk ); Wlc_NtkCleanNameId( pNtk );
...@@ -357,6 +370,25 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) ...@@ -357,6 +370,25 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
int NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT ); int NameId = Ndr_ObjReadBody( p, Obj, NDR_OUTPUT );
Vec_IntClear( vFanins ); Vec_IntClear( vFanins );
Vec_IntAppend( vFanins, vTemp ); Vec_IntAppend( vFanins, vTemp );
if ( Type == ABC_OPER_DFF )
{
// save init state
if ( pNtk->vInits == NULL )
pNtk->vInits = Vec_IntAlloc( 100 );
if ( Vec_IntSize(vFanins) == 2 )
Vec_IntPush( pNtk->vInits, Vec_IntPop(vFanins) );
else // assume const0 if init is not given
Vec_IntPush( pNtk->vInits, -(End-Beg+1) );
// save flop output
pObj = Wlc_NtkObj(pNtk, iObj);
assert( Wlc_ObjType(pObj) == WLC_OBJ_FO );
Wlc_ObjSetNameId( pNtk, iObj, NameId );
Vec_IntPush( &pNtk->vFfs, NameId );
// save flop input
assert( Vec_IntSize(vFanins) == 1 );
Vec_IntPush( &pNtk->vFfs, Vec_IntEntry(vFanins, 0) );
continue;
}
if ( Type == ABC_OPER_SLICE ) if ( Type == ABC_OPER_SLICE )
Vec_IntPushTwo( vFanins, End, Beg ); Vec_IntPushTwo( vFanins, End, Beg );
else if ( Type == ABC_OPER_CONST ) else if ( Type == ABC_OPER_CONST )
...@@ -365,6 +397,13 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) ...@@ -365,6 +397,13 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
ABC_SWAP( int, Vec_IntEntryP(vFanins, 1)[0], Vec_IntEntryP(vFanins, 2)[0] ); ABC_SWAP( int, Vec_IntEntryP(vFanins, 1)[0], Vec_IntEntryP(vFanins, 2)[0] );
Wlc_ObjAddFanins( pNtk, Wlc_NtkObj(pNtk, iObj), vFanins ); Wlc_ObjAddFanins( pNtk, Wlc_NtkObj(pNtk, iObj), vFanins );
Wlc_ObjSetNameId( pNtk, iObj, NameId ); Wlc_ObjSetNameId( pNtk, iObj, NameId );
if ( Type == ABC_OPER_ARI_SMUL )
{
pObj = Wlc_NtkObj(pNtk, iObj);
assert( Wlc_ObjFaninNum(pObj) == 2 );
Wlc_ObjFanin0(pNtk, pObj)->Signed = 1;
Wlc_ObjFanin1(pNtk, pObj)->Signed = 1;
}
} }
// mark primary outputs // mark primary outputs
Ndr_ModForEachPo( p, Mod, Obj ) Ndr_ModForEachPo( p, Mod, Obj )
...@@ -388,6 +427,27 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) ...@@ -388,6 +427,27 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
for ( k = 0; k < Wlc_ObjFaninNum(pObj); k++ ) for ( k = 0; k < Wlc_ObjFaninNum(pObj); k++ )
pFanins[k] = Vec_IntEntry(vName2Obj, pFanins[k]); pFanins[k] = Vec_IntEntry(vName2Obj, pFanins[k]);
} }
if ( pNtk->vInits )
{
Vec_IntForEachEntry( &pNtk->vFfs, NameId, i )
Vec_IntWriteEntry( &pNtk->vFfs, i, Vec_IntEntry(vName2Obj, NameId) );
Vec_IntForEachEntry( pNtk->vInits, NameId, i )
if ( NameId > 0 )
Vec_IntWriteEntry( pNtk->vInits, i, Vec_IntEntry(vName2Obj, NameId) );
// move FO/FI to be part of CI/CO
assert( (Vec_IntSize(&pNtk->vFfs) & 1) == 0 );
assert( Vec_IntSize(&pNtk->vFfs) == 2 * Vec_IntSize(pNtk->vInits) );
Wlc_NtkForEachFf( pNtk, pObj, i )
if ( i & 1 )
Wlc_ObjSetCo( pNtk, pObj, 1 );
//else
// Wlc_ObjSetCi( pNtk, pObj );
Vec_IntClear( &pNtk->vFfs );
// convert init values into binary string
//Vec_IntPrint( &p->pNtk->vInits );
pNtk->pInits = Wlc_PrsConvertInitValues( pNtk );
//printf( "%s", p->pNtk->pInits );
}
Vec_IntFree(vName2Obj); Vec_IntFree(vName2Obj);
// create fake object names // create fake object names
NameIdMax = Vec_IntFindMax(&pNtk->vNameIds); NameIdMax = Vec_IntFindMax(&pNtk->vNameIds);
...@@ -395,14 +455,17 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) ...@@ -395,14 +455,17 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData )
pNtk->pManName = Abc_NamStart( NameIdMax+1, 10 ); pNtk->pManName = Abc_NamStart( NameIdMax+1, 10 );
for ( i = 1; i <= NameIdMax; i++ ) for ( i = 1; i <= NameIdMax; i++ )
{ {
char pName[20]; sprintf( pName, "n%0*d", nDigits, i ); char pName[20]; sprintf( pName, "s%0*d", nDigits, i );
NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound ); NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound );
assert( !fFound && i == NameId ); assert( !fFound && i == NameId );
} }
//Ndr_NtkPrintNodes( pNtk );
// derive topological order // derive topological order
pNtk = Wlc_NtkDupDfs( pTemp = pNtk, 0, 1 ); pNtk = Wlc_NtkDupDfs( pTemp = pNtk, 0, 1 );
Wlc_NtkFree( pTemp ); Wlc_NtkFree( pTemp );
//Ndr_NtkPrintNodes( pNtk ); //Ndr_NtkPrintNodes( pNtk );
pNtk->fMemPorts = 1; // the network contains memory ports
pNtk->fEasyFfs = 1; // the network contains simple flops
return pNtk; return pNtk;
} }
......
...@@ -860,6 +860,7 @@ void Wlc_NtkDupDfs_rec( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p, int iObj, Vec_Int_t * v ...@@ -860,6 +860,7 @@ void Wlc_NtkDupDfs_rec( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p, int iObj, Vec_Int_t * v
int i, iFanin; int i, iFanin;
if ( Wlc_ObjCopy(p, iObj) ) if ( Wlc_ObjCopy(p, iObj) )
return; return;
//printf( "Visiting node %d\n", iObj );
pObj = Wlc_NtkObj( p, iObj ); pObj = Wlc_NtkObj( p, iObj );
Wlc_ObjForEachFanin( pObj, iFanin, i ) Wlc_ObjForEachFanin( pObj, iFanin, i )
Wlc_NtkDupDfs_rec( pNew, p, iFanin, vFanins ); Wlc_NtkDupDfs_rec( pNew, p, iFanin, vFanins );
...@@ -876,6 +877,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfsSimple( Wlc_Ntk_t * p ) ...@@ -876,6 +877,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfsSimple( Wlc_Ntk_t * p )
vFanins = Vec_IntAlloc( 100 ); vFanins = Vec_IntAlloc( 100 );
pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc ); pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
pNew->fSmtLib = p->fSmtLib; pNew->fSmtLib = p->fSmtLib;
pNew->fMemPorts = p->fMemPorts;
pNew->fEasyFfs = p->fEasyFfs;
Wlc_NtkForEachCi( p, pObj, i ) Wlc_NtkForEachCi( p, pObj, i )
Wlc_ObjDup( pNew, p, Wlc_ObjId(p, pObj), vFanins ); Wlc_ObjDup( pNew, p, Wlc_ObjId(p, pObj), vFanins );
Wlc_NtkForEachCo( p, pObj, i ) Wlc_NtkForEachCo( p, pObj, i )
...@@ -902,6 +905,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfs( Wlc_Ntk_t * p, int fMarked, int fSeq ) ...@@ -902,6 +905,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfs( Wlc_Ntk_t * p, int fMarked, int fSeq )
Wlc_NtkCleanCopy( p ); Wlc_NtkCleanCopy( p );
pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc ); pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
pNew->fSmtLib = p->fSmtLib; pNew->fSmtLib = p->fSmtLib;
pNew->fMemPorts = p->fMemPorts;
pNew->fEasyFfs = p->fEasyFfs;
Wlc_NtkForEachCi( p, pObj, i ) Wlc_NtkForEachCi( p, pObj, i )
if ( !fMarked || pObj->Mark ) if ( !fMarked || pObj->Mark )
{ {
...@@ -951,6 +956,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfsAbs( Wlc_Ntk_t * p, Vec_Int_t * vPisOld, Vec_Int_t * vP ...@@ -951,6 +956,8 @@ Wlc_Ntk_t * Wlc_NtkDupDfsAbs( Wlc_Ntk_t * p, Vec_Int_t * vPisOld, Vec_Int_t * vP
Wlc_NtkCleanCopy( p ); Wlc_NtkCleanCopy( p );
pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc ); pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
pNew->fSmtLib = p->fSmtLib; pNew->fSmtLib = p->fSmtLib;
pNew->fMemPorts = p->fMemPorts;
pNew->fEasyFfs = p->fEasyFfs;
// duplicate marked PIs // duplicate marked PIs
vFanins = Vec_IntAlloc( 100 ); vFanins = Vec_IntAlloc( 100 );
...@@ -1132,6 +1139,8 @@ Wlc_Ntk_t * Wlc_NtkDupSingleNodes( Wlc_Ntk_t * p ) ...@@ -1132,6 +1139,8 @@ Wlc_Ntk_t * Wlc_NtkDupSingleNodes( Wlc_Ntk_t * p )
vFanins = Vec_IntAlloc( 100 ); vFanins = Vec_IntAlloc( 100 );
pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc ); pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
pNew->fSmtLib = p->fSmtLib; pNew->fSmtLib = p->fSmtLib;
pNew->fMemPorts = p->fMemPorts;
pNew->fEasyFfs = p->fEasyFfs;
Wlc_NtkForEachObj( p, pObj, i ) Wlc_NtkForEachObj( p, pObj, i )
{ {
if ( Wlc_ObjIsCi(pObj) ) if ( Wlc_ObjIsCi(pObj) )
......
...@@ -186,13 +186,13 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops ) ...@@ -186,13 +186,13 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops )
continue; continue;
Range[0] = 0; Range[0] = 0;
} }
if ( pObj->fIsPo || (fNoFlops && pObj->fIsFi) ) if ( (pObj->fIsPo || (fNoFlops && pObj->fIsFi)) && pObj->Type != WLC_OBJ_FF )
{ {
if ( Wlc_ObjFaninNum(pObj) == 0 ) if ( Wlc_ObjFaninNum(pObj) == 0 )
continue; continue;
fprintf( pFile, " assign " ); fprintf( pFile, " assign " );
} }
else if ( pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3 ) else if ( (pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3) || pObj->Type == WLC_OBJ_FF )
fprintf( pFile, "reg %s ", Range ); fprintf( pFile, "reg %s ", Range );
else else
fprintf( pFile, "wire %s ", Range ); fprintf( pFile, "wire %s ", Range );
...@@ -255,6 +255,18 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops ) ...@@ -255,6 +255,18 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops )
} }
else if ( pObj->Type == WLC_OBJ_READ || pObj->Type == WLC_OBJ_WRITE ) else if ( pObj->Type == WLC_OBJ_READ || pObj->Type == WLC_OBJ_WRITE )
{ {
if ( p->fMemPorts )
{
fprintf( pFile, "%s ;\n", Wlc_ObjName(p, i) );
fprintf( pFile, " " );
fprintf( pFile, "%s (", pObj->Type == WLC_OBJ_READ ? "ABC_READ" : "ABC_WRITE" );
Wlc_ObjForEachFanin( pObj, iFanin, k )
fprintf( pFile, " .%s(%s)", k==0 ? "mem_in" : (k==1 ? "addr": "data"), Wlc_ObjName(p, iFanin) );
fprintf( pFile, " .%s(%s) ) ;\n", pObj->Type == WLC_OBJ_READ ? "data" : "mem_out", Wlc_ObjName(p, i) );
continue;
}
else
{
int nBitsMem = Wlc_ObjRange( Wlc_ObjFanin(p, pObj, 0) ); int nBitsMem = Wlc_ObjRange( Wlc_ObjFanin(p, pObj, 0) );
//int nBitsAddr = Wlc_ObjRange( Wlc_ObjFanin(p, pObj, 1) ); //int nBitsAddr = Wlc_ObjRange( Wlc_ObjFanin(p, pObj, 1) );
int nBitsDat = pObj->Type == WLC_OBJ_READ ? Wlc_ObjRange(pObj) : Wlc_ObjRange(Wlc_ObjFanin(p, pObj, 2)); int nBitsDat = pObj->Type == WLC_OBJ_READ ? Wlc_ObjRange(pObj) : Wlc_ObjRange(Wlc_ObjFanin(p, pObj, 2));
...@@ -265,7 +277,19 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops ) ...@@ -265,7 +277,19 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops )
fprintf( pFile, "%s_%d (", pObj->Type == WLC_OBJ_READ ? "CPL_MEM_READ" : "CPL_MEM_WRITE", Depth ); fprintf( pFile, "%s_%d (", pObj->Type == WLC_OBJ_READ ? "CPL_MEM_READ" : "CPL_MEM_WRITE", Depth );
Wlc_ObjForEachFanin( pObj, iFanin, k ) Wlc_ObjForEachFanin( pObj, iFanin, k )
fprintf( pFile, " .%s(%s)", k==0 ? "mem_data_in" : (k==1 ? "addr_in": "data_in"), Wlc_ObjName(p, iFanin) ); fprintf( pFile, " .%s(%s)", k==0 ? "mem_data_in" : (k==1 ? "addr_in": "data_in"), Wlc_ObjName(p, iFanin) );
fprintf( pFile, " .%s(%s) );\n", "data_out", Wlc_ObjName(p, i) ); fprintf( pFile, " .%s(%s) ) ;\n", "data_out", Wlc_ObjName(p, i) );
continue;
}
}
else if ( pObj->Type == WLC_OBJ_FF )
{
char * pInNames[7] = {"d", "clk", "reset", "set", "enable", "async", "init"};
fprintf( pFile, "%s ;\n", Wlc_ObjName(p, i) );
fprintf( pFile, " " );
fprintf( pFile, "%s (", "ABC_DFFRSE" );
Wlc_ObjForEachFanin( pObj, iFanin, k )
fprintf( pFile, " .%s(%s)", pInNames[k], Wlc_ObjName(p, iFanin) );
fprintf( pFile, " .%s(%s) ) ;\n", "q", Wlc_ObjName(p, i) );
continue; continue;
} }
else else
...@@ -426,23 +450,36 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops ) ...@@ -426,23 +450,36 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops )
if ( pObj->Type == WLC_OBJ_PI ) if ( pObj->Type == WLC_OBJ_PI )
continue; continue;
fprintf( pFile, " " ); fprintf( pFile, " " );
if ( p->fEasyFfs )
{
fprintf( pFile, "ABC_DFF" );
fprintf( pFile, " reg%d (", i );
fprintf( pFile, " .q(%s),", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
fprintf( pFile, " .d(%s),", Wlc_ObjName(p, Wlc_ObjId(p, Wlc_ObjFo2Fi(p, pObj))) );
if ( p->vInits )
fprintf( pFile, " .init(%s_init)", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
fprintf( pFile, " ) ;\n" );
}
else
{
fprintf( pFile, "CPL_FF" ); fprintf( pFile, "CPL_FF" );
if ( Wlc_ObjRange(pObj) > 1 ) if ( Wlc_ObjRange(pObj) > 1 )
fprintf( pFile, "#%d%*s", Wlc_ObjRange(pObj), 4 - Abc_Base10Log(Wlc_ObjRange(pObj)+1), "" ); fprintf( pFile, "#%d%*s", Wlc_ObjRange(pObj), 4 - Abc_Base10Log(Wlc_ObjRange(pObj)+1), "" );
else else
fprintf( pFile, " " ); fprintf( pFile, " " );
fprintf( pFile, " reg%d (", i ); fprintf( pFile, " reg%d (", i );
fprintf( pFile, " .q( %s ),", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) ); fprintf( pFile, " .q(%s),", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
fprintf( pFile, " .qbar()," ); fprintf( pFile, " .qbar()," );
fprintf( pFile, " .d( %s ),", Wlc_ObjName(p, Wlc_ObjId(p, Wlc_ObjFo2Fi(p, pObj))) ); fprintf( pFile, " .d(%s),", Wlc_ObjName(p, Wlc_ObjId(p, Wlc_ObjFo2Fi(p, pObj))) );
fprintf( pFile, " .clk( %s ),", "1\'b0" ); fprintf( pFile, " .clk(%s),", "1\'b0" );
fprintf( pFile, " .arst( %s ),", "1\'b0" ); fprintf( pFile, " .arst(%s),", "1\'b0" );
if ( p->vInits ) if ( p->vInits )
fprintf( pFile, " .arstval( %s_init )", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) ); fprintf( pFile, " .arstval(%s_init)", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
else else
fprintf( pFile, " .arstval( %s )", "1\'b0" ); fprintf( pFile, " .arstval(%s)", "1\'b0" );
fprintf( pFile, " ) ;\n" ); fprintf( pFile, " ) ;\n" );
} }
}
assert( !p->vInits || iFanin == (int)strlen(p->pInits) ); assert( !p->vInits || iFanin == (int)strlen(p->pInits) );
} }
fprintf( pFile, "endmodule\n\n" ); fprintf( pFile, "endmodule\n\n" );
......
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