Fix constant string function assignment (#3945)
This commit is contained in:
parent
cf88700fc2
commit
d3cbb1e53f
|
|
@ -4543,7 +4543,7 @@ public:
|
|||
dtypeSetString();
|
||||
}
|
||||
ASTGEN_MEMBERS_AstCvtPackString;
|
||||
void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; }
|
||||
void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); }
|
||||
string emitVerilog() override { return "%f$_CAST(%l)"; }
|
||||
string emitC() override { return "VL_CVT_PACK_STR_N%lq(%lW, %li)"; }
|
||||
bool cleanOut() const override { return true; }
|
||||
|
|
|
|||
|
|
@ -2201,8 +2201,8 @@ V3Number& V3Number::opAssignNonXZ(const V3Number& lhs, bool ignoreXZ) {
|
|||
m_data.m_isNull = true;
|
||||
} else if (isString()) {
|
||||
if (VL_UNLIKELY(!lhs.isString())) {
|
||||
// Non-compatible types, erase value.
|
||||
m_data.str() = "";
|
||||
// Numbers can still be strings
|
||||
m_data.str() = lhs.toString();
|
||||
} else {
|
||||
m_data.str() = lhs.m_data.str();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2023 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(
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// DESCRIPTION: Verilator: constant string functions
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2023 by Wilson Snyder
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t ();
|
||||
|
||||
function automatic string foo_func();
|
||||
foo_func = "FOO";
|
||||
endfunction
|
||||
|
||||
localparam string the_foo = foo_func();
|
||||
|
||||
initial begin
|
||||
if (the_foo != "FOO") $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue