⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ovm_sequencer_base.svh

📁 This is OVM 2.0 source code .Very useful for developing system verilog Env
💻 SVH
📖 第 1 页 / 共 3 页
字号:
///////////////////////////////////////////////////  local task lock_req(ovm_sequence_base sequence_ptr, bit lock);    integer my_seq_id;    seq_req_class new_req;        if (sequence_ptr == null)      ovm_report_fatal("ovm_sequence_controller", "lock_req passed null sequence_ptr");    my_seq_id = register_sequence(sequence_ptr);    new_req = new();    new_req.grant = 0;    new_req.sequence_id = sequence_ptr.get_sequence_id();    new_req.request = SEQ_TYPE_LOCK;    new_req.sequence_ptr = sequence_ptr;    new_req.request_id = new_req.g_request_id++;        if (lock == 1) begin      // Locks are arbitrated just like all other requests      arb_sequence_q.push_back(new_req);    end else begin      // Grabs are not arbitrated - they go to the front      // TODO:      // Missing: grabs get arbitrated behind other grabs      arb_sequence_q.push_front(new_req);      m_update_lists();    end    // If this lock can be granted immediately, then do so.    grant_queued_locks();        wait_for_arbitration_completed(new_req.request_id);endtask    /////////////////////////////////////////////////////// unlock_req//    Called by a sequence to request an unlock.  This//    will remove a lock for this sequence if it exists///////////////////////////////////////////////////  function void unlock_req(ovm_sequence_base sequence_ptr);    integer my_seq_id;        if (sequence_ptr == null) begin      ovm_report_fatal("ovm_sequencer", "unlock_req passed null sequence_ptr");    end    my_seq_id = register_sequence(sequence_ptr);        foreach (lock_list[i]) begin      if (lock_list[i].m_get_sqr_sequence_id(m_sequencer_id, 0) ==           sequence_ptr.m_get_sqr_sequence_id(m_sequencer_id, 0)) begin        lock_list.delete(i);        m_update_lists();        return;      end    endendfunction // voidtask lock(ovm_sequence_base sequence_ptr);    lock_req(sequence_ptr, 1);endtask // locktask grab(ovm_sequence_base sequence_ptr);    lock_req(sequence_ptr, 0);endtask // lockfunction void unlock(ovm_sequence_base sequence_ptr);    unlock_req(sequence_ptr);endfunction // lockfunction void  ungrab(ovm_sequence_base sequence_ptr);    unlock_req(sequence_ptr);endfunction // locklocal function void remove_sequence_from_queues(ovm_sequence_base sequence_ptr);    integer i;    // Remove all queued items for this sequence and any child sequences    i = 0;    do       begin        if (arb_sequence_q.size() > i) begin          if ((arb_sequence_q[i].sequence_id == sequence_ptr.m_get_sqr_sequence_id(m_sequencer_id, 0)) ||              (is_child(sequence_ptr, arb_sequence_q[i].sequence_ptr))) begin            arb_sequence_q.delete(i);            m_update_lists();          end          else begin            i++;          end        end      end    while (i < arb_sequence_q.size());        // remove locks for this sequence, and any child sequences    i = 0;    do      begin        if (lock_list.size() > i) begin          if ((lock_list[i].m_get_sqr_sequence_id(m_sequencer_id, 0) ==                sequence_ptr.m_get_sqr_sequence_id(m_sequencer_id, 0)) ||              (is_child(sequence_ptr, lock_list[i]))) begin            lock_list.delete(i);            m_update_lists();          end          else begin            i++;          end        end      end    while (i < lock_list.size());        // Unregister the sequence_id, so that any returning data is dropped    unregister_sequence(sequence_ptr.m_get_sqr_sequence_id(m_sequencer_id, 1));endfunction // voidfunction void stop_sequences();    ovm_sequence_base seq_ptr;        // remove all sequences    seq_ptr = find_sequence(-1);    while (seq_ptr != null)      begin        kill_sequence(seq_ptr);        seq_ptr = find_sequence(-1);      endendfunction // void      function void sequence_exiting(ovm_sequence_base sequence_ptr);    remove_sequence_from_queues(sequence_ptr);endfunction // voidfunction void kill_sequence(ovm_sequence_base sequence_ptr);    integer i;    remove_sequence_from_queues(sequence_ptr);    // kill the sequence    sequence_ptr.m_kill();endfunction // voidvirtual function bit is_grabbed();    return(lock_list.size() != 0);endfunction // bitvirtual function ovm_sequence_base current_grabber();    if (lock_list.size() == 0) begin      return (null);    end    return (lock_list[lock_list.size()-1]);endfunction // ovm_sequence_base  ///////////////////////////////////////////////////  //  // has_do_available function  //   Determines if a sequence is ready to supply  //   a transaction.  A sequence that obtains a  //   transaction in pre-do must determine if the  //   upstream object is ready to provide an item  //  //  returns 1 if a sequence is ready to issue an  //  operation.  returns 0 if no unblocked, relevant  //  sequence is requesting.  //  //////////////////////////////////////////////////  function bit has_do_available();        foreach (arb_sequence_q[i]) begin      if (arb_sequence_q[i].sequence_ptr.is_relevant() == 1) begin        return (1);      end    end // UNMATCHED !!    return (0);  endfunction    ///////////////////////////////////////////////////  //  //  function void set_arbitration(SEQ_ARB_TYPE val);  //  //  Specify the arbitration mode for the sequencer.  //  the arbitration mode must be one of:  //  //  SEQ_ARB_FIFO:          All requests are granted in FIFO order  //  SEQ_ARB_WEIGHTED:      Requests are granted randomly by weight  //  SEQ_ARB_RANDOM:        Requests are granted randomly  //  SEQ_ARB_STRICT_FIFO:   All requests at the highest priority are granted  //                         in fifo order  //  SEQ_ARB_STRICT_RANDOM: All requests at the highest priority are granted  //                         in random order  //  SEQ_ARB_USER:          The user function user_priority_arbitration is  //                         called.  That function will specify the next  //                         sequence to grant.  The default user function   //                         specifies FIFO order  //  //////////////////////////////////////////////////  function void set_arbitration(SEQ_ARB_TYPE val);    arbitration = val;  endfunction  virtual function void analysis_write(ovm_sequence_item t);    return;  endfunction  ///////////////////////////////////////////////////  //  // Methods available to Pull Drivers  //   ///////////////////////////////////////////////////  virtual task wait_for_sequences();    for (int i = 0; i < pound_zero_count; i++) begin      #0;    end  endtask // wait_for_sequences   // add_sequence// ------------function void add_sequence(string type_name);    //assign typename key to an int based on size    //used with get_seq_kind to return an int key to match a type name    sequence_ids[type_name] = sequences.size();    //used w/ get_sequence to return a ovm_sequence factory object that     //matches an int id    sequences.push_back(type_name);endfunction// remove_sequence// ---------------function void remove_sequence(string type_name);  sequence_ids.delete(type_name);  for (int i = 0; i < sequences.size(); i++) begin    if (sequences[i] == type_name)      sequences.delete(i);  endendfunction// set_sequences_queue// -------------------function void set_sequences_queue(ref string sequencer_sequence_lib[$]);        for(integer j=0; j < sequencer_sequence_lib.size(); j++) begin      sequence_ids[sequencer_sequence_lib[j]] = sequences.size();      this.sequences.push_back(sequencer_sequence_lib[j]);    endendfunction // void// get_seq_kind// ------------// Return a unique sequence id given the name of a sequence.// This id is expected to be used in inline constraints.function integer get_seq_kind(string type_name);  if (sequence_ids.exists(type_name))    return sequence_ids[type_name];  ovm_report_fatal("SEQNF",     $psprintf("Sequence type_name '%0s' not registered with this sequencer.",    type_name));endfunction// get_sequence// ------------function ovm_sequence_base get_sequence(integer req_kind);  ovm_factory factory = ovm_factory::get();  ovm_sequence_base m_seq ;  string m_seq_type;  if (req_kind < 0 || req_kind >= sequences.size()) begin    ovm_report_error("SEQRNG",       $psprintf("Kind arg '%0d' out of range. Need 0-%0d",       req_kind, sequences.size()-1));  end  m_seq_type = sequences[req_kind];  if (!$cast(m_seq, factory.create_object_by_name(m_seq_type,                                          get_full_name(),                                          m_seq_type)))   begin      ovm_report_fatal("FCTSEQ",         $psprintf("Factory can not produce a sequence of type %0s.",        m_seq_type));  end  m_seq.print_sequence_info = 1;  m_seq.set_sequencer (this);  return m_seq;  endfunction // ovm_sequence_base  function integer num_sequences();    return (sequences.size());  endfunction // num_sequences  virtual function void send_request(ovm_sequence_base sequence_ptr, ovm_sequence_item t, bit rerandomize = 0);    return;  endfunction///// End of Copied from ovm_sequencer//////////////////////////////////////////////////// Deprecated Methods//////////////////////////////////////////////////  virtual task start_sequence(ovm_sequence_base seq_base);    fork      seq_base.start(this);    join_none  endtask // start_sequenceendclass

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -