Commit 77dbe2b6 by Alan Mishchenko

Major rehash of the CBA code.

parent a523ab79
......@@ -783,10 +783,6 @@ SOURCE=.\src\base\cba\cbaBlast.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaBuild.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaCom.c
# End Source File
# Begin Source File
......@@ -803,15 +799,27 @@ SOURCE=.\src\base\cba\cbaPrs.h
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaReadBlif.c
SOURCE=.\src\base\cba\cbaPrsBuild.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaReadVer.c
SOURCE=.\src\base\cba\cbaPrsTrans.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaPtr.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaSimple.c
SOURCE=.\src\base\cba\cbaPtrAbc.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaReadBlif.c
# End Source File
# Begin Source File
SOURCE=.\src\base\cba\cbaReadVer.c
# End Source File
# Begin Source File
......
......@@ -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 [Command handlers.]
Author [Alan Mishchenko]
......@@ -33,6 +33,7 @@ static int Cba_CommandWrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandPs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandPut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandGet ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandClp ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandCec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -46,6 +47,48 @@ static inline void Cba_AbcUpdateMan( Abc_Frame_t * pAbc, Cba_Man_t * p )
/**Function********************************************************************
Synopsis [Accessing current Cba_Ntk_t.]
Description []
SideEffects []
SeeAlso []
******************************************************************************/
void Abc_FrameImportDes( Vec_Ptr_t * vDes )
{
Cba_Man_t * p;
if ( Abc_FrameGetGlobalFrame() == NULL )
{
printf( "ABC framework is not started.\n" );
return;
}
p = Cba_PtrTransformToCba( vDes );
if ( p == NULL )
printf( "Converting from Ptr failed.\n" );
Cba_AbcUpdateMan( Abc_FrameGetGlobalFrame(), p );
}
Vec_Ptr_t * Abc_FrameExportDes()
{
Vec_Ptr_t * vDes;
Cba_Man_t * p;
if ( Abc_FrameGetGlobalFrame() == NULL )
{
printf( "ABC framework is not started.\n" );
return NULL;
}
p = Cba_AbcGetMan( Abc_FrameGetGlobalFrame() );
if ( p == NULL )
printf( "There is no CBA design present.\n" );
vDes = Cba_PtrDeriveFromCba( p );
if ( vDes == NULL )
printf( "Converting to Ptr has failed.\n" );
return vDes;
}
/**Function********************************************************************
Synopsis []
Description []
......@@ -62,6 +105,7 @@ void Cba_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "New word level", "@ps", Cba_CommandPs, 0 );
Cmd_CommandAdd( pAbc, "New word level", "@put", Cba_CommandPut, 0 );
Cmd_CommandAdd( pAbc, "New word level", "@get", Cba_CommandGet, 0 );
Cmd_CommandAdd( pAbc, "New word level", "@clp", Cba_CommandClp, 0 );
Cmd_CommandAdd( pAbc, "New word level", "@cec", Cba_CommandCec, 0 );
Cmd_CommandAdd( pAbc, "New word level", "@test", Cba_CommandTest, 0 );
}
......@@ -97,7 +141,8 @@ void Cba_End( Abc_Frame_t * pAbc )
int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pFile;
Cba_Man_t * p = NULL, * pTemp;
Cba_Man_t * p = NULL;
Vec_Ptr_t * vDes = NULL;
char * pFileName = NULL;
int c, fUseAbc = 0, fVerbose = 0;
Extra_UtilGetoptReset();
......@@ -133,26 +178,34 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
}
fclose( pFile );
// perform reading
if ( fUseAbc )
{
extern Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk );
Abc_Ntk_t * pAbcNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 0 );
Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pAbcNtk );
p = Cba_PrsReadPtr( vDes );
ABC_FREE( p->pSpec );
p->pSpec = Abc_UtilStrsav( pAbcNtk->pSpec );
p = Cba_PtrTransformToCba( vDes );
Cba_PtrFree( vDes ); // points to names in pAbcNtk
if ( p )
{
ABC_FREE( p->pSpec );
p->pSpec = Abc_UtilStrsav( pAbcNtk->pSpec );
}
Abc_NtkDelete( pAbcNtk );
Ptr_ManFreeDes( vDes ); // points to names in pAbcNtk
}
else if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) )
p = Cba_PrsReadBlif( pFileName );
{
vDes = Prs_ManReadBlif( pFileName );
p = Prs_ManBuildCba( pFileName, vDes );
Prs_ManVecFree( vDes );
}
else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
p = Cba_PrsReadVerilog( pFileName, 1 );
{
vDes = Prs_ManReadVerilog( pFileName );
p = Prs_ManBuildCba( pFileName, vDes );
Prs_ManVecFree( vDes );
}
else assert( 0 );
p = Cba_ManBuild( pTemp = p );
Cba_ManFree( pTemp );
Cba_AbcUpdateMan( pAbc, p );
return 0;
usage:
......@@ -336,7 +389,7 @@ usage:
******************************************************************************/
int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cba_Man_t * pNew, * p = Cba_AbcGetMan(pAbc);
Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc);
int c, fMapped = 0, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF )
......@@ -400,11 +453,57 @@ usage:
SeeAlso []
******************************************************************************/
int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc);
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( p == NULL )
{
Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
return 0;
}
pNew = Cba_ManDup( p );
Cba_AbcUpdateMan( pAbc, pNew );
return 0;
usage:
Abc_Print( -2, "usage: @clp [-vh]\n" );
Abc_Print( -2, "\t collapses the current hierarchical design\n" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
/**Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
******************************************************************************/
int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cba_Man_t * pTemp, * p = Cba_AbcGetMan(pAbc);
Cec_ParCec_t ParsCec, * pPars = &ParsCec;
Cba_Man_t * p = Cba_AbcGetMan(pAbc);
Gia_Man_t * pFirst, * pSecond, * pMiter;
Cec_ParCec_t ParsCec, * pPars = &ParsCec;
Vec_Ptr_t * vDes;
char * FileName, * pStr, ** pArgvNew;
int c, nArgcNew, fDumpMiter = 0, fVerbose = 0;
FILE * pFile;
......@@ -454,6 +553,7 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
fclose( pFile );
// extract AIG from the current design
pFirst = Cba_ManExtract( p, 0, 0 );
if ( pFirst == NULL )
......@@ -463,12 +563,12 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// extract AIG from the second design
if ( !strcmp( Extra_FileNameExtension(FileName), "blif" ) )
p = Cba_PrsReadBlif( FileName );
vDes = Prs_ManReadBlif( FileName );
else if ( !strcmp( Extra_FileNameExtension(FileName), "v" ) )
p = Cba_PrsReadVerilog( FileName, 1 );
vDes = Prs_ManReadVerilog( FileName );
else assert( 0 );
p = Cba_ManBuild( pTemp = p );
Cba_ManFree( pTemp );
p = Prs_ManBuildCba( FileName, vDes );
Prs_ManVecFree( vDes );
pSecond = Cba_ManExtract( p, 0, 0 );
Cba_ManFree( p );
if ( pSecond == NULL )
......@@ -495,7 +595,7 @@ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
Abc_Print( -2, "usage: @cec [-vh]\n" );
Abc_Print( -2, "\t combinational equivalence checking for the hierarchical design\n" );
Abc_Print( -2, "\t combinational equivalence checking\n" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
......@@ -514,7 +614,9 @@ usage:
******************************************************************************/
int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Cba_PrsReadVerilogTest( char * pFileName );
extern void Prs_ManReadBlifTest();
extern void Prs_ManReadVerilogTest();
Cba_Man_t * p = Cba_AbcGetMan(pAbc);
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
......@@ -531,13 +633,14 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
}
}
/*
if ( pNtk == NULL )
if ( p == NULL )
{
Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
return 0;
}
*/
Cba_PrsReadVerilogTest( NULL );
//Cba_PtrTransformTestTest();
Prs_ManReadVerilogTest();
return 0;
usage:
Abc_Print( -2, "usage: @test [-vh]\n" );
......
......@@ -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 [Library procedures.]
Author [Alan Mishchenko]
......
/**CFile****************************************************************
FileName [cbaPrsTrans.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Hierarchical word-level netlist.]
Synopsis [Parse tree to netlist transformation.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 29, 2014.]
Revision [$Id: cbaPrsTrans.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
***********************************************************************/
#include "cba.h"
#include "cbaPrs.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
SRC += src/base/cba/cbaBlast.c \
src/base/cba/cbaBuild.c \
src/base/cba/cbaCom.c \
src/base/cba/cbaLib.c \
src/base/cba/cbaNtk.c \
src/base/cba/cbaPrsBuild.c \
src/base/cba/cbaPrsTrans.c \
src/base/cba/cbaPtr.c \
src/base/cba/cbaPtrAbc.c \
src/base/cba/cbaReadBlif.c \
src/base/cba/cbaReadVer.c \
src/base/cba/cbaSimple.c \
src/base/cba/cbaWriteBlif.c \
src/base/cba/cbaWriteVer.c
......@@ -98,6 +98,7 @@ extern Mio_Gate_t * Mio_LibraryReadGates ( Mio_Library_t * pLib );
extern Mio_Gate_t ** Mio_LibraryReadGateArray ( Mio_Library_t * pLib );
extern Mio_Gate_t * Mio_LibraryReadGateByName ( Mio_Library_t * pLib, char * pName, char * pOutName );
extern char * Mio_LibraryReadSopByName ( Mio_Library_t * pLib, char * pName );
extern Mio_Gate_t * Mio_LibraryReadGateByTruth( Mio_Library_t * pLib, word t );
extern Mio_Gate_t * Mio_LibraryReadConst0 ( Mio_Library_t * pLib );
extern Mio_Gate_t * Mio_LibraryReadConst1 ( Mio_Library_t * pLib );
extern Mio_Gate_t * Mio_LibraryReadNand2 ( Mio_Library_t * pLib );
......
......@@ -112,6 +112,26 @@ Mio_Gate_t * Mio_LibraryReadGateByName( Mio_Library_t * pLib, char * pName, char
/**Function*************************************************************
Synopsis [Returns the first gate in the library with the given TT.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Mio_Gate_t * Mio_LibraryReadGateByTruth( Mio_Library_t * pLib, word t )
{
Mio_Gate_t * pGate;
Mio_LibraryForEachGate( pLib, pGate )
if ( pGate->nInputs <= 6 && pGate->uTruth == t )
return pGate;
return NULL;
}
/**Function*************************************************************
Synopsis [Read Mvc of the gate by name.]
Description []
......
......@@ -478,7 +478,7 @@ int Abc_NamStrFindOrAddLim( Abc_Nam_t * p, char * pStr, char * pLim, int * pfFou
***********************************************************************/
char * Abc_NamStr( Abc_Nam_t * p, int NameId )
{
return NameId? Abc_NamIntToStr(p, NameId) : NULL;
return NameId > 0 ? Abc_NamIntToStr(p, NameId) : NULL;
}
/**Function*************************************************************
......
......@@ -65,7 +65,9 @@ struct Vec_Int_t_
for ( i = 0; (i < Vec_IntSize(vVec1)) && (((Entry1) = Vec_IntEntry(vVec1, i)), 1) && (((Entry2) = Vec_IntEntry(vVec2, i)), 1); i++ )
#define Vec_IntForEachEntryDouble( vVec, Entry1, Entry2, i ) \
for ( i = 0; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
#define Vec_IntForEachEntryTriple( vVec, Entry1, Entry2, Entry3, i ) \
#define Vec_IntForEachEntryDoubleStart( vVec, Entry1, Entry2, i, Start ) \
for ( i = Start; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
#define Vec_IntForEachEntryTriple( vVec, Entry1, Entry2, Entry3, i ) \
for ( i = 0; (i+2 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1) && (((Entry3) = Vec_IntEntry(vVec, i+2)), 1); i += 3 )
#define Vec_IntForEachEntryThisNext( vVec, This, Next, i ) \
for ( i = 0, (This) = (Next) = (Vec_IntSize(vVec) ? Vec_IntEntry(vVec, 0) : -1); (i+1 < Vec_IntSize(vVec)) && (((Next) = Vec_IntEntry(vVec, i+1)), 1); i += 2, (This) = (Next) )
......@@ -613,6 +615,11 @@ static inline int Vec_IntGetEntry( Vec_Int_t * p, int i )
Vec_IntFillExtra( p, i + 1, 0 );
return Vec_IntEntry( p, i );
}
static inline int Vec_IntGetEntryFull( Vec_Int_t * p, int i )
{
Vec_IntFillExtra( p, i + 1, -1 );
return Vec_IntEntry( p, i );
}
/**Function*************************************************************
......@@ -1170,6 +1177,20 @@ static inline int Vec_IntCountEntry( Vec_Int_t * p, int Entry )
Counter += (p->pArray[i] == Entry);
return Counter;
}
static inline int Vec_IntCountLarger( Vec_Int_t * p, int Entry )
{
int i, Counter = 0;
for ( i = 0; i < p->nSize; i++ )
Counter += (p->pArray[i] > Entry);
return Counter;
}
static inline int Vec_IntCountSmaller( Vec_Int_t * p, int Entry )
{
int i, Counter = 0;
for ( i = 0; i < p->nSize; i++ )
Counter += (p->pArray[i] < Entry);
return Counter;
}
/**Function*************************************************************
......
......@@ -706,6 +706,39 @@ static inline int Vec_StrSum( Vec_Str_t * p )
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Vec_StrCountEntry( Vec_Str_t * p, char Entry )
{
int i, Counter = 0;
for ( i = 0; i < p->nSize; i++ )
Counter += (p->pArray[i] == Entry);
return Counter;
}
static inline int Vec_StrCountLarger( Vec_Str_t * p, char Entry )
{
int i, Counter = 0;
for ( i = 0; i < p->nSize; i++ )
Counter += (p->pArray[i] > Entry);
return Counter;
}
static inline int Vec_StrCountSmaller( Vec_Str_t * p, char Entry )
{
int i, Counter = 0;
for ( i = 0; i < p->nSize; i++ )
Counter += (p->pArray[i] < Entry);
return Counter;
}
/**Function*************************************************************
Synopsis [Compares two strings.]
Description []
......
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