mirror of
https://github.com/verilator/verilator.git
synced 2025-01-06 06:37:45 +00:00
Tests: Add unsupported test for interface typedef (#2783)
This commit is contained in:
parent
64887bd92d
commit
2b2fe13e79
@ -2209,7 +2209,7 @@ type_declaration<nodep>: // ==IEEE: type_declaration
|
||||
AstNodeDType* dtp = GRAMMARP->createArray(refp, $4, true);
|
||||
$$ = GRAMMARP->createTypedef($<fl>5, *$5, $7, dtp, $6); }
|
||||
// //
|
||||
| yTYPEDEF id/*interface*/ '.' idAny/*type*/ idAny/*type*/ ';'
|
||||
| yTYPEDEF id/*interface*/ '.' idAny/*type*/ idAny/*type*/ dtypeAttrListE ';'
|
||||
{ $$ = nullptr; BBUNSUP($1, "Unsupported: SystemVerilog 2005 typedef in this context"); }
|
||||
// // Allow redeclaring same typedef again
|
||||
// // Alternative is use of idAny below, but this will cause conflicts with ablve
|
||||
|
7
test_regress/t/t_interface_typedef.out
Normal file
7
test_regress/t/t_interface_typedef.out
Normal file
@ -0,0 +1,7 @@
|
||||
%Error-UNSUPPORTED: t/t_interface_typedef.v:46:4: Unsupported: SystemVerilog 2005 typedef in this context
|
||||
46 | typedef ifc_if.struct_t struct_t;
|
||||
| ^~~~~~~
|
||||
%Error: t/t_interface_typedef.v:51:16: syntax error, unexpected IDENTIFIER
|
||||
51 | struct_t substruct;
|
||||
| ^~~~~~~~~
|
||||
%Error: Exiting due to
|
23
test_regress/t/t_interface_typedef.pl
Executable file
23
test_regress/t/t_interface_typedef.pl
Executable 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 2003-2009 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;
|
56
test_regress/t/t_interface_typedef.v
Normal file
56
test_regress/t/t_interface_typedef.v
Normal file
@ -0,0 +1,56 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2021 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
`define stop $stop
|
||||
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0)
|
||||
|
||||
interface ifc
|
||||
#(
|
||||
parameter int unsigned WIDTH
|
||||
) ();
|
||||
typedef struct {
|
||||
logic [WIDTH-1:0] data;
|
||||
} struct_t;
|
||||
endinterface
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
input clk;
|
||||
|
||||
ifc #(10) i_ifc10();
|
||||
ifc #(20) i_ifc20();
|
||||
|
||||
sub #(10) u_sub10 (.clk, .ifc_if(i_ifc10));
|
||||
sub #(20) u_sub20 (.clk, .ifc_if(i_ifc20));
|
||||
|
||||
integer cyc = 1;
|
||||
always @ (posedge clk) begin
|
||||
cyc <= cyc + 1;
|
||||
if (cyc==20) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
||||
module sub #(
|
||||
parameter int EXP_WIDTH)
|
||||
(
|
||||
input logic clk,
|
||||
ifc ifc_if);
|
||||
typedef ifc_if.struct_t struct_t;
|
||||
|
||||
wire [EXP_WIDTH-1:0] expval = '1;
|
||||
|
||||
initial begin
|
||||
struct_t substruct;
|
||||
substruct.data = '1;
|
||||
`checkh(substruct.data, expval);
|
||||
end
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user