Skip to content

Commit e67af0a

Browse files
committed
Command "netexact".
1 parent 3300194 commit e67af0a

File tree

3 files changed

+1399
-1
lines changed

3 files changed

+1399
-1
lines changed

src/base/abci/abc.c

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static int Abc_CommandTwoExact ( Abc_Frame_t * pAbc, int argc, cha
174174
static int Abc_CommandLutExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
175175
static int Abc_CommandAndExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
176176
static int Abc_CommandAllExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
177-
static int Abc_CommandTopoExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
177+
static int Abc_CommandTopoExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
178+
static int Abc_CommandNetExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
178179
static int Abc_CommandTestExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
179180
static int Abc_CommandMajGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
180181
static int Abc_CommandOrchestrate ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -1007,6 +1008,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
10071008
Cmd_CommandAdd( pAbc, "Exact synthesis", "andexact", Abc_CommandAndExact, 0 );
10081009
Cmd_CommandAdd( pAbc, "Exact synthesis", "allexact", Abc_CommandAllExact, 0 );
10091010
Cmd_CommandAdd( pAbc, "Exact synthesis", "topoexact", Abc_CommandTopoExact, 0 );
1011+
Cmd_CommandAdd( pAbc, "Exact synthesis", "netexact", Abc_CommandNetExact, 0 );
10101012
Cmd_CommandAdd( pAbc, "Exact synthesis", "testexact", Abc_CommandTestExact, 0 );
10111013
Cmd_CommandAdd( pAbc, "Exact synthesis", "majgen", Abc_CommandMajGen, 0 );
10121014

@@ -11509,6 +11511,158 @@ int Abc_CommandTopoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1150911511
return 1;
1151011512
}
1151111513

11514+
/**Function*************************************************************
11515+
11516+
Synopsis []
11517+
11518+
Description []
11519+
11520+
SideEffects []
11521+
11522+
SeeAlso []
11523+
11524+
***********************************************************************/
11525+
int Abc_CommandNetExact( Abc_Frame_t * pAbc, int argc, char ** argv )
11526+
{
11527+
extern int Tn_ReadHexTruth( char * pInput, word * pTruth );
11528+
extern void Tn_SolveProblem( int nIns, int nOuts, word * pOuts, char * pTypes, int nEdgeLimit, int nLevelLimit, int nSolsMax, int Seed, int TimeOut, int fVerbose );
11529+
int c, nIns = 0, nOuts = 0, nEdgeLimit = 0, nLevelLimit = 0, nSolsMax = 1, Seed = 0, TimeOut = 0, fVerbose = 0;
11530+
char * pTypes = NULL;
11531+
word Truths[16] = {0};
11532+
Extra_UtilGetoptReset();
11533+
while ( ( c = Extra_UtilGetopt( argc, argv, "CELNSTVvh" ) ) != EOF )
11534+
{
11535+
switch ( c )
11536+
{
11537+
case 'C':
11538+
if ( globalUtilOptind >= argc )
11539+
{
11540+
Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
11541+
goto usage;
11542+
}
11543+
pTypes = argv[globalUtilOptind];
11544+
globalUtilOptind++;
11545+
break;
11546+
case 'S':
11547+
if ( globalUtilOptind >= argc )
11548+
{
11549+
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
11550+
goto usage;
11551+
}
11552+
Seed = atoi(argv[globalUtilOptind]);
11553+
globalUtilOptind++;
11554+
if ( Seed < 0 )
11555+
goto usage;
11556+
break;
11557+
case 'E':
11558+
if ( globalUtilOptind >= argc )
11559+
{
11560+
Abc_Print( -1, "Command line switch \"-E\" should be followed by an integer.\n" );
11561+
goto usage;
11562+
}
11563+
nEdgeLimit = atoi(argv[globalUtilOptind]);
11564+
globalUtilOptind++;
11565+
if ( nEdgeLimit < 0 )
11566+
goto usage;
11567+
break;
11568+
case 'L':
11569+
if ( globalUtilOptind >= argc )
11570+
{
11571+
Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
11572+
goto usage;
11573+
}
11574+
nLevelLimit = atoi(argv[globalUtilOptind]);
11575+
globalUtilOptind++;
11576+
if ( nLevelLimit < 0 )
11577+
goto usage;
11578+
break;
11579+
case 'N':
11580+
if ( globalUtilOptind >= argc )
11581+
{
11582+
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
11583+
goto usage;
11584+
}
11585+
nSolsMax = atoi(argv[globalUtilOptind]);
11586+
globalUtilOptind++;
11587+
if ( nSolsMax < 0 )
11588+
goto usage;
11589+
break;
11590+
case 'T':
11591+
if ( globalUtilOptind >= argc )
11592+
{
11593+
Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
11594+
goto usage;
11595+
}
11596+
TimeOut = atoi(argv[globalUtilOptind]);
11597+
globalUtilOptind++;
11598+
if ( TimeOut < 0 )
11599+
goto usage;
11600+
break;
11601+
case 'V':
11602+
if ( globalUtilOptind >= argc )
11603+
{
11604+
Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
11605+
goto usage;
11606+
}
11607+
fVerbose = atoi(argv[globalUtilOptind]);
11608+
globalUtilOptind++;
11609+
if ( fVerbose < 0 )
11610+
goto usage;
11611+
break;
11612+
case 'v':
11613+
fVerbose ^= 1;
11614+
break;
11615+
case 'h':
11616+
goto usage;
11617+
default:
11618+
goto usage;
11619+
}
11620+
}
11621+
11622+
for ( c = globalUtilOptind; c < argc; c++ ) {
11623+
if ( Abc_TtIsHexDigit(argv[c][0]) == -1 ) {
11624+
Abc_Print( -1, "Cannot read truth table \"%s\".\n", argv[c] );
11625+
goto usage;
11626+
}
11627+
int nVarsOut = Tn_ReadHexTruth( argv[c], Truths + nOuts++ );
11628+
if ( nIns == 0 )
11629+
nIns = nVarsOut;
11630+
else if ( nIns != nVarsOut ) {
11631+
Abc_Print( -1, "The support size of output functions is not the same.\n" );
11632+
goto usage;
11633+
}
11634+
}
11635+
11636+
printf( "Finished reading %d output%s\n\n", nOuts, nOuts == 1 ? "" : "s" );
11637+
Tn_SolveProblem( nIns, nOuts, Truths, pTypes, nEdgeLimit, nLevelLimit, nSolsMax, Seed, TimeOut, fVerbose );
11638+
return 0;
11639+
11640+
usage:
11641+
11642+
Abc_Print( -2, "usage: netexact -C <str> [-ELNSTV <num>] <truth[0]> ... <truth[m-1]>\n" );
11643+
Abc_Print( -2, " this program synthesizes networks for multi-output functions\n" );
11644+
Abc_Print( -2, "\n" );
11645+
Abc_Print( -2, " -C <str> : the configuration string (no default)\n" );
11646+
Abc_Print( -2, " -E <num> : the max number of edges (default = no limit)\n" );
11647+
Abc_Print( -2, " -L <num> : the max number of levels (default = no limit)\n" );
11648+
Abc_Print( -2, " -N <num> : the max number of solutions (default = 1)\n" );
11649+
Abc_Print( -2, " -S <num> : the random seed (default = 0)\n" );
11650+
Abc_Print( -2, " -T <num> : the timeout in seconds (default = no timeout)\n" );
11651+
Abc_Print( -2, " -V <num> : the verbosiness levels (default = %d)\n", fVerbose );
11652+
Abc_Print( -2, " <truth[0]> : the truth table of the first output in the hexadecimal notation\n" );
11653+
Abc_Print( -2, " <truth[m-1]> : the truth table of the last output in the hexadecimal notation\n" );
11654+
Abc_Print( -2, " the truth tables are assumed to depend on the same variables\n" );
11655+
Abc_Print( -2, " the strings should contain 2^(<num_inputs>-2) hexadecimal digits\n" );
11656+
Abc_Print( -2, "\n" );
11657+
Abc_Print( -2, " Example 1: Synthesizing 3-node 2-edge 2-input and-gate:\n" );
11658+
Abc_Print( -2, " %s -C *11** -E 2 8\n", argv[0] );
11659+
Abc_Print( -2, " Example 2: Synthesizing 4-node 5-edge 3-input majority gate:\n" );
11660+
Abc_Print( -2, " %s -C *111*** -E 5 E8\n", argv[0] );
11661+
Abc_Print( -2, " Example 3: Synthesizing 10-edge 3-input 2-output full-adder:\n" );
11662+
Abc_Print( -2, " %s -C *222****** -E 10 E8 96\n", argv[0] );
11663+
return 1;
11664+
}
11665+
1151211666
/**Function*************************************************************
1151311667

1151411668
Synopsis []

src/misc/util/module.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SRC += src/misc/util/utilBridge.c \
99
src/misc/util/utilMiniver.c \
1010
src/misc/util/utilMulSim.c \
1111
src/misc/util/utilNam.c \
12+
src/misc/util/utilNet.c \
1213
src/misc/util/utilPrefix.cpp \
1314
src/misc/util/utilPth.c \
1415
src/misc/util/utilSignal.c \

0 commit comments

Comments
 (0)