Skip to content

Multi-cycle divider improvements: FSM enum, 1's complement, and quotient-only mode#287

Open
joserochh wants to merge 7 commits into
intel:mainfrom
joserochh:joserochh/divider_refactor
Open

Multi-cycle divider improvements: FSM enum, 1's complement, and quotient-only mode#287
joserochh wants to merge 7 commits into
intel:mainfrom
joserochh:joserochh/divider_refactor

Conversation

@joserochh
Copy link
Copy Markdown
Contributor

@joserochh joserochh commented Apr 24, 2026

Description & Motivation

This PR refactors and extends the MultiCycleDivider with two key changes:

  1. 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.

  2. 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.

  3. 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

  • Existing tests for MultiCycleDivider were extended to run in both computeRemainder: true and computeRemainder: false modes (all test groups are now parameterised over both modes).
  • New VF test infrastructure added for OnesComplementDivider: dedicated OnesComplementInputMonitor, OnesComplementScoreboard, OnesComplementAgent, OnesComplementEnv, and OnesComplementTest classes.
  • New test sequences added: OnesCompBasicSequence, OnesCompEvilSequence (including negative-zero divisor edge cases), OnesCompVolumeSequence (1000 random vectors), and OnesCompSignedCornerSequence (all four sign quadrants + both divide-by-zero forms).
  • Corner-case sequence (MultiCycleDividerCornerSequence) added for the two's complement divider covering signed boundaries, overflow (MIN_INT ÷ −1), and divide-by-zero.
  • A fix to currIndex width (logDataWidth + 1 bits) ensures the loop-exit condition works correctly for all data widths.

Backwards-compatibility

Is this a breaking change that will not be backwards-compatible? If yes, how so?

No

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

Doc changes included in this PR.

@joserochh joserochh changed the title Joserochh/divider refactor Multi-cycle divider improvements: FSM enum, 1's complement, and quotient-only mode Apr 28, 2026
@joserochh joserochh marked this pull request as ready for review April 28, 2026 21:23
@mkorbel1 mkorbel1 linked an issue May 1, 2026 that may be closed by this pull request
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.

Multi-cycle divider improvements

1 participant