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_DEBUG_MON_TRN_LOGGER_SV__
`define __UVMA_DEBUG_MON_TRN_LOGGER_SV__
/**
* Component writing Debug monitor transactions debug data to disk as plain text.
*/
class uvma_debug_mon_trn_logger_c extends uvml_logs_mon_trn_logger_c#(
.T_TRN (uvma_debug_mon_trn_c),
.T_CFG (uvma_debug_cfg_c ),
.T_CNTXT(uvma_debug_cntxt_c )
);
`uvm_component_utils(uvma_debug_mon_trn_logger_c)
/**
* Default constructor.
*/
function new(string name="uvma_debug_mon_trn_logger", uvm_component parent=null);
super.new(name, parent);
endfunction : new
/**
* Writes contents of t to disk
*/
virtual function void write(uvma_debug_mon_trn_c t);
// TODO Implement uvma_debug_mon_trn_logger_c::write()
// Ex: fwrite($sformatf(" %t | %08h | %02b | %04d | %02h |", $realtime(), t.a, t.b, t.c, t.d));
endfunction : write
/**
* Writes log header to disk
*/
virtual function void print_header();
// TODO Implement uvma_debug_mon_trn_logger_c::print_header()
// Ex: fwrite("----------------------------------------------");
// fwrite(" TIME | FIELD A | FIELD B | FIELD C | FIELD D ");
// fwrite("----------------------------------------------");
endfunction : print_header
endclass : uvma_debug_mon_trn_logger_c
/**
* Component writing DEBUG monitor transactions debug data to disk as JavaScript Object Notation (JSON).
*/
class uvma_debug_mon_trn_logger_json_c extends uvma_debug_mon_trn_logger_c;
`uvm_component_utils(uvma_debug_mon_trn_logger_json_c)
/**
* Set file extension to '.json'.
*/
function new(string name="uvma_debug_mon_trn_logger_json", uvm_component parent=null);
super.new(name, parent);
fextension = "json";
endfunction : new
/**
* Writes contents of t to disk.
*/
virtual function void write(uvma_debug_mon_trn_c t);
// TODO Implement uvma_debug_mon_trn_logger_json_c::write()
// Ex: fwrite({"{",
// $sformatf("\"time\":\"%0t\",", $realtime()),
// $sformatf("\"a\":%h," , t.a ),
// $sformatf("\"b\":%b," , t.b ),
// $sformatf("\"c\":%d," , t.c ),
// $sformatf("\"d\":%h," , t.c ),
// "},"});
endfunction : write
/**
* Empty function.
*/
virtual function void print_header();
// Do nothing: JSON files do not use headers.
endfunction : print_header
endclass : uvma_debug_mon_trn_logger_json_c
`endif // __UVMA_DEBUG_MON_TRN_LOGGER_SV__
lib/uvm_agents/uvma_debug/uvma_debug_mon_trn_logger.sv
1. 简要介绍
该文件是Debug验证环境的监控事务日志记录器实现,主要功能包括:
- 提供文本和JSON两种日志格式
- 记录监控事务数据到磁盘
- 支持自定义日志头格式
2. 接口介绍
2.1 基类定义
class uvma_debug_mon_trn_logger_c extends uvml_logs_mon_trn_logger_c#(
.T_TRN(uvma_debug_mon_trn_c),
.T_CFG(uvma_debug_cfg_c),
.T_CNTXT(uvma_debug_cntxt_c)
);
- 代码介绍:定义基础日志记录器类
- 模板参数:
- T_TRN:事务类型
- T_CFG:配置类型
- T_CNTXT:上下文类型
2.2 JSON派生类
class uvma_debug_mon_trn_logger_json_c extends uvma_debug_mon_trn_logger_c;
- 代码介绍:定义JSON格式日志记录器
- 继承关系:继承自基础日志记录器
3. 参数介绍
3.1 文件扩展名
fextension = "json";
- 参数说明:设置JSON文件扩展名
- 位置:JSON派生类构造函数
3.2 UVM组件宏
`uvm_component_utils(uvma_debug_mon_trn_logger_c)
- 参数说明:注册UVM组件
- 功能:支持自动化操作
4. 模块实现介绍
4.1 构造函数
function new(string name="uvma_debug_mon_trn_logger", uvm_component parent=null);
super.new(name, parent);
endfunction
- 代码分析:简单调用父类构造函数
- 关键点:保持标准初始化流程
4.2 写方法
virtual function void write(uvma_debug_mon_trn_c t);
// TODO Implement write logic
endfunction
- 代码分析:预留事务写入实现
- 设计特点:待扩展的事务记录逻辑
5. 总结
该日志记录器具有以下特点:
- 灵活的多格式支持
- 清晰的类层次结构
- 可扩展的写入接口
- 标准化的UVM实现
作为验证环境的辅助组件,它为Debug监控事务提供了可靠的记录能力,便于后续分析和调试。
// 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_DEBUG_MON_SV__
`define __UVMA_DEBUG_MON_SV__
/**
* Component sampling transactions from a Debug virtual interface
* (uvma_debug_if).
*/
class uvma_debug_mon_c extends uvm_monitor;
// Objects
uvma_debug_cfg_c cfg;
uvma_debug_cntxt_c cntxt;
// TLM
uvm_analysis_port#(uvma_debug_mon_trn_c) ap;
`uvm_component_utils_begin(uvma_debug_mon_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_debug_mon", uvm_component parent=null);
/**
* 1. Ensures cfg & cntxt handles are not null.
* 2. Builds ap.
*/
extern virtual function void build_phase(uvm_phase phase);
/**
* Updates the context's reset state.
*/
extern virtual task observe_reset();
/**
* Called by run_phase() while agent is in pre-reset state.
*/
extern virtual task mon_pre_reset(uvm_phase phase);
/**
* Called by run_phase() while agent is in reset state.
*/
extern virtual task mon_in_reset(uvm_phase phase);
/**
* Called by run_phase() while agent is in post-reset state.
*/
extern virtual task mon_post_reset(uvm_phase phase);
/**
* Creates trn by sampling the virtual interface's (cntxt.vif) signals.
*/
extern virtual task sample_trn(output uvma_debug_mon_trn_c trn);
/**
* TODO Describe uvma_debug_mon_c::process_trn()
*/
extern virtual function void process_trn(ref uvma_debug_mon_trn_c trn);
endclass : uvma_debug_mon_c
`pragma protect begin
function uvma_debug_mon_c::new(string name="uvma_debug_mon"