Fix non-constant replication in concats (#5171)

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
This commit is contained in:
Arkadiusz Kozdra 2024-06-10 17:21:43 +02:00 committed by GitHub
parent d4c3e35f97
commit e9f59e44a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 853 additions and 833 deletions

View File

@ -581,8 +581,13 @@ class WidthVisitor final : public VNVisitor {
<< vdtypep->prettyDTypeNameQ() << " data type");
}
iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH);
iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH);
if (vdtypep && vdtypep->isString()) {
iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH);
iterateCheckString(nodep, "RHS", nodep->rhsp(), BOTH);
} else {
iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH);
iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH);
}
nodep->dtypeSetLogicUnsized(nodep->lhsp()->width() + nodep->rhsp()->width(),
nodep->lhsp()->widthMin() + nodep->rhsp()->widthMin(),
VSigning::UNSIGNED);
@ -773,7 +778,12 @@ class WidthVisitor final : public VNVisitor {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Replication to form "
<< vdtypep->prettyDTypeNameQ() << " data type");
}
iterateCheckSizedSelf(nodep, "LHS", nodep->srcp(), SELF, BOTH);
if (vdtypep && vdtypep->isString()) {
iterateCheckString(nodep, "LHS", nodep->srcp(), BOTH);
} else {
iterateCheckSizedSelf(nodep, "LHS", nodep->srcp(), SELF, BOTH);
}
if ((vdtypep && vdtypep->isString()) || nodep->srcp()->isString()) {
AstNode* const newp
= new AstReplicateN{nodep->fileline(), nodep->srcp()->unlinkFrBack(),
@ -6731,11 +6741,11 @@ class WidthVisitor final : public VNVisitor {
(void)underp; // cppcheck
}
void iterateCheckString(AstNode* nodep, const char* side, AstNode* underp, Stage stage) {
AstNodeDType* const expDTypep = nodep->findStringDType();
if (stage & PRELIM) {
underp = userIterateSubtreeReturnEdits(underp, WidthVP{SELF, PRELIM}.p());
underp = userIterateSubtreeReturnEdits(underp, WidthVP{expDTypep, PRELIM}.p());
}
if (stage & FINAL) {
AstNodeDType* const expDTypep = nodep->findStringDType();
underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP);
}
(void)underp; // cppcheck

File diff suppressed because it is too large Load Diff

View File

@ -24,12 +24,12 @@ module t(/*AUTOARG*/
integer cyc = 0;
string s;
string s, s2;
// Test loop
always @ (posedge clk) begin
cyc <= cyc + 1;
s = {cyc{"*"}};
s = {s2, {cyc{"*"}}};
if (cyc != s.len()) $stop;
if (cyc == 0 && s != "") $stop;
if (cyc == 1 && s != "*") $stop;

View File

@ -541,20 +541,22 @@
</begin>
<begin>
<assign loc="d,53,14,53,15" dtype_id="10">
<concatn loc="d,53,20,53,21" dtype_id="10">
<varref loc="d,53,17,53,20" name="t.all" dtype_id="10"/>
<cvtpackstring loc="d,53,24,53,28" dtype_id="10">
<arraysel loc="d,53,24,53,28" dtype_id="10">
<varref loc="d,17,12,17,16" name="__Venumtab_enum_name2" dtype_id="16"/>
<and loc="d,53,24,53,28" dtype_id="13">
<const loc="d,53,24,53,28" name="32&apos;h7" dtype_id="14"/>
<ccast loc="d,53,22,53,23" dtype_id="13">
<varref loc="d,53,22,53,23" name="t.unnamedblk1.e" dtype_id="13"/>
</ccast>
</and>
</arraysel>
</cvtpackstring>
</concatn>
<cvtpackstring loc="d,53,20,53,21" dtype_id="10">
<concatn loc="d,53,20,53,21" dtype_id="10">
<varref loc="d,53,17,53,20" name="t.all" dtype_id="10"/>
<cvtpackstring loc="d,53,24,53,28" dtype_id="10">
<arraysel loc="d,53,24,53,28" dtype_id="10">
<varref loc="d,17,12,17,16" name="__Venumtab_enum_name2" dtype_id="16"/>
<and loc="d,53,24,53,28" dtype_id="13">
<const loc="d,53,24,53,28" name="32&apos;h7" dtype_id="14"/>
<ccast loc="d,53,22,53,23" dtype_id="13">
<varref loc="d,53,22,53,23" name="t.unnamedblk1.e" dtype_id="13"/>
</ccast>
</and>
</arraysel>
</cvtpackstring>
</concatn>
</cvtpackstring>
<varref loc="d,53,10,53,13" name="t.all" dtype_id="10"/>
</assign>
</begin>
@ -578,10 +580,12 @@
<varref loc="d,55,7,55,8" name="t.e" dtype_id="11"/>
</assign>
<assign loc="d,56,11,56,12" dtype_id="10">
<concatn loc="d,56,17,56,18" dtype_id="10">
<varref loc="d,56,14,56,17" name="t.all" dtype_id="10"/>
<const loc="d,56,21,56,25" name="&quot;E04&quot;" dtype_id="10"/>
</concatn>
<cvtpackstring loc="d,56,17,56,18" dtype_id="10">
<concatn loc="d,56,17,56,18" dtype_id="10">
<varref loc="d,56,14,56,17" name="t.all" dtype_id="10"/>
<const loc="d,56,21,56,25" name="&quot;E04&quot;" dtype_id="10"/>
</concatn>
</cvtpackstring>
<varref loc="d,56,7,56,10" name="t.all" dtype_id="10"/>
</assign>
<if loc="d,57,10,57,12">