Skip to content

Commit

Permalink
Fix infinite loop in std_cache_pkg::one_hot_to_bin (#1302)
Browse files Browse the repository at this point in the history
Use int unsigned for loop variable i to avoid wrapping before loop exit
condition is met.

Resolves bug #1301 (#1301)

Co-authored-by: Max Bjurling <[email protected]>
  • Loading branch information
maxbjurling and maxbjurling authored Jul 12, 2023
1 parent 513bb91 commit 622409a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/include/std_cache_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ package std_cache_pkg;
function automatic logic [$clog2(ariane_pkg::DCACHE_SET_ASSOC)-1:0] one_hot_to_bin (
input logic [ariane_pkg::DCACHE_SET_ASSOC-1:0] in
);
for (logic [$clog2(ariane_pkg::DCACHE_SET_ASSOC)-1:0] i = 0; i < ariane_pkg::DCACHE_SET_ASSOC; i++) begin
for (int unsigned i = 0; i < ariane_pkg::DCACHE_SET_ASSOC; i++) begin
if (in[i])
return i;
end
Expand Down

0 comments on commit 622409a

Please sign in to comment.