chisel icon indicating copy to clipboard operation
chisel copied to clipboard

Bits refactor

Open sequencer opened this issue 4 years ago • 0 comments

I'm trying to split Bits into small types, and add return type to each type in type hierarchy. I don't know will this work or not, seems to be a big change. However this may help splitting implementation between Scala3 and Scala213. And IDEA will be much happier if we successfully implement this. Based on https://docs.scala-lang.org/tour/self-types.html, I think usage of self.type is wrong in type hierarchy. After cleaning up, implementation to chisel3.internal.operators will be split out from each classes, and moved to 2.13 specific directory based on tutorial-macro-cross-building. A possible gain in the future might be dsptool-like spiral-based design more easy to implement.

During refactoring I found these strange behaviors:

  1. Num[T <: Data] seems to be a flawed design which doesn't provide a cross type operation, for example: UInt + SInt, UInt + FixedPoint.
  2. slice to Bits will return UInt, really wish a type-safe behavior here.
  3. Bits not being concrete, while Bits.apply just return a UInt is a confusing design, I think we should concrete Bits directly(this may affect RocketChip). seeking for opinions from @aswaterman

macro refactor strategy

  1. Split out all API implemented by marco to small traits
  2. Split all macro to FooMacroImp trait, creating corresponding version specific sources

Contributor Checklist

  • [ ] Did you add Scaladoc to every public function/method?
  • [ ] Did you add at least one test demonstrating the PR?
  • [ ] Did you delete any extraneous printlns/debugging code?
  • [ ] Did you specify the type of improvement?
  • [ ] Did you add appropriate documentation in docs/src?
  • [ ] Did you state the API impact?
  • [ ] Did you specify the code generation impact?
  • [ ] Did you request a desired merge strategy?
  • [ ] Did you add text to be included in the Release Notes for this change?

Type of Improvement

API Impact

Backend Code Generation Impact

Desired Merge Strategy

Release Notes

Reviewer Checklist (only modified by reviewer)

  • [ ] Did you add the appropriate labels?
  • [ ] Did you mark the proper milestone (Bug fix: 3.3.x, [small] API extension: 3.4.x, API modification or big change: 3.5.0)?
  • [ ] Did you review?
  • [ ] Did you check whether all relevant Contributor checkboxes have been checked?
  • [ ] Did you mark as Please Merge?

sequencer avatar Dec 04 '21 21:12 sequencer