-
Notifications
You must be signed in to change notification settings - Fork 615
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
Support literals and DontCare in DataView targets #3389
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature improvement. The valid view is pretty slick.
object ValidExtensions { | ||
implicit def view[T <: Data] = DataView[T, Valid[T]]( | ||
x => Valid(x.cloneType), // Valid will strip direction with `Output(...)` anyway | ||
_ -> _.bits, | ||
(_, v) => true.B -> v.valid | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a public utility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, we need to figure out a general coding style for such methods. I think it should probably be a factory method on object Valid
rather than making people call .viewAs[Valid[CorrectType]]
. The problem is that the natural answer would be Valid.apply
, but that is obviously taken by the factory for making types rather than values. It's sort of the "VecInit" pattern (but obviously that name is not the best), and if we can come up with a decent "standard", I think this would be a great example of it.
(cherry picked from commit 0f803cd) # Conflicts: # src/test/scala/chiselTests/experimental/DataView.scala
(cherry picked from commit 0f803cd) # Conflicts: # src/test/scala/chiselTests/experimental/DataView.scala
…3391) * Support literals and DontCare in DataView targets (#3389) (cherry picked from commit 0f803cd) # Conflicts: # src/test/scala/chiselTests/experimental/DataView.scala * Resolve backport conflicts --------- Co-authored-by: Jack Koenig <[email protected]>
…3390) * Support literals and DontCare in DataView targets (#3389) (cherry picked from commit 0f803cd) # Conflicts: # src/test/scala/chiselTests/experimental/DataView.scala * Resolve backport conflicts --------- Co-authored-by: Jack Koenig <[email protected]>
The best example of why this is useful is the test showing some possible uses with
Valid
:This enables you to box any
T
as aValid[T]
where thevalid
bit is the literal true:Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.5.x
or3.6.x
depending on impact, API modification or big change:5.0.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.