Push real values into queue using parameterized class

Problem: output of my queue is zero, instead I am expecting the queue to get filled with 6 random real values.
Here is the parameterized base class defining my queue:

class stack #(type T=int,int depth=10);
	rand T data;	
	T Q[$:depth-1]; // defining datatype and depth of queue using pamaeterization 

	task push_Q(T data);
	        
		Q.push_back(data);		

	endtask	

endclass

Below is the child class which converts randomized bit type into real value and then push real value into queue. Since I am unaware of a direct way to randomize the real values, so I do it this way.

class newStack_P #(type T = real,int depth = 6) extends stack; // with parameterization in extended class
rand bit [7:0] bit_val;
T temp;
task put_real (T temp);
		
		
	      temp = $bitstoreal(bit_val); 
	      super.push_Q(temp);
              $display(" bit_val = %b", bit_val);
	      $display(" temp in extended class = %0p", temp);	
	      $display(" queue in extended class = %0p", super.Q);
endtask
endclass

Below is my top module:

module top;
newStack_P #(real,6) ext_stkP_h;
initial begin
ext_stkP_h = new;
		for (int i2=0; i2<6; i2++) begin // push 6 elements in extended class with parameterization case.
			ext_stkP_h.randomize();
			ext_stkP_h.put_real(ext_stkP_h.temp);
		end
end
endmodule

So in brief, I want to push in random real values into the queue, but only using my base class method ‘push_Q’. How can I get this done ? Thank you.

In reply to rakesh2learn:

If you want the child class to be parameterized with real type and queue depth of 6, then you class definition should be

 class newStack extends stack #(real, 6); 

The child class definition that you have written means that the child class is being extended from the base class with it’s default parameters i.e. (int, 10)

I have re-written the code which should work fine.


class stack #(type T = int, int depth = 10);
   T Q[$:depth - 1];
   
   task push_Q(T data);
      Q.push_back(data);
   endtask
endclass

class newStack extends stack #(real, 6);
   
    rand bit [7:0] bit_val;
    real temp;

    task put_real();
        temp = $btistoreal(bit_val);
        push_Q(temp);
        $display("temp in extended class = %0p", temp);	
	$display(" queue in extended class = %0p", Q);
    endtask
endclass

module top;

   newStack  ext_stkP_h;
   initial begin
       ext_stkP_h = new;
       for (int i2=0; i2<6; i2++) begin // push 6 elements in extended class with parameterization case.
           ext_stkP_h.randomize();
	   ext_stkP_h.put_real();
	end
   end
endmodule

In reply to sharat:

couple of typo in your answer. Though, no big deal about it, I fixed those. Thanks for your time.