0

I was working on OVM driver sequencer communication. I am using try_get_item() in ovm driver but it is still getting stuck. In my sequencer I redefined try_next_item and just printed a display statement before and after m_req_fifo.peek(t); The statement before peek got executed but not the statement after the peek. I even displayed size of the m_req_fifo using m_req_fifo.size() and it printed out 1. Why is peek not returning anything even after the size is 1? The modified try_next_item (Just addition of display) is given below. The line After PEEK never gets executed after the line Line 398 with fifo size 1

   virtual task try_next_item(output REQ t);
    int selected_sequence;
    time arb_time;
    ovm_sequence_base seq;

    if (get_next_item_called == 1) begin
      ovm_report_error(get_full_name(), "get_next_item/try_next_item called twice without item_done or get in between", OVM_NONE);
      return;
    end

    wait_for_sequences();
    selected_sequence = choose_next_request();
    if (selected_sequence == -1) begin
      t = null;
      return;
    end
    set_arbitration_completed(arb_sequence_q[selected_sequence].request_id);
    seq = arb_sequence_q[selected_sequence].sequence_ptr;
    arb_sequence_q.delete(selected_sequence);
    m_update_lists();
    sequence_item_requested = 1;
    get_next_item_called = 1;
    $display("Line 398 with fifo size %0d\n", m_req_fifo.size());
    m_req_fifo.peek(t);

    $display("After PEEK\n");
    wait_for_sequences();

    // attempt to get the item; if it fails, produce an error and return
    if (!m_req_fifo.try_peek(t))
      ovm_report_error("TRY_NEXT_BLOCKED", {"try_next_item: the selected sequence '",
        seq.get_full_name(), "' did not produce an item during wait_for_sequences(). ",
        "Sequences should not consume time between calls to start_item and finish_item. ",
        "Returning null item."}, OVM_NONE);

  endtask
user1978273
  • 484
  • 10
  • 24

1 Answers1

0

uvm_tlm_fifo::size() doesn't return the number of elements in the FIFO, but its capacity (i.e. the maximum number of elements it can hold). The function you're looking for is uvm_tlm_fifo::used() which returns the number of stored elements.

The function names are not intuitive at all and I remember spending a couple of hourse trying to understand some similar code to the one you had until noticing in the documentation that I was using the wrong method.

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53
  • Thank you very much. I have a follow up question here https://stackoverflow.com/questions/48836101/ovm-sequence-item-not-getting-arbitrated – user1978273 Feb 16 '18 at 23:08