Conversation
desmonddak
reviewed
Aug 28, 2026
| ROHD HCL provides two multi-cycle integer divider modules that share a common interface: | ||
|
|
||
| * `MultiCycleDivider` — uses **two's complement** signed arithmetic. | ||
| * `OnesComplementDivider` — uses **one's complement** signed arithmetic. |
Contributor
There was a problem hiding this comment.
I wonder about the organization -- both dividers could share a common class that has all the state management, and this could be called MultiCycleDivider, and then we could have a TwosComplementDivider and a OnesComplementDivider extend and use some customization of the logic. Right now, OnesComplementDivider uses the states of the MultiCycleDivider, but everything else is different, and it isn't clear why.
One good reason to figure this out is that we may end up with other 1 versus 2s complement arithmetics and we might be able to borrow some of the key differences (say during accumulation you need to do slightly different things).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description & Motivation
This PR refactors and extends the MultiCycleDivider with two key changes:
FSM Refactor (divider.dart): Replaces the manual ad-hoc FSM (using _MultiCycleDividerState static constants, raw Combinational/Sequential blocks, and a currentState/nextState pair) with ROHD's FiniteStateMachine. The state constants are promoted to a proper enum MultiCycleDividerStates. This reduces boilerplate, improves readability, and aligns with idiomatic ROHD patterns.
Quotient-only mode (computeRemainder flag): Adds a computeRemainder parameter to MultiCycleDivider. When false, the divider uses a faster O(n) binary long-division algorithm (one quotient bit per clock cycle) instead of the full O(n²) greedy algorithm, and the remainder output is always 0.
New OnesComplementDivider (ones_complement_divider.dart): Adds a new sibling divider that uses one's complement signed arithmetic instead of two's complement. It shares the same MultiCycleDividerInterface and MultiCycleDividerStates FSM but replaces the sign-negate operation (~x + 1) with a simpler bitwise invert (~x), reducing the critical path in the convert state. It also supports the computeRemainder flag with both O(n²) and O(n) modes.
Related Issue(s)
#139
Testing
Backwards-compatibility
No
Documentation
Doc changes included in this PR.