-
Notifications
You must be signed in to change notification settings - Fork 647
add PopCount atLeast API #2711
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 PopCount atLeast API #2711
Conversation
| private def _apply_impl(in: Iterable[Bool])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = | ||
| SeqUtils.count(in.toSeq) | ||
|
|
||
| /** a threshold PopCount which has optimization to 0,1,2. |
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.
| /** a threshold PopCount which has optimization to 0,1,2. | |
| /** performs PopCount(x) >= n.U, with optimizations for n=0,1,2 |
jerryz123
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.
For clarity
| case 0 => true.B | ||
| case 1 => x.orR | ||
| case 2 => two(x)._2 | ||
| case 3 => PopCount(x) >= n.U |
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.
This should be case _, not case 3. (Otherwise it'll crash for n >= 4. It's a bug in rocket-chip, too)
| def atLeast(n: Int, x: UInt): Bool = macro SourceInfoTransform.nxArg | ||
|
|
||
| /** @group SourceInfoTransformMacro */ | ||
| def do_atLeast(n: Int, x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { |
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.
| def do_atLeast(n: Int, x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { | |
| def do_atLeast(n: Int, x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { |
|
Merged in #5002 |
Contributor Checklist
docs/src?Type of Improvement
API Impact
Backend Code Generation Impact
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.4.x, [small] API extension:3.5.x, API modification or big change:3.6.0)?Enable auto-merge (squash), clean up the commit message, and label withPlease Merge.Create a merge commit.