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

util: add GrayCode #2353

Merged
merged 3 commits into from
Jan 19, 2022
Merged

util: add GrayCode #2353

merged 3 commits into from
Jan 19, 2022

Conversation

ekiwi
Copy link
Contributor

@ekiwi ekiwi commented Jan 18, 2022

Contributor Checklist

  • 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?
  • Did you add appropriate documentation in docs/src?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?

Type of Improvement

  • new feature/API

API Impact

  • adds two new utility functions to convert binary to gray code and back

Backend Code Generation Impact

  • this change does not impact existing code

Desired Merge Strategy

  • squash

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (Bug fix: 3.4.x, [small] API extension: 3.5.x, API modification or big change: 3.6.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

@ekiwi ekiwi force-pushed the gray-code branch 2 times, most recently from e077aeb to 756fb76 Compare January 18, 2022 19:11
Copy link
Member

@aswaterman aswaterman 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 a good util to have.

I'm pretty sure that the GrayToBinary is just something like

Cat((in.getWidth - 2 to 0 by -1).scanLeft(in.head(1)) { case (prev, ii) => prev ^ in(ii) }

so you can get rid of the var.

Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Copy link
Member

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

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

lgtm

@ekiwi
Copy link
Contributor Author

ekiwi commented Jan 18, 2022

@jackkoenig Did you want to backport this?

@ekiwi ekiwi added this to the 3.5.x milestone Jan 18, 2022
@jackkoenig
Copy link
Contributor

@jackkoenig Did you want to backport this?

Why not!

@jackkoenig jackkoenig merged commit 91d7baa into chipsalliance:master Jan 19, 2022
mergify bot pushed a commit that referenced this pull request Jan 19, 2022
(cherry picked from commit 91d7baa)
@mergify mergify bot added the Backported This PR has been backported label Jan 19, 2022
mergify bot added a commit that referenced this pull request Jan 19, 2022
(cherry picked from commit 91d7baa)

Co-authored-by: Kevin Laeufer <laeufer@cs.berkeley.edu>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants