Two write_ function in Scoreboard pushing item to the same queue at the same time

Hi Community,
There is a 2-input, 2 output router and I am trying to write a scoreboard for this router
My idea is based on the destination port number in the packet, whenever an input packet comes, push it to the corresponding queue(exp_q_out1/2)
The question is what if both input port1 and input port2 receives packets target at output port 1 at the same time, which write_ function will be called first. How to implement the scoreboard so it can handle such case(assuming RTL is doing round robin arbitration).

`uvm_analysis_imp_decl(_input_1)
`uvm_analysis_imp_decl(_input_2)

`uvm_analysis_imp_decl(_output_1)
`uvm_analysis_imp_decl(_output_2)



class test_scoreboard extends uvm_scoreboard;
  `uvm_analysis_imp_input_1#(router_packet_t, test_scoreboard)  input_port_1;
  `uvm_analysis_imp_input_2#(router_packet_t, test_scoreboard)  input_port_2;

  
  `uvm_analysis_imp_output_1#(router_packet_t, test_scoreboard)  output_port_1;
  `uvm_analysis_imp_output_2#(router_packet_t, test_scoreboard)  output_port_2;


  route_packet_t     exp_q_out1[$];
  route_packet_t     exp_q_out2[$];



  virtual function void write_input_1 (router_packet_t input_packet );
    case(input_packet.dst_port)
      PORT_1:exp_q_out_1.push_back(input_packet);
      PORT_2:exp_q_out_2.push_back(input_packet);
      default: `uvm_info($sformatf("unexpected dst port number %0d", input_packet.dst_port))
    endcase
  endfunction
        
  virtual function void write_input_2 (router_packet_t input_packet );
    case(input_packet.dst_port)
      PORT_1:exp_q_out_1.push_back(input_packet);
      PORT_2:exp_q_out_2.push_back(input_packet);
      default: `uvm_info($sformatf("unexpected dst port number %0d", input_packet.dst_port))
    endcase
  endfunction

  virtual function void write_output_1 (router_packet_t output_packet);
  	router_packet_t  test_packet;
    if(exp_q_out_1.size())begin
    	test_packet = exp_q_out_1.pop_front();
        output_packet.compare(test_packet);
    end
  endfunction
endclass

In reply to elilee267:

There is no timing problem. The write-function is called when the monitor has received a packet.
And the scoreboard does not know anything about the timing. Only the order of data is relevant.
In the compare function you are defining the compare order.
BTW why are you using queues instead of analysis fifos? The analysis fifo’s get function is blocking until a packet is available and you do not have to check if a packet is there or not.