Support %p of union with real

This commit is contained in:
Wilson Snyder 2023-01-28 21:41:50 -05:00
parent 248bd173d3
commit 7855a78a0f
4 changed files with 7 additions and 1 deletions

View File

@ -1793,6 +1793,7 @@ std::string VL_TO_STRING(CData lhs) { return VL_SFORMATF_NX("'h%0x", 8, lhs); }
std::string VL_TO_STRING(SData lhs) { return VL_SFORMATF_NX("'h%0x", 16, lhs); }
std::string VL_TO_STRING(IData lhs) { return VL_SFORMATF_NX("'h%0x", 32, lhs); }
std::string VL_TO_STRING(QData lhs) { return VL_SFORMATF_NX("'h%0x", 64, lhs); }
std::string VL_TO_STRING(double lhs) { return VL_SFORMATF_NX("%d", 64, lhs); }
std::string VL_TO_STRING_W(int words, const WDataInP obj) {
return VL_SFORMATF_NX("'h%0x", words * VL_EDATASIZE, obj);
}

View File

@ -45,6 +45,7 @@ extern std::string VL_TO_STRING(CData lhs);
extern std::string VL_TO_STRING(SData lhs);
extern std::string VL_TO_STRING(IData lhs);
extern std::string VL_TO_STRING(QData lhs);
extern std::string VL_TO_STRING(double lhs);
inline std::string VL_TO_STRING(const std::string& obj) { return "\"" + obj + "\""; }
extern std::string VL_TO_STRING_W(int words, const WDataInP obj);

View File

@ -4592,7 +4592,7 @@ private:
|| VN_IS(dtypep, UnpackArrayDType) //
|| VN_IS(dtypep, QueueDType)
|| (VN_IS(dtypep, NodeUOrStructDType)
&& !VN_AS(dtypep, StructDType)->packed())) {
&& !VN_AS(dtypep, NodeUOrStructDType)->packed())) {
added = true;
newFormat += "%@";
VNRelinker handle;

View File

@ -9,12 +9,16 @@ module t(/*AUTOARG*/);
union {
bit [7:0] val1;
bit [3:0] val2;
real r;
} u;
initial begin
u.val1 = 8'h7c;
if (u.val1 != 8'h7c) $stop;
if (u.val2 != 4'hc) $stop;
u.r = 1.24;
if (u.r != 1.24) $stop;
$display("%p", u);
$write("*-* All Finished *-*\n");
$finish;
end