Add UNSUPPORTED on $sampled in sensitivity list (#7093)

This commit is contained in:
Ryszard Rozak 2026-02-19 08:36:21 +01:00 committed by GitHub
parent 702d6ede09
commit f843780aad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 0 deletions

View File

@ -382,6 +382,14 @@ private:
nodep->v3error("Event controls cannot be used in "
"synchronous drives (IEEE 1800-2023 14.16)");
}
const AstSampled* sampledp;
if (nodep->exists([&sampledp](const AstSampled* const sp) {
sampledp = sp;
return true;
})) {
sampledp->v3warn(E_UNSUPPORTED, "Unsupported: $sampled inside sensitivity list");
}
}
void visit(AstNodeVarRef* nodep) override {
UINFO(8, " -varref: " << nodep);

View File

@ -0,0 +1,6 @@
%Error-UNSUPPORTED: t/t_sampled_sensitivity.v:14:20: Unsupported: $sampled inside sensitivity list
: ... note: In instance 't'
14 | always @(posedge $sampled(clk)) begin
| ^~~~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: Exiting due to

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# 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-FileCopyrightText: 2024 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('vlt')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,18 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Antmicro
// SPDX-License-Identifier: CC0-1.0
module t ( /*AUTOARG*/
// Inputs
clk
);
input clk;
always @(posedge $sampled(clk)) begin
$write("*-* All Finished *-*\n");
$finish;
end
endmodule