core-v-verif系列之lib<49>

UVM环境介绍
HEAD commitID: 1f968ef

1. core-v-verif/lib/uvm_agents/uvma_cvxif/src/comps/uvma_cvxif_mon.sv



// Copyright 2021 Thales DIS design services SAS
//
// Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.0
// You may obtain a copy of the License at https://solderpad.org/licenses/
//
// Original Author: Zineb EL KACIMI ([email protected])

`ifndef __UVMA_CVXIF_MON_SV__
`define __UVMA_CVXIF_MON_SV__


class uvma_cvxif_mon_c extends uvm_monitor;

   //objects
   uvma_cvxif_cfg_c    cfg;
   uvma_cvxif_cntxt_c  cntxt;

   // add to factory
   `uvm_component_utils_begin(uvma_cvxif_mon_c)
      `uvm_field_object(cfg,   UVM_DEFAULT)
      `uvm_field_object(cntxt, UVM_DEFAULT)
   `uvm_component_utils_end

   string info_tag = "CVXIF_MONITOR";

   int req_valid;

   uvm_analysis_port#(uvma_cvxif_req_item_c)  req_ap;
   uvm_analysis_port#(uvma_cvxif_resp_item_c) resp_ap;

   uvma_cvxif_req_item_c req_tr;
   uvma_cvxif_resp_item_c resp_tr;

   /**
    * Default constructor.
    */
   extern function new(string name="uvma_cvxif_mon", uvm_component parent=null);

   /**
    * 1. Ensures vif handle is not null.
    * 2. Builds ap.
   */
   extern virtual function void build_phase(uvm_phase phase);

   /**
    * Monitoring transaction
   */
   extern virtual task run_phase(uvm_phase phase);

   /**
    * Send transaction request to sequencer
   */
   extern task send_req_to_sqr(uvma_cvxif_req_item_c req);

   /**
    * Collect and send request items to sequencer
   */
   extern task collect_and_send_req(uvma_cvxif_req_item_c req_tr);

   /**
    * Collect and send response items to coverage model
   */
   extern task collect_and_send_resp(uvma_cvxif_resp_item_c resp_tr);

   /**
    * Observe reset state
   */
   extern task observe_reset();

   /**
    * Monitor pre-reset phase
    */
   extern virtual task mon_cvxif_pre_reset();

   /**
    * Monitor in-reset phase
    */
   extern virtual task mon_cvxif_in_reset();

   /**
    * Monitor post-reset phase
    */
   extern virtual task mon_cvxif_post_reset();

endclass : uvma_cvxif_mon_c

function uvma_cvxif_mon_c::new(string name="uvma_cvxif_mon", uvm_component parent=null);

   super.new(name, parent);

endfunction : new

function void uvma_cvxif_mon_c::build_phase(uvm_phase phase);

   super.build_phase(phase);

   void'(uvm_config_db#(uvma_cvxif_cfg_c)::get(this, "", "cfg", cfg));
   if (cfg == null) begin
      `uvm_fatal("CFG", "Configuration handle is null")
   end

   void'(uvm_config_db#(uvma_cvxif_cntxt_c)::get(this, "", "cntxt", cntxt));
   if (cntxt == null) begin
      `uvm_fatal("CNTXT", "Context handle is null")
   end

   req_ap = new("req_ap", this);
   resp_ap = new("resp_ap", this);

endfunction : build_phase

task uvma_cvxif_mon_c::run_phase(uvm_phase phase);
   super.run_phase(phase);

   fork
      observe_reset();

      forever begin
         case (cntxt.reset_state)
            UVMA_CVXIF_RESET_STATE_PRE_RESET:  mon_cvxif_pre_reset();
            UVMA_CVXIF_RESET_STATE_IN_RESET:   mon_cvxif_in_reset();
            UVMA_CVXIF_RESET_STATE_POST_RESET: mon_cvxif_post_reset();
         endcase
      end
   join

endtask: run_phase

task uvma_cvxif_mon_c::mon_cvxif_post_reset();

   fork
      begin
         collect_and_send_resp(resp_tr);
      end
      begin
         collect_and_send_req(req_tr);
      end
   join_any

endtask

task uvma_cvxif_mon_c::mon_cvxif_in_reset();

   @(cntxt.vif.clk);

endtask

task uvma_cvxif_mon_c::mon_cvxif_pre_reset();

   @(cntxt.vif.clk);

endtask

task uvma_cvxif_mon_c::send_req_to_sqr(uvma_cvxif_req_item_c req);

   req_ap.write(req);

endtask : send_req_to_sqr

task uvma_cvxif_mon_c::collect_and_send_req(uvma_cvxif_req_item_c req_tr);

   forever begin
      // wait for a transaction
      if ((cntxt.vif.issue_valid && cntxt.vif.issue_ready) || (cntxt.vif.compressed_valid && cntxt.vif.compressed_ready)

你可能感兴趣的:(core-v-verif)