Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CombToAIG] Add a pattern for mul #8015

Merged
merged 2 commits into from
Dec 27, 2024
Merged

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Dec 24, 2024

This commit adds a pattern to lower mul. Mul is lowered into chains of comb.add + comb.mux. There must be more efficient implementation but for now this naive pattern should work fine. LEC is verified.

{a_{n}, a_{n-1}, ..., a_0} * b
= sum_{i=0}^{n} a_i * 2^i * b
= sum_{i=0}^{n} (a_i ? b : 0) << i

This commit adds a pattern to lower mul. Mul is lowered into chains of
comb.add + comb.mux

```
a_{n}a_{n-1}...a_0 * b
= sum_{i=0}^{n} a_i * 2^i * b
= sum_{i=0}^{n} (a_i ? b : 0) << i
@uenoku uenoku merged commit 5b128a1 into main Dec 27, 2024
4 checks passed
@uenoku uenoku deleted the dev/hidetou/comb-to-aig-mul-2 branch December 27, 2024 05:02
@Max-astro
Copy link
Contributor

It's great to see the progress made with the circt-synth tool.

I have a question about the current CombToAIG lowering flow. In a commercial logic synthesizer, the operator lowering process considers the timing/area trade-off, especially for operators on the critical path. For example, a multiply operator will be mapped into a Wallace Tree multiplier if it's on the critical path. Other non-critical multiply operators might be mapped to serial multipliers to save chip area.

So, Suppose multiple implementation architectures are available for each operator in the future. How do you plan to approach the operator in selecting the most suitable architecture during the lowering process? To achieve that, the synthesis flow might need to incorporate a timing and area analyzer.

@uenoku
Copy link
Member Author

uenoku commented Dec 27, 2024

the operator lowering process considers the timing/area trade-off, especially for operators on the critical path

That's great point!

One thing we can possibly do is to lazily lower heavy operations
such as mul or div. We can keep them first, and analyze the timing
and critical path in the partically lowered AIG IR. We'll definitely implement
timing and area analyzer (in fact they are implemented in my local branch)
so we should be able to use that in the future.

That said I agree it would be really nice if the compiler/synthesizer
can automatically optimize the critical path or area but
I think it's also important for users to specify the lowering choice.
Users shouldn't use builtin operators for heavy operations like mul
or div in the first place for the modules that are performance critical.

@Max-astro
Copy link
Contributor

We'll implement timing and area analyzer (in fact they are implemented in my local branch)
so we should be able to use that in the future.

Cool! It's good to know that.
I have experience developing an STA tool and am willing to contribute to this area.

@uenoku
Copy link
Member Author

uenoku commented Dec 27, 2024

Awesome, thanks! That would be really really helpful. Can we set a meeting? (or we can use CIRCT open meeting if time works for you). Do you mind if you could send me email to hideto.ueno@sifive.com?

@Max-astro
Copy link
Contributor

Max-astro commented Dec 27, 2024

Yeah sure! I sent you an email before (about a month ago) when I first saw your commit about the circt-synth , but maybe your mailbox blocked that mail. I'll resend that letter, and my email is max_astro@qq.com

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.

2 participants