Commit Graph

10108 Commits

Author SHA1 Message Date
Martin Erhart c56d5659d5 [RTG] Use FlatSymbolRefAttr for SymbolDCE to pick it up as SymbolUse 2025-07-30 12:59:26 +01:00
Michael dcb2d92b98
[HWToLLVM] Add lowering support for 'hw.array_inject' op (#8774) 2025-07-30 10:31:23 +02:00
Hideto Ueno 9e27c4ddae
[HWToSMT] Return an unbound value for OOB hw.array_inject (#8794)
This is a follow up to 186dcc8b0e to fix OOB behavior.

h/t @fzi-hielscher for pointing out the issue
2025-07-29 17:00:06 -07:00
Martin Erhart a11a834d96
[RTG] Simplify EmitISAEmission pass (#8798) 2025-07-29 21:16:48 +01:00
Fabian Schuiki 367921e352
[MooreToCore] Mark Seq dialect as legal
Add the Seq dialect as a legal dialect for the Moore-to-Core conversion.
This will allow the conversion to properly pass through `seq.to_clock`
in case the conversion is called on an IR that is already lowered to the
core dialects. This allows circt-verilog to accept core-level IR as
input.
2025-07-29 11:51:43 -07:00
Martin Erhart 175e30d32f [RTG] Rely on textual pass pipeline in Python and CAPI
The textual pass pipeline has a bit more overhead due to the string parsing, but it reduces the required maintenance as we don't have to write CAPI and Python bindings for all the pass options.
2025-07-29 17:48:13 +01:00
Martin Erhart 327def313c [RTG] Use tablegen generated pass registration 2025-07-29 17:48:13 +01:00
Martin Erhart 01a53d4552
[RTG] Sequences are always private (#8792) 2025-07-29 17:45:52 +01:00
Martin Erhart 964cc8be4f
[RTG] Don't hardcode the root op of passes where not necessary (#8791) 2025-07-29 17:45:08 +01:00
Martin Erhart 1a7fc25c63
Bump LLVM to 76bebb5be9daf9ca035777b17fa63d4ce13e79b9 (#8796) 2025-07-29 17:16:26 +01:00
Martin Erhart 1ef47b3cdb
[RTG] Add InsertTestToFileMappingPass (#8795)
Add a pass to group tests to output files. Currently, this matches what the emission pass does but can be extended to group tests according to certain requirements demanded from the execution environment. Also add a simple pass that inlines the tests without any gluecode (matching what the emission pass currently does). The emission pass will be simplified in a future PR to only iterate over the file operations and print what's inside
2025-07-29 17:09:29 +01:00
Morten Borup Petersen e070aed1f3
[ESI] Extend instead of override CMAKE_CXX_FLAGS (#8551)
* [ESI] Extend instead of override CMAKE_CXX_FLAGS

* regex purge

---------

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2025-07-29 08:39:44 +02:00
Morten Borup Petersen 82bd22bda3
[ESI] Better single-argument handling for FunctionPort (#8782)
Previously, if one has a function with only a single `BitsType` argument, there was no way that this code could provide a correct argument to be serialized, given that only `kwargs` would be accepted - which is a dict, and not serializeable by `BitsType`.

Modified argument handling abit s.t.
1. users have to provide either kwargs or positional
2. if positional arguments are provided, and only a single is present, it is unpacked, ensuring that the validation and serialization code doesn't recieve a tuple, but instead the underlying value.
2025-07-29 08:39:23 +02:00
Morten Borup Petersen d9545ff5a0
[ESI] Expose accelerator through AcceleratorConnection py api (#8781)
It is possible that the `AcceleratorConnection` that is instantiated has handed ownership of a constructed accelerator through ` `AcceleratorConnection::takeOwnership`. In that case, it should be possible to retrieve a handle to the given accelerator through the python API. That is this PR.
2025-07-29 08:36:22 +02:00
Hideto Ueno 7f9e66f5f5
[FIRRTL] Type check in Cat operatnds in FIR parser (#8793)
Fix a parser crashe when cat is constructed with invalid type operands.
2025-07-28 18:26:56 -07:00
Hideto Ueno 108965f1e5
[HW][HWAggregateToComb] Add support for hw.array_inject operation in HWAggregateToComb pass (#8788)
This patch implements lowering of hw.array_inject operations to combinational
logic in the HWAggregateToComb transformation pass.

The implementation creates a 2D array where each row represents the result
of injecting the new value at a specific index. A multiplexer then selects
the appropriate row based on the injection index.
2025-07-28 11:34:15 -07:00
Maria Fernanda Guimarães 2f0ca3c18e
[Comb] Add comb.reverse operation (#8758)
This commit introduces a new operation to the Comb dialect:
`comb.reverse`, which performs bitwise reversal (mirroring) of an 
integer value.

It also adds Verilog export support for this operation using 
SystemVerilog’s streaming operator `{<<{}}`.

Bit reversal is a common operation in hardware design, especially in 
signal processing and communication protocols. Previously, reversing 
bits required generating many explicit `assign` statements. This new 
operation makes the IR cleaner and enables direct export to compact 
Verilog syntax.
2025-07-28 11:28:22 -07:00
Morten Borup Petersen 29f4e1311e
[ESI] Yield gil before blocking operations in MessageDataFuture (#8789)
In case an ESI runtime backend uses some form of multi-threading, and a user has registered a Python callback with an ESI port, deadlock may occur when calling `MessageDataFuture` functions, due to calling a blocking operation while holding the GIL.

Instead, release the GIL while calling the blocking operations.
2025-07-28 19:39:46 +02:00
Morten Borup Petersen 9fe4c337fb
[ESI] Also publish releases on workflow_dispatch (#8780)
Minor bugfixes _during development_ doesn't always warrant a new ESI tag. Allow the `esiRuntimePublish` pipeline to publish `dev` packages upon manual CI runs (`workflow_dispatch`).
2025-07-28 19:39:05 +02:00
Jacques Pienaar 728d2ca159
Create .git-blame-ignore-revs (#8787)
Enables flagging skipping over more mechanical refactoring.

https://docs.github.com/en/repositories/working-with-files/using-files/viewing-and-understanding-files#ignore-commits-in-the-blame-view
2025-07-27 08:34:06 +02:00
Jacques Pienaar 7f1c3399e4
Update to new builder format. (#8785)
Basically did

set(CMAKE_CXX_CLANG_TIDY local/clang-tidy -checks=-*,llvm-use-new-mlir-op-builder -fix)

and then fixed cases where temporary OpBuilders were used (as passed in
by reference now).
2025-07-26 04:55:06 -07:00
Hideto Ueno fce6984ba5
Bump LLVM (#8783)
Bump to e76780b9da76295f88cb24817e9384b88e6416dc
2025-07-25 21:59:28 -07:00
Hideto Ueno 896e80ec9a
[AIG] Remove aig.cut (#8784)
Technology mapping/Cut rewriting requires enumerating multiple cuts to find best cuts, so representing a single cut as an operation doesn't make sense in general. When the AIG dialect was originally introduced, the cut operation was not well-thought-out and not used anywhere so clean up before implementing tech mapping.

Close https://github.com/llvm/circt/issues/8761
2025-07-25 21:59:14 -07:00
Bea Healy 82a8af4acf
[Comb] Fix more recursive mux folders (#8756)
Co-authored-by: Fabian Schuiki <fabian@schuiki.ch>
2025-07-25 15:57:07 +01:00
Samuel Coward 30a4a38fca
[Datapath] Create Datapath to Comb Pass (#8736)
* Initiate datapath to comb pass

* Add tests and tidy datapath to compress implementation

* Improve comments

* Formatting and test corrections

* Correct CAPI

* Move wallace tree reduction and full-adder to comb ops

* Adding integration tests using circt-lec and correcting review comments

* Fix bug in Booth code for final sign correction row and add testing using lec. Add a forceBooth option largely for testing purposes

* Minor fix

* Formatting

* Removing populate patterns function

* Formatting
2025-07-25 14:13:24 +01:00
Morten Borup Petersen a681fefd5e [ESI] Add missing `const` to `Callback::get` argument
The underlying constructor requires a `const BundleType*`...
2025-07-25 09:28:10 +00:00
Morten Borup Petersen d41ea14885
[ESI] Disallow calls on an unconnected `FuncService::Function` (#8779)
because currently, that'll result in segfaults.

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2025-07-25 11:01:59 +02:00
Morten Borup Petersen 2696da0895
[ESI] Always find_package Python3 Development (#8778)
AFAICT, pybind11 v. 3.0.0 (release 2 weeks ago) changed a bit how modules are being defined. A result of that is that it's not sufficient to just look for `Python3_FOUND`. That can be evident when e.g. building the ESI runtime alongside the rest of CIRCT, if python bindings are _not_ enabled. In that case [here](https://github.com/llvm/circt/blob/main/CMakeLists.txt) the top-level CMakeLists won't look for the Python3 `Development` component... I'm a bit surprised that this isn't done inside the pybind11 cmake files, but oh well... the problem is fixed by always `find_package`'ing for both `Interpreter` and `Development` in the ESI runtime CMakeLists.txt.

Also sneaks in a .gitignore for the `ESI/runtime` library, to better support in-tree builds of just the runtime.

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2025-07-25 10:59:57 +02:00
Morten Borup Petersen 0a79297ac2
[ESI] MessageData utility functions (#8777)
Just a few utility functions for `esi::MessageData` to make it play nicer with other things.

Co-authored-by: Morten Borup Petersen <mpetersen@microsoft.com>
2025-07-25 10:59:46 +02:00
Kazu Hirata 5e2e73845c
Migrate away from ArrayRef(std::nullopt_t) (#8776)
LLVM has deprecated ArrayRef(std::nullopt_t).  This CL migrates away
from that.
2025-07-24 15:04:17 -07:00
Andrew Young dafbb02738
[FIRRTL] FRT: support creating 0-valued enums (#8772)
This adds the ability to the FullResetTransform to create enumeration
values which are 0.  When the enumeration has a valid variant that is
encoded as a 0, we create this value using the FEnumCreateOp.  If there
is no valid variant with the value 0, we create a constant 0 and bitcast
it to the enumeration type.
2025-07-23 15:52:56 -07:00
Andrew Young 57a2a9aedb [FIRRTL] make mux type inference support enumeration types 2025-07-23 15:52:34 -07:00
Andrew Young da47d826f6 [FIRRTL] mark some FIRRTLBaseType functions as const
This marks a few more FIRRTLBaseType functions as const, namely
`isConst()` and `getConstType()`.  Probably all functions defined on
this class should be marked const eventually, as none of them should
actually be modifying the object.
2025-07-23 15:52:34 -07:00
Andrew Young 237f744475
[FIRRTL] Fix TagExtractOp's type inference (#8766)
TagExtractOp's type inference predates adding user-defined encodings for
enums in FIRRTL. This fixes the issue by using the bitwidth helpers
defined on the enumeration type.
2025-07-23 15:29:56 -07:00
Fabian Schuiki dbbc952d89
[circt-verilog] Add register-to-memory pass to pipeline (#8773)
Add the new RegOfVecToMem pass to the circt-verilog pipeline. This will
detect memories described as `always` blocks and map them from the
current `seq.firreg` representation to the correpsonding `seq.firmem`.
This allows later parts of the pipeline to reason about memories more
easily and transform them if needed.
2025-07-23 15:24:37 -07:00
Fabian Schuiki 5c3780f58b
[MooreToCore] Preserve module port order (#8768)
Preserve the order of module ports when converting from `moore.module`
to `hw.module`. The current implementation populates separate input and
output vectors, which makes all inputs appear before all outputs. The
updated version just populates a single array of ports, which preserves
order. This makes it easier to round-trip Verilog through circt-verilog,
and makes the output of circt-verilog more predictable.
2025-07-23 10:39:09 -07:00
Hideto Ueno 754f72d04c
[Support] Add NPN class for Boolean function canonicalization (#8747)
This commit introduces NPNClass and BinaryTruthTable classes to the CIRCT
Support library for Boolean function equivalence checking and canonicalization.

NPNClass computes Negation-Permutation-Negation canonical forms for Boolean
functions, enabling efficient detection of functionally equivalent circuits
under input/output transformations. BinaryTruthTable provides compact
representation using APInt with support for multi-input, multi-output functions.

This infrastructure is essential for technology mapping and Boolean function
optimization in synthesis flows.
2025-07-23 10:27:52 -07:00
Leon Hielscher ab7a0a6c85
[VerifToSMT] Lower `verif.refines` to SMT (#8749)
Implement a conversion pattern for the `verif.refines` operation to the SMT dialect.
2025-07-23 11:42:19 +02:00
Hideto Ueno 186dcc8b0e
[HWToSMT] Add ArrayInject lowering to HWToSMT (#8765)
This commit implements the lowering of hw.array_inject operations to SMT
expressions using smt.array.store operations. The lowering creates a new
array with the specified element injected at the given index, with proper
bounds checking to handle out-of-bounds accesses gracefully.

The implementation includes bounds checking that compares the index against
the maximum valid index (numElements - 1) and uses smt.ite to return either
the updated array (if in bounds) or the original array (if out of bounds).
2025-07-23 01:21:59 -07:00
Andrew Young 959e0f18e2 [FIRRTL] FlattenMemories: code cleanup, nfci 2025-07-22 21:16:25 -07:00
Andrew Young b4da671b10 [FIRRTL] FlattenMemories: handle memories with enums
This adds support to flatten memories with enumeration in them.
Enumerations are treated as non-aggregate types, and so they get a
single bit mask to control the whole value.
2025-07-22 21:16:25 -07:00
Andrew Young 0c5f60cb8f
[FIRRTL] Make enums behave less like aggregates (#8742)
This makes enums behave more like ground types, but doesn't quite take
the jump and make them ground types.  It removes the ability to index
into enum variants using field refs, which was used produce error
messages in InferWidths (and enums no longer support having unknown
widths).  This change adds some helpers to determine the sizes of
enumerations.

This change modifes InferWidths to to take advantage of the fact that
enumerations do not support containing uninferred widths, and removes
some dead code.  In addition to this, field refs no longer index into
the variants of an enum type, so we can handle them in a similar way to
ground types.
2025-07-22 15:20:23 -07:00
Prithayan Barua 4ce45d581f
[Seq] Add a pass to convert an array seq.firreg to seq.firmem (#8716)
This commit introduces a new transformation pass `RegOfVecToMem` that converts
register arrays following memory access patterns into `seq.firmem` operations.

When a valid pattern is detected, the pass replaces the register array with a
`seq.firmem` operation and corresponding read/write ports.

This is required for the `circt-verilog` tool, to identify memories, such that
other `circt` transformations/analysis can be run in the `seq` dialect on the
`mlir` parsed from verilog.
2025-07-22 14:17:34 -07:00
Hideto Ueno 640daf0c92
[HW][AIG] Add InstancePath CAPI and use native structures for AIG longest path analysis (#8760)
This commit refactors the AIG longest path analysis C API to use native C structures instead of JSON strings, providing better performance and type safety.

The API changes replace `aigLongestPathCollectionGetPath` returning JSON with `aigLongestPathCollectionGetDataflowPath` returning native objects. New opaque handle types are added including `AIGLongestPathObject`, `AIGLongestPathHistory`, and `AIGLongestPathDataflowPath`. Comprehensive APIs are provided for accessing path data, history, and object properties. 

InstancePath C API support is introduced in `circt-c/Support/InstanceGraph.h`. Currently `InstancePathCache` itself is not provided, as the use of LongestPathAnalysis is read-only and there is no need to mutate/construct InstancePath. Unfortunately due to that testing of CAPI of InstancePath got a bit tricky. For now AIGLongestPathAnalysis is used to produce InstancePath in CAPI.

The Python binding updates refactor Object, DataflowPath, and LongestPathHistory classes to use the native C API. JSON parsing dependencies and from_json_string() methods are removed. Proper property accessors using the new C API are added while maintaining backward compatibility for existing Python interfaces. So the existing integration tests cover most of the APIs. 

Testing updates include comprehensive coverage in the existing C API tests in `test/CAPI/aig.c`. A new `test/CAPI/support.c` is added for InstancePath API testing. Python integration tests are updated to work with the new API.

This change improves performance by eliminating JSON serialization/deserialization overhead and provides a more robust, type-safe interface for accessing longest path analysis results.
2025-07-22 11:30:43 -07:00
Michael 9088c29f4b
[ImportVerilog] Add full_case attribute support (#8762)
This patch adds support of `(* full_case *)` attribute in case 
statements [1], which says that all possible case items have been 
covered and no default clause is needed.

[1]: http://www1.pldworld.com/@xilinx/html/technote/TOOL/MANUAL/21i_doc/data/fndtn/ver/ver7_4.htm
2025-07-22 10:46:16 -07:00
Leon Hielscher e80a67d30d
[VerifToSMT] Fix lowering of no output, no result LEC op (#8763) 2025-07-22 18:16:17 +02:00
Hideto Ueno f0ec28ac16
[AIG][NFC] Add a module to OutputPort data structure and refactor the name handling (#8759)
This is a preparation commit for subsequent AIG python binding PR. 

 - Modified OutputPort type from pair to tuple to include module reference
 - Added getName() method to Object class for consistent name access
 - Updated JSON serialization to handle the new OutputPort structure
2025-07-21 20:33:45 -07:00
Martin Erhart f1352362d1
[RTG] Add operations to report test result (#8751) 2025-07-21 18:43:42 +01:00
Yicheng Liu 331820d6d0
[circt-bmc] Support `seq.firreg` with sync reset (#8698)
This adds support for seq.firreg with synchronous reset in ExternalizeRegistersPass.
2025-07-21 17:34:37 +01:00
Atticus Kuhn 888e6787e4
[FSMToSV] Fix bug of operations not being cloned in transition region (#8753)
Co-authored-by: Atticus Kuhn <atticusmkuhn@gmail.com>
2025-07-21 17:27:07 +01:00