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 setAll() and clearAll() for Data #1078

Merged
merged 3 commits into from
May 19, 2023
Merged

Conversation

MarekPikula
Copy link
Contributor

@MarekPikula MarekPikula commented Apr 7, 2023

Context, Motivation & Description

Sometimes I need to zero out an entire bundle, but assigning each bundle signal is tedious, especially for multi-level Bundles. I ended up using the method in the PR as it's simple and uses some of the most basic methods available (even for Data), so I figured that it could be added directly to Data. Let me know if that's the place for this sort of general method, or should it be higher up in the hard type hierarchy?

Also, I noticed that this pattern is often used in RegIf, so I changed it as well to use the new construct from Data.

Impact on code generation

None, convenience function for Data, which is already implemented for BitVector and some of its children.

Checklist

  • Unit tests were added – should there be any for such a small change?
  • API changes are or will be documented:

@@ -422,6 +422,15 @@ trait Data extends ContextUser with NameableByComponent with Assignable with Spi
def assignFromBits(bits: Bits, hi: Int, low: Int): Unit
def assignFromBits(bits: Bits, offset: Int, bitCount: BitCount): Unit = this.assignFromBits(bits, offset + bitCount.value - 1, offset)

def clearAll(): this.type = {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be great to provide clearAll setAll implementation to the Bool class too, to reduce the number of nodes in the netlist :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I somehow missed your comment in my inbox. Pushed the commit addressing Bool.

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
To reduce the number of nodes in the netlist.

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
@Dolu1990 Dolu1990 merged commit b278e42 into SpinalHDL:dev May 19, 2023
13 checks passed
@Dolu1990
Copy link
Member

Thanks :)

@MarekPikula MarekPikula deleted the data_clearall branch May 19, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants