Tests: Cast enum test
This commit is contained in:
parent
77ec2dc875
commit
0818d88113
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue