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

Enrich ShiftRegister with SyncReadMem-based implementation. #2891

Merged
merged 16 commits into from
Oct 5, 2023

Conversation

milovanovic
Copy link
Contributor

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

  • backend code generation
  • new feature/API
  • performance improvement

API Impact

This feature extends the current API preserving full backward compatibility.

Backend Code Generation Impact

If SyncReadMem-based Shift Register implementation is selected this will impact the generated Verilog code.

Desired Merge Strategy

No preference.

Release Notes

Supplement ShiftRegister with SyncReadMem-based implementation.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (Bug fix: 3.4.x, [small] API extension: 3.5.x, API modification or big change: 3.6.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
  • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
  • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@milovanovic milovanovic marked this pull request as ready for review December 19, 2022 19:34
Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

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

After taking a look at the implementation of new ShiftRegister with use_sp_mem = true, I think this is simply adding a new instance of mem to increase ShiftRegister to multiple bank?

Besides the nitpick on names and the usage of null, I think this PR is actually "adding multiple banks support to ShiftRegister."? if so, I think the new banks to add should be 2,4,8..., rather than only being 2.

src/main/scala/chisel3/util/Reg.scala Outdated Show resolved Hide resolved
src/main/scala/chisel3/util/Reg.scala Outdated Show resolved Hide resolved
src/main/scala/chisel3/util/Reg.scala Outdated Show resolved Hide resolved
src/main/scala/chisel3/util/Reg.scala Outdated Show resolved Hide resolved
* @param use_sp_mem single port or dual port SRAM based implementation
* @param name name of SyncReadMem object
*/
def apply[T <: Data](in: T, n: Int, en: Bool, use_sp_mem: Boolean, name: String): T =
Copy link
Member

Choose a reason for hiding this comment

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

How about using name: Option[String]? null in Scala is a bad design choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the whole idea is summarized in a recent issue. In other words, please have a look at slide 34: for larger (i.e., wider and deeper) shift registers it is much more power and area efficient to implement them using SRAM than with flip-flops. If dual-port SRAM is available (i.e., if such memory compiler exists) that is a straightforward path. If you want to be even more power and area efficient, or if dual-port memory compiler isn't available in the target technology, you can alternatively use two half-size single-port SRAMs in ping-pong configuration. This is well explained in, say, Chapter 9 (pp. 208-211) of the textbook OFDM Baseband Receiver Design for Wireless Communications by Tzi-Dar Chiueh and Pei-Yun Tsai. Even though it is certainly possible to have any number of banks, just as you've said, there is no real gain in power and area for anything larger than two due to (control) logic overhead.

By the way, thanks on the suggestion how to eliminate null. You can review it again.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clear explanation! Would you mind renaming the arg to useDualSRAMPort and default to false or something similar and provide a documentation to which? That will be much clear to users.

Copy link
Contributor

@mwachs5 mwachs5 left a comment

Choose a reason for hiding this comment

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

Looking good! Please consider my suggestion on the parameter name

milovanovic and others added 3 commits January 29, 2023 20:26
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Megan Wachs <megan@sifive.com>
@milovanovic milovanovic requested review from sequencer and mwachs5 and removed request for mwachs5 and sequencer March 16, 2023 21:36
@jackkoenig jackkoenig added the Feature New feature, will be included in release notes label Oct 5, 2023
@jackkoenig jackkoenig added this to the 3.5.x milestone Oct 5, 2023
@jackkoenig jackkoenig enabled auto-merge (squash) October 5, 2023 18:23
@jackkoenig jackkoenig merged commit 3382cab into chipsalliance:main Oct 5, 2023
14 checks passed
@mergify mergify bot added the Backported This PR has been backported label Oct 5, 2023
mergify bot pushed a commit that referenced this pull request Oct 5, 2023
Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)

# Conflicts:
#	src/test/scala/chiselTests/util/RegSpec.scala
mergify bot pushed a commit that referenced this pull request Oct 5, 2023
Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)
mergify bot pushed a commit that referenced this pull request Oct 5, 2023
Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)
jackkoenig pushed a commit that referenced this pull request Nov 16, 2023
Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)
jackkoenig pushed a commit that referenced this pull request Nov 16, 2023
Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)
mergify bot added a commit that referenced this pull request Nov 16, 2023
…3571)

Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 3382cab)

Co-authored-by: Vladimir Milovanović <barun@eecs.berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants