3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-17 11:25:48 +00:00

Add CONST_FLAG_UNSIZED

In order to support unsized constants being used as parameters, the `const` struct needs to know if it is unsized (so that the parameter can be used to set the size).
Add unsized flag to param value serialization and rtlil back-/front-end.
Add cell params to `tests/rtlil/everything.v`.
This commit is contained in:
Krystine Sherwin 2025-11-07 17:45:07 +13:00
parent e4c5900acd
commit 7302bf9a66
No known key found for this signature in database
5 changed files with 39 additions and 8 deletions

View file

@ -993,6 +993,8 @@ RTLIL::Const AstNode::asParaConst() const
RTLIL::Const val = asAttrConst();
if (is_signed)
val.flags |= RTLIL::CONST_FLAG_SIGNED;
if (is_unsized)
val.flags |= RTLIL::CONST_FLAG_UNSIZED;
return val;
}
@ -1766,7 +1768,10 @@ static std::string serialize_param_value(const RTLIL::Const &val) {
res.push_back('s');
if (val.flags & RTLIL::ConstFlags::CONST_FLAG_REAL)
res.push_back('r');
res += stringf("%d", GetSize(val));
if (val.flags & RTLIL::ConstFlags::CONST_FLAG_UNSIZED)
res.push_back('u');
else
res += stringf("%d", GetSize(val));
res.push_back('\'');
res.append(val.as_string("?"));
return res;
@ -1860,7 +1865,7 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dict<RTLIL::Id
} 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);
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);
rewritten.insert(it->first);
}