-
Notifications
You must be signed in to change notification settings - Fork 33
Add Count Pattern Occurrence #247
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ramli, Nurul Izziany <[email protected]>
Signed-off-by: laeticiachee <[email protected]>
Signed-off-by: laeticiachee <[email protected]>
mkorbel1
left a comment
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.
Thank you for your contribution! Some comments :)
| /// | ||
| /// Takes in [bus] of type [Logic]. | ||
| /// [pattern] is the pattern to be counted in the bus. | ||
| /// If [fromStart] is `true`, the count starts from the beginning of the bus. |
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.
What is the meaning of counting from the start or the end? Shouldn't the resulting count be the same?
|
|
||
| if (generateError) { | ||
| // If pattern is not found (count equals to 0), return error | ||
| addOutput('error'); |
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.
why is it an error if count is 0?
| count += valCheck.zeroExtend(count.width); | ||
| } | ||
|
|
||
| _output = addOutput('count', width: count.width); |
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.
what's the purpose of the internal _output vairable? Why not just assign this.count <= count or something?
| /// Count the number of occurence of a fixed-width pattern in a bus. | ||
| /// | ||
| /// Takes in [bus] of type [Logic]. | ||
| /// [pattern] is the pattern to be counted in the bus. |
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.
it may be worth explicitly stating that if the pattern width is greater than the width of the bus, the count will always be 0
Description & Motivation
Similar to the Count bit occurrence, but instead, find an entire multi-bit pattern
Related Issue(s)
Count pattern occurrence #170
Testing
Test are defined in test/count_pattern_test.dart with multiple cases
Backwards-compatibility
No
Documentation
Yes, documentation on how to use it, and some examples are added in doc/components/count_pattern.md