Skip to content

Add unit test covering narrow multiplier area estimates - #517

Open
samvratgowda wants to merge 1 commit into
UCSBarchlab:developmentfrom
samvratgowda:test-small-multiplier-area
Open

samvratgowda wants to merge 1 commit into
UCSBarchlab:developmentfrom
samvratgowda:test-small-multiplier-area

Conversation

@samvratgowda

Copy link
Copy Markdown

No description provided.

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.8%. Comparing base (44fcdf1) to head (2d382d1).

Additional details and impacted files
@@              Coverage Diff              @@
##           development    #517     +/-   ##
=============================================
+ Coverage         93.8%   93.8%   +0.1%     
=============================================
  Files               30      30             
  Lines             7178    7178             
=============================================
+ Hits              6729    6732      +3     
+ Misses             449     446      -3     

☔ View full report in Codecov by Harness.
📢 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.

@fdxmw fdxmw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for improving PyRTL's test coverage!

Comment thread tests/test_analysis.py
self.assertGreater(logic_area, 0)
areas.append(logic_area)

self.assertEqual(areas, sorted(areas))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this really tests the special-case code for small multipliers? I think this checks that smaller-bitwidth multipliers have smaller areas, which should be true for all multipliers. If you removed the special-case code entirely, I think this test would still pass?

It seems better to directly compare each area result against a constant expected value, with assertAlmostEqual

Comment thread tests/test_analysis.py
def test_area_est_small_multipliers(self):
"""Multipliers narrower than four bits use their own area estimates."""
areas = []
for width in (1, 2, 3, 4):

@fdxmw fdxmw Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See the comment on L111 first.

I think this is four tests masquerading as one test :) These kinds of tests are usually harder to debug, because when something goes wrong, you usually want to know what width was, but that does not show up in a stack trace.

You can work around this by moving the loop body into a new function, then writing four two-line tests that just call the new function. For example:

def test_area_est_bitwidth_1_multiplier(self):
    area = self.small_multiplier_area(bitwidth=1)
    self.assertAlmostEqual(area, ...)

This way, when a failure occurs, it should be clear what the problematic width was.

While you're here, consider renaming width to bitwidth, which is a little more specific.

This branch has not been deployed

No deployments
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.

2 participants