From ad912bc787fb4d4b0f4a46f33a30d988dc7ddca5 Mon Sep 17 00:00:00 2001 From: nella Date: Tue, 12 May 2026 12:01:11 +0200 Subject: [PATCH] Preserve param signedness across overrides. --- frontends/ast/ast.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index c190bc7d4..979ff9f1e 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1875,8 +1875,13 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dictchildren[0]->realvalue = std::stod(it->second.decode_string()); } else if ((it->second.flags & RTLIL::CONST_FLAG_STRING) != 0) child->children[0] = AstNode::mkconst_str(loc, it->second.decode_string()); - else - child->children[0] = AstNode::mkconst_bits(loc, it->second.to_bits(), (it->second.flags & RTLIL::CONST_FLAG_SIGNED) != 0, (it->second.flags & RTLIL::CONST_FLAG_UNSIZED) != 0); + else { + bool is_signed = child->is_signed; + if (!is_signed && !child->children.empty() && child->children[0] && child->children[0]->type == AST_CONSTANT) + is_signed = child->children[0]->is_signed; + is_signed = is_signed || ((it->second.flags & RTLIL::CONST_FLAG_SIGNED) != 0); + child->children[0] = AstNode::mkconst_bits(loc, it->second.to_bits(), is_signed, (it->second.flags & RTLIL::CONST_FLAG_UNSIZED) != 0); + } rewritten.insert(it->first); }