Commit Graph

49 Commits

Author SHA1 Message Date
Hideto Ueno 1fb38a58ea
[circt-synth] [Synthesis] Add synthesis pipeline and refactor the lib structure (#8681)
This commit introduces a standardized synthesis pipeline and restructures the codebase:

* Creates a new SynthesisPipeline class to define the default synthesis pipeline. This pipeline serves both circt-synth and is exposed through the C API for Python bindings.
* Added a dedicated Synthesis directory under `lib/` to house synthesis-related code. This architectural change is aimed to promote synthesis capabilities to a first-class component within CIRCT rather than limiting it to the circt-synth tool.
2025-07-10 16:16:11 -07:00
Hideto Ueno 8fbefed670
[Python] Add Python bindings for AIG dialect (#8646)
This commit adds comprehensive Python bindings for the AIG (And-Inverter Graph) dialect.

The implementation includes an AIG C API header with dialect registration and an AIG C API implementation with pass registration.
It adds an AIG Python dialect TableGen file and Python dialect module. The AIG Python module C++ bindings are implemented using nanobind.

The implementation follows the pattern used by other CIRCT dialects
and enables Python users to work with AIG operations like and_inv through the
circt.dialects.aig module.
2025-07-03 09:04:50 -07:00
Martin Erhart ae167116fa
[RTG] Add CAPI and python bindings to register passes (#8632) 2025-07-01 13:30:29 +01:00
John Demme df6ca02a06
[Kanagawa] Python dialect and pass registration (#8613)
- Register the kanagawa dialect in Python bindings
- Register kanagawa dialect passes
- Add C API header and implementation for kanagawa dialect
- Add integration test for kanagawa dialect and passes

Follows the same pattern as pipeline dialect registration in commit 5c4d8ae.
2025-06-27 13:49:44 -07:00
John Demme 5c4d8ae62b
[Pipeline] Python dialect and pass registration (#8612)
- Register the pipeline dialect
- Register pipeline dialect passes
- Add passes to the PyCDE pipelines
2025-06-27 12:37:21 -07:00
Martin Erhart dd4eb8768d
[PyRTG] Add control flow constructs (#8365)
This is a first implementation for if-statements and for/foreach-loops. We probably want to iterate on that because the stack frame manipulations and accessing is not great.
2025-04-28 15:08:55 +02:00
Maksim Levental d07c799f60
[LLVM] bump to 9deb08a and integrate upstream SMT C APIs (#8424) 2025-04-17 15:26:22 -04:00
Martin Erhart 5deee45e23
[PyRTG] Support integers (#8235) 2025-02-19 13:38:05 +00:00
Mike Urbach c8416f7ed9
[Python] Switch CIRCT Python extension and dialects to nanobind. (#8110)
This follows the general nanobind porting guide and the upstream MLIR
changes in the same vein. For the most part, this is a very direct
migration accomplished with sed.

There were a couple minor differences.

Nanobind is more strict about implicit casting, which popped up in a
couple places:

* In MSFTModule, getNearestFreeInColumn was expecting a
CIRCTMSFTPrimitiveType (int), but was actually being passed
PrimitiveType enums at the call sites. Nanobind refused to
automatically cast enum to int, so it was done manually.
* In SVModule, SVAttributeAttr.get was expecting a bool for
emitAsComment, even though it was declared as having a default of
None. Nanobind refused to automatically cast None to bool, so it was
done manually, with a default of false.

Nanobind also prints enums slightly differently, so one FileCheck test
had to be updated for ESI.

Otherwise, the changes were purely mechanical.
2025-01-22 15:28:10 -07:00
Maksim Levental ca92024004
[CAPI] disambiguate mlirRegisterConversionPasses (#8072) 2025-01-13 16:40:28 -05:00
Maksim Levental baea6c20c8
[SMT][python] enable python bindings (#8071) 2025-01-13 08:59:35 -05:00
Martin Erhart 69b551d2b4
[RTG][RTGTest] Add Python Bindings (#7883) 2024-12-04 21:40:56 +00:00
John Demme e5842649d2
[DC] Add CAPI bindings for DC (#7906)
Registers the DC passes.
2024-11-26 19:47:52 -08:00
yassinz 3f6cbf6bde
[CAPI][Python][Arc, HW] Register Arc and HW passes (#7790)
Expose Arc and HW passes to CAPI and Python bindings.
2024-11-19 15:50:23 -08:00
Hideto Ueno c433d61523
[python] Add `walk_with_filter` to walk subset of IR (#7591)
This adds `walk_with_filter` python method to invoke callbacks
only for subset of operations. We require GIL to call python function
so this could improve performance of the tools based on Python API.

```
Starting walk_with_filter
walk_with_filter elapsed time: 0.005462 seconds cnt=1
Starting operation.walk
operation.walk elapsed time: 1.061360 seconds cnt=2
```
2024-09-10 15:13:59 +09:00
Schuyler Eldridge 077826e06c
[capi][python] Add Emit Dialect
Add the emit dialect to the C-API and to Python.  This is both missing and
is necessary for downstream Python tooling to not break.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-03-02 17:14:23 -05:00
John Demme 5cdff6351f [Python] Register the comb dialect lowerings 2024-01-31 21:20:11 +00:00
Fabian Schuiki 878303a1fe
[Python] Add debug dialect bindings (#6471)
Add basic Python bindings for the debug dialect.
2023-11-29 15:02:59 -08:00
Nandor Licker 0fc8656168
[Seq] Switch all seq ops to use seq.clock (#6139) 2023-09-18 16:38:32 +03:00
Hideto Ueno 1656984ebe
[Verif][LTL] Add basic python binding support (#6040)
This adds basic python binding support for verif and LTL dialects so that we can parse and analyses output MLIR file with these dialects.
2023-09-06 13:45:35 +09:00
Nandor Licker ac141282dc
[Seq] Merge Seq-to-SV lowering passes (#5901)
The pattern rewriter can be applied alongside the FIR register lowering transforms to eliminate the need for two separate passes.
2023-08-22 22:12:11 +03:00
Mike Urbach 4f05655418
[OM] Add initial Python API for OM dialect evaluator. (#5250)
This adds the usual Python API structure and dialect registration
boilerplate, as well as Python APIs around the Evaluator library.

The C++ implementations with pybind are intended to be as minimal and
straightforward as possible, simply wrapping the CAPI.

In order to provide a handy user-facing API, a couple of the C++
implementations are wrapped in pure Python to provide a nicer
interface:

The Evaluator constructor is wrapped in Python to also set up a logger
and diagnostic handler that uses the logger. This allows the CAPI and
C++ implementation to avoid dealing with Diagnostics. The CAPI simply
returns null on failure, and the C++ implementation simply throws a
Python error in this case. The pure Python diagnostic handler ensure
the error and any notes are logged before the error is thrown.

The Evaluator instantiate method is also wrapped in Python to handle
a few things required to provide a handy, type-safe API. It takes care
of accepting Python objects for actual parameters, and converting
these to Attributes using an existing helper function. It does a
similar conversion back to Python objects for primitive fields. It
also handles some minor metaprogramming to inspect an incoming
dataclass to determine its fields, extract them from the instantiated
Object, and return an instance of the dataclass.

Note that this initial implementation only supports Attributes in
Object fields in the pure Python wrapper around instantiation. Support
for Objects in Object fields will be added shortly in a subsequent
patch.
2023-05-24 11:49:11 -06:00
John Demme 3f6565e38b
[Python] Register handshake passes (#4290) 2022-11-10 19:01:37 -08:00
John Demme c512402b78 [Python] Register standard transforms from MLIR
Makes passes like CSE accessible from Python via the PassManager.
2022-10-26 17:31:08 -07:00
Morten Borup Petersen bc4c6874fd
[HWArith] HWArith passes CAPI boilerplate (#3605) 2022-07-26 15:45:01 +02:00
Will Dietz 69a110f97f
Update LLVM (#3502)
In llvm submodule: set branch to main, so can just update with:

$ git submodule update --remote --merge

See PR for summary of significant upstream changes and details of how they were handled:
https://github.com/llvm/circt/pull/3502
2022-07-18 14:18:53 -05:00
Morten Borup Petersen d904317dd1
[HWArith, CAPI] Add CAPI boilerplate for HWArith (#3550) 2022-07-18 15:19:08 +02:00
Morten Borup Petersen 5e9a0b4048 [PyCDE] Also run convert-fsm-to-sv in passes 2022-07-18 10:24:55 +02:00
Morten Borup Petersen d66cbfe9ea
[PyCDE,CAPI] Add support for the FSM dialect (#3400)
This is an initial commit for adding a CAPI for FSM as well as PyCDE support for constructing these.

See `test_fsm.py` for usage.

FSMs are constructed in a similar manner to PyCDE modules through a decorator on a class describing the FSM.
The FSM class may contain inputs (no outputs for now) and must provide
- A dictionary containing the states and their transitions
- A default state

State transitions may be either always taken, or taken based on some guard. This guard is defined by a function provided to the transition, which (like `@generator` functions) acts on the ports of the FSM.

The FSM will then be constructed with an output for each state, asserted when that state is active.

One important implementation note is the fact that the `fsm.machine` operation is treated as a PyCDE Module - there was surprisingly little friction slotting it into the current code and everything works as expected wrt. referencing `fsm.machine` in/out arguments through the transition guard functions.
However, modules instantiating the FSM expect a hardware-like interface, this being the ports of the `fsm.machine` operation + clock and reset signals. An `fsm.machine` op does not have these signals at the top level, since these are added during hardware lowering. To me, this is a sensible design choice, seeing that the FSM dialect should be applicable to both software and hardware representations (...eventually).

To get around this, the user will specify the intended name of the `clock` and optional `reset` signal of an FSM. A wrapper module is then created that provides the correct interface to the instantiating module, as well as instantiating the FSM through a `fsm.hw_instance` operation, doing the proper hoop-jumping to attach the clock signal (see `fsm_wrapper_class`).

There's still some work to do on the CIRCT side of the FSM dialect to clean it up a bit + make it a viable target for a front-end, but this commit represents the brunt of work on the PyCDE side.
2022-06-27 16:14:38 +02:00
John Demme c39757fc81
[Python] Add support for SV attributes (#3349)
Lots of boilerplate which should _really_ be autogenerated. Added support for SystemVerilog attributes to the python bindings for the SV and Seq dialects.
2022-06-14 16:08:42 -07:00
Mike Urbach 0d864829da [Python] Expose exportSplitVerilog API to Python.
This just needed to be plumbed through the CAPI.
2021-11-09 13:28:54 -07:00
Mike Urbach 22e0ea8a6c [MSFT] Combine attributes and ops into same Python namespace.
Previously, `circt.msft` contained the attributes and pysical design
functionality, and `circt.dialects.msft` contained the ops. To unify
things and avoid confusion, combine these into the
`circt.dialects.msft` Python namespace.
2021-11-05 10:09:18 -06:00
Chris Lattner 53b1c077d6 [RTL->HW] Rename C++ namespace, command line flags and a bunch of other stuff. 2021-05-15 14:33:45 -07:00
Chris Lattner 4d43103122 [RTL->HW] Rename the string "RTL" to "HW"
This makes sure not to rename FIRRTL to HWRTL :-), and I spot checked a
many things to avoid changing general references to RTL (e.g. when referring
to external tools) but I suspect that I missed some.  Please let me know (or
directly correct) any mistakes in this mechanical patch.
2021-05-15 12:44:05 -07:00
Chris Lattner 61e70086c6 [RTL->HW] Move a few more files in conversions and documentation. NFC. 2021-05-15 12:23:45 -07:00
Mike Urbach 7ef39a974c [Python] Switch to upstream PybindAdaptors, NFC. 2021-05-13 22:03:05 -06:00
Mike Urbach 56f3380405 [Python] Add stacktrace printing on error signal.
This is normally set up by tools that call InitLLVM, like circt-opt
and circt-translate. Set it up when the `circt` module is imported.
2021-05-13 21:36:22 -06:00
mikeurbach 68dee0e70b
[Python] [RTL] Add RTL pybind module with array and struct type. (#1002) 2021-05-06 11:38:32 -06:00
mikeurbach ac4847b61e
[Python][Seq] Add Python bindings to Seq CompReg and tests. (#1008) 2021-05-05 11:06:02 -06:00
mikeurbach 8999656964
Changes to exercise new pybind adaptors (#1000)
This enables the new adaptors in integration tests:
* Re-juggle headers to work with new pybind adaptors.
* Use the new utility for getting channel types in ESI.
2021-05-03 17:37:26 -06:00
John Demme c15faa7fc4
[MSFT] [Python] Physically locate an op (#937)
Adds an API call to physically place an op's sub-entity.
2021-04-20 16:20:22 -07:00
John Demme b67f1dcdde
[MSFT] [Python] Python bindings infrastructure for MSFT dialect (#936)
No functionality -- purely mechanical addition.
2021-04-20 14:36:09 -07:00
John Demme d9afe2ff3e
[ESI] [SystemAssembler] Run lowering passes, print Verilog (#920)
- Adds necessary passes
- Runs export verilog
2021-04-19 23:02:16 -07:00
John Demme ac14de2630
[Python] Register passes, export_verilog, and stack traces (#930)
- Registers the SV passes when the 'circt' Python module is imported and the ESI passes when 'circt.esi' is imported.
- Adds a Python 'export_verilog' call.
- Enables LLVM 'pretty' stack traces for easier debugging. Makes assertion messages appear in Python instead of just crashing with no output.
2021-04-19 22:05:40 -07:00
John Demme b6d5f65558
[ESI] Add wrap function to Python API (#893)
This new Python API function takes a module and a list of ports then constructs and returns a ESI wrapper module. Sets up the infrastructure for the ESI Python API.
2021-04-08 14:13:38 -07:00
John Demme d3cfca3c6b
[ESI] C API and Python bindings (#870)
Just the ability to 'import' ESI into Python.
2021-04-02 14:09:20 -07:00
mikeurbach 6aa2fc597f
[Python] Add bindings for Comb and SV dialects. (#843)
This adds the bindings and just checks that the dialects can be
imported in the integration test. Full integration test is coming, but
I have some small improvements to land first.
2021-03-29 12:39:28 -06:00
mikeurbach 9b2331e10f
Add Python bindings for the RTL dialect. (#767) 2021-03-23 20:13:49 -06:00
mikeurbach d6930641f5
[Python] Set up initial Python bindings for CIRCT. (#727)
This is the first step towards #710. This should be the minimal amount
of boilerplate to set up a Python module such that we can write
`import circt`. Note that this module does not actually bind to or
expose any API at the moment; this is just the boilerplate, and that
will follow.

The setup here is based on both the upstream MLIR Python bindings, as
well as what NPComp does.
2021-03-09 20:03:40 -07:00