From 367b407fba9ddc3769977cc78760301691ccebd0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Feb 2026 19:47:14 -0800 Subject: [PATCH] Extending "lutexact" to get function from the current network. --- src/base/abci/abc.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index a13728d54..4205c4cd8 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -10940,15 +10940,35 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( 0, "If LUT mapping is not enabled (switch \"-r\"), permutation has not effect.\n" ); if ( argc == globalUtilOptind + 1 ) pPars->pTtStr = argv[globalUtilOptind]; - else if ( argc == globalUtilOptind && Abc_FrameReadNtk(pAbc) ) + else if ( argc == globalUtilOptind && Abc_FrameReadNtk(pAbc) ) { - pPars->pTtStr = Abc_NtkReadTruth( Abc_FrameReadNtk(pAbc) ); - if ( pPars->pTtStr ) - pPars->nVars = Abc_NtkCiNum(Abc_FrameReadNtk(pAbc)); + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + if ( Abc_NtkCiNum(pNtk) > 30 ) + { + Abc_Print( -1, "Cannot derive truth table from network: too many inputs (%d > 30).\n", Abc_NtkCiNum(pNtk) ); + Abc_Print( -1, "Please provide truth table on the command line or use a smaller network.\n" ); + return 1; + } + if ( Abc_NtkCoNum(pNtk) != 1 ) + { + Abc_Print( -1, "Cannot derive truth table from network: network must have exactly one output (has %d).\n", Abc_NtkCoNum(pNtk) ); + return 1; + } + pPars->pTtStr = Abc_NtkReadTruth( pNtk ); + if ( pPars->pTtStr ) + { + pPars->nVars = Abc_NtkCiNum(pNtk); + Abc_Print( 0, "Derived %d-input truth table from current network.\n", pPars->nVars ); + } + else + { + Abc_Print( -1, "Failed to derive truth table from current network.\n" ); + return 1; + } } if ( pPars->pTtStr == NULL && pPars->pSymStr == NULL && pPars->nRandFuncs == 0 ) { - Abc_Print( -1, "Truth table should be given on the command line.\n" ); + Abc_Print( -1, "Truth table should be given on the command line, or derived from current single-output network.\n" ); return 1; } if ( pPars->nVars == 0 && pPars->pTtStr )