Fix VL_TO_STRING function for array of structs (#7912)
Signed-off-by: Kornel Uriasz <kuriasz@antmicro.com>
This commit is contained in:
parent
a21bd8a417
commit
9740203485
|
|
@ -6680,7 +6680,13 @@ class WidthVisitor final : public VNVisitor {
|
||||||
} else if (dtypep->isString()) {
|
} else if (dtypep->isString()) {
|
||||||
formatAttr = VFormatAttr::STRING;
|
formatAttr = VFormatAttr::STRING;
|
||||||
} else if (isFormatNonNumericArg(dtypep)) {
|
} else if (isFormatNonNumericArg(dtypep)) {
|
||||||
if (AstVarRef* const varRefp = VN_CAST(argp, VarRef)) {
|
const AstNodeExpr* formatTypeArgp = argp;
|
||||||
|
if (const AstCMethodHard* const cmethp = VN_CAST(formatTypeArgp, CMethodHard)) {
|
||||||
|
if (cmethp->method() == VCMethod::ARRAY_AT) formatTypeArgp = cmethp->fromp();
|
||||||
|
} else if (const AstArraySel* const arselp = VN_CAST(formatTypeArgp, ArraySel)) {
|
||||||
|
formatTypeArgp = arselp->fromp();
|
||||||
|
}
|
||||||
|
if (const AstVarRef* const varRefp = VN_CAST(formatTypeArgp, VarRef)) {
|
||||||
if (AstClassRefDType* const classRefp
|
if (AstClassRefDType* const classRefp
|
||||||
= VN_CAST(varRefp->dtypep(), ClassRefDType)) {
|
= VN_CAST(varRefp->dtypep(), ClassRefDType)) {
|
||||||
if (classRefp->classp()) {
|
if (classRefp->classp()) {
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,17 @@ module t (
|
||||||
int mem[2] = '{1, 2};
|
int mem[2] = '{1, 2};
|
||||||
string s;
|
string s;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
integer dummy;
|
||||||
|
} test_struct_t;
|
||||||
|
|
||||||
|
test_struct_t structs[1];
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
n = 4'b1100;
|
n = 4'b1100;
|
||||||
q = 64'h1234_5678_abcd_0123;
|
q = 64'h1234_5678_abcd_0123;
|
||||||
wide = "hello-there12345";
|
wide = "hello-there12345";
|
||||||
|
|
||||||
$sformat(str, "n=%b q=%d w=%s", n, q, wide);
|
$sformat(str, "n=%b q=%d w=%s", n, q, wide);
|
||||||
`checks(str, "n=1100 q= 1311768467750060323 w=hello-there12345");
|
`checks(str, "n=1100 q= 1311768467750060323 w=hello-there12345");
|
||||||
|
|
||||||
|
|
@ -135,6 +142,11 @@ module t (
|
||||||
|
|
||||||
$display(mem); // Implied %p
|
$display(mem); // Implied %p
|
||||||
|
|
||||||
|
structs[0].dummy = 0;
|
||||||
|
|
||||||
|
s = $sformatf("%p", structs[0]);
|
||||||
|
`checks(s, "'{dummy:'h0}");
|
||||||
|
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue