update the warning message
This commit is contained in:
parent
be83c9751f
commit
6c40409f72
|
@ -6272,16 +6272,15 @@ class WidthVisitor final : public VNVisitor {
|
|||
}
|
||||
}
|
||||
if (VN_IS(exprp, MemberSel)) {
|
||||
argp->v3warn(CONSTRAINTIGN,
|
||||
"std::randomize ("
|
||||
<< exprp->prettyTypeName()
|
||||
<< ") is non-LRM compliant (IEEE 1800-2023 18.12)."
|
||||
<< "Args should be in current scope, "
|
||||
<< "but are supported in Verilator for compatibility.");
|
||||
// Non-standard usage: std::randomize() with class-scoped member
|
||||
// IEEE 1800-2023 (18.12) limits args to current scope variables.
|
||||
// Verilator accepts this for compatibility with other simulators.
|
||||
continue;
|
||||
} else if (VN_IS(exprp, VarRef)) {
|
||||
// Valid usage
|
||||
continue;
|
||||
} else {
|
||||
if (!VN_IS(exprp, VarRef)) {
|
||||
argp->v3error("Non-variable arguments for 'std::randomize()'.");
|
||||
}
|
||||
argp->v3error("Non-variable arguments for 'std::randomize()'.");
|
||||
}
|
||||
if (!argp) continue;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ module t_scope_std_randomize;
|
|||
old_addr = addr;
|
||||
old_data = data;
|
||||
old_ready = ready;
|
||||
success = randomize(addr, ready);
|
||||
success = randomize(addr, ready); // std::randomize
|
||||
if (success == 0) return 0;
|
||||
if (addr == old_addr && data != old_data && ready == old_ready) begin
|
||||
return 0;
|
||||
|
@ -57,7 +57,18 @@ module t_scope_std_randomize;
|
|||
std_randomize_class test;
|
||||
|
||||
initial begin
|
||||
bit ok;
|
||||
bit ok = 0;
|
||||
int success;
|
||||
|
||||
test = new();
|
||||
test.old_addr = test.addr;
|
||||
test.old_data = test.data;
|
||||
test.old_data_x_4 = test.data_x_4;
|
||||
success = std::randomize(test.addr, test.data);
|
||||
ok = (success == 1) && !(test.addr == test.old_addr || test.data == test.old_data) && test.data_x_4 == test.old_data_x_4;
|
||||
if (!ok) $stop;
|
||||
|
||||
ok = 0;
|
||||
ok = run();
|
||||
if (!ok) $stop;
|
||||
ok = 0;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
%Warning-CONSTRAINTIGN: t/t_std_randomize_bad2.v:48:38: std::randomize (MEMBERSEL 'addr') is non-LRM compliant (IEEE 1800-2023 18.12).Args should be in current scope, but are supported in Verilator for compatibility.
|
||||
: ... note: In instance 't_std_randomize_bad2'
|
||||
48 | success = std::randomize(test.addr, test.data);
|
||||
| ^
|
||||
... For warning description see https://verilator.org/warn/CONSTRAINTIGN?v=latest
|
||||
... Use "/* verilator lint_off CONSTRAINTIGN */" and lint_on around source to disable this message.
|
||||
%Warning-CONSTRAINTIGN: t/t_std_randomize_bad2.v:48:49: std::randomize (MEMBERSEL 'data') is non-LRM compliant (IEEE 1800-2023 18.12).Args should be in current scope, but are supported in Verilator for compatibility.
|
||||
: ... note: In instance 't_std_randomize_bad2'
|
||||
48 | success = std::randomize(test.addr, test.data);
|
||||
| ^
|
||||
%Error: Exiting due to
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2025 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('linter')
|
||||
|
||||
test.lint(fails=True, expect_filename=test.golden_filename)
|
||||
|
||||
test.passes()
|
|
@ -1,58 +0,0 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2025 by PlanV GmbH.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
class std_randomize_class;
|
||||
|
||||
rand bit [7:0] addr;
|
||||
rand bit [31:0] data;
|
||||
rand bit [63:0] data_x_4;
|
||||
|
||||
bit [7:0] old_addr;
|
||||
bit [31:0] old_data;
|
||||
bit [63:0] old_data_x_4;
|
||||
|
||||
function int std_randomize();
|
||||
bit valid;
|
||||
int success;
|
||||
|
||||
old_addr = addr;
|
||||
old_data = data;
|
||||
old_data_x_4 = data_x_4;
|
||||
|
||||
success = std::randomize(addr, data);
|
||||
|
||||
valid = (success == 1) && !(addr == old_addr || data == old_data) && data_x_4 == old_data_x_4;
|
||||
if (!valid) return 0;
|
||||
return 1;
|
||||
endfunction
|
||||
|
||||
endclass
|
||||
|
||||
|
||||
module t_std_randomize_bad2;
|
||||
|
||||
bit valid;
|
||||
int success;
|
||||
std_randomize_class test;
|
||||
|
||||
initial begin
|
||||
|
||||
test = new();
|
||||
|
||||
test.old_addr = test.addr;
|
||||
test.old_data = test.data;
|
||||
test.old_data_x_4 = test.data_x_4;
|
||||
success = std::randomize(test.addr, test.data);
|
||||
valid = (success == 1) && !(test.addr == test.old_addr || test.data == test.old_data) && test.data_x_4 == test.old_data_x_4;
|
||||
|
||||
// valid = test.std_randomize();
|
||||
|
||||
if (!valid) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule : t_std_randomize_bad2
|
Loading…
Reference in New Issue