Error: uninitialized virtual interface object

Hi I declared an array of interface in virtual sequencer, and I tried to assign value to is in vseq, here is what I do:

In virtual sqr:

   virtual dft_chain_intf gpio_chain1_vi[3];

         `cn_get_intf(virtual dft_chain_intf, "dft_pkg::dft_chain_intf", $sformatf("gpio_chain_vi[%0s]", "XX1"), gpio_chain1_vi[0])
         `cn_get_intf(virtual dft_chain_intf, "dft_pkg::dft_chain_intf", $sformatf("gpio_chain_vi[%0s]", "XX2"), gpio_chain1_vi[1])
         `cn_get_intf(virtual dft_chain_intf, "dft_pkg::dft_chain_intf", $sformatf("gpio_chain_vi[%0s]", "XX3"), gpio_chain1_vi[2])

and in the corresponding vsq, I did:

     for (int ii =0; ii < 3; ii++) begin
            fork
            repeat (500) begin
               bit data =  $urandom_range(0,1);
               p_sequencer.gpio_chain1_vi[ii].in <= data;
               @(p_sequencer.gpio_chain1_vi[ii].drv_cb);
            end
            join_none
         end

and I got: Error: uninitialized virtual interface object

So I did several experiment:
1, in vsq, instead of using for loop, I use p_sequencer.gpio_chain1_vi[0], p_sequencer.gpio_chain1_vi[1], p_sequencer.gpio_chain1_vi[2] and it works.
2, I change array definition to associative array, and it works.

But I am still very confused, why my original method doesn’t work, I simply declare an array of interfaces, and connect those to actual interfaces.

thanks

In reply to charlie.zl:

Please read this thread.

In reply to cgales:

In reply to charlie.zl:
Please read this thread.

Hi cgales,

Thanks for your reply, I added automatic in my code, and it did pass. But a follow up question is, when I declare the interface array as associative array like:
virtual dft_chain_intf gpio_chain1_vi[int];
the original code didn’t complain about any syntax error, but only gpio_chain1_vi[2] get the value, which is expected.
But when I declare that as traditional array:
virtual dft_chain_intf gpio_chain1_vi[3];

I got uninitialized virtual interface object error? Why isn’t that only gpio_chain1_vi[2] got the value like associative array does?

thanks

In reply to cgales:

In reply to charlie.zl:
Please read this thread.

Ignore for my questions above… I think what happens is when I declare as an associative array, it iterate from 0,1,2,null, when it hit null, it stops. when I declare as a traditional array, it iterate from 0,1,2,3 and stops, all interface gets the value of 3, that’s why I saw that error.

thanks for pointing me to that thread