Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions abclib.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/base/io/ioWriteEdgelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ int Io_NtkEdgelistWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode, int Length, in
{
if ( !fReport )
fReport = 1, printf( "Warning: Missing second output of gate(s) \"%s\".\n", Mio_GateReadName(pGate) );
// record of a cell with one output used
fprintf( pFile, " %s", Mio_GateReadName(pGate) );
fprintf( pFile, " %lu", Mio_GateReadTruth(pGate) );
return 0;
}
fprintf( pFile, " %s", Abc_ObjName( Abc_ObjFanout0(pNode2) ) );
Expand Down
120 changes: 104 additions & 16 deletions src/map/emap/emap.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,90 @@ int Emap_Command( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Abc_Ntk_t * pNtkRes;
int c, fUseMogs = 1, fAreaMode = 0, fVerbose = 0;

Emap_Par_t Pars, * pPars = &Pars;
int c;

memset( pPars, 0, sizeof(Emap_Par_t) );
pPars->nCutNum = 16;
pPars->nFlowRounds = 2;
pPars->nAreaRounds = 4;
pPars->fUseMogs = 1;
pPars->fNldm = 1;
pPars->nPropBudget = 2000;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "amvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "CFADBamNOvh" ) ) != EOF )
{
switch ( c )
{
case 'C':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCutNum = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nCutNum < 1 )
goto usage;
break;
case 'F':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFlowRounds = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nFlowRounds < 0 )
goto usage;
break;
case 'A':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
goto usage;
}
pPars->nAreaRounds = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nAreaRounds < 0 )
goto usage;
break;
case 'D':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating-point number.\n" );
goto usage;
}
pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->DelayTarget < 0 )
goto usage;
break;
case 'a':
fAreaMode ^= 1;
pPars->fAreaMode ^= 1;
break;
case 'm':
fUseMogs ^= 1;
pPars->fUseMogs ^= 1;
break;
case 'N':
pPars->fNldm ^= 1;
break;
case 'B':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPropBudget = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nPropBudget < 0 )
goto usage;
break;
case 'O':
pPars->fLegacy ^= 1;
break;
case 'v':
fVerbose ^= 1;
pPars->fVerbose ^= 1;
break;
case 'h':
goto usage;
Expand All @@ -116,17 +185,27 @@ int Emap_Command( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pAbc->Err, "The current network is not an AIG. Run strash first.\n" );
return 1;
}
//Rejects sequential networks
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
fprintf( pAbc->Err, "The current network has latches; emap maps combinational networks only.\n" );
return 1;
}

if ( fVerbose )
if ( pPars->fVerbose )
{
int nMogPairs = fUseMogs ? Emap_CommandCountMogPairs( pLib ) : 0;
int nMogPairs = pPars->fUseMogs ? Emap_CommandCountMogPairs( pLib ) : 0;
fprintf( pAbc->Out, "ABC-native emap setup: PI = %d PO = %d AND = %d\n",
Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkNodeNum(pNtk) );
fprintf( pAbc->Out, "GENLIB \"%s\": gates = %d MOG pairs = %d MOG use = %s mode = %s\n",
Mio_LibraryReadName(pLib), Mio_LibraryReadGateNum(pLib), nMogPairs, fUseMogs ? "yes" : "no", fAreaMode ? "area" : "delay" );
fprintf( pAbc->Out, "GENLIB \"%s\": gates = %d MOG pairs = %d MOG use = %s mode = %s%s\n",
Mio_LibraryReadName(pLib), Mio_LibraryReadGateNum(pLib), nMogPairs, pPars->fUseMogs ? "yes" : "no",
pPars->fAreaMode ? "area" : "delay", pPars->fLegacy ? " (original implementation)" : "" );
}

pNtkRes = Emap_ManMapAigStructural( pNtk, pLib, fUseMogs, fAreaMode, fVerbose );
if ( pPars->fLegacy )
pNtkRes = Emap_ManMapAigStructural( pNtk, pLib, pPars->fUseMogs, pPars->fAreaMode, pPars->fVerbose );
else
pNtkRes = Emap_ManMapNew( pNtk, pLib, pPars );
if ( pNtkRes == NULL )
{
fprintf( pAbc->Err, "ABC-native emap structural mapping has failed.\n" );
Expand All @@ -137,11 +216,20 @@ int Emap_Command( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;

usage:
fprintf( pAbc->Err, "usage: emap [-amvh]\n" );
fprintf( pAbc->Err, "\t maps the current AIG using the current GENLIB library\n" );
fprintf( pAbc->Err, "\t-a : toggle area-oriented mode without required-time pruning [default = %s]\n", fAreaMode ? "yes" : "no" );
fprintf( pAbc->Err, "\t-m : toggle using multi-output gates when present [default = %s]\n", fUseMogs ? "yes" : "no" );
fprintf( pAbc->Err, "\t-v : toggle verbose output [default = %s]\n", fVerbose ? "yes" : "no" );
fprintf( pAbc->Err, "usage: emap [-CFAB num] [-D float] [-amNOvh]\n" );
fprintf( pAbc->Err, "\t maps the current AIG using the current GENLIB library; if the library\n" );
fprintf( pAbc->Err, "\t was read by \"read_lib\", the cells are timed with its NLDM tables\n" );
fprintf( pAbc->Err, "\t-C num : the maximum number of priority cuts per node [default = %d]\n", pPars->nCutNum );
fprintf( pAbc->Err, "\t-F num : the number of area-flow rounds [default = %d]\n", pPars->nFlowRounds );
fprintf( pAbc->Err, "\t-A num : the maximum number of exact-area rounds [default = %d]\n", pPars->nAreaRounds );
fprintf( pAbc->Err, "\t-B num : the incremental timing budget in node updates per AIG node and round;\n" );
fprintf( pAbc->Err, "\t after that, each round is timed and repaired as a whole (0 = no limit) [default = %d]\n", pPars->nPropBudget );
fprintf( pAbc->Err, "\t-D float : the delay target (0 = the best delay) [default = %.2f]\n", pPars->DelayTarget );
fprintf( pAbc->Err, "\t-a : toggle area-oriented mode without required-time pruning [default = %s]\n", pPars->fAreaMode ? "yes" : "no" );
fprintf( pAbc->Err, "\t-m : toggle using multi-output gates when present [default = %s]\n", pPars->fUseMogs ? "yes" : "no" );
fprintf( pAbc->Err, "\t-N : toggle NLDM timing when a Liberty library is loaded (else GENLIB delays) [default = %s]\n", pPars->fNldm ? "yes" : "no" );
fprintf( pAbc->Err, "\t-O : toggle running the original implementation (ignores -CFABDN) [default = %s]\n", pPars->fLegacy ? "yes" : "no" );
fprintf( pAbc->Err, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose ? "yes" : "no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n\n" );
fprintf( pAbc->Err, "\tThe mapper is inspired by \"emap\" in Mockturtle developed by Alessandro Tempia Calvino\n" );
fprintf( pAbc->Err, "\tavailable at https://mockturtle.readthedocs.io/en/latest/algorithms/mapper.html\n" );
Expand Down
16 changes: 16 additions & 0 deletions src/map/emap/emap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ ABC_NAMESPACE_HEADER_START
typedef struct Abc_Ntk_t_ Abc_Ntk_t;
typedef struct Mio_LibraryStruct_t_ Mio_Library_t;

typedef struct Emap_Par_t_ Emap_Par_t;
struct Emap_Par_t_
{
int nCutNum; // priority cuts per node
int nFlowRounds; // area-flow rounds
int nAreaRounds; // exact-area rounds
int fUseMogs; // use multi-output gates
int fAreaMode; // area mode without required times
int fNldm; // use NLDM timing if a Liberty library is loaded
int nPropBudget; // incremental timing budget: retimed nodes per AIG node and round (0 = no limit)
float DelayTarget; // delay target (0 = the best delay)
int fLegacy; // run the original implementation
int fVerbose; // verbose output
};

extern void Emap_Init ( Abc_Frame_t * pAbc );
extern void Emap_End ( Abc_Frame_t * pAbc );
extern int Emap_Command( Abc_Frame_t * pAbc, int argc, char ** argv );

extern Abc_Ntk_t * Emap_ManMapAigStructural( Abc_Ntk_t * pNtk, Mio_Library_t * pLib, int fUseMogs, int fAreaMode, int fVerbose );
extern Abc_Ntk_t * Emap_ManMapNew( Abc_Ntk_t * pNtk, Mio_Library_t * pLib, Emap_Par_t * pPars );

ABC_NAMESPACE_HEADER_END

Expand Down
Loading