Data push into Q which is from child sequence item - uvm scoreboard

Hi,
I am developing basic scoreboard where am facing some issues which is explained below with code.

uvm_analysis_imp_TX_expected_data #(sequence_item_base, my_scoreboard) item_collect_export;
1)Is it compulsory to register with sequence_item_base or its possible to register with child class(sequence_item_child) extended from of sequence_item_base;

class sequence_item_base extends uvm_sequence_item;

//All the transcation items are defined in child class or grand child class.
//constructor

endclass

class sequence_item_child extends sequence_item_base;

int addr,write,enable,data;

//constructor field macros everything defined in this class

endclass

class my_scoreboard extends uvm_scoreboard;

int temp_data;
bit[7:0] actual_queue[$];

sequence_item_base item;

uvm_analysis_imp_TX_expected_data #(sequence_item_base, my_scoreboard) item_collect_export;

function void build_phase(uvm_phase phase);
item_collect_export = new(“item_collect_export”, this);
endfunction : build_phase

virtual function void write_TX_expected_data(sequence_item_base seq_item);
seq_item.print();
temp_data = seq_item.data;
actual_queue.push_back(temp_data);

endfunction : write

endclass

Output: Error - data is not a class item.

//Since above registed analysis port with base class(data is not a class item of base class ) and trying to push data into Queue but data object is not defined in base class , its defined in child class.
How to push data into the Queue for compare in scoreboard for this type of cases.
Could anyone please comment on this case. Thanks!

In reply to LokeshB:

You should use a tlm_analysis_fifo and put in the seq_item.

In reply to LokeshB:

What if you cast the seq_item into a child class handle in the write function and then push the data into queue

In reply to chr_sue:

In reply to LokeshB:
You should use a tlm_analysis_fifo and put in the seq_item.

Hi,
Thanks for your reply.
I am not getting how it will get solve the issue by using tlm_analysis_fifo. Do you mean that , is it possible to define directly child class(sequence_item_child) as below.
uvm_tlm_analysis_fifo #(sequence_item_child) analy_fifo;

Could you please more elaborate to understand this. Thanks!

In reply to svq:

In reply to LokeshB:
What if you cast the seq_item into a child class handle in the write function and then push the data into queue

Thanks for your comment.
After doing $cast in below way , data is always 0. but able to see the packet with data as 12 after fifo data get method.
Could you please mention the reason behind always data as 0. Thanks!

//snippet code
sequence_item_base seq_item;
int temp_data;
bit [31:0] actual_queue[$];
uvm_tlm_analysis_fifo #(sequence_item_base ) analy_fifo;

task collect_data();
sequence_item_child child_h;

