mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Fix enum name method (#5563)
This commit is contained in:
parent
292c2e289e
commit
ec2eae607a
@ -209,6 +209,12 @@ protected:
|
||||
m_packed = (numericUnpack != VSigning::NOSIGN);
|
||||
numeric(VSigning::fromBool(numericUnpack.isSigned()));
|
||||
}
|
||||
AstNodeUOrStructDType(const AstNodeUOrStructDType& other)
|
||||
: AstNodeDType(other)
|
||||
, m_name(other.m_name)
|
||||
, m_uniqueNum(uniqueNumInc())
|
||||
, m_packed(other.m_packed)
|
||||
, m_isFourstate(other.m_isFourstate) {}
|
||||
|
||||
public:
|
||||
ASTGEN_MEMBERS_AstNodeUOrStructDType;
|
||||
@ -664,6 +670,11 @@ public:
|
||||
childDTypep(dtp); // Only for parser
|
||||
dtypep(nullptr); // V3Width will resolve
|
||||
}
|
||||
AstDefImplicitDType(const AstDefImplicitDType& other)
|
||||
: AstNodeDType(other)
|
||||
, m_name(other.m_name)
|
||||
, m_containerp(other.m_containerp)
|
||||
, m_uniqueNum(uniqueNumInc()) {}
|
||||
ASTGEN_MEMBERS_AstDefImplicitDType;
|
||||
int uniqueNum() const { return m_uniqueNum; }
|
||||
bool same(const AstNode* samep) const override {
|
||||
@ -793,6 +804,10 @@ public:
|
||||
dtypep(nullptr); // V3Width will resolve
|
||||
widthFromSub(subDTypep());
|
||||
}
|
||||
AstEnumDType(const AstEnumDType& other)
|
||||
: AstNodeDType(other)
|
||||
, m_name(other.m_name)
|
||||
, m_uniqueNum(uniqueNumInc()) {}
|
||||
ASTGEN_MEMBERS_AstEnumDType;
|
||||
|
||||
const char* broken() const override;
|
||||
|
18
test_regress/t/t_enum_name_sformatf.py
Executable file
18
test_regress/t/t_enum_name_sformatf.py
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2024 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
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('simulator')
|
||||
|
||||
test.compile()
|
||||
|
||||
test.execute()
|
||||
|
||||
test.passes()
|
35
test_regress/t/t_enum_name_sformatf.v
Normal file
35
test_regress/t/t_enum_name_sformatf.v
Normal file
@ -0,0 +1,35 @@
|
||||
// DESCRIPTION: Verilator: Demonstrate struct literal param assignment problem
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2024 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module sub #(parameter int param_a, parameter bit [1:0] enum_param = '0) ();
|
||||
typedef enum logic [1:0] {
|
||||
FOO = enum_param,
|
||||
BAR,
|
||||
BAZ
|
||||
} enum_t;
|
||||
enum_t the_enum = enum_t'(1);
|
||||
|
||||
initial $display("%s", the_enum.name());
|
||||
endmodule
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
// finish report
|
||||
always @ (posedge clk) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
sub #(.param_a(1)) the_sub1();
|
||||
sub #(.param_a(2)) the_sub2();
|
||||
sub #(.param_a(2), .enum_param(2'd1)) the_sub3();
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user