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

[RFC] [do-not-merge] Refactor Bits into Separate Files #875

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seldridge
Copy link
Member

Bits.scala is currently 1200 lines and a pain to read (it's 1700 with the API documentation of #873!). The initial motivation for this was the good approach of sealing everything in the Bits hierarchy (as bad things happen if you start extending Bits). However, the need to ram all of the implementations of all sealed children of Bits into one file isn't necessary and it contributes to the bloat of Bits.scala.

This proposes breaking up the sealed traits in Bits.scala into separate files with private traits containing the macro and method implementations of these traits. This would create the following files:

  • Element.scala
  • Bits.scala
  • Num.scala
  • UInt.scala
  • SInt.scala
  • FixedPoint.scala
  • Analog.scala

This PR currently shows an example of how this can be done for UInt by breaking it up into:

  • private [core] UIntMacros
  • private [core] UIntMethods

It may also make sense to breakup the whole hierarchy going back to Data into macro and method traits.

There is no effect on ScalaDoc by doing this. Methods provided by private traits mixed into public classes will still show up.

As this will have major conflicts with #873, I'll wait to act on any full implementation of this.

Related issue:

Type of change: other enhancement

Impact: no functional change

Development Phase: proposal

Release Notes

This refactors UInt into two private traits: one for macros and one for
method implementations. This is one way to cleanup Bits while moving the
body of sealed classes (Bits, UInt, SInt, FixedPoint, Analog) into
separate files.

Signed-off-by: Schuyler Eldridge <[email protected]>
@chick
Copy link
Contributor

chick commented Aug 21, 2018

This seems like a good idea. Another reason to wait, a little, is we are in the middle of adding yet another bunch of lines to Bits.scala in order to support the new Interval type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants