3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-11 20:21:26 +00:00
Commit graph

435 commits

Author SHA1 Message Date
Robert O'Callahan
b3baba4522
Merge cd370bf6d1 into c2291c10a6 2025-09-10 11:49:17 +02:00
Jannis Harder
3ebecb631c Add a compile time check that kernel/constids.inc is sorted
This is an invariant now required by the ID macro, so it's better to
have an actual check and not rely on a comment at the top of
kernel/constids.inc.
2025-09-09 09:56:55 +12:00
Robert O'Callahan
23af52c3c8 Use well-known constants in ID macro and make the constant values known at compile time 2025-09-09 09:56:55 +12:00
Robert O'Callahan
c7df6954b9 Remove .c_str() from stringf parameters 2025-09-01 23:34:42 +00:00
Robert O'Callahan
cd370bf6d1 Stop using mutable in Const.
Now that we only call `bitvectorize()` in non-const methods, we can move the casting-away-const to only happen
in `bitvectorize()`, which is deprecated so only some plugins (maybe) are using it.

This means `const` `Const` methods don't change the underlying data, which means
they'll be safe to use from multiple threads if/when we want to do that.
2025-09-01 02:45:58 +00:00
Robert O'Callahan
a515055be4 Make Const::is_*() functions work on packed bits without decaying to vector<State> 2025-09-01 02:45:58 +00:00
Robert O'Callahan
9c96e61e9b Const::decode_string() doesn't need to call bitvectorize 2025-09-01 02:45:58 +00:00
Robert O'Callahan
a57b7dfd2e Make Const::as_string work without reducing packed bits to vector<State> 2025-09-01 02:45:58 +00:00
Robert O'Callahan
c2ad2a407a Optimize Const::hash_into to hash packed bits efficiently 2025-09-01 02:45:57 +00:00
Robert O'Callahan
ec52d6c649 Fast path for Const::operator== 2025-09-01 02:45:57 +00:00
Robert O'Callahan
60099e5005 Make Const::as_bool and Const::as_int work with packed bits without decaying to vector<State> 2025-09-01 02:45:57 +00:00
Robert O'Callahan
e206b059f6 Make Const::Const(long long) constructor use packed bits internally if possible 2025-09-01 02:45:57 +00:00
Robert O'Callahan
31fc0f53e5 Deprecate Const::bitvectorize() 2025-09-01 02:45:57 +00:00
Robert O'Callahan
e41bf86cc3 Deprecate Const::bits() 2025-09-01 02:45:57 +00:00
Robert O'Callahan
360a625785 Update kernel to avoid bits() 2025-09-01 02:45:57 +00:00
Robert O'Callahan
8bae779bb8 Fix Const::const_iterator tag to be bidirectional_iterator_tag 2025-08-31 23:43:27 +00: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
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
Emil J. Tywoniak
99ab73424d verilog_location: rename location to Location to avoid conflict with Pass::location 2025-08-11 13:34:10 +02:00
Emil J
aedc237c7a rtlil: remove comment
Co-authored-by: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com>
2025-08-11 13:34:10 +02:00
Emil J. Tywoniak
ecec9a760b ast, read_verilog: unify location types, reduce filename copying 2025-08-11 13:34:10 +02: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
Emil J
41295175dc
Merge pull request #5248 from calewis/try_unordereded_map
Use unordered_map instead of dict for IdString's char* to index storage.
2025-07-29 18:40:07 +02:00
Drew Lewis
2c8b4d7ad1 Use unordered_map instead of dict for IdString char* to index storage.
dict is pretty slow when you don't ever need to iterate the container in
order.  And the hashfunction for char* in dict hashes for every single
byte in the string, likely doing significantly more work than std::hash.
2025-07-29 10:48:44 +02:00
Robert O'Callahan
f25f8fe7c4 In the Verilog backend, only sort modules that we're going to emit.
If you have a large design with a lot of modules and you use the Verilog
backend to emit modules one at a time to separate files, performance is
very low. The problem is that the Verilog backend calls `design->sort()`
every time, which sorts the contents of all modules, and this is slow
even when everything is already sorted.

