Skip to content

assignment to member of array of struct not working in some constellations  #5618

@sumpster

Description

@sumpster

Some of my test suites started failing when upgrading from 5.020 to 5.030 and I tried to locate the breaking change. At first it looked like the culprit is this, because after this change my tests start to fail: (When I undo the change to V3Unknown.cpp the tests are green again.)

8c3cc3a#diff-bf2735b07bd0b382ff641879225a1d4957732b6fbfc5d4a91d77cf0668964f73R122

However, in the process of creating a small example of the problem for this bug report I ended up with the code below which is already not working for me in 5.020.

Problem: counter will not get incremented unless the line making the assignment to flag is commented out.

module demo_tb;
    typedef struct {
        logic [2:0] counter;
        logic flag;
    } SimpleStruct;

    SimpleStruct s [1];

    logic clock = 0;

    initial forever #5 clock = ~clock;

    always @(posedge clock) begin
        for (int i = 0; i < 1; i++) begin
            s[i].counter <= s[i].counter + 3'd1;
            s[i].flag <= 0; // <-- comment out this line and the test will pass
        end        
    end
    
    initial begin
        if (s[0].counter != 0) $stop;
        for (int i = 1; i < 8; i++)
            #10 if (s[0].counter != 3'(i)) $stop;

        $write("*-* All Finished *-*\n");
        $finish;
    end
endmodule

Reproduced with:

  • Verilator 5.020
  • Verilator 5.031 devel rev v5.030-78-g5470cf9fa

OS: Ubuntu 24.04.1 LTS
Run from cocotb 1.9 via python runner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions