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

booth cleanup #3938

Merged
merged 11 commits into from
Oct 2, 2023
Merged

booth cleanup #3938

merged 11 commits into from
Oct 2, 2023

Conversation

povik
Copy link
Member

@povik povik commented Sep 18, 2023

Following up to #3924, this PR will to some degree clean up the code of the Booth pass.

To represent intermediate signals use the `SigBit`/`SigSpec` classes as
is customary in the Yosys codebase. Do not pass around `Wire` pointers
unless we have special reason to.
For the basic single-bit operations, opt for gate cells (`$_AND_` etc.)
instead of the coarse cells (`$and` etc.). For the emission of cells
move to the conventional module methods (`module->addAndGate`) away
from the local helpers. While at it, touch on the surrounding code.
Use the `addFa` helper, do not misuse `new_id` and make other changes
to the transformation code.
@povik povik marked this pull request as ready for review September 25, 2023 12:52
@povik
Copy link
Member Author

povik commented Sep 25, 2023

@andyfox-rushc Take a look, feel free to ask and/or object.

log_assert(s_vec.size() == c_vec.size());
log_assert(c_vec.size() == s_vec.size());
// TODO: doesn't pass
//log_assert(result.size() == s_vec.size() + 2);
Copy link
Member Author

Choose a reason for hiding this comment

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

@andyfox-rushc Here I moved the result.size() == s_vec.size() + 2 condition down from the "axioms" comment to an actual assert, but it wasn't passing. Should this be upheld?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, Martin,
My comment is wrong and the axiom you refer to does not need to be upheld. The axiom for the unsigned case should be result.size() ==s_vec.size().
In this unsigned case an array of CSA (Wallace) trees is used: 1 per result bit. Each CSA tree produces a sum and carry. These are summed up by the CPA. The final carry out is ignored in the unsigned case. My error comes from the use of the same structure for signed multiplication, in which case the multiplier is not padded out and one partial product removed which leads to the different axiom for the size. But again my comment was wrong for the unsigned case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the analysis! I wanted to make sure there's not an issue lurking there.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS Martin, sorry for being quiet. I did quickly go through all your changes which look good to me. I like the addition of the full adder helper creator to RTLIL. The simplifications to the cell selection and the extension of the arguments to fit the right size (I was adding weird buffers), all seem to make the code much clearer to me. I see these all got safely merged in today. All looks great to me. Thanks.

Fix assertion to what it should be per Andy's comments.
Cut the test down from taking ~25 s to ~3 s.
@nakengelhardt nakengelhardt merged commit dcb600a into YosysHQ:master Oct 2, 2023
15 checks passed
@povik povik deleted the booth-cleanup branch October 9, 2023 09:54
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