Skip to content

Commit

Permalink
Tests: Don't use indices in check_rand (verilator#5561)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak authored Oct 25, 2024
1 parent 81ee89d commit 87ac611
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 18 deletions.
7 changes: 5 additions & 2 deletions test_regress/t/t_constraint_dist.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
if (!bit'(cl.randomize())) $stop; \
prev_result = longint'(field); \
if (!(cond)) $stop; \
repeat(9) begin \
longint result; \
if (!bit'(cl.randomize())) $stop; \
result = longint'(field); \
if (!(cond)) $stop; \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
7 changes: 5 additions & 2 deletions test_regress/t/t_constraint_foreach.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
if (!bit'(cl.randomize())) $stop; \
prev_result = longint'(field); \
if (!(cond)) $stop; \
repeat(9) begin \
longint result; \
if (!bit'(cl.randomize())) $stop; \
result = longint'(field); \
if (!(cond)) $stop; \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
7 changes: 5 additions & 2 deletions test_regress/t/t_constraint_inheritance.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
if (!bit'(cl.randomize())) $stop; \
prev_result = longint'(field); \
if (!(cond)) $stop; \
repeat(9) begin \
longint result; \
if (!bit'(cl.randomize())) $stop; \
result = longint'(field); \
if (!(cond)) $stop; \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
7 changes: 5 additions & 2 deletions test_regress/t/t_constraint_inheritance_with.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
if (!bit'(cl.randomize() with { constr; })) $stop; \
prev_result = longint'(field); \
if (!(cond)) $stop; \
repeat(9) begin \
longint result; \
if (!bit'(cl.randomize() with { constr; })) $stop; \
result = longint'(field); \
if (!(cond)) $stop; \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
6 changes: 4 additions & 2 deletions test_regress/t/t_randomize_array.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
void'(cl.randomize()); \
prev_result = longint'(field); \
repeat(9) begin \
longint result; \
void'(cl.randomize()); \
result = longint'(field); \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
6 changes: 4 additions & 2 deletions test_regress/t/t_randomize_array_constraints.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
void'(cl.randomize()); \
prev_result = longint'(field); \
repeat(9) begin \
longint result; \
void'(cl.randomize()); \
result = longint'(field); \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
6 changes: 4 additions & 2 deletions test_regress/t/t_randomize_method.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
void'(cl.randomize()); \
prev_result = longint'(field); \
repeat(9) begin \
longint result; \
void'(cl.randomize()); \
result = longint'(field); \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
6 changes: 4 additions & 2 deletions test_regress/t/t_randomize_method_with.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
void'(cl.randomize()); \
prev_result = longint'(field); \
repeat(9) begin \
longint result; \
void'(cl.randomize()); \
result = longint'(field); \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down
7 changes: 5 additions & 2 deletions test_regress/t/t_randomize_queue_constraints.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
begin \
longint prev_result; \
int ok = 0; \
for (int i = 0; i < 10; i++) begin \
if (!bit'(cl.randomize())) $stop; \
prev_result = longint'(field); \
if (!(cond)) $stop; \
repeat(9) begin \
longint result; \
if (!bit'(cl.randomize())) $stop; \
result = longint'(field); \
if (!(cond)) $stop; \
if (i > 0 && result != prev_result) ok = 1; \
if (result != prev_result) ok = 1; \
prev_result = result; \
end \
if (ok != 1) $stop; \
Expand Down

0 comments on commit 87ac611

Please sign in to comment.