Skip to content

Conversation

@arvindajaybharadwaj
Copy link

This PR adds Posit number format support to PyRTL, including configurable nbits and es and basic arithmetic operations (addition, multiplication, and matmul).

  • Implements Posit representation, normalization, and rounding.
  • Added helper functions for Posit operations.
  • Added unit tests to verify correctness against reference Posit operations.
  • Offers better precision and dynamic range, particularly for low-bitwidth hardware designs.

@fdxmw
Copy link
Member

fdxmw commented Oct 6, 2025

Thank you for submitting this pull request! It looks very interesting, but I am unfamiliar with Posits, and I will be away next week, so it will take me some time to review these commits.

In the meantime, the pull request checks point to some code style issues that will need to be addressed. Don't worry about any reported issues in code that you haven't changed in your pull request, I will look into that separately. I don't yet know what's happening there, ruff does not seem to report these issues on my computer.

Thanks again, and thank you for your patience while I review this pull request!

@fdxmw fdxmw self-assigned this Oct 6, 2025
@fdxmw
Copy link
Member

fdxmw commented Oct 6, 2025

I don't yet know what's happening there, ruff does not seem to report these issues on my computer.

Ah, tox was caching an older version of ruff, and I can reproduce the ruff check failures with tox -r. I'll put together a commit to fix the existing failures.

@fdxmw
Copy link
Member

fdxmw commented Oct 6, 2025

Commit 8c706f6 should fix the pre-existing code style issues, so you should update your fork and rebase to see only the code style issues in your PR.

Sorry for the noise, I will try to improve pyrtl's testing workflows so this doesn't happen in the future.

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 94.36202% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.1%. Comparing base (8c706f6) to head (fab8280).

Files with missing lines Patch % Lines
pyrtl/positutils.py 90.8% 13 Missing ⚠️
pyrtl/rtllib/positmatmul.py 75.0% 6 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           development    #473     +/-   ##
=============================================
+ Coverage         91.0%   91.1%   +0.1%     
=============================================
  Files               25      29      +4     
  Lines             7091    7384    +293     
=============================================
+ Hits              6450    6722    +272     
- Misses             641     662     +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timsherwood
Copy link
Contributor

Thank you for the PR arvindajaybharadwaj, it is really cool to learn about Posits -- I was not aware of this format. I had a chance to read through your PR and we are open in theory bringing this into pyrtl, it could be a nice addition to rtllib, but there is a bit of work that would be required here to finalize the test and bring it into the preferred pyrtl style of python. If you are interested to do this work to see it in pyrtl let us know and we can start scoping it out in more detail. If not, we are happy to link to your project somewhere else in case anyone is trying to find a library on this. Thanks for working on cool hardware in python with us!

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.

5 participants