Commit Graph

4666 Commits

Author SHA1 Message Date
Robert O'Callahan 4fc782ef2b Make ABC_DONE detection more robust.
1) Change token from ABC_DONE to YOSYS_ABC_DONE to be a bit more robust against false matches.
2) Emit the token from the sourced script so that we don't have to worry about it showing up in the echoing
of the command as it executes. It will only appear in ABC stdout when it executes, i.e. when
our script has completed.
3) `set abcout` doesn't actually switch ABC to line buffering on stdout, since HAVE_SETVBUF is not actually
set in ABC builds in general. So stop using that. ABC does the necessary flushing when
`source` has finished.
2025-09-22 05:01:51 +00:00
Robert O'Callahan 2de641d051 Don't redirect spawned ABCs' stderr to our pipe.
popen() doesn't do this and we should emulate the behavior of popen() as much as possible.
2025-09-22 05:01:51 +00:00
Robert O'Callahan 4fe21dd652 Reduce hashops verbiage in OptMergePass 2025-09-19 03:31:46 +00:00
Emil J. Tywoniak 96f87aa2d4 simplemap: fix src attribute transfer 2025-09-18 12:59:12 +02:00
Jannis Harder 4f239b536b abc_new: Hide buffered 'z drivers from read/write_xaiger2
With the updated bufnorm code, buffered 'z drivers are used as anchor
points for undirected connections. These are currently not supported by
read/write_xaiger2, so we temporarily replace those by roughly
equivalent $tribuf cells which will be handled as blackboxes that
properly roundtrip through the xaiger2 front and backend.
2025-09-17 13:56:46 +02:00
Jannis Harder 5f79a6e868 Clean up $buf with 'z inputs, $input_port and $connect cells
This ensures that entering and leaving bufnorm followed by `opt_clean`
is equivalent to just running `opt_clean`.

Also make sure that 'z-$buf cells get techmapped in a compatible way.
2025-09-17 13:56:46 +02:00
Emil J 73e47ac3fe
Merge pull request #5357 from rocallahan/builtin-ff
Instead of using `builtin_ff_cell_types()` directly, go through a method `Cell::is_builtin_ff()`
2025-09-17 11:37:16 +02:00
Robert O'Callahan d24488d3a5 Instead of using builtin_ff_cell_types() directly, go through a method Cell::is_builtin_ff() 2025-09-17 03:24:19 +00:00
Robert O'Callahan a7c46f7b4a Remove .c_str() calls from parameters to log_warning()/log_warning_noprefix() 2025-09-16 23:02:16 +00:00
Robert O'Callahan d1fd6de6da Remove .c_str() calls from parameters to log_header() 2025-09-16 23:00:42 +00:00
Robert O'Callahan 5ac6858f26 Remove .c_str() from log_cmd_error() and log_file_error() parameters 2025-09-16 22:59:08 +00:00
Jannis Harder b95549b469
Merge pull request #5348 from rocallahan/remove-string_buf
Remove `string_buf` by making `log_signal()` and `log_const()` return `std::string`
2025-09-16 20:20:56 +02:00
Emil J. Tywoniak 73747f6928 read_verilog: add -relativeshare for synthesis reproducibility testing 2025-09-16 15:47:35 +02:00
Emil J. Tywoniak 68ad52c6ae bugpoint: don't sort 2025-09-16 15:39:13 +02:00
Emil J. Tywoniak e11ea42af0 raise_error: whitespace 2025-09-16 15:39:13 +02:00
Robert O'Callahan 7f247fb125 Update passes/hierarchy to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 159ca3ba56 Update passes/tests to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 8cc86b2643 Update passes/techmap to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan d1642bf510 Update passes/sat to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 2d5ce8c363 Update passes/proc to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 5600eb2e5b Update passes/opt to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 23f196a3b8 Update passes/memory to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan e1d0c010ef Update passes/fsm to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 1b589b065d Update passes/cmds to avoid bits() 2025-09-16 03:17:23 +00:00
Robert O'Callahan 8492c49f6c Remove `string_buf` by making `log_signal()` and `log_const()` return `std::string`
We only have to fix one caller in-tree so this probably has very low impact on out-of-tree plugins.

Resolves #5215
2025-09-16 03:06:17 +00:00
Robert O'Callahan ae0ca7578a Use a pool of ABC processes.
Doing ABC runs in parallel can actually make things slower when every ABC run requires
spawning an ABC subprocess --- especially when using popen(), which on glibc does not
use vfork(). What seems to happen is that constant fork()ing keeps making the main
process data pages copy-on-write, so the main process code that is setting up each ABC
call takes a lot of minor page-faults, slowing it down.

The solution is pretty straightforward although a little tricky to implement.
We just reuse ABC subprocesses. Instead of passing the ABC script name on the command
line, we spawn an ABC REPL and pipe a command into it to source the script. When that's
done we echo an `ABC_DONE` token instead of exiting. Yosys then puts the ABC process
onto a stack which we can pull from the next time we do an ABC run.

For one of our large designs, this is an additional 5x speedup of the primary AbcPass.
It does 5155 ABC runs, all very small; runtime of the AbcPass goes from 760s to 149s
(not very scientific benchmarking but the effect size is large).
2025-09-15 17:22:15 +02:00
Robert O'Callahan 27462da208 Run ABCs in parallel.
Large circuits can run hundreds or thousands of ABCs in a single AbcPass.
For some circuits, some of those ABC runs can run for hundreds of seconds.
Running ABCs in parallel with each other and in parallel with main-thread
processing (reading and writing BLIF files, copying ABC BLIF output into
the design) can give large speedups.
2025-09-15 17:18:42 +02:00
Robert O'Callahan 38f8165c80 Remove direct RTLIL access from gate_t 2025-09-15 17:10:20 +02:00
Robert O'Callahan 222f457a04 Only write out stdcells/lutcosts once for all ABC runs 2025-09-15 17:10:07 +02:00
Robert O'Callahan 13b3418a7f Split `abc_module()` into `prepare_module()` and `run_abc()`
`prepare_module()` will have to run on the main thread.
2025-09-15 17:01:25 +02:00
Claire Xen a2fc7e4dd7
Merge pull request #4252 from zapta/master
Added to the Show command a -wireshape <graphviz-shape> flag.
2025-09-15 15:40:40 +02:00
Jannis Harder dd9627ed05
Merge pull request #5336 from rocallahan/remove-log-cstr
Remove `.c_str()` calls from `log()`/`log_error()`
2025-09-12 14:09:48 +02:00
Krystine Sherwin f102b25914 Reapply "Merge pull request #5301 from KrystalDelusion/krys/re_5280"
This reverts commit 88eb83a0c3.
2025-09-12 10:41:01 +02:00
Robert O'Callahan e0ae7b7af4 Remove .c_str() calls from log()/log_error()
There are some leftovers, but this is an easy regex-based approach that removes most of them.
2025-09-11 20:59:37 +00:00
Robert O'Callahan 66d2c2af08 Make `log_header()` use variadic templates. 2025-09-09 15:41:03 +02:00
Robert O'Callahan d34ac0c87d Make `log()` use the `FmtString` infrastructure.
Now `log()` supports `std::string`.

We have to fix a few places where the format parameter was not a compile time constant.
This is mostly trivial.
2025-09-09 15:41:03 +02:00
Jannis Harder 61a00b9131 memory_libmap: Fix use of uninitialized value for async read ports
The code in memory_libmap expects `clk_en` to be initialized for all
`PortVariant`s but the parsing in memlib.cc didn't initialize it for
variants of kind `PortKind::Ar` (async read ports).

