Skip to content

Fix HLS MVAU/VVAU threshold datatype minimization#1561

Merged
auphelia merged 1 commit intodevfrom
fix/mvau_thresh_minimization
Apr 15, 2026
Merged

Fix HLS MVAU/VVAU threshold datatype minimization#1561
auphelia merged 1 commit intodevfrom
fix/mvau_thresh_minimization

Conversation

@auphelia
Copy link
Copy Markdown
Collaborator

This PR fixes a bug where the threshold datatype could be minimized narrower than the accumulator datatype in HLS MVAU and VVAU, causing incorrect results when accumulator values exceed the threshold type's range.

The HLS implementation uses the threshold datatype for comparisons. When MinimizeWeightBitWidth() reduced threshold dtype to a narrower type than the accumulator (e.g., INT8 thresholds vs INT14 accumulator), accumulator values were truncated during comparison, producing wrong outputs.

Changes

  • matrixvectoractivation.py / vectorvectoractivation.py: Removed threshold minimization logic from base classes (RTL variants don't support embedded thresholds)
  • matrixvectoractivation_hls.py / vectorvectoractivation_hls.py: Added minimize_weight_bit_width() override that:
  • Minimizes threshold dtype based on actual values
  • Ensures threshold bitwidth ≥ accumulator bitwidth to prevent truncation
  • test_fpgadataflow_mvau.py: Added test case with small thresholds and extreme inputs to verify the fix

@auphelia auphelia merged commit 122f633 into dev Apr 15, 2026
2 checks passed
@auphelia auphelia deleted the fix/mvau_thresh_minimization branch April 15, 2026 14:31
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.

1 participant