Fix array index out-of-bounds risk in comb_repeater.sv
by restructuring generate
blocks
#5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a compile-time array index out-of-bounds risk in
comb_repeater.sv
by moving conditionals outsidealways_comb
blocks within thegenerate
loop.Problem
The original code uses
always_comb
with internalif-else
to select betweenin
ands2[i+1]
fors1[i]
:While functionally correct (due to the
if-else
guard), this structure forces the compiler to statically checks2[i+1]
even wheni==LENGTH-1
, which could theoretically trigger tool errors or synthesis issues.Fix
Restructure to prune invalid paths at compile time by moving conditionals into the
generate
block:Impact
- Safer compilation: Eliminates any tool-specific warnings about potential OOB accesses.
- Better synthesis: Tools will not see unused array indices (e.g.,
s2[LENGTH]
).Additional Context
This follows the same pattern as the fix for
adder_tree.sv
(PR #4), where generate-level conditionals are safer thanalways_comb
-internal branching.