child_h= sequence_item_child ::type_id::create(“child_h”);
$cast(seq_item, child_h);
//Getting trans from FIFO
analy_fifo.get(seq_item);
`uvm_info(get_type_name(),$sformatf(" Printing seq_item, \n %s",seq_item.sprint()),UVM_LOW) --------------o/p In pkt print data is 12.
temp_data=child_h.data;
actual_queue.push_back(temp_data);
$display(“ACTUAL_Q_data=%0p”,actual_queue); -----o/p always data is 0.
endtask

//In run_phase
task run_phase(uvm_phase phase);
super.run_phase(phase);
fork
forever begin
collect_data();
end
join
endtask

In reply to LokeshB:

In reply to chr_sue:
Hi,
Thanks for your reply.
I am not getting how it will get solve the issue by using tlm_analysis_fifo. Do you mean that , is it possible to define directly child class(sequence_item_child) as below.
uvm_tlm_analysis_fifo #(sequence_item_child) analy_fifo;

The OOP says you can use everywhere a child object when defined for the parent and vica-versa.
This answers your question. Did you try it?
The tlm_analysis_fifo is the dedicated component for the analysis path.

In reply to chr_sue:

In reply to LokeshB:
The OOP says you can use everywhere a child object when defined for the parent and vica-versa.
This answers your question. Did you try it?
The tlm_analysis_fifo is the dedicated component for the analysis path.

I have tried like this, but getting below syntax error.
typedef sequence_item_child #(SELECT_WIDTH) sequence_item_child_class;
class my_scoreboard extends uvm_scoreboard;
sequence_item_child_class sequence_item_child_h;
uvm_tlm_analysis_fifo #(sequence_item_child_class) analy_fifo;
endclass

top_env.sv,157 agent.ap[“tx_in”].connect(sb.analy_fifo.analysis_export);

xmelab: *E,TYCMPAT (…/uvm/top_env.sv,157|81): formal and actual do not have assignment compatible data types on instance ‘env_pkg’
(expecting datatype compatible with ‘class uvm_pkg::uvm_port_base#(.IF(class uvm_pkg::uvm_tlm_if_base#(.T1(class vc_pkg::sequence_item_base),
.T2(class vc_pkg::sequence_item_base))))’ but found ‘class uvm_pkg::uvm_analysis_imp#(.T(class v2_0_pkg::sequence_item_child #(SELECT_WIDTH(2))),
.IMP(class uvm_pkg::uvm_tlm_analysis_fifo#(.T(class v2_0_pkg::sequence_item_child#(.SELECT_WIDTH(2))))))’ instead).

In reply to LokeshB:

Looks like your child object has a parameter and the base object do not.
Please show the definitions of your seq_items.

In reply to LokeshB:

$cast should be used as $cast(destination,source);

child_h= sequence_item_child ::type_id::create(“child_h”);

//Getting trans from FIFO
analy_fifo.get(seq_item);
$cast(child_h,seq_item);
`uvm_info(get_type_name(),$sformatf(" Printing seq_item, \n %s",seq_item.sprint()),UVM_LOW) --------------o/p In pkt print data is 12.
temp_data=child_h.data;
actual_queue.push_back(temp_data);

In reply to chr_sue:

In reply to LokeshB:
Looks like your child object has a parameter and the base object do not.
Please show the definitions of your seq_items.

Yes you are correct, child object has a parameter and the base object do not. That’s why unable to define uvm_analysis_fifo in scoreboard(got some error which is mentioned in the previous post). Could you please mention how to define it.
And also please mention if need of any more information to solve this issue.

//snippet codes.
class sequence_item_base extends uvm_sequence_item;
//All the transcation items are defined in child class or grand child class.
//constructor
endclass

class sequence_item_child(int SELECT_WIDTH = 2) extends sequence_item_base(vip_config #(SELECT_WIDTH));

int addr,write,enable,data;

//constructor field macros everything defined in this class
endclass.

In reply to LokeshB:

The definition of your class sequence_item_base does not have a parameter.
In the extend construct you are using a parameter like this

class sequence_item_child(int SELECT_WIDTH = 2) extends sequence_item_base(vip_config #(SELECT_WIDTH));

There is your problem.

In reply to chr_sue:

In reply to LokeshB:
The definition of your class sequence_item_base does not have a parameter.
In the extend construct you are using a parameter like this

class sequence_item_child(int SELECT_WIDTH = 2) extends sequence_item_base(vip_config #(SELECT_WIDTH));

There is your problem.

okay. I have two clarification here.
1)Can analysis port in uvm scoreboard register child class sequence item or its limited to base class sequence item only.
2)If above one is true (we can register child class sequence item in sb),then limitation with parameterized class cannot be registed with uvm_analysis_fifo.
Please comment. Thanks!

In reply to LokeshB:

Either you have a parameterized class or not. If your base class is parameterized and also the extended class you have to use for both parameters the same value like this.

class sequence_item_child(int SELECT_WIDTH = 2) extends sequence_item_base(vip_config #(SELECT_WIDTH = 2));

IMO the better solution is to use a package which holds the parameters.

In reply to svq:

In reply to LokeshB:
$cast should be used as $cast(destination,source);
child_h= sequence_item_child ::type_id::create(“child_h”);
//Getting trans from FIFO
analy_fifo.get(seq_item);
$cast(child_h,seq_item);
`uvm_info(get_type_name(),$sformatf(" Printing seq_item, \n %s",seq_item.sprint()),UVM_LOW) --------------o/p In pkt print data is 12.
temp_data=child_h.data;
actual_queue.push_back(temp_data);

Thanks for your comments, It works fine.