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

Add private Module API and internal DataMirror API for moduleIOs. #4036

Merged
merged 4 commits into from
May 1, 2024

Conversation

mikeurbach
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 request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Feature (or new API)

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).

Release Notes

The DataMirror API allows users who know what they're doing to access a module's ports before it is closed.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.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.

@mikeurbach mikeurbach added the Feature New feature, will be included in release notes label May 1, 2024
@mikeurbach mikeurbach added this to the 7.0 milestone May 1, 2024
@mikeurbach mikeurbach requested a review from jackkoenig May 1, 2024 00:33
*
* @param target BaseModule to get IOs from
*/
def moduleIOs(target: BaseModule): Seq[Data] = target.getIOs
Copy link
Member

Choose a reason for hiding this comment

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

Maybe constraint target to be FixedIOModule? I'm afraid in some complex design pattern, this function will execute to early.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the use case I had in mind, I don't want to add that constraint. Indeed, this is not generally safe, which I tried to explain in the scaladoc and by putting this into DataMirror.internal object.

Copy link
Contributor

Choose a reason for hiding this comment

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

we need this for more than FixedIOModule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add more "this is unsafe" text to the scaladoc at least.

Copy link
Member

Choose a reason for hiding this comment

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

I see, this sounds to be an advance unsafe API, wish normal user won't touch it;p

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can try to add a hook in builder, if user called this function and new IO is created, log an warning to user saying the IO they got is not enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's fine to start with the new API "hidden" in DataMirror.internal, with a comment explaining the dangers. If users start using this and continue to be surprised by the documented behavior, I guess we could add the extra state to give warnings.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

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

LGTM, consider tweaking the test but merge when you're ready.

@mikeurbach mikeurbach enabled auto-merge (squash) May 1, 2024 18:08
@mikeurbach mikeurbach merged commit fe5bf69 into main May 1, 2024
14 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/datamirror-chisel-ports branch May 1, 2024 18:20
@@ -245,4 +245,24 @@ class DataMirrorSpec extends ChiselFlatSpec {
DataMirror.getLayerColor(foo.c) should be(Some(A))
}

"moduleIOs" should "return an in-progress module's IOs" in {
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit you changed the name of this function and maybe we should have changed this string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, i wish we could push NFC changes to main.

@mwachs5 mwachs5 mentioned this pull request May 1, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants