diff --git a/test_regress/t/t_castdyn.out b/test_regress/t/t_castdyn.out index 2b0ae4bce..2e5c96249 100644 --- a/test_regress/t/t_castdyn.out +++ b/test_regress/t/t_castdyn.out @@ -2,28 +2,28 @@ : ... In instance t 28 | i = $cast(ao, a); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:32:7: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:33:7: Unsupported: $cast. Suggest try static cast. : ... In instance t - 32 | $cast(ao, a); + 33 | $cast(ao, a); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:35:11: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:36:11: Unsupported: $cast. Suggest try static cast. : ... In instance t - 35 | i = $cast(ao, 2.1 * 3.7); + 36 | i = $cast(ao, 2.1 * 3.7); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:39:11: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:40:11: Unsupported: $cast. Suggest try static cast. : ... In instance t - 39 | i = $cast(bo, null); + 40 | i = $cast(bo, null); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:45:11: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:46:11: Unsupported: $cast. Suggest try static cast. : ... In instance t - 45 | i = $cast(bao, b); + 46 | i = $cast(bao, b); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:51:11: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:52:11: Unsupported: $cast. Suggest try static cast. : ... In instance t - 51 | i = $cast(bbo, b); + 52 | i = $cast(bbo, b); | ^~~~~ -%Error-UNSUPPORTED: t/t_castdyn.v:58:11: Unsupported: $cast. Suggest try static cast. +%Error-UNSUPPORTED: t/t_castdyn.v:59:11: Unsupported: $cast. Suggest try static cast. : ... In instance t - 58 | i = $cast(bao, b); + 59 | i = $cast(bao, b); | ^~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_castdyn.v b/test_regress/t/t_castdyn.v index 123268419..4c8761f96 100644 --- a/test_regress/t/t_castdyn.v +++ b/test_regress/t/t_castdyn.v @@ -28,6 +28,7 @@ module t (/*AUTOARG*/); i = $cast(ao, a); if (i != 1) $stop; if (ao != 1234) $stop; + a = 12345; $cast(ao, a); if (ao != 12345) $stop; diff --git a/test_regress/t/t_castdyn_enum.out b/test_regress/t/t_castdyn_enum.out new file mode 100644 index 000000000..893b3046b --- /dev/null +++ b/test_regress/t/t_castdyn_enum.out @@ -0,0 +1,5 @@ +%Error-UNSUPPORTED: t/t_castdyn_enum.v:23:11: Unsupported: $cast. Suggest try static cast. + : ... In instance t + 23 | i = $cast(en, cyc); + | ^~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_castdyn_enum.pl b/test_regress/t/t_castdyn_enum.pl new file mode 100755 index 000000000..2ad4a887d --- /dev/null +++ b/test_regress/t/t_castdyn_enum.pl @@ -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 2020 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( + fails => $Self->{vlt_all}, + expect_filename => $Self->{golden_filename}, + ); + +execute( + check_finished => 1, + ) if !$Self->{vlt_all}; + +ok(1); +1; diff --git a/test_regress/t/t_castdyn_enum.v b/test_regress/t/t_castdyn_enum.v new file mode 100644 index 000000000..44cf50098 --- /dev/null +++ b/test_regress/t/t_castdyn_enum.v @@ -0,0 +1,54 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2020 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +typedef enum {TEN=10, + ELEVEN=11, + SIXTEEN=16} enum_t; + +module t (/*AUTOARG*/ + // Inputs + clk + ); + input clk; + + int i; + int cyc; + enum_t en; + + // Test loop + always @ (posedge clk) begin + i = $cast(en, cyc); +`ifdef TEST_VERBOSE + $write("[%0t] cyc==%0d i=%0d en=%0d\n",$time, cyc, i, en); +`endif + cyc <= cyc + 1; + if (cyc == 10) begin + if (i != 1) $stop; + if (en != TEN) $stop; + end + else if (cyc == 11) begin + if (i != 1) $stop; + if (en != ELEVEN) $stop; + end + else if (cyc == 12) begin + if (i != 0) $stop; + if (en != ELEVEN) $stop; + end + else if (cyc == 16) begin + if (i != 1) $stop; + if (en != SIXTEEN) $stop; + end + else if (cyc == 17) begin + if (i != 0) $stop; + if (en != SIXTEEN) $stop; + end + else if (cyc == 99) begin + $write("*-* All Finished *-*\n"); + $finish; + end + end + +endmodule