Commit Graph

6222 Commits

Author SHA1 Message Date
alanminko 5ea3464324
Merge pull request #535 from aiquoc/experiment-x-aware-equivalence-checking
Experiment x aware equivalence checking
2026-08-17 15:21:07 +09:00
Alan Mishchenko 324081b6a4 Update word-level data-structure 2026-08-16 23:13:47 -07:00
alanminko 371e53f93e
Merge pull request #545 from fxreichl/master
Fix a bug that can arise when reducing circuit depth.
2026-08-16 01:50:28 +09:00
alanminko 89bef47d8d
Merge pull request #543 from marcelwa/cec-verdict-const0
&cec -x/-y: is the AND-free check meant to be sufficient for equivalence?
2026-08-16 01:49:49 +09:00
alanminko fe862d3647
Merge pull request #541 from marcelwa/acd-local-extend-shift-ub
ACD: 64-bit shift by 64 or more in local_extend_to
2026-08-16 01:48:58 +09:00
alanminko 1d28820170
Merge pull request #540 from marcelwa/lpk-mux-split-support-guard
lutpack: assertion failure in Lpk_MuxSplit from an approximate cofactor support
2026-08-16 01:48:22 +09:00
alanminko 25b0e5399c
Merge pull request #539 from marcelwa/acd-uninit-bestperm
acd: uninitialised read of bestPerm in enumerate_iset_combinations
2026-08-16 01:47:52 +09:00
alanminko a954df2892
Merge pull request #538 from marcelwa/fraig-store-restore-pi-order
fraig_store: restore the PI order when the name comparison fails
2026-08-16 01:46:54 +09:00
Alan Mishchenko 094c1ca741 Fix windows build 2026-08-15 09:35:04 -07:00
Alan Mishchenko 12eb48b476 Add experimental word-level data-structure 2026-08-15 09:23:19 -07:00
Alan Mishchenko d389f88285 Remove obsolete ACB command interface 2026-08-15 09:18:47 -07:00
Franz Reichl ebd3e31a8d Fix a bug that can arise when reducing circuit depth. 2026-08-13 12:57:15 +02:00
Alan Mishchenko e4383a8d67 Remove BAC and CBA from Windows project 2026-08-11 20:30:25 -07:00
Alan Mishchenko e69c02c3f2 Remove legacy BAC and CBA packages 2026-08-11 20:15:35 -07:00
Marcel Walter d4e3670e21
&cec -x/-y, &icec: also require the swept miter outputs to be constant 0
The equivalence verdict in these three branches is taken from
Gia_ManAndNum(pNew) == 0 after Cec4_/Cec5_ManSimulateTest3. An AND-free GIA can
still have outputs that are constant 1 or CI literals, which are satisfiable, so
this reports "Networks are equivalent" for some non-equivalent pairs -- for
example `a & b` against `~(a & b)`, where the miter sweeps to constant 1.

Check the outputs as well: AND nodes remaining -> UNDECIDED as before; AND-free
with all outputs constant 0 -> equivalent as before; AND-free otherwise -> NOT
equivalent, which is decidable by inspection since such a miter is satisfiable.
2026-08-11 19:22:06 +02:00
Alan Mishchenko 6c51a92385 Adding an option t0 &cec against a truth table. 2026-08-08 17:29:15 -07:00
agentic-synthesis 5cbfa76dc3
lutpack: do not trust an approximate cofactor support in the MUX split
`lutpack` aborts on some networks with

  abc: src/opt/lpk/lpkAbcMux.c:192: Lpk_MuxSplit:
       Assertion `iVarVac < (int)p->nVars' failed.

Reproducer (a 24.7k-LUT `sqrt` netlist produced by `if -K 10 -Z 6`, ~10 s):

  read_blif sqrt-mapped.blif; lutpack

Lpk_MuxSplit() splits one component off a function and stores the new component
in a *vacant* fanin slot of the retained one:

  p->uSupp  = Kit_TruthSupport( Pol ? pTruth1 : pTruth0, p->nVars );
  p->uSupp |= (1 << Var);
  iVarVac   = Kit_WordFindFirstBit( ~p->uSupp );
  assert( iVarVac < (int)p->nVars );

A vacant slot is supposed to be guaranteed by Lpk_MuxAnalize(), which rejects a
candidate variable when

  nSuppSizeL = max(nSuppSize0 + 2*!Polarity, nSuppSize1 + 2*Polarity) > p->nVars

but it reads nSuppSize0/nSuppSize1 out of the *cached* p->puSupps[].  When those
came from Lpk_ComputeSupports() they are not exact: that routine builds two
BDDs of the function in opposite variable orders and stitches the two support
estimates together at the cofactoring variable, and the result can be a strict
subset of the true cofactor support.  Lpk_MuxAnalize() then admits a variable
whose split needs one slot more than the function has.

On the reproducer this happens for a 12-variable component at Var = 3,
Polarity = 1: the cached support of cofactor 1 is 0x3f7 (9 variables) while the
truth table's is 0xff7 (11).  The guard sees 9 + 2 = 11 <= 12 and accepts;
the split then produces uSupp = 0xff7 | (1 << 3) = 0xfff, which is full.

Instrumenting the same run shows the estimate differs from the exact support in
484 of 101970 cofactor supports, and is narrower in 352 of them, so this is not
a one-off.

Rather than change the support estimator or weaken the assertion -- which
documents a real invariant of Lpk_MuxSplit() -- re-derive the single support the
split depends on, once the candidate has been chosen, and decline the MUX
decomposition when it does not fit.  That is one cofactor and one support scan
per accepted candidate, not per candidate variable.  On the reproducer lutpack
then completes and yields the same result as recomputing every cached support
from the truth table (24694 -> 24635 nodes, 237 levels in both cases).
2026-08-08 10:21:19 +02:00
agentic-synthesis 0f5951ab2c
ACD: avoid a 64-bit shift by 64 or more in local_extend_to
ac_decomposition_impl::local_extend_to() replicates a truth table that really
depends on `real_num_vars` variables across the full `num_vars`-variable static
truth table.  For real_num_vars < 6 it does so by folding the first word:

    for ( auto i = real_num_vars; i < num_vars; ++i )
      mask |= ( mask << ( 1 << i ) );

Once i reaches 6 the shift distance is 1 << 6 == 64, which is at least the width
of the 64-bit operand, so the shift has undefined behaviour.  This is reached
whenever the cut being decomposed has more than six variables, i.e. in every
ordinary use of `if -K k -Z n` with k > 6; UBSan reports

  ac_decomposition.hpp: runtime error: shift exponent 64 is too large for
  64-bit type 'long unsigned int'

on, for example, `read adder.aig; strash; dch -f; if -K 11 -Z 6 -C 12`.

On x86 the shift is taken modulo 64 and the iteration happens to be a no-op, so
the observable behaviour today is correct, but that is not guaranteed by the
language and other targets shift in a saturating or unspecified way.

Variables 6 and above do not need the fold at all: the subsequent
std::fill() over the whole block array already replicates the word across every
block.  Clamp the loop to the variables that live inside one word.  No
behavioural change on x86.
2026-08-08 09:50:02 +02:00
Marcel Walter 4473e39efc
acd: seed bestPerm to avoid an uninitialised read in enumerate_iset_combinations
bestPerm is only written inside the 'cost < best_cost' branch. When no
combination beats the initial best_cost -- which happens for an infeasible
free-set size -- the array is never written, yet the tail of the function still
evaluates permutations[bestPerm[i]]. That reads uninitialised stack and then
uses the value to index permutations[], so it is an out-of-bounds read as well.

Upstream results are unaffected in practice because the caller discards the
permutation on that path, but it is undefined behaviour and it becomes a hard
segfault as soon as the stack layout changes -- adding two members to the
decomposer object was enough to trigger it reliably.

Seeding the identity permutation in the existing initialisation loop is
sufficient and costs nothing.
2026-08-08 08:43:10 +02:00
Marcel Walter 4d504f20ba
fraig_store: restore the PI order when the name comparison fails
Abc_NtkCompareSignals() sorts the PIs, POs and boxes of both networks by name
before comparing them. That is deliberate and is what lets fraig_store accept
two networks that use the same names in a different order.

When the names do not match, though, the comparison fails, Abc_NtkFraigStore()
resets the store and keeps the incoming network -- which by then has already
been sorted. The network that ends up in the store is a permutation of the one
the caller read in, and nothing reports it. The two lines printed on that path
say the store was reset; they do not say the interface changed.

Sorting is by name as a string, so numeric port names are where it shows up
worst: 1, 2, ..., 10 sort as 1, 10, 2, 3, ... With the EPFL cavlc benchmark and
its published reference netlist, whose ports are named "1".."10",

    read_aiger cavlc.aig; strash; fraig_store
    read_blif  cavlc_size.blif; strash; fraig_store
    fraig_restore; write_blif out.blif

gives an out.blif whose inputs are ordered 1, 10, 2, 3, ... instead of
1, 2, 3, ..., 10. It has the right number of inputs and outputs, it passes
Abc_NtkCheck(), and "cec -n out.blif cavlc.aig" reports a counterexample.

Save the three vectors before the comparison and put them back if it fails,
then rebuild vCis/vCos with Abc_NtkOrderCisCos(). The success path is
untouched, and so is every path where the names already agree -- those never
reach Abc_NtkCompareSignals(), since Abc_NodeCompareCiCo() has already
returned 1.
2026-08-07 20:54:11 +02:00
Alan Mishchenko 8e224cd794 Update mapped delay computation. 2026-08-01 15:27:17 -07:00
aiquoc 85770ba29d fix build windows 2026-07-29 13:46:44 +08:00
aiquoc 842a265d82 fix error build 2026-07-29 13:46:38 +08:00
aiquoc bd52945300 fix error build 2026-07-29 13:46:33 +08:00
aiquoc 2918589334 experiment X-aware equivalence checking 2026-07-29 13:46:16 +08:00
Alan Mishchenko e76768b9d3 Crtical path detection for AIGs. 2026-07-27 07:10:10 -07:00
alanminko 4e1b34d744
Merge pull request #534 from zxxr1113/scorr2-upstream
new command &scorr2 extended from &scorr
2026-07-27 22:56:46 +09:00
xiran 77cd6f4b04 new command &scorr2 extended from &scorr 2026-07-27 18:43:56 +08:00
Alan Mishchenko c1f9a942ca Add dumping truth tables in the PLA format. 2026-07-25 16:19:26 -07:00
Alan Mishchenko 57ad5cd47b Updating %ysoys to abstract modules/instances. 2026-07-25 16:19:26 -07:00
alanminko 3ed7e4179a
Merge pull request #530 from wjrforcyber/choice_fix
Fix(choices): On pSibls
2026-07-23 07:53:37 +09:00
JingrenWang c130edd5e8
Fix(choices): On pSibls
Signed-off-by: JingrenWang <wjrforcyber@163.com>
2026-07-03 14:47:40 +08:00
alanminko bcfdf59228
Merge pull request #523 from fxreichl/master
Improve support for -D 3 together with -X
2026-07-02 12:55:08 +07:00
alanminko a082d1ba3a
Merge pull request #524 from YosysHQ/upsteaming
Upsteaming Yosys changes
2026-07-02 12:54:37 +07:00
alanminko 523af52dd4
Merge pull request #525 from wjrforcyber/rand_fix
Fix(rand): UB on different platform
2026-07-02 12:54:21 +07:00
alanminko 0a297ad527
Merge pull request #529 from zxxr1113/scorr-i-pr3-upstream-merge
Add dynamic SRM and incremental simulation into &scorr -i ; Fix a bug of &scorr -i ;
2026-07-02 12:54:03 +07:00
xiran f8faf4379e add dynamic SRM and incremental simulation into -i 2026-07-02 12:45:29 +08:00
Alan Mishchenko a01df4b82c Adding function printout to &put. 2026-07-01 13:44:00 -07:00
JingrenWang f7c7cf0099
Fix(rand): UB on different platform
Signed-off-by: JingrenWang <wjrforcyber@163.com>
2026-07-01 16:23:45 +08:00
Alan Mishchenko b4ca3e7f52 Adding &put -i to preserve special LUT mapping. 2026-06-29 22:51:13 -07:00
Alan Mishchenko 79f1e0b41d Bug fixes. 2026-06-29 16:34:36 -07:00
Miodrag Milanovic 9794114a68 Change to ABC_NO_HISTORY so it is possible to change externally 2026-06-25 14:15:03 +02:00
Miodrag Milanovic b89ccd36bc Fix for case where ABC_USE_PTHREADS is not used 2026-06-25 13:24:00 +02:00
Miodrag Milanovic 0e32819325 Fix WASI and make prototype valid 2026-06-25 13:15:56 +02:00
Petter Reinholdtsen 5100825c51 Only use __int128 on architectures where it is present.
With GCC and Clang, look for the __SIZEOF_INT128__ define only defined
when __int128 is present before trying to use it.

This fixes build problem on all 32 bit Linux architectures.
2026-06-25 13:15:01 +02:00
Franz Reichl feaf7a773d Improve support for -D 3 together with -X and fix an issue in the construction of Gias. 2026-06-25 11:28:02 +02:00
alanminko 3ce53c361f
Merge pull request #519 from heshpdx/master
Fix strict aliasing violations
2026-06-25 02:53:37 +07:00
Mahesh Madhav 2eb8f38cd1 Fix build errors and spacing 2026-06-24 14:35:55 -04:00
Alan Mishchenko 7d253d7cb2 Do not support extension "e" (equiv classes of nodes). 2026-06-22 19:35:32 -07:00
alanminko 68bf7cba8e
Merge pull request #521 from fxreichl/master
Fix issue with constant replacements
2026-06-18 20:42:01 +07:00