Fix queue `[$-i]` select as reference argument (#5411)

Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
This commit is contained in:
Krzysztof Bieganski 2024-08-28 17:29:12 +02:00 committed by GitHub
parent 5cb6f370e9
commit d896f1ff08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View File

@ -493,7 +493,7 @@ class TaskVisitor final : public VNVisitor {
|| VN_IS(pinp, ArraySel)) {
refArgOk = true;
} else if (const AstCMethodHard* const cMethodp = VN_CAST(pinp, CMethodHard)) {
refArgOk = cMethodp->name() == "at";
refArgOk = cMethodp->name() == "at" || cMethodp->name() == "atBack";
}
if (refArgOk) {
if (AstVarRef* const varrefp = VN_CAST(pinp, VarRef)) {

View File

@ -3677,10 +3677,11 @@ class WidthVisitor final : public VNVisitor {
}
void methodCallQueue(AstMethodCall* nodep, AstQueueDType* adtypep) {
AstCMethodHard* newp = nullptr;
if (nodep->name() == "at") { // Created internally for []
if (nodep->name() == "at" || nodep->name() == "atBack") { // Created internally for []
methodOkArguments(nodep, 1, 1);
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), "at"};
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
nodep->name()};
newp->dtypeFrom(adtypep->subDTypep());
} else if (nodep->name() == "num" // function int num()
|| nodep->name() == "size") {

View File

@ -9,8 +9,13 @@ module t(/*AUTOARG*/);
int q[$];
int r;
function void set_val(ref int lhs, input int rhs);
lhs = rhs;
endfunction
initial begin
q = { 20, 30, 40 };
q = { 20, 50, 40 };
set_val(q[$-1], 30);
r = q[$];
if (r != 40) $stop;