mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Support selects on arbitrary string expressions (#5773)
This commit is contained in:
+11
-5
@@ -305,13 +305,19 @@ class WidthSelVisitor final : public VNVisitor {
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
} else if (VN_IS(ddtypep, BasicDType) && ddtypep->isString()) {
|
||||
// SELBIT(string, index) -> GETC(string, index)
|
||||
const AstNodeVarRef* const varrefp = VN_CAST(fromp, NodeVarRef);
|
||||
if (!varrefp) {
|
||||
nodep->v3warn(E_UNSUPPORTED,
|
||||
"Unsupported: String array operation on non-variable");
|
||||
AstNodeExpr* exprp = fromp;
|
||||
while (true) {
|
||||
if (AstMemberSel* const memberselp = VN_CAST(exprp, MemberSel)) {
|
||||
exprp = memberselp->fromp();
|
||||
} else if (AstStructSel* const structselp = VN_CAST(exprp, StructSel)) {
|
||||
exprp = structselp->fromp();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const AstNodeVarRef* const varrefp = VN_CAST(exprp, NodeVarRef);
|
||||
AstNodeExpr* newp;
|
||||
if (varrefp && varrefp->access().isReadOnly()) {
|
||||
if (!varrefp || varrefp->access().isReadOnly()) {
|
||||
newp = new AstGetcN{nodep->fileline(), fromp, rhsp};
|
||||
} else {
|
||||
newp = new AstGetcRefN{nodep->fileline(), fromp, rhsp};
|
||||
|
||||
Reference in New Issue
Block a user