Tests: Add nettype test

This commit is contained in:
Wilson Snyder 2023-03-02 20:29:42 -05:00
parent dd917d50eb
commit 1e28387541
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,17 @@
%Error-UNSUPPORTED: t/t_nettype.v:24:4: Unsupported: SystemVerilog 2012 reserved word not implemented: 'nettype'
24 | nettype real real1_n with Pkg::resolver;
| ^~~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: t/t_nettype.v:24:25: syntax error, unexpected with, expecting ',' or ';'
24 | nettype real real1_n with Pkg::resolver;
| ^~~~
%Error-UNSUPPORTED: t/t_nettype.v:28:4: Unsupported: SystemVerilog 2012 reserved word not implemented: 'nettype'
28 | nettype real real2_n with local_resolver;
| ^~~~~~~
%Error: t/t_nettype.v:28:25: syntax error, unexpected with, expecting ',' or ';'
28 | nettype real real2_n with local_resolver;
| ^~~~
%Error-UNSUPPORTED: t/t_nettype.v:33:4: Unsupported: SystemVerilog 2012 reserved word not implemented: 'nettype'
33 | nettype real2_n real3_n;
| ^~~~~~~
%Error: Exiting due to

19
test_regress/t/t_nettype.pl Executable file
View File

@ -0,0 +1,19 @@
#!/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(linter => 1);
lint(
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,50 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
package Pkg;
real last_resolve;
function automatic real resolver(input real drivers[]);
resolver = 0.0;
foreach (drivers[i]) resolver += drivers[i];
last_resolve = resolver;
endfunction
endpackage
module t(/*AUTOARG*/);
function automatic real local_resolver(input real drivers[]);
local_resolver = 0.0;
foreach (drivers[i]) local_resolver += drivers[i];
endfunction
nettype real real1_n with Pkg::resolver;
real1_n real1;
assign real1 = 1.23;
nettype real real2_n with local_resolver;
real2_n real2;
assign real2 = 1.23;
// Create alias using new name
nettype real2_n real3_n;
real3_n real3;
assign real3 = 1.23;
// TODO when implement net types need to check multiple driver cases, across
// submodules
initial begin
#10;
if (real1 != 1.23) $stop;
if (real2 != 1.23) $stop;
if (real3 != 1.23) $stop;
if (Pkg::last_resolve != 1.23) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule