Tests: Add t_interface_localparam_unsup (#3857 partial) (#3858)

This commit is contained in:
Justin Thiel 2023-09-26 20:35:23 -04:00 committed by Wilson Snyder
parent 72b4a74245
commit a948be184c
4 changed files with 80 additions and 0 deletions

View File

@ -88,6 +88,7 @@ Josh Redford
Julian Daube
Julie Schwartz
Julien Margetts
Justin Thiel
Kaleb Barrett
Kamil Rakoczy
Kanad Kanhere

View File

@ -0,0 +1,5 @@
*-* All Finished *-*
top.t.intf: symbolsPerBeat 16, symbolsPerBeatDivBy2 8, mismatch 0
top.t.theCore.core_intf: symbolsPerBeat 64, symbolsPerBeatDivBy2 8, mismatch 1
%Error: t/t_interface_localparam_unsup.v:23: Verilog $stop
Aborting...

View File

@ -0,0 +1,23 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2023 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
scenarios(simulator => 1);
compile(
);
execute(
check_finished => 1,
fails => $Self->{vlt_all},
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,51 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2023 by Justin Thiel.
// SPDX-License-Identifier: CC0-1.0
interface SimpleIntf
#(
parameter int symbolsPerBeat = 16
)
();
// This value is calculated incorrectly for other instances of
// this interface when it is accessed via the HDL for any other
// instance of this interface
localparam int symbolsPerBeatDivBy2 = symbolsPerBeat/2;
localparam bit mismatch = (symbolsPerBeat != (2*symbolsPerBeatDivBy2) );
initial begin
$write("%m: symbolsPerBeat %0d, symbolsPerBeatDivBy2 %0d, mismatch %0d\n",
symbolsPerBeat, symbolsPerBeatDivBy2, mismatch);
if (mismatch) $stop;
end
endinterface
module Core(
SimpleIntf intf
);
// NOTE: When this line is commented out the test will pass
localparam intf_symbolsPerBeatDivBy2 = intf.symbolsPerBeatDivBy2;
localparam int core_intf_symbolsPerBeat = 64;
SimpleIntf #(.symbolsPerBeat(core_intf_symbolsPerBeat)) core_intf ();
endmodule
module t();
SimpleIntf intf();
Core theCore (.intf);
initial begin
$write("*-* All Finished *-*\n");
$finish;
end
endmodule