core-v-verif系列之lib<45>
UVM环境介绍
HEAD commitID: 1f968ef
//
// Copyright 2020 OpenHW Group
// Copyright 2020 Datum Technology Corporation
//
// 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_CLKNRST_BASE_SEQ_SV__
`define __UVMA_CLKNRST_BASE_SEQ_SV__
/**
* Abstract object from which all other Clock & Reset agent sequences must extend.
* Subclasses must be run on Clock & Reset sequencer (uvma_clknrst_sqr_c) instance.
*/
class uvma_clknrst_base_seq_c extends uvm_sequence#(
.REQ(uvma_clknrst_seq_item_c),
.RSP(uvma_clknrst_seq_item_c)
);
`uvm_object_utils(uvma_clknrst_base_seq_c)
`uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
/**
* Default constructor.
*/
extern function new(string name="uvma_clknrst_base_seq");
endclass : uvma_clknrst_base_seq_c
function uvma_clknrst_base_seq_c::new(string name="uvma_clknrst_base_seq");
super.new(name);
endfunction : new
`endif // __UVMA_CLKNRST_BASE_SEQ_SV__
下面将基于你当前正在编辑的 /home/corelab/lincoln/core-v-verif/core-v-verif/lib/uvm_agents/uvma_clknrst/seq/uvma_clknrst_base_seq.sv
文件,按照要求进行分析。
class uvma_clknrst_base_seq_c extends uvm_sequence#(
.REQ(uvma_clknrst_seq_item_c),
.RSP(uvma_clknrst_seq_item_c)
);
uvma_clknrst_base_seq_c
的类,它继承自 uvm_sequence
。uvm_sequence
是 UVM(通用验证方法学)里用于定义序列的基类。这里通过参数化的方式,将请求(REQ
)和响应(RSP
)的类型都指定为 uvma_clknrst_seq_item_c
,表明该序列处理的事务类型为 uvma_clknrst_seq_item_c
。uvm_sequence
让 uvma_clknrst_base_seq_c
具备序列的基本功能,能在 UVM 环境里生成和管理事务序列。指定请求和响应类型,保证了序列和其他组件间能正确传递 uvma_clknrst_seq_item_c
类型的事务。`uvm_object_utils(uvma_clknrst_base_seq_c)
`uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
uvm_object_utils(uvma_clknrst_base_seq_c)
:这是 UVM 提供的宏,用于将 uvma_clknrst_base_seq_c
类注册到 UVM 对象工厂。注册后,该类就能在 UVM 环境里动态创建、复制和打印等。uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
:此宏声明了一个指向 uvma_clknrst_sqr_c
类型序列器的指针 p_sequencer
,方便序列访问序列器的成员和方法。uvma_clknrst_base_seq_c
能更好地融入 UVM 框架;声明序列器指针,使序列能和指定类型的序列器交互,完成事务的发送和调度。extern function new(string name="uvma_clknrst_base_seq");
extern
关键字声明构造函数 new
,意味着该函数的实现位于类定义外部。构造函数接收一个字符串参数 name
,默认值为 "uvma_clknrst_base_seq"
,用于指定对象的名称。extern function new(string name="uvma_clknrst_base_seq");
name
,默认值是 "uvma_clknrst_base_seq"
。这个参数用于在创建 uvma_clknrst_base_seq_c
类的对象时指定对象的名称。`ifndef __UVMA_CLKNRST_BASE_SEQ_SV__
`define __UVMA_CLKNRST_BASE_SEQ_SV__
// ... 类定义 ...
`endif // __UVMA_CLKNRST_BASE_SEQ_SV__
ifndef
、define
和 endif
来防止头文件的重复包含。当 __UVMA_CLKNRST_BASE_SEQ_SV__
宏未定义时,定义该宏并编译类定义部分的代码;若已定义,则跳过这部分代码的编译。function uvma_clknrst_base_seq_c::new(string name="uvma_clknrst_base_seq");
super.new(name);
endfunction : new
uvm_sequence
的构造函数 super.new(name)
,把传入的 name
参数传递给父类进行初始化。uvma_clknrst_base_seq_c
类的对象时,先调用父类的构造函数完成父类部分的初始化,保证对象能正常使用父类的属性和方法。uvma_clknrst_base_seq_c
类是一个基于 UVM 方法学的序列基类,其他时钟与复位代理的序列都要继承该类。它借助继承 uvm_sequence
获得序列的基本功能,通过 UVM 工具宏注册到 UVM 对象工厂并声明序列器指针,方便和序列器交互。头文件保护机制保证了代码不会被重复编译,构造函数调用父类构造函数完成初始化。该类为时钟与复位代理的序列设计提供了基础框架,提升了代码的可维护性和可扩展性。
//
// Copyright 2020 OpenHW Group
// Copyright 2020 Datum Technology Corporation
//
// 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_CLKNRST_RESTART_CLK_SEQ_SV__
`define __UVMA_CLKNRST_RESTART_CLK_SEQ_SV__
/**
* Object holding sequence library for Clock & Reset agent.
*/
class uvma_clknrst_restart_clk_seq_c extends uvma_clknrst_base_seq_c;
`uvm_object_utils (uvma_clknrst_restart_clk_seq_c);
`uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
extern function new(string name="uvma_clknrst_restart_clk_seq");
extern task body();
endclass : uvma_clknrst_restart_clk_seq_c
function uvma_clknrst_restart_clk_seq_c::new(string name="uvma_clknrst_restart_clk_seq");
super.new(name);
endfunction : new
task uvma_clknrst_restart_clk_seq_c::body();
uvma_clknrst_seq_item_c clknrst_seq_item;
clknrst_seq_item = uvma_clknrst_seq_item_c::type_id::create("clknrst_seq_item", , get_full_name());
start_item(clknrst_seq_item);
clknrst_seq_item.action = UVMA_CLKNRST_SEQ_ITEM_ACTION_RESTART_CLK;
finish_item(clknrst_seq_item);
endtask : body
`endif // __UVMA_CLKNRST_RESTART_CLK_SEQ_SV__
class uvma_clknrst_restart_clk_seq_c extends uvma_clknrst_base_seq_c;
uvma_clknrst_restart_clk_seq_c
的类,它继承自 uvma_clknrst_base_seq_c
。uvma_clknrst_base_seq_c
可能是时钟和复位序列的基类,通过继承,uvma_clknrst_restart_clk_seq_c
可以复用基类的属性和方法。uvma_clknrst_restart_clk_seq_c
专注于实现重启时钟的序列功能,而一些通用的序列操作可以在基类中实现。`uvm_object_utils (uvma_clknrst_restart_clk_seq_c);
`uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
uvm_object_utils(uvma_clknrst_restart_clk_seq_c)
:这是 UVM 提供的宏,用于将 uvma_clknrst_restart_clk_seq_c
类注册到 UVM 对象工厂。注册后,该类的对象可以在 UVM 环境中动态创建、复制和打印等。uvm_declare_p_sequencer(uvma_clknrst_sqr_c)
:声明一个指向 uvma_clknrst_sqr_c
类型序列器的指针 p_sequencer
,方便序列访问序列器的成员和方法。uvma_clknrst_restart_clk_