We can easily fix this by only sorting the contents of modules that
we're actually going to emit.
2025-07-21 05:32:31 +00:00
George Rennie
478b6a2b3f kernel: treat zero width constant as zero 2025-07-08 19:37:59 +01:00
N. Engelhardt
3fe31294d6 disable warning for intentional use of deprecated function (to assert the feature isn't used any more) 2025-06-06 16:41:25 +02:00
George Rennie
e0c1e88f19 kernel: use try_as_int to implement as_int_compress 2025-05-26 15:34:13 +01:00
George Rennie
33a22b5cd1 kernel: fix convertible_to_int for overflowing unsigned values 2025-05-26 15:28:14 +01:00
George Rennie
e2485000c7 kernel: handle unsigned case for as_int_saturating correctly
* This fixes #5105
2025-05-08 11:08:25 +02:00
George Rennie
7cbe6ed048 kernel: add safer variants of as_int 2025-05-07 14:39:17 +02:00
Krystine Sherwin
ca57df8927
cutpoint: Add $scopeinfo cell
Also adds "blackbox" as a valid TYPE.
2025-04-11 04:12:34 +12:00
Krystine Sherwin
1ef9908a85
rtlil.cc: Fix box checks in selected_modules 2025-04-08 11:59:36 +12:00
Krystine Sherwin
cd3b914132
Reinstate #4768
Revert the reversion so that we can fix the bugs that the PR missed.
2025-04-08 11:58:05 +12:00
Miodrag Milanović
d49364d96f
Revert "Refactor full_selection" 2025-04-07 12:11:55 +02:00
Krystine Sherwin
d8a9ad6860
Add Selection::clear() method
Use method in `select.cc` to reduce code duplication.
2025-04-05 10:56:01 +13:00
Krystine Sherwin
68adac691d
rtlil.cc: Add comment to log_assert
Because the use of `RTLIL::AttrObject::get_blackbox_attribute()` is deprecated, but the assert is needed in case users are doing weird things.
2025-03-14 14:40:06 +13:00
Krystine Sherwin
add5eba9b2
Design::selection_stack should never be empty
Add a `log_assert` for it in `Design::check()`.
Remove unneeded checks in other places.
2025-03-14 14:08:16 +13:00
Krystine Sherwin
a30bacfcb1
Add Selection::complete_selection
Used to select all modules including boxes, set when both `full` and `boxes` are true in the constructor, pulling down `full_selection`.
Add `Selection::selects_all()` method as short hand for `full_selection || complete_selection`.
Update selection operations to account for complete selections.
Add static methods to `Selection` for creating a new empty/full/complete selection to make it clearer to users when doing so.
Use said static methods to replace most instances of the `Selection` constructor.
Update `Selection::optimize` to use
2025-03-14 14:08:15 +13:00
Krystine Sherwin
d09ae42951
Fixing selections 2025-03-14 14:08:14 +13:00
Krystine Sherwin
091e9488fe
rtlil: Design::top_module() can be const
Since it doesn't change anything and is just a lookup.
2025-03-14 14:08:14 +13:00
Krystine Sherwin
dac2bb7d4d
Use selection helpers
Catch more uses of selection constructor without assigning a design.
2025-03-14 14:08:13 +13:00
Krystine Sherwin
a67b57bd64
rtlil: Add selection helpers
New methods on Design to push/pop selection instead of accessing the selection stack directly. Includes methods for pushing a full/complete/empty selection.
Also helper methods on modules to check `is_selected` and `is_selected_whole`.
2025-03-14 14:05:40 +13:00
Krystine Sherwin
3b1b09baf6
Can clean boxed modules
If a selection contains a boxed module, but does not select boxes, it should be removed from the selection.
2025-03-14 14:05:40 +13:00
Krystine Sherwin
2f907e8be4
Unify Design::selected_modules variants
Now uses two enums, one to control whether or not to include partially selected
modules (and what to do if they are encountered), and one to control whether or
not to include boxed modules (and what to do if they are encountered).

Mark Design::selected{modules, whole_modules}() deprecated and make them
provide warnings on boxes. There are a lot of places that use them and I can't
always tell which ones support boxed modules and which don't.
2025-03-14 14:05:40 +13:00
Krystine Sherwin
398afd102e
Refactor full_selection
The `Design::selected_*()` methods no longer unconditionally skip boxed modules.  Instead, selections are now box and design aware.
The selection constructor now optionally takes a design pointer, and has a new `selects_boxes` flag.  If the selection has an assigned design, then `Selection::selected_*()` will only return true for boxed modules if the selects_boxes flag is set.  A warning is raised if a selection is checked and no design is set.  Selections can change design via the `Selection::optimize()` method.
Most places that iterate over `Design::modules()` and check `Selection::selected_module()` should instead use `Design::selected_modules()`.
Since boxed modules should only ever be selected explicitly, and `full_selection` (now) refers to all non-boxed modules, `Selection::optimize()` will clear the `full_selection` flag if the `selects_boxes` flag is enabled, and instead explicitly selects all modules (including boxed modules).  This also means that `full_selection` will only get automatically applied to a design without any boxed modules.

These changes necessitated a number of changes to `select.cc` in order to support this functionality when operating on selections, in particular when combining selections (e.g. by union or difference).
To minimize redundancy, a number of places that previously iterated over `design->modules()` now push the current selection to the design, use `design->selected_modules()`, and then pop the selection when done.

Introduce `RTLIL::NamedObject`, to allow for iterating over all members of a module with a single iterator instead of needing to iterate over wires, cells, memories, and processes separately.
Also implement `Module::selected_{memories, processes, members}()` to match wires and cells methods.  The `selected_members()` method combines each of the other `selected_*()` methods into a single list.
2025-03-14 14:05:39 +13:00
Martin Povišer
1d57a7cf6b macc_v2: Relax and fix cell check 2025-01-27 15:52:49 +01:00
Martin Povišer
aabb4ea1df macc_v2: Fix checks and parameter padding 2025-01-27 13:08:19 +01:00
Martin Povišer
cb8f855f34 rtlil: Fix macc_v2 cell check 2025-01-24 12:38:03 +01:00
Martin Povišer
61450e8b6e Update codebase for macc_v2 2025-01-24 12:38:03 +01:00