From 752f425025d6ad36815ca181667aba4c9e8ea8fa Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 11 Sep 2022 13:05:13 -0400 Subject: [PATCH] Tests: Process/Semaphore/Mailbox testing (all fail until supported) --- src/V3Width.cpp | 2 +- test_regress/t/t_mailbox.out | 6 ++++-- test_regress/t/t_mailbox.v | 2 +- test_regress/t/t_mailbox_bad.out | 6 ++++++ test_regress/t/t_mailbox_bad.pl | 22 ++++++++++++++++++++++ test_regress/t/t_mailbox_bad.v | 17 +++++++++++++++++ test_regress/t/t_process.v | 8 ++++---- test_regress/t/t_process_bad.out | 10 ++++++++++ test_regress/t/t_process_bad.pl | 22 ++++++++++++++++++++++ test_regress/t/t_process_bad.v | 20 ++++++++++++++++++++ test_regress/t/t_semaphore.out | 3 +++ test_regress/t/t_semaphore.v | 8 +++++++- test_regress/t/t_semaphore_bad.out | 7 +++++++ test_regress/t/t_semaphore_bad.pl | 22 ++++++++++++++++++++++ test_regress/t/t_semaphore_bad.v | 17 +++++++++++++++++ 15 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 test_regress/t/t_mailbox_bad.out create mode 100755 test_regress/t/t_mailbox_bad.pl create mode 100644 test_regress/t/t_mailbox_bad.v create mode 100644 test_regress/t/t_process_bad.out create mode 100755 test_regress/t/t_process_bad.pl create mode 100644 test_regress/t/t_process_bad.v create mode 100644 test_regress/t/t_semaphore_bad.out create mode 100755 test_regress/t/t_semaphore_bad.pl create mode 100644 test_regress/t/t_semaphore_bad.v diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 9b85d5c12..7fdbf20f0 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -538,7 +538,7 @@ private: || VN_IS(vdtypep, DynArrayDType) // || VN_IS(vdtypep, QueueDType)) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Concatenation to form " - << vdtypep->prettyDTypeNameQ() << "data type"); + << vdtypep->prettyDTypeNameQ() << " data type"); } iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); diff --git a/test_regress/t/t_mailbox.out b/test_regress/t/t_mailbox.out index 5a7cc1581..4d5432212 100644 --- a/test_regress/t/t_mailbox.out +++ b/test_regress/t/t_mailbox.out @@ -1,4 +1,6 @@ %Error: t/t_mailbox.v:20:4: Can't find typedef: 'mailbox' - 20 | mailbox m; + 20 | mailbox #(int) m; | ^~~~~~~ -%Error: Exiting due to +%Error: Internal Error: t/t_mailbox.v:20:14: ../V3LinkDot.cpp:#: Pin not under instance? + 20 | mailbox #(int) m; + | ^~~ diff --git a/test_regress/t/t_mailbox.v b/test_regress/t/t_mailbox.v index 21eadf323..06ea1f834 100644 --- a/test_regress/t/t_mailbox.v +++ b/test_regress/t/t_mailbox.v @@ -17,7 +17,7 @@ // endclass module t(/*AUTOARG*/); - mailbox m; + mailbox #(int) m; int msg; int out; diff --git a/test_regress/t/t_mailbox_bad.out b/test_regress/t/t_mailbox_bad.out new file mode 100644 index 000000000..4d5432212 --- /dev/null +++ b/test_regress/t/t_mailbox_bad.out @@ -0,0 +1,6 @@ +%Error: t/t_mailbox.v:20:4: Can't find typedef: 'mailbox' + 20 | mailbox #(int) m; + | ^~~~~~~ +%Error: Internal Error: t/t_mailbox.v:20:14: ../V3LinkDot.cpp:#: Pin not under instance? + 20 | mailbox #(int) m; + | ^~~ diff --git a/test_regress/t/t_mailbox_bad.pl b/test_regress/t/t_mailbox_bad.pl new file mode 100755 index 000000000..8de551634 --- /dev/null +++ b/test_regress/t/t_mailbox_bad.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 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(vlt => 1); + +top_filename("t_mailbox.v"); + +lint( + verilator_flags2 => ["--xml-only"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_mailbox_bad.v b/test_regress/t/t_mailbox_bad.v new file mode 100644 index 000000000..a8bcb84fc --- /dev/null +++ b/test_regress/t/t_mailbox_bad.v @@ -0,0 +1,17 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2022 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/); + mailbox #(int) m; + + initial begin + m = new(4); + if (m.bad_method() != 0) $stop; + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule diff --git a/test_regress/t/t_process.v b/test_regress/t/t_process.v index f6ee27bac..0d495ab17 100644 --- a/test_regress/t/t_process.v +++ b/test_regress/t/t_process.v @@ -6,16 +6,16 @@ // Methods defined by IEEE: // class process; -// enum state { FINISHED, RUNNING, WAITING, SUSPENDED, KILLED }; +// enum state { FINISHED, RUNNING, WAITING, SUSPENDED, KILLED }; // UVM uses KILLED, FINISHED // static function process self(); // function state status(); // function void kill(); // task await(); // Warn as unsupported (no UVM library use) // function void suspend(); // Warn as unsupported (no UVM library use) // function void resume(); // Warn as unsupported (no UVM library use) -// function void srandom( int seed ); // Just ignore? -// function string get_randstate(); // Just ignore? -// function void set_randstate( string state ); // Just ignore? +// function void srandom( int seed ); // Operate on all proceses for now? +// function string get_randstate(); // Operate on all proceses for now? +// function void set_randstate( string state ); // Operate on all proceses for now? // endclass module t(/*AUTOARG*/); diff --git a/test_regress/t/t_process_bad.out b/test_regress/t/t_process_bad.out new file mode 100644 index 000000000..a4ada3778 --- /dev/null +++ b/test_regress/t/t_process_bad.out @@ -0,0 +1,10 @@ +%Error: t/t_process.v:22:4: Can't find typedef: 'process' + 22 | process p; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_process.v:26:20: Unsupported: 'process' + 26 | p = process::self(); + | ^~~~ + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest +%Error: Internal Error: t/t_process.v:26:11: ../V3LinkDot.cpp:#: Bad package link + 26 | p = process::self(); + | ^~~~~~~ diff --git a/test_regress/t/t_process_bad.pl b/test_regress/t/t_process_bad.pl new file mode 100755 index 000000000..7be24ae56 --- /dev/null +++ b/test_regress/t/t_process_bad.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 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(vlt => 1); + +top_filename("t_process.v"); + +lint( + verilator_flags2 => ["--xml-only"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_process_bad.v b/test_regress/t/t_process_bad.v new file mode 100644 index 000000000..d32afb72b --- /dev/null +++ b/test_regress/t/t_process_bad.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2022 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/); + process p; + + initial begin + if (p != null) $stop; + p = process::self(); + if (p.bad_method() != 0) $stop; + + p.bad_method_2(); + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule diff --git a/test_regress/t/t_semaphore.out b/test_regress/t/t_semaphore.out index 21345fd35..76d60e04d 100644 --- a/test_regress/t/t_semaphore.out +++ b/test_regress/t/t_semaphore.out @@ -1,4 +1,7 @@ %Error: t/t_semaphore.v:17:4: Can't find typedef: 'semaphore' 17 | semaphore s; | ^~~~~~~~~ +%Error: t/t_semaphore.v:18:4: Can't find typedef: 'semaphore' + 18 | semaphore s2; + | ^~~~~~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_semaphore.v b/test_regress/t/t_semaphore.v index 322a8541a..bc229ad75 100644 --- a/test_regress/t/t_semaphore.v +++ b/test_regress/t/t_semaphore.v @@ -13,8 +13,9 @@ // endclass module t(/*AUTOARG*/); - //From UVM: + // From UVM: semaphore s; + semaphore s2; int msg; initial begin @@ -30,6 +31,7 @@ module t(/*AUTOARG*/); s.put(2); if (s.try_get(2) <= 0) $stop; +`ifndef VERILATOR fork begin #10; // So later then get() starts below @@ -42,6 +44,10 @@ module t(/*AUTOARG*/); s.get(); end join +`endif + + s2 = new; + if (s2.try_get() != 0) $stop; $write("*-* All Finished *-*\n"); $finish; diff --git a/test_regress/t/t_semaphore_bad.out b/test_regress/t/t_semaphore_bad.out new file mode 100644 index 000000000..76d60e04d --- /dev/null +++ b/test_regress/t/t_semaphore_bad.out @@ -0,0 +1,7 @@ +%Error: t/t_semaphore.v:17:4: Can't find typedef: 'semaphore' + 17 | semaphore s; + | ^~~~~~~~~ +%Error: t/t_semaphore.v:18:4: Can't find typedef: 'semaphore' + 18 | semaphore s2; + | ^~~~~~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_semaphore_bad.pl b/test_regress/t/t_semaphore_bad.pl new file mode 100755 index 000000000..92483cce2 --- /dev/null +++ b/test_regress/t/t_semaphore_bad.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 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(vlt => 1); + +top_filename("t_semaphore.v"); + +lint( + verilator_flags2 => ["--xml-only"], + fails => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_semaphore_bad.v b/test_regress/t/t_semaphore_bad.v new file mode 100644 index 000000000..68e6ee38b --- /dev/null +++ b/test_regress/t/t_semaphore_bad.v @@ -0,0 +1,17 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2022 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/); + semaphore s; + + initial begin + s = new(4); + if (s.bad_method() != 0) $stop; + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule