UVM环境介绍
HEAD commitID: 1f968ef
// Copyright 2020 OpenHW Group
// Copyright 2020 Datum Technology Corporation
// Copyright 2020 Silicon Labs, Inc.
//
// Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://solderpad.org/licenses/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
`ifndef __UVMA_FENCEI_CNTXT_SV__
`define __UVMA_FENCEI_CNTXT_SV__
/**
* Object encapsulating all state variables for all Fencei agent
* (uvma_fencei_agent_c) components.
*/
class uvma_fencei_cntxt_c extends uvm_object;
// Handle to fetch interface
virtual uvma_fencei_if fencei_vif;
// Events
uvm_event sample_cfg_e;
uvm_event sample_cntxt_e;
// Integrals
uvma_fencei_reset_state_enum reset_state = UVMA_FENCEI_RESET_STATE_PRE_RESET;
`uvm_object_utils_begin(uvma_fencei_cntxt_c)
`uvm_field_enum(uvma_fencei_reset_state_enum, reset_state, UVM_DEFAULT)
`uvm_field_event( sample_cfg_e , UVM_DEFAULT)
`uvm_field_event( sample_cntxt_e, UVM_DEFAULT)
`uvm_object_utils_end
/**
* Builds events.
*/
extern function new(string name="uvma_fencei_cntxt");
/**
* TODO Describe uvma_fencei_cntxt_c::reset()
*/
extern function void reset();
endclass : uvma_fencei_cntxt_c
`pragma protect begin
function uvma_fencei_cntxt_c::new(string name="uvma_fencei_cntxt");
super.new(name);
sample_cfg_e = new("sample_cfg_e" );
sample_cntxt_e = new("sample_cntxt_e");
endfunction : new
function void uvma_fencei_cntxt_c::reset();
endfunction : reset
`pragma protect end
`endif // __UVMA_FENCEI_CNTXT_SV__
lib/uvm_agents/uvma_fencei/uvma_fencei_cntxt.sv
1. 简要介绍
该文件是Fencei验证环境的上下文类实现,主要功能包括:
- 管理验证环境的运行时状态
- 存储虚拟接口句柄
- 提供事件通知机制
- 支持复位操作
2. 接口介绍
2.1 类定义
class uvma_fencei_cntxt_c extends uvm_object;
- 代码介绍:定义上下文类,继承自UVM基础对象类
- 功能:作为验证环境的运行时状态容器
2.2 虚拟接口
virtual uvma_fencei_if fencei_vif;
- 代码介绍:定义虚拟接口句柄
- 用途:连接DUT接口
3. 参数介绍
3.1 复位状态
uvma_fencei_reset_state_enum reset_state = UVMA_FENCEI_RESET_STATE_PRE_RESET;
- 参数说明:存储当前复位状态
- 初始值:预设为复位前状态
3.2 事件对象
uvm_event sample_cfg_e;
uvm_event sample_cntxt_e;
- 参数说明:UVM事件对象
- 用途:
sample_cfg_e
:配置采样事件sample_cntxt_e
:上下文采样事件
4. 模块实现介绍
4.1 构造函数
function uvma_fencei_cntxt_c::new(string name="uvma_fencei_cntxt");
super.new(name);
sample_cfg_e = new("sample_cfg_e");
sample_cntxt_e = new("sample_cntxt_e");
endfunction
- 代码分析:
- 调用父类构造函数
- 初始化事件对象
- 关键点:确保事件对象在构造时创建
4.2 复位函数
function void uvma_fencei_cntxt_c::reset();
// TODO Implement reset logic
endfunction
- 代码分析:预留复位功能实现
- 设计特点:待扩展的复位逻辑
5. 总结
该上下文类具有以下特点:
- 完整的UVM标准实现
- 清晰的接口管理
- 灵活的事件机制
- 可扩展的设计架构
作为验证环境的核心组件,它为Fencei验证提供了必要的运行时状态管理能力,确保验证过程能够正确执行和监控。
//
// Copyright 2021 OpenHW Group
// Copyright 2021 Silicon Labs
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
//
// Licensed under the Solderpad Hardware License v 2.1 (the "License"); you may
// not use this file except in compliance with the License, or, at your option,
// the Apache License version 2.0. You may obtain a copy of the License at
//
// https://solderpad.org/licenses/SHL-2.1/
//
// Unless required by applicable law or agreed to in writing, any work
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
//
`ifndef __UVMA_FENCEI_DRV_SV__
`define __UVMA_FENCEI_DRV_SV__
/**
* Component driving a Open Bus Interface virtual interface (uvma_obi_if).
* @note The req & rsp's roles are switched when this driver is in 'slv' mode.
* @todo Move implementation to a sequence-based approach
*/
class uvma_fencei_drv_c extends uvm_driver#(
.REQ(uvma_fencei_seq_item_c),
.RSP(uvma_fencei_seq_item_c )
);
// Objects
uvma_fencei_cfg_c cfg;
uvma_fencei_cntxt_c cntxt;
`uvm_component_utils_begin(uvma_fencei_drv_c)
`uvm_field_object(cfg , UVM_DEFAULT)
`uvm_field_object(cntxt, UVM_DEFAULT)
`uvm_component_utils_end
/**
* Default constructor.
*/
extern function new(string name="uvma_fencei_drv", uvm_component parent=null);
/**
* 1. Ensures cfg & cntxt handles are not null.
* 2. Builds ap.
*/
extern virtual function void build_phase(uvm_phase phase);
/**
* Oversees driving, depending on the reset state, by calling drv_<pre|in|post>_reset() tasks.
*/
extern virtual task run_phase(uvm_phase phase);
/**
* Called by run_phase() while agent is in pre-reset state.
*/
extern task drv_pre_reset();
/**
* Called by run_phase() while agent is in reset state.
*/
extern task drv_in_reset();
/**
* Called by run_phase() while agent is in post-reset state.
*/
extern task drv_post_reset();
/**
* Drives the 'flush_ack' signal in response to 'flush_req' being asserted.
*/
extern task drv_slv_flush_ack();
endclass : uvma_fencei_drv_c
function uvma_fencei_drv_c::new(string name="uvma_fencei_drv", uvm_component parent=null