Use of item.addr

I have a transaction class which has a member variable called addr.

In the checker class, inside whom the transaction class object(currenttxn) is instantiated by means of new().

Now, inside an if statement the currenttxn.addr is compared with item.addr.

I’m confused since item object is not instantiated.
Is “item” a keyword?

I also found a reference called item.index in the site WWW.TESTBENCH.IN - Systemverilog Randomization

Please help me out.

In reply to sachins:

It is difficult to provide an answer without seeing the source code you are describing. If you can post the code in question, perhaps a more definitive answer can be given.

In reply to cgales:

In reply to sachins:
It is difficult to provide an answer without seeing the source code you are describing. If you can post the code in question, perhaps a more definitive answer can be given.

class mem_ctl_checker;

mailbox#(mem_xactn) in_box;
mem_xactn cur_xactn,mem_q[$],found_xactn_q[$];
int num_dut_err, found_ind_q[$];

function new( mailbox#(mem_xactn) new_mbox);
this.in_box=new_mbox;
endfunction

virtual task main;

forever begin :loop

in_box.get(cur_xactn);

if(cur_xactn.kind==RST) begin: clrmem
mem_q.delete();
end: clrmem

if(cur_xactn.kind==WR) begin: wrmem
found_ind_q=mem_q.find_first_index with(cur_xactn.addr==item.addr);

	if(found_ind_q.size!=0) begin: indeq
	mem_q[found_ind_q[0]].data_in=cur_xactn.data_in;
	end: indeq

	else begin: notmatch
	mem_q.push_back(cur_xactn);
	end: notmatch
end:wrmem

Here is the transaction class
class mem_xactn;
 rand logic [DATA_WIDTH-1:0] data_in;
 logic [DATA_WIDTH-1:0] rd_data;
 rand logic [ADDR_WIDTH-1:0] addr;
 rand bit [3:0] no_of_rst;
 rand mem_op kind;

 virtual function string show_as_string ();
   if(kind == WR)
 	    show_as_string = $psprintf ("%s KIND: %s ADDR: %0d DATA %0d",`CVC_PREFIX,kind.name, addr, data_in);
     if(kind == RD)
       show_as_string = $psprintf ("%s KIND: %s ADDR: %0d",`CVC_PREFIX,kind.name, addr);
     if(kind == RST)
       show_as_string = $psprintf ("%s KIND: %s", `CVC_PREFIX,kind.name);
 endfunction : show_as_string


  }
  
 	
endclass : mem_xactn

In reply to sachins:

If you look at the line found_ind_q=mem_q.find_first_index with(cur_xactn.addr==item.addr); the intent here is to find the item’s index that matches the current address. This is the inbuilt way of searching items (with various attributes like first index) in the queue. Hope this answers your question…

  • Siva

In reply to Subrahmanyam:

Thanks. It does answer.