Skip to content

Conversation

cowardsa
Copy link
Contributor

@cowardsa cowardsa commented Jul 2, 2025

Creating the boilerplate dialect definition to split up a closed PR - a follow-up PR will add the operations described below and much more.

The datapath dialect will be used as part of the growing synthesis capabilities, where arithmetic operators such as comb.mul and multi-input comb.add can be lowered to gates via the datapath dialect. The datapath dialect allows us to directly express efficient circuits such as compressor trees, in the IR itself, allowing us to manipulate and combine arithmetic operations.

The key idea is to view datapath operators as generators of circuits that satisfy some contract, for example in the case of the datapath.compress summing it's results is equivalent to summing it's inputs. This allows us to defer implementing these critical circuits until later in the synthesis flow.

In a simple example, we can fold a*b+c using the datapath dialect to remove a carry-propagate adder:

%0 = comb.mul %a, %b : i4
%1 = comb.add %0, %c : i4

Which is equivalent to:

%0:4 = datapath.pp %a, %b : 4 x i4
%1:2 = datapath.compress %0#0, %0#1, %0#2, %0#3, %c : 5 x i4 -> (i4, i4)
%2 = comb.add %1#0, %1#1 : i4

This is the first in a series of PRs to add datapath synthesis capabilities that will include the following (implemented but not merged):

Comb to Datapath pass
Datapath to Comb pass - for lowering datapath ops to comb gates
Datapath to SMT - for contract verification
Incorporating datapath passes into circt-synth
Replicate adds pass - to enable unsharing for better delay performance

@TaoBi22 TaoBi22 requested a review from uenoku July 2, 2025 10:07
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! I think the dialect definition is great. Could you add a rational doc under docs/Dialects/ to describe the purpose of the Dialect (which you explained in a PR description). Also could you update https://github.com/llvm/circt/blob/main/test/circt-opt/commandline.mlir?

@cowardsa
Copy link
Contributor Author

cowardsa commented Jul 2, 2025

Added a rationale document and corrected @uenoku comments above

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks! Do you have a commit access?

@cowardsa
Copy link
Contributor Author

cowardsa commented Jul 2, 2025

Not yet - am awaiting this request to be approved! So if you someone can merge that would be great.

@uenoku - have been testing out the longest path analysis on small datapath benchmarks - so hope to share results soon!

Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Can't wait for CIRCT to get more serious about data path synthesis 🥳. Thanks for adding docs as well 🏅!

@uenoku uenoku merged commit 3011bf1 into llvm:main Jul 2, 2025
7 checks passed
@uenoku
Copy link
Member

uenoku commented Jul 2, 2025

Merged the PR 👍 Thank you for trying LongestPath analysis! #8644 should provide more nicer report FYI.

uenoku pushed a commit that referenced this pull request Jul 3, 2025
The datapath dialect will be used as part of the growing synthesis capabilities, where arithmetic operators such as comb.mul and multi-input comb.add can be lowered to gates via the datapath dialect. The datapath dialect allows us to directly express efficient circuits such as compressor trees, in the IR itself, allowing us to manipulate and combine arithmetic operations.

The key idea is to view datapath operators as generators of circuits that satisfy some contract, for example in the case of the datapath.compress summing it's results is equivalent to summing it's inputs. This allows us to defer implementing these critical circuits until later in the synthesis flow.

In a simple example, we can fold a*b+c using the datapath dialect to remove a carry-propagate adder:

```mlir
%0 = comb.mul %a, %b : i4
%1 = comb.add %0, %c : i4
```
Which is equivalent to:
```mlir
%0:4 = datapath.pp %a, %b : 4 x i4
%1:2 = datapath.compress %0#0, %0#1, %0#2, %0#3, %c : 5 x i4 -> (i4, i4)
%2 = comb.add %1#0, %1#1 : i4
```
This is the first in a series of commits to add datapath synthesis capabilities that will include the following (implemented but not merged):
TaoBi22 pushed a commit to TaoBi22/circt that referenced this pull request Jul 17, 2025
The datapath dialect will be used as part of the growing synthesis capabilities, where arithmetic operators such as comb.mul and multi-input comb.add can be lowered to gates via the datapath dialect. The datapath dialect allows us to directly express efficient circuits such as compressor trees, in the IR itself, allowing us to manipulate and combine arithmetic operations.

The key idea is to view datapath operators as generators of circuits that satisfy some contract, for example in the case of the datapath.compress summing it's results is equivalent to summing it's inputs. This allows us to defer implementing these critical circuits until later in the synthesis flow.

In a simple example, we can fold a*b+c using the datapath dialect to remove a carry-propagate adder:

```mlir
%0 = comb.mul %a, %b : i4
%1 = comb.add %0, %c : i4
```
Which is equivalent to:
```mlir
%0:4 = datapath.pp %a, %b : 4 x i4
%1:2 = datapath.compress %0#0, %0#1, %0#2, %0#3, %c : 5 x i4 -> (i4, i4)
%2 = comb.add %1#0, %1#1 : i4
```
This is the first in a series of commits to add datapath synthesis capabilities that will include the following (implemented but not merged):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants