From 5f3a4fec8371bff667729efc13265d8ffdd57e1e Mon Sep 17 00:00:00 2001 From: JingrenWang Date: Fri, 23 Jan 2026 07:05:10 +0800 Subject: [PATCH 1/8] Fix(&put): Missing spec in cec Signed-off-by: JingrenWang --- src/base/abci/abc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 89c1b0751..a33fc7b5b 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -34603,6 +34603,11 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_NtkDelete( pNtkNoCh ); Aig_ManStop( pMan ); } + // transfer the spec name to the pNtk + if( pAbc->pGia->pSpec ) + { + pNtk->pSpec = Extra_UtilStrsav( pAbc->pGia->pSpec ); + } // transfer PI names to pNtk if ( pAbc->pGia->vNamesIn ) { From 6fcdfdbc5e620328660ca947ccb02ee0561f7877 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 28 Jan 2026 09:52:01 +0100 Subject: [PATCH 2/8] WASI compile fixes --- src/misc/util/utilAigSim.c | 18 ++++++++++++++++++ src/opt/ufar/UfarMgr.cpp | 2 -- src/opt/ufar/UfarPth.cpp | 4 ++++ src/opt/untk/NtkNtk.cpp | 1 - src/opt/util/util.cpp | 2 ++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/misc/util/utilAigSim.c b/src/misc/util/utilAigSim.c index 3bbde59a8..4d89b615f 100644 --- a/src/misc/util/utilAigSim.c +++ b/src/misc/util/utilAigSim.c @@ -30,6 +30,8 @@ #define mkstemp(p) _mktemp_s(p, strlen(p)+1) #else #include // mkstemp(), close(), unlink() +#include +#include #endif #ifdef _WIN32 @@ -333,8 +335,14 @@ static int ends_with(const char *s, const char *suf) { static int make_tmp_file(char *path, size_t cap, const char *prefix) { // Creates an existing temp file (for input) +#if defined(__wasm) + static int seq = 0; // no risk of collision since we're in a sandbox + snprintf(path, cap, "%s%08d", prefix, seq++); + int fd = open(path, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE); +#else snprintf(path, cap, "/tmp/%sXXXXXX", prefix); int fd = mkstemp(path); +#endif if (fd < 0) return 0; close(fd); return 1; @@ -342,8 +350,14 @@ static int make_tmp_file(char *path, size_t cap, const char *prefix) { static int make_tmp_path_noexist(char *path, size_t cap, const char *prefix) { // Creates a unique temp path that does not exist (for output) +#if defined(__wasm) + static int seq = 0; // no risk of collision since we're in a sandbox + snprintf(path, cap, "%s%08d", prefix, seq++); + int fd = open(path, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE); +#else snprintf(path, cap, "/tmp/%sXXXXXX", prefix); int fd = mkstemp(path); +#endif if (fd < 0) return 0; close(fd); unlink(path); @@ -612,7 +626,11 @@ static int SimulateCompareAigBin(const AigMan *p1, const char *bin, // Run external binary: " " remove(outFile); snprintf(cmd, sizeof(cmd), "%s %s %s", bin, inFile, outFile); +#if defined(__wasm) + int rc = -1; +#else int rc = system(cmd); +#endif if (rc != 0) { fprintf(stderr, "Error: system() failed (rc=%d): %s\n", rc, cmd); goto fail; diff --git a/src/opt/ufar/UfarMgr.cpp b/src/opt/ufar/UfarMgr.cpp index 924ad0d6b..67b5aed85 100755 --- a/src/opt/ufar/UfarMgr.cpp +++ b/src/opt/ufar/UfarMgr.cpp @@ -16,8 +16,6 @@ #ifdef _WIN32 #include -#else -#include #endif #include diff --git a/src/opt/ufar/UfarPth.cpp b/src/opt/ufar/UfarPth.cpp index f2ef59374..6de28dbc5 100755 --- a/src/opt/ufar/UfarPth.cpp +++ b/src/opt/ufar/UfarPth.cpp @@ -188,6 +188,10 @@ class PDRWLA : public Solver { Wlc_Par_t _Pars; }; +#if defined(__wasm) +static void pthread_exit(void *retval) __attribute__((noreturn)) { } +#endif + void KillOthers() { pthread_cond_signal( &g_cond ); ++g_nRunIds; diff --git a/src/opt/untk/NtkNtk.cpp b/src/opt/untk/NtkNtk.cpp index 62ab1e343..0c74a4761 100755 --- a/src/opt/untk/NtkNtk.cpp +++ b/src/opt/untk/NtkNtk.cpp @@ -9,7 +9,6 @@ #include #else #include -#include #endif #include diff --git a/src/opt/util/util.cpp b/src/opt/util/util.cpp index a4b3ceba5..fa80bebd9 100644 --- a/src/opt/util/util.cpp +++ b/src/opt/util/util.cpp @@ -6,7 +6,9 @@ */ #include +#if !defined(__wasm) #include +#endif #ifdef _WIN32 #include #else From 29656286cf795de7f30bd95fde50cd6c2b9ab9bc Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 28 Jan 2026 18:39:21 +0700 Subject: [PATCH 3/8] New command &init1. --- src/aig/gia/giaDup.c | 34 +++++++++++++++++++++++++++ src/base/abci/abc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index 84ed665f0..0c0fd3d1e 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -656,6 +656,40 @@ Gia_Man_t * Gia_ManDupFlip( Gia_Man_t * p, int * pInitState ) return pNew; } +/**Function************************************************************* + + Synopsis [Complements some flops without duplicating AIG.] + + Description [The array of integers containing the initial state + of each flop in the AIG.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFlipInit1( Gia_Man_t * p, Vec_Int_t * vInit ) +{ + Gia_Obj_t * pObj; int c; + assert( Gia_ManRegNum(p) == Vec_IntSize(vInit) ); + Gia_ManForEachRo( p, pObj, c ) + pObj->fMark0 = (int)(Vec_IntEntry(vInit, c) == 1); + Gia_ManForEachAnd( p, pObj, c ) { + if ( Gia_ObjFanin0(pObj)->fMark0 ) + pObj->fCompl0 ^= 1; + if ( Gia_ObjFanin1(pObj)->fMark0 ) + pObj->fCompl1 ^= 1; + } + Gia_ManForEachCo( p, pObj, c ) + if ( Gia_ObjFanin0(pObj)->fMark0 ) + pObj->fCompl0 ^= 1; + Gia_ManForEachRo( p, pObj, c ) + pObj->fMark0 = 0; + Gia_ManForEachRi( p, pObj, c ) + if ( Vec_IntEntry(vInit, c) == 1 ) + pObj->fCompl0 ^= 1; +} + /**Function************************************************************* diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 73c723a90..bba7b3bcf 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -635,6 +635,7 @@ static int Abc_CommandAbc9Gen ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Cfs ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9ProdAdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9AddFlop ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Init1 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9BMiter ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9GenHie ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9PutOnTop ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1477,6 +1478,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&cfs", Abc_CommandAbc9Cfs, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&prodadd", Abc_CommandAbc9ProdAdd, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&addflop", Abc_CommandAbc9AddFlop, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&init1", Abc_CommandAbc9Init1, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&bmiter", Abc_CommandAbc9BMiter, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&gen_hie", Abc_CommandAbc9GenHie, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&putontop", Abc_CommandAbc9PutOnTop, 0 ); @@ -57029,6 +57031,59 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Init1( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManFlipInit1( Gia_Man_t * p, Vec_Int_t * vInit ); + 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 ( pAbc->pGia == NULL ) { + Abc_Print( -1, "Abc_CommandAbc9Init1(): There is no AIG.\n" ); + return 0; + } + if ( Gia_ManRegNum(pAbc->pGia) == 0 ) { + Abc_Print( -1, "Abc_CommandAbc9Init1(): There is no flops.\n" ); + return 0; + } + if ( pAbc->pGia->vRegInits == NULL ) { + Abc_Print( -1, "Abc_CommandAbc9Init1(): Flop init states are not available.\n" ); + return 0; + } + Gia_ManFlipInit1( pAbc->pGia, pAbc->pGia->vRegInits ); + return 0; + +usage: + Abc_Print( -2, "usage: &init1 [-vh]\n" ); + Abc_Print( -2, "\t complements the inputs/outputs of flops with const-1 initial state\n" ); + Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + + /**Function************************************************************* Synopsis [] From ade1882ffc6c21ee5979f8f4341961db43acbaaf Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 29 Jan 2026 11:33:37 +0700 Subject: [PATCH 4/8] Commenting out an assertion. --- src/aig/gia/giaTim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aig/gia/giaTim.c b/src/aig/gia/giaTim.c index 080c74471..5f13dcfa7 100644 --- a/src/aig/gia/giaTim.c +++ b/src/aig/gia/giaTim.c @@ -77,7 +77,8 @@ int Gia_ManClockDomainNum( Gia_Man_t * p ) if ( p->vRegClasses == NULL ) return 0; nDoms = Vec_IntFindMax(p->vRegClasses); - assert( Vec_IntCountEntry(p->vRegClasses, 0) == 0 ); + // Class 0 is now allowed - means unmergeable flops not in any clock domain + // assert( Vec_IntCountEntry(p->vRegClasses, 0) == 0 ); for ( i = 1; i <= nDoms; i++ ) if ( Vec_IntCountEntry(p->vRegClasses, i) > 0 ) Count++; From f2ae808236ed155399521fbb43a7ea5bf1742b5a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 29 Jan 2026 09:26:58 +0100 Subject: [PATCH 5/8] MINGW proper pthread handling --- src/aig/gia/giaKf.c | 2 +- src/aig/gia/giaTranStoch.c | 2 +- src/base/cmd/cmdAuto.c | 2 +- src/base/cmd/cmdStarter.c | 2 +- src/base/wlc/wlcPth.c | 2 +- src/map/if/ifDsd.c | 2 +- src/map/if/ifTest.c | 2 +- src/misc/util/utilPth.c | 4 ++-- src/opt/ufar/UfarPth.cpp | 2 +- src/proof/abs/absPth.c | 2 +- src/proof/cec/cecProve.c | 2 +- src/proof/cec/cecSplit.c | 2 +- src/proof/ssw/sswPart.c | 2 +- src/sat/bmc/bmcBmcS.c | 2 +- src/sat/cnf/cnfUtil.c | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/aig/gia/giaKf.c b/src/aig/gia/giaKf.c index 6909851f1..820178d36 100644 --- a/src/aig/gia/giaKf.c +++ b/src/aig/gia/giaKf.c @@ -29,7 +29,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/aig/gia/giaTranStoch.c b/src/aig/gia/giaTranStoch.c index f7b300c0d..286eae98b 100644 --- a/src/aig/gia/giaTranStoch.c +++ b/src/aig/gia/giaTranStoch.c @@ -37,7 +37,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/base/cmd/cmdAuto.c b/src/base/cmd/cmdAuto.c index 8151c2e53..98cb6a5a2 100644 --- a/src/base/cmd/cmdAuto.c +++ b/src/base/cmd/cmdAuto.c @@ -29,7 +29,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/base/cmd/cmdStarter.c b/src/base/cmd/cmdStarter.c index bfbe5533d..f0cb121b1 100644 --- a/src/base/cmd/cmdStarter.c +++ b/src/base/cmd/cmdStarter.c @@ -27,7 +27,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/base/wlc/wlcPth.c b/src/base/wlc/wlcPth.c index ddafab23c..5a699e888 100644 --- a/src/base/wlc/wlcPth.c +++ b/src/base/wlc/wlcPth.c @@ -23,7 +23,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/map/if/ifDsd.c b/src/map/if/ifDsd.c index c25873a9f..f72df0ac5 100644 --- a/src/map/if/ifDsd.c +++ b/src/map/if/ifDsd.c @@ -32,7 +32,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/map/if/ifTest.c b/src/map/if/ifTest.c index fa9a64443..4b1ede06f 100644 --- a/src/map/if/ifTest.c +++ b/src/map/if/ifTest.c @@ -23,7 +23,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/misc/util/utilPth.c b/src/misc/util/utilPth.c index 940f7929a..0e7194235 100644 --- a/src/misc/util/utilPth.c +++ b/src/misc/util/utilPth.c @@ -23,7 +23,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #include // nanosleep implementation for Windows @@ -41,7 +41,7 @@ static inline int nanosleep(const struct timespec *req, struct timespec *rem) { #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/opt/ufar/UfarPth.cpp b/src/opt/ufar/UfarPth.cpp index 6de28dbc5..85bb0e178 100755 --- a/src/opt/ufar/UfarPth.cpp +++ b/src/opt/ufar/UfarPth.cpp @@ -1,7 +1,7 @@ #include "misc/util/abc_namespaces.h" -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/proof/abs/absPth.c b/src/proof/abs/absPth.c index f04a20d1c..d8cb34359 100644 --- a/src/proof/abs/absPth.c +++ b/src/proof/abs/absPth.c @@ -25,7 +25,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/proof/cec/cecProve.c b/src/proof/cec/cecProve.c index ff10e8cae..281dc2704 100644 --- a/src/proof/cec/cecProve.c +++ b/src/proof/cec/cecProve.c @@ -30,7 +30,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/proof/cec/cecSplit.c b/src/proof/cec/cecSplit.c index 34a635b88..9c402a89f 100644 --- a/src/proof/cec/cecSplit.c +++ b/src/proof/cec/cecSplit.c @@ -28,7 +28,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/proof/ssw/sswPart.c b/src/proof/ssw/sswPart.c index 3a65f17dd..094ffab88 100644 --- a/src/proof/ssw/sswPart.c +++ b/src/proof/ssw/sswPart.c @@ -25,7 +25,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include #include #include "../lib/pthread.h" diff --git a/src/sat/bmc/bmcBmcS.c b/src/sat/bmc/bmcBmcS.c index 8bfda56ba..f43722c9e 100644 --- a/src/sat/bmc/bmcBmcS.c +++ b/src/sat/bmc/bmcBmcS.c @@ -48,7 +48,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include diff --git a/src/sat/cnf/cnfUtil.c b/src/sat/cnf/cnfUtil.c index 3a47ae796..0c5791f6f 100644 --- a/src/sat/cnf/cnfUtil.c +++ b/src/sat/cnf/cnfUtil.c @@ -29,7 +29,7 @@ #ifdef ABC_USE_PTHREADS -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #include "../lib/pthread.h" #else #include From b6105230bf23bed165f74049d90c2318bf5ee342 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 30 Jan 2026 17:29:15 +0700 Subject: [PATCH 6/8] Transforming init1 states. --- src/aig/gia/giaAiger.c | 100 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/aig/gia/giaAiger.c b/src/aig/gia/giaAiger.c index 6339b057f..9bc6c93fc 100644 --- a/src/aig/gia/giaAiger.c +++ b/src/aig/gia/giaAiger.c @@ -982,6 +982,106 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSi pNew->pAigExtra = pAigExtra; } + // Apply init state transformation for register boxes with init=1 + if ( pNew->vRegInits && Vec_IntCountEntry(pNew->vRegInits, 1) > 0 ) + { + extern void Gia_ManFlipInit1( Gia_Man_t * p, Vec_Int_t * vInit ); + Tim_Man_t * pTimMan = (Tim_Man_t *)pNew->pManTime; + + if ( pTimMan && Gia_ManRegBoxNum(pNew) > 0 ) + { + // Handle register boxes: apply transformation to box inputs/outputs + Gia_Obj_t * pObj; + int i, curCo, curCi, nBoxIns, nBoxOuts; + int iRegBox = 0; + + assert( Vec_IntSize(pNew->vRegInits) == Gia_ManRegBoxNum(pNew) ); + + // Step 1: Mark register box outputs with init state 1 + curCi = Tim_ManPiNum(pTimMan); + for ( i = 0; i < Gia_ManBoxNum(pNew); i++ ) + { + nBoxIns = Tim_ManBoxInputNum(pTimMan, i); + nBoxOuts = Tim_ManBoxOutputNum(pTimMan, i); + // Check if this is a register box (1-input, 1-output) + if ( nBoxIns == 1 && nBoxOuts == 1 ) + { + if ( Vec_IntEntry(pNew->vRegInits, iRegBox) == 1 ) + { + pObj = Gia_ManCi(pNew, curCi); + pObj->fMark0 = 1; + } + iRegBox++; + } + curCi += nBoxOuts; + } + + // Step 2: Propagate complementation through AND gates + Gia_ManForEachAnd( pNew, pObj, i ) + { + if ( Gia_ObjFanin0(pObj)->fMark0 ) + pObj->fCompl0 ^= 1; + if ( Gia_ObjFanin1(pObj)->fMark0 ) + pObj->fCompl1 ^= 1; + } + + // Step 3: Complement CO fanins if needed + Gia_ManForEachCo( pNew, pObj, i ) + { + if ( Gia_ObjFanin0(pObj)->fMark0 ) + pObj->fCompl0 ^= 1; + } + + // Step 4: Clear marks + curCi = Tim_ManPiNum(pTimMan); + iRegBox = 0; + for ( i = 0; i < Gia_ManBoxNum(pNew); i++ ) + { + nBoxIns = Tim_ManBoxInputNum(pTimMan, i); + nBoxOuts = Tim_ManBoxOutputNum(pTimMan, i); + if ( nBoxIns == 1 && nBoxOuts == 1 ) + { + if ( Vec_IntEntry(pNew->vRegInits, iRegBox) == 1 ) + { + pObj = Gia_ManCi(pNew, curCi); + pObj->fMark0 = 0; + } + iRegBox++; + } + curCi += nBoxOuts; + } + + // Step 5: Complement register box inputs with init state 1 + curCo = Tim_ManPoNum(pTimMan); + iRegBox = 0; + for ( i = 0; i < Gia_ManBoxNum(pNew); i++ ) + { + nBoxIns = Tim_ManBoxInputNum(pTimMan, i); + nBoxOuts = Tim_ManBoxOutputNum(pTimMan, i); + if ( nBoxIns == 1 && nBoxOuts == 1 ) + { + if ( Vec_IntEntry(pNew->vRegInits, iRegBox) == 1 ) + { + pObj = Gia_ManCo(pNew, curCo); + pObj->fCompl0 ^= 1; + } + iRegBox++; + } + curCo += nBoxIns; + } + + // Clear all init states to 0 (transformation is now structural) + Vec_IntFill( pNew->vRegInits, Vec_IntSize(pNew->vRegInits), 0 ); + } + else if ( Gia_ManRegNum(pNew) > 0 ) + { + // Handle regular flops (no boxes) + Gia_ManFlipInit1( pNew, pNew->vRegInits ); + // Clear all init states to 0 (transformation is now structural) + Vec_IntFill( pNew->vRegInits, Vec_IntSize(pNew->vRegInits), 0 ); + } + } + if ( fHieOnly ) { // Tim_ManPrint( (Tim_Man_t *)pNew->pManTime ); From 5899aa5df1d6b6eeba54a85796b4dd38e17dd9fc Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Feb 2026 19:24:35 -0800 Subject: [PATCH 7/8] Allow for backward compatibility (when nly PI/PO timing is given). --- src/misc/tim/timMan.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/misc/tim/timMan.c b/src/misc/tim/timMan.c index 2df6007cc..274dc0c0e 100644 --- a/src/misc/tim/timMan.c +++ b/src/misc/tim/timMan.c @@ -562,33 +562,56 @@ void Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * */ if ( vInArrs ) { - assert( Vec_FltSize(vInArrs) >= Tim_ManPiNum(p) ); - if ( Vec_FltSize(vInArrs) == Tim_ManPiNum(p) ) { + // Handle special case when timing is only for PIs (without boxes/flops) + // This happens when old files provide timing for actual design PIs only + if ( Vec_FltSize(vInArrs) < Tim_ManPiNum(p) ) + { + // Special case: timing for actual PIs only (less than Tim_ManPiNum when boxes exist) + for ( i = 0; i < Vec_FltSize(vInArrs); i++ ) + p->pCis[i].timeArr = Vec_FltEntry(vInArrs, i); + } + else if ( Vec_FltSize(vInArrs) == Tim_ManPiNum(p) ) + { + // Original case: timing for PIs (up to first box) Tim_ManForEachPi( p, pObj, i ) pObj->timeArr = Vec_FltEntry(vInArrs, i); } - else { + else + { + // General case: timing for all or partial CIs float Num; Vec_FltForEachEntry( vInArrs, Num, i ) - p->pCis[i].timeArr = Num; + if ( i < p->nCis ) + p->pCis[i].timeArr = Num; } } // create required times - // Handles: POs only, POs+Flops (partial COs), or all COs if ( vOutReqs ) { - assert( Vec_FltSize(vOutReqs) >= Tim_ManPoNum(p) ); - if ( Vec_FltSize(vOutReqs) == Tim_ManPoNum(p) ) { + // Handle special case when timing is only for POs (without boxes/flops) + // This happens when old files provide timing for actual design POs only + if ( Vec_FltSize(vOutReqs) < Tim_ManPoNum(p) ) + { + // Special case: timing for actual POs only (less than Tim_ManPoNum when boxes exist) + for ( i = 0; i < Vec_FltSize(vOutReqs); i++ ) + p->pCos[i].timeReq = Vec_FltEntry(vOutReqs, i); + } + else if ( Vec_FltSize(vOutReqs) == Tim_ManPoNum(p) ) + { + // Original case: timing for POs k = 0; Tim_ManForEachPo( p, pObj, i ) pObj->timeReq = Vec_FltEntry(vOutReqs, k++); assert( k == Tim_ManPoNum(p) ); } - else { + else + { + // General case: timing for all or partial COs float Num; Vec_FltForEachEntry( vOutReqs, Num, i ) - p->pCos[i].timeReq = Num; + if ( i < p->nCos ) + p->pCos[i].timeReq = Num; } } } From 367b407fba9ddc3769977cc78760301691ccebd0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Feb 2026 19:47:14 -0800 Subject: [PATCH 8/8] 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 )