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.