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

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

UVM环境介绍
HEAD commitID: 1f968ef

1. core-v-verif/lib/uvm_agents/uvma_clknrst/seq/uvma_clknrst_base_seq.sv

// 
// 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 文件,按照要求进行分析。

2. 接口介绍

2.1 类定义与继承
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_sequenceuvm_sequence 是 UVM(通用验证方法学)里用于定义序列的基类。这里通过参数化的方式,将请求(REQ)和响应(RSP)的类型都指定为 uvma_clknrst_seq_item_c,表明该序列处理的事务类型为 uvma_clknrst_seq_item_c
  • 逻辑分析:继承 uvm_sequenceuvma_clknrst_base_seq_c 具备序列的基本功能,能在 UVM 环境里生成和管理事务序列。指定请求和响应类型,保证了序列和其他组件间能正确传递 uvma_clknrst_seq_item_c 类型的事务。
2.2 UVM 工具宏
`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 框架;声明序列器指针,使序列能和指定类型的序列器交互,完成事务的发送和调度。
2.3 构造函数声明
extern function new(string name="uvma_clknrst_base_seq");
  • 代码介绍:使用 extern 关键字声明构造函数 new,意味着该函数的实现位于类定义外部。构造函数接收一个字符串参数 name,默认值为 "uvma_clknrst_base_seq",用于指定对象的名称。
  • 逻辑分析:将构造函数的声明和实现分离,能让代码结构更清晰。默认的对象名称方便在创建对象时不指定名称,使用默认值即可。

3. 参数介绍

3.1 构造函数参数
extern function new(string name="uvma_clknrst_base_seq");
  • 代码介绍:构造函数有一个字符串类型的参数 name,默认值是 "uvma_clknrst_base_seq"。这个参数用于在创建 uvma_clknrst_base_seq_c 类的对象时指定对象的名称。
  • 逻辑分析:提供默认值让对象创建更灵活,若用户不指定名称,就使用默认名称;若指定名称,则使用用户提供的名称。

4. 模块实现介绍

4.1 头文件保护
`ifndef __UVMA_CLKNRST_BASE_SEQ_SV__
`define __UVMA_CLKNRST_BASE_SEQ_SV__
// ... 类定义 ...
`endif // __UVMA_CLKNRST_BASE_SEQ_SV__
  • 代码介绍:运用条件编译指令 ifndefdefineendif 来防止头文件的重复包含。当 __UVMA_CLKNRST_BASE_SEQ_SV__ 宏未定义时,定义该宏并编译类定义部分的代码;若已定义,则跳过这部分代码的编译。
  • 逻辑分析:在大型项目里,一个文件可能会被多个地方包含,使用头文件保护机制可避免因重复包含引发的编译错误。
4.2 构造函数实现
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 类的对象时,先调用父类的构造函数完成父类部分的初始化,保证对象能正常使用父类的属性和方法。

5. 总结

uvma_clknrst_base_seq_c 类是一个基于 UVM 方法学的序列基类,其他时钟与复位代理的序列都要继承该类。它借助继承 uvm_sequence 获得序列的基本功能,通过 UVM 工具宏注册到 UVM 对象工厂并声明序列器指针,方便和序列器交互。头文件保护机制保证了代码不会被重复编译,构造函数调用父类构造函数完成初始化。该类为时钟与复位代理的序列设计提供了基础框架,提升了代码的可维护性和可扩展性。

2. core-v-verif/lib/uvm_agents/uvma_clknrst/seq/uvma_clknrst_restart_clk_seq.sv

//
// 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__

2. 接口介绍

2.1 类定义与继承
class uvma_clknrst_restart_clk_seq_c extends uvma_clknrst_base_seq_c;
  • 代码介绍:定义了一个名为 uvma_clknrst_restart_clk_seq_c 的类,它继承自 uvma_clknrst_base_seq_cuvma_clknrst_base_seq_c 可能是时钟和复位序列的基类,通过继承,uvma_clknrst_restart_clk_seq_c 可以复用基类的属性和方法。
  • 逻辑分析:继承机制使得代码具有更好的可维护性和扩展性。uvma_clknrst_restart_clk_seq_c 专注于实现重启时钟的序列功能,而一些通用的序列操作可以在基类中实现。
2.2 UVM 工具宏
`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_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值