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 Probes to .toString Data methods #4478

Merged
merged 5 commits into from
Oct 18, 2024
Merged

Conversation

azidar
Copy link
Contributor

@azidar azidar commented Oct 17, 2024

Contributor Checklist

  • [N/A] 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?
  • [N/A] 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

  • Bugfix

Desired Merge Strategy

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

Release Notes

Probe chisel types now include the kind of probe and layer in their .toString method

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.

@azidar azidar requested a review from jackkoenig October 17, 2024 17:43
@azidar azidar added the Bugfix Fixes a bug, will be included in release notes label Oct 17, 2024
@azidar azidar added this to the 6.x milestone Oct 17, 2024
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.

this is great!

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.

by the way, i personally think (how I usually do this when i put a comment about the type) to have it as

Probe[A]<BundleTest>

Comment on lines 490 to 495
case None => addProbeModifier(chiselType)
// Handle DontCares specially as they are "literal-like" but not actually literals
case Some(DontCareBinding()) => s"$chiselType(DontCare)"
case Some(topBinding) =>
val binding: String = thiz._bindingToString(topBinding)
val name = thiz.earlyName
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sort of surprised the test is below is working:

Wire(probe.Probe(UInt(1.W))).toString should be("BoundDataModule.?: Wire[Probe<UInt<1>>]")

A Wire of probe should have a top binding...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does have a top binding? Not sure I understand..

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it should have top binding, this does not make sense to me

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I missed that you also had addProbeModifier below.

I think it would be better to only do that once, will suggest above.

Comment on lines 477 to 484
def addProbeModifier(chiselType: String): String = {
probeInfo match {
case None => chiselType
case Some(ProbeInfo(writeable, layer)) =>
val layerString = layer.map(x => s"[${x.fullName}]").getOrElse("")
(if (writeable) "RWProbe" else "Probe") + s"$layerString<$chiselType>"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def addProbeModifier(chiselType: String): String = {
probeInfo match {
case None => chiselType
case Some(ProbeInfo(writeable, layer)) =>
val layerString = layer.map(x => s"[${x.fullName}]").getOrElse("")
(if (writeable) "RWProbe" else "Probe") + s"$layerString<$chiselType>"
}
}
val chiselTypeWithModifier =
probeInfo match {
case None => chiselType
case Some(ProbeInfo(writeable, layer)) =>
val layerString = layer.map(x => s"[${x.fullName}]").getOrElse("")
(if (writeable) "RWProbe" else "Probe") + s"$layerString<$chiselType>"
}

Then use chiselTypeWithModifier below anywhere chiselType was being used.

@azidar azidar enabled auto-merge (squash) October 18, 2024 16:03
@azidar azidar merged commit 8c718b2 into main Oct 18, 2024
15 checks passed
@azidar azidar deleted the azidar-add-probe-to-tostring branch October 18, 2024 17:37
@mergify mergify bot added the Backported This PR has been backported label Oct 18, 2024
mergify bot pushed a commit that referenced this pull request Oct 18, 2024
* Add probe string to .toString Data methods

* Update chisel tests with new probe toString

(cherry picked from commit 8c718b2)

# Conflicts:
#	core/src/main/scala/chisel3/Data.scala
#	src/test/scala/chisel3/TypeEquivalenceSpec.scala
#	src/test/scala/chiselTests/LayerSpec.scala
#	src/test/scala/chiselTests/ProbeSpec.scala
@dtzSiFive
Copy link
Member

Thanks!

jackkoenig pushed a commit that referenced this pull request Nov 26, 2024
* Add probe string to .toString Data methods

* Update chisel tests with new probe toString

(cherry picked from commit 8c718b2)
chiselbot pushed a commit that referenced this pull request Nov 26, 2024
* Add probe string to .toString Data methods

* Update chisel tests with new probe toString

(cherry picked from commit 8c718b2)

Co-authored-by: Adam Izraelevitz <[email protected]>
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 Bugfix Fixes a bug, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants