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