A queue I created never pop front

In the base class (base_class.svh), I created below code.


class my_base_class;
    
    function new(...);
        super.new(name);
    endfunction: new

    bit st_ld_buf[$];

    task store(logic [47:0] addr, logic [63:0] data);
        ......  // do something related with sequence and sequencer
        my_buf.push_back(1);
    endtask
endclass

And I created another class named my_func_class which is extending from my_base_class.


class my_func_class extends my_base_class;
    function new(...);
        super.new(name);
    endfunction: new
endclass

And Then I created another class named my_important_class which is extending from my_func_class.
In this body(), the my_process() task is forever executed to wait the my_buf is not empty.


class my_important_class extends my_base_class;
    function new(...);
        super.new(name);
    endfunction: new

    task body();
        fork
           my_process();
           other_proc();
        join
        ......
    endtask
    
    task my_process();
       bit is_op;
       forever begin
           wait(my_buf.size);
           is_op = my_buf.pop_front();
           ......
       end
    endtask
endclass

Now I created a test, which is extended from my_func_class. and here is the snippet of code.


class my_test0 extends my_func_class;
    function new(...);
        super.new(name);
    endfunction: new

    task body();
         logic [47:0] addr;
         logic [63:0] data;
         // do something to get addr and data
         store(addr, data);
         .....
    endtask
    
endclass

But when the test starts, I just saw we hit the “push_back” operation but never reach to “pop_front”. May I know what’s wrong here ?

In reply to zz8318:

You show two declarations of ‘my_func_class’ extending ‘my_base_class’. You also mention ‘my_important_class’ which you never show any code for.

It would be great if you can post a complete example on EDA Playground which completely demonstrates your issue.

In reply to cgales:

Thank you. Actually my question could be simplified as shown below.

We have a base class A and there is a member declared as “int x”.
and then class B is created, which is extending from A.
after that, we have two class, C and D. which both are extended from B.

so when we instance C and D, they have the “int x” as a member separately because they both extended from B, which extended from A.

my question is, how to implement if we need the “x” in class C and the “x” in class D are only one copy. ( I mean they are pointed to the same location, if the “x” in C changed, the “x” in D also changed)

In reply to zz8318:


class a;
  static int local_var;

endclass

class b extends a;

endclass

class c extends b;

endclass

class d extends b;

endclass

module testbench();

  c my_c;
  d my_d;

  initial begin
    my_c = new();
    my_d = new();

    my_c.local_var = 10;
    $display("my_c.local_var = %d", my_c.local_var);
    $display("my_d.local_var = %d", my_d.local_var);

    my_d.local_var = 20;
    $display("my_c.local_var = %d", my_c.local_var);
    $display("my_d.local_var = %d", my_d.local_var);

  end

endmodule