While this fixes the immediate CI failure, it would be best to refactor
the code so it becomes obvious if something isn't initialized.
2025-09-09 13:32:46 +02:00
Jannis Harder b6db32873d Add IdString const &id_string() const to StaticIdString and IdString
The vast majority of ID(...) uses are in a context that is overloaded
for StaticIdString or will cause implicit conversion to an IdString
constant reference. For some sufficently overloaded contexts, implicit
conversion may fail, so it's useful to have a method to force obtaining
a `IdString const &` from an ID(...) use.

When turning all literal IdStrings of the codebase into StaticIdStrings
this was needed in exactly one place, for which this commit adds an
`id_string()` call.
2025-09-09 09:56:55 +12:00
Jannis Harder 3d14108a96
Merge pull request #5323 from rocallahan/IdString-references
Pass `IdString` by reference in more places
2025-09-08 20:40:24 +02:00
Jannis Harder c468ee7add
Merge pull request #5304 from rocallahan/idstring-stringf
Support `IdString` parameters in `stringf()` and remove `.c_str()` in a lot of places
2025-09-08 20:29:20 +02:00
Emil J 80582e02b0
Merge pull request #5317 from donn/libparse_error_weak
libparse/filterlib: mark LibertyParser::error() as weak
2025-09-08 19:59:08 +02:00
Krystine Sherwin bc77b6213b autoname: Fix selection arg 2025-09-05 00:15:26 +02:00
Krystine Sherwin fc2cb32e50 autoname.cc: Avoid int overflow 2025-09-05 00:15:26 +02:00
Mohamed Gaber ae8c4e2ea6 libparse/filterlib: mark LibertyParser::error() as weak
When FILTERLIB is defined (attempts to compile libparse more or less standalone,) mark the `LibertyParser::error()` as weak so utilities using libparse as a library can override its behavior (the default behavior being exit(1)). As the code is quite performance-critical, I've elected to not modify it to raise an exception or have a callback or similar and simply allow for a link-time replacement.
2025-09-05 00:13:45 +02:00
Mike Inouye 6276464ea7
Increase muxtree glob eval attempts to 10M. 2025-09-04 10:52:37 -07:00
Robert O'Callahan 54a258f854 In hash_cell_inputs, avoid constructing an std::pair (which requires copying the port IdString) 2025-09-04 14:17:08 +02:00
Krystine Sherwin d70f132792
wrapcell.cc: Avoid format name collision 2025-09-03 03:32:01 +12:00
Robert O'Callahan c7df6954b9 Remove .c_str() from stringf parameters 2025-09-01 23:34:42 +00:00
Emil J 5aa71505fc
Merge pull request #5287 from Anhijkt/opt_dff-fix-5279
opt_dff: fix timeout issue
2025-09-01 11:20:35 +02:00
Miodrag Milanovic 88eb83a0c3 Revert "Merge pull request #5301 from KrystalDelusion/krys/re_5280"
This reverts commit c9a602e882, reversing
changes made to 51eaaffe09.
2025-08-28 11:58:02 +02:00
Miodrag Milanović c9a602e882
Merge pull request #5301 from KrystalDelusion/krys/re_5280
Reapply "Workflow adjustments"
2025-08-28 10:51:49 +02:00
Emil J c5d096b7b8
Merge pull request #5308 from YosysHQ/emil/opt_muxtree-refactor
opt_muxtree: refactor
2025-08-25 16:48:01 +02:00
Emil J. Tywoniak b45e5854bf opt_muxtree: comment wording 2025-08-25 16:36:07 +02:00
Emil J. Tywoniak 4dea774171 opt_muxtree: refactor 2025-08-21 12:52:22 +02:00
Robert O'Callahan 8c04e5266c Use commutative hashing instead of expensive allocation and sorting
For one of our large circuits, this improves the `OptMergePass` runtime
from about 150s to about 130s. It's also simpler code.
2025-08-20 19:35:22 +00:00
Robert O'Callahan 7d0ea0d64f Refactor call to sorted_pmux_in to avoid copying the connection dictionary 2025-08-20 19:35:22 +00:00
Emil J 025d7a5641
Merge pull request #5290 from rocallahan/opt-mux-perf
Make `OptMuxtreePass` int-indexed vectors into hashtables
2025-08-20 20:00:26 +02:00
Jannis Harder c9ad7b7ad0
Merge pull request #5284 from jix/fix_5282
check: Limit detailed cell edge checking for $pmux and $bmux
2025-08-20 14:27:19 +02:00
Krystine Sherwin 3ca2b7951f
memlib: Fix ubsan 2025-08-19 17:05:51 +12:00
Jannis Harder 7c409e2d5a
Merge pull request #5285 from jix/abstract_initstates
abstract: Add -initstates option
2025-08-18 15:39:09 +02:00
Emil J f0ccc65820
Merge pull request #5297 from rocallahan/redundant-assignmap
Remove redundant construction of `assign_map`.
2025-08-18 10:43:44 +02:00
Robert O'Callahan 3f2c4f6f83 Remove redundant construction of `assign_map`.
We call 'assign_map.set()' below which wipes the `SigMap` and reconstructs it.

