forked from verilator/verilator
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support side effects of form
variable[index_function()]++
.
- Loading branch information
Showing
9 changed files
with
172 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('simulator_st') | ||
|
||
test.compile() | ||
|
||
test.execute() | ||
|
||
test.passes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2025 by Wilson Snyder. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
`define stop $stop | ||
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d (%s !== %s)\n", `__FILE__,`__LINE__, (gotv), (expv), `"gotv`", `"expv`"); `stop; end while(0); | ||
|
||
class Cls; | ||
int m_index; | ||
|
||
function automatic int get_index(); | ||
int rtn; | ||
rtn = m_index; | ||
++m_index; | ||
`ifdef VERILATOR | ||
return $c(rtn); // Avoid optimizations | ||
`else | ||
return rtn; | ||
`endif | ||
endfunction | ||
endclass | ||
|
||
module t (/*AUTOARG*/); | ||
|
||
Cls cls; | ||
int array[10]; | ||
|
||
initial begin | ||
cls = new; | ||
// Common UVM construct 'id_cnt[get_id()]++;' | ||
// Properly avoid/handle SIDEEFF warnings | ||
cls.m_index = 5; | ||
array[5] = 50; | ||
array[6] = 60; | ||
array[7] = 70; | ||
array[8] = 80; | ||
|
||
array[cls.get_index()]++; | ||
`checkd(array[5], 51); | ||
array[cls.get_index()]++; | ||
`checkd(array[6], 61); | ||
|
||
++array[cls.get_index()]; | ||
`checkd(array[7], 71); | ||
++array[cls.get_index()]; | ||
`checkd(array[8], 81); | ||
|
||
$write("*-* All Finished *-*\n"); | ||
$finish; | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
%Warning-SIDEEFFECT: t/t_stmt_incr_unsup.v:17:12: Expression side effect may be mishandled | ||
%Warning-SIDEEFFECT: t/t_stmt_incr_unsup.v:17:31: Expression side effect may be mishandled | ||
: ... Suggest use a temporary variable in place of this expression | ||
17 | arr[postincrement_i()]++; | ||
| ^ | ||
17 | arr[postincrement_i()][postincrement_i()]++; | ||
| ^ | ||
... For warning description see https://verilator.org/warn/SIDEEFFECT?v=latest | ||
... Use "/* verilator lint_off SIDEEFFECT */" and lint_on around source to disable this message. | ||
%Warning-SIDEEFFECT: t/t_stmt_incr_unsup.v:17:13: Expression side effect may be mishandled | ||
: ... note: In instance 't' | ||
: ... Suggest use a temporary variable in place of this expression | ||
17 | arr[postincrement_i()]++; | ||
17 | arr[postincrement_i()][postincrement_i()]++; | ||
| ^~~~~~~~~~~~~~~ | ||
%Warning-SIDEEFFECT: t/t_stmt_incr_unsup.v:17:32: Expression side effect may be mishandled | ||
: ... note: In instance 't' | ||
: ... Suggest use a temporary variable in place of this expression | ||
17 | arr[postincrement_i()][postincrement_i()]++; | ||
| ^~~~~~~~~~~~~~~ | ||
%Error: Exiting due to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters