UVM scoreboard scoreboard instantiates subscriber (uvm_sunscriber). inside write function how can i compare properly

Hi friends ,
I have written a scoreboard. Inside the scoreboard I have 4 subscribers talking to 4 interfaces. each subscriber has a queue. inside scoreboard code i am pushing the value to the queue of subscriber. Now I want to compare the value of data pushed in the queue with data from the dut o/p. My question is in uvm_subscriber there is a write function. when I am adding some print statement there , I donot see any data in the queue.But when I add print statement in the report_phase of subscriber I see queue getting values.Why do i see queue empty inside write function? I have added my chunk of scoreboard and subscriber code.

class tb_scoreboard extends uvm_scoreboard;
     port_sb sb[4];  // 4 subscribers for 4 interfaces 
virtual function void write_before(packet pkt);
      pkt.print();
      sb[get_oport(pkt)].expected_data_q.push_back(pkt);  // each subscriber has a queue . push dat
   
---------
class port_sb extends uvm_subscriber#(packet) ;  

  packet expected_data_q[$];

 virtual function void write(packet pkt); 
        
        $display("size of expected queue is = %d", expected_data_q.size) ;  ---> this shows the size always 0
       
         pkt.print();
     endfunction:write


In reply to lagnaray:

Hey,

At what point of time are you calling subscriber’s write() method? Is it before filling the Queue or after? :P

In reply to lagnaray:

My question is where are you calling method write_before?

In reply to chr_sue:

Hi
My intention is first scoreboard should fill the queues inside the subscribers. then subscriber write function should work.

I donot call the write_before function explicitly again.

How do I make sure that first scoreboard write_before happens before write() of subscriber ?
Thanks

In reply to lagnaray:

I looked at my log report. First write_before is kicking in before write().
I am not sure why queue still is 0.

In reply to lagnaray:

If the queue is filled before the write was issued. The queue is not empty (assuming, it is implemented correctly).
For me it is not clear what are you doing with your 2 scoreboards and why thea are of the same type.

In reply to chr_sue:

i have one score board. That instantiates 4 subscribers. Each subscriber has a queue inside. The reason is I have a 4 input , 4 output serial router to test.
At the output side , each output agent (passive agent) is connect to the one instance of subscriber. So that each o/p port of DUT has a unique subscriber where the data goes.

In reply to lagnaray:

I got some understanding from the code . You have two analysis export in scoreboard.
You have 4 subscriber. Are they connected directly with monitor analysis port ?
How are the subscriber ports connected ? Looks like you want to fill the queue based on write method of scoreboard, and you want to use in subscriber’s write method and they are not in sync. Can you please elaborate more regarding your connections ?

In reply to kddholak:

Found the issue. I connected the top level dut pins incorrectly.
Thanks every one for your help.
Thanks