This operation is expensive because it scans the whole module. I think it's
better to make heavyweight operations more visible so I'm removing
the less obvious operation.
2025-08-17 23:34:11 +00:00
KrystalDelusion 6d55ca204b
Merge pull request #5281 from suisseWalter/add_parameterised_cells_stat
STAT: Add parameterised cells
2025-08-18 09:21:45 +12:00
clemens 4e45b5e1bb permit trailing comma 2025-08-16 09:40:03 +02:00
clemens 8b1f77ebd2 cleanup. printf to errors or warnings 2025-08-16 09:40:03 +02:00
clemens 50fe9dd7f2 clean parsing code 2025-08-16 09:40:03 +02:00
clemens 5fc0e77c3d add functionality to be able to use parameterised cells.
cells can have their area as a function of the input port width.
2025-08-16 09:40:03 +02:00
clemens a6e0ab5ea5 Update (sequential) area to be only local without -hierarchy 2025-08-16 09:09:57 +02:00
suisseWalter f5b219f59e
Update passes/cmds/stat.cc
Co-authored-by: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com>
2025-08-16 08:36:06 +02:00
KrystalDelusion 7799c6e6ac
Merge pull request #5291 from YosysHQ/krys/rename_escape
rename.cc: Fixup ports after -unescape
2025-08-16 12:19:49 +12:00
Emil J 70600bb596
Merge pull request #5239 from rocallahan/abc-incremental
In the ABC pass, avoid scanning the entire module for each ABC run
2025-08-15 20:17:32 +02:00
Robert O'Callahan dd88423334 Make OptMuxtree int-indexed vectors into hashtables
For one of our large circuits, this reduced the time for an OPT_MUXTREE pass from
169s to 5s.
2025-08-14 23:09:15 +00:00
Krystine Sherwin ec18d1aede
rename.cc: Fixup ports after -unescape 2025-08-15 10:48:32 +12:00
Robert O'Callahan 62c441107d Build FfInitVals for the entire module once and use it for every ABC run. 2025-08-14 22:29:51 +00:00
Robert O'Callahan 2654bd5355 Compute `is_port` in AbcPass without iterating through all cells and wires in the module every time we run ABC.
This does not scale when we run ABC thousands of times in a single AbcPass.
2025-08-14 22:29:45 +00:00
Robert O'Callahan ac8259b02e Preserve `assign_map` across ABC invocations.
Currently `assign_map` is rebuilt from the module from scratch every time we invoke ABC.
That doesn't scale when we do thousands of ABC runs over large modules. Instead,
create it once and then maintain incrementally it as we update the module.
2025-08-14 22:27:04 +00:00
Robert O'Callahan 4de3ee093e Mark kept FF output wires as ports directly instead of via the 'keep' attribute 2025-08-14 22:26:38 +00:00
clemens 71307b4a51 add Testcases
Fix existing testcases
Fix edgecase where modules where counted as cells.
2025-08-13 14:46:01 +02:00
Emil J. Tywoniak 856fc43a87 rename: format vector slices consistently with HDL upto/downto direction 2025-08-13 11:11:53 +02:00
Jannis Harder 77089a8d03 rename: add -move-to-cell option in -wire mode 2025-08-13 11:11:52 +02:00
clemens 383d11c2ac fix design overview in json.
Fix some unknown cells apearing twice.
2025-08-13 10:09:02 +02:00
clemens 1eb8844e38 fix labeling in report
fix design hierarchy containing wrong values.
remove left over debug print.
2025-08-13 08:36:26 +02:00
Robert O'Callahan ccb23ffc1a Fix indentation 2025-08-13 05:44:52 +00:00
Robert O'Callahan 885bb744e3 Make `module` a parameter of the function so we can change its constness in context 2025-08-13 05:44:52 +00:00
Robert O'Callahan 53c72c0d39 Move code in `abc_module()` that modifies the design into a new function `extract()`
Splits up the big `abc_module()` function and isolates the code that modifies the design
after running ABC.
2025-08-13 05:44:52 +00:00
Robert O'Callahan ceedcecfae Move the input parameters to `abc_module` that are identical across modules to an `AbcConfig` struct. 2025-08-13 05:44:52 +00:00
Robert O'Callahan 4ba42c4752 Move ABC pass state to a struct instead of storing it in global variables. 2025-08-13 05:44:52 +00:00
Anhijkt b3ca5ee0f1 opt_dff: fix timeout issue 2025-08-13 01:48:59 +03:00
Jannis Harder 1f876f3a22 abstract: Add -initstates option 2025-08-12 15:37:12 +02:00
Jannis Harder 256aa3e389 check: Limit detailed cell edge checking for $pmux and $bmux
While these cells can't have a quadratic number of edges between A, B
and Y, they do have a quadratic number of edges between S and Y.
2025-08-12 14:38:20 +02:00
Emil J fb024c4d55
Merge pull request #5135 from YosysHQ/emil/ast-ownership
ast, read_verilog: ownership in AST, use C++ styles for parser and lexer
2025-08-12 10:58:12 +02:00
clemens 2a97987cf2 formatting and remove debug statements 2025-08-12 09:16:05 +02:00
clemens a0dde68487 Improve STAT 2025-08-12 09:04:16 +02:00
Krystine Sherwin 20c2d2a6f3
test_cell: Add comment on $pmux
`-simlib` also doesn't work.
2025-08-12 10:57:59 +12:00
Martin Povišer c589714433
test_cell: Update to $macc_v2 2025-08-12 10:57:59 +12:00
Krystine Sherwin db4ffaffd2
consteval: Fix $bwmux handling
If the cell type has a S signal and hasn't already been handled, use `CellTypes::eval(cell, A, B, S)`.
2025-08-12 10:57:58 +12:00
Krystine Sherwin 014eadd8b9
test_cell: Fix $bweqx 2025-08-12 10:57:58 +12:00
Krystine Sherwin 22aa9fba3b
test_cell: Support more cell types
Still unsupported:
- wide muxes (`$_MUX16_` and friends)

Partially supported types have comments in `test_cell.cc`.

Fix `CellTypes::eval() for `$_NMUX_`.
Fix `RTLIL::Cell::fixup_parameters()` for $concat, $bwmux and $bweqx.
2025-08-12 10:57:58 +12:00
Krystine Sherwin 481ecb51a7
test_cell: Disable $macc testing
Needs updating to `$macc_v2`.
2025-08-12 10:57:58 +12:00
Emil J. Tywoniak c8e0ac0c61 ast, read_verilog: ownership in AST, use C++ styles for parser and lexer 2025-08-11 13:34:10 +02:00