Flow synchronization in scoreboard

Good day!
i have a design, in which input data go to the output without delay:


assign data_out = data_in;
assign valid_out = valid_in;

looked on the behaviour on “wave”, output data appears one delta later, then input.
input and output monitors are objects of a same class. they collect data like this:


@(posedge clk iff valid);
trnx.data = data;
mon_ap.write(trnx);

in scoreboard i use separate write functions for input and output monitors and store results in two queues. after that i want to gather data from both of them and to make a comparison.


after_fifo.get(t_after);
predicted_t_after_queue.pop_back(t_predicted);
...

when test encounters “pop_back” line, it sends an error, that queue is empty, and my test dies. so it’s not a safety way to just use queues if there are no delays between input and output.
i tried to rewrite my code, using wait statement or whie cycle. none of it works: events never happen.


after_fifo.get(t_after);
wait (predicted_t_after_queue.size);
predicted_t_after_queue.pop_back(t_predicted);


after_fifo.get(t_after);
while (!predicted_t_after_queue.size) @(predicted_t_after_queue.size);
predicted_t_after_queue.pop_back(t_predicted);

how do i synchronize these flows?
thank you.

Your question is not clear to me .
But anyways i think you are asking how to compare two queue which has different time delay filling the queue.

Below is the pusedocode it may help you to get some idea.


`uvm_put_imp_decl(_1)
`uvm_put_imp_decl(_2)


class scoreboard;
  
  int 	input_queue[$];
  int 	output_queue [$];
  
  int    fifo_count1; fifo_count2;
  
  uvm_put_imp_1 #(int) put_imp1;
  uvm_put_imp_2 #(int) put_imp2;
  
  
  virtual task run_phase (uvm_phase phase)
    int t1,t2;
    while (1) begin
      wait ((input_queue.size() > 0) && (output_queue.size() > 0));
      t1 = input_queue.pop_front();
      t2 = output_queue.pop_front(); 
      
      if(t1 != t2)
        $display ("ERROR");
      
    end
    
  endtask
  
  virtual function report_phase();
  
    if(fifo_count1 != fifo_count2) begin
      
      $display ("Error");
      
      // Also pop the elements from queue which is not empty.
    
    
  endtask
  
  
  function void put_1 (input int t);
     //puts comming into put_imp1
    input_queue.push_back(t);
    fifo_count1++;
  endfunction
  
  function void put_2(input int t);
     //puts comming into put_imp2
    output_queue.push_back(t);
    fifo_count2++;
  endfunction
  
endclass