[转]UVM入门实验0

一、编译UVM代码

编译文件uvm_compile.sv,等待正常编译结束,在work库中仿真模块uvm_compile,在命令窗口执行run -all

uvm_compile.sv代码

module uvm_compile;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  initial begin
    `uvm_info("UVM", "Hello, welcome to RKV UVM training!", UVM_LOW)
    #1us;
    `uvm_info("UVM", "Bye, and more gifts waiting for you!", UVM_LOW)
  end
endmodule

UVM验证顶层都必须有import uvm_pkg::*'include "uvm_macros.svh"这两行代码代表着预编译的UVM库。

仿真结果:
在这里插入图片描述

二、SV与UVM之间的关系

通过编译仿真sv_class_inst.sv文件,实际上是SV模块实验环节的抽象,它只是在顶层module容器中要例化软件验证环境的顶层,即SV class top。从打印出的信息可以看出,相当于测试的开始,到验证环境的搭建,激励的发送,检查的执行等,最后又到了测试的结束。

sv_class_inst.sv代码

module sv_class_inst;

  import uvm_pkg::*;
  `include "uvm_macros.svh"

  class top;
    function new();
      `uvm_info("SV_TOP", "SV TOP creating", UVM_LOW)
    endfunction
  endclass

  initial begin
    top t; 
    `uvm_info("SV_TOP", "test started", UVM_LOW)
    t = new();
    `uvm_info("SV_TOP", "test finished", UVM_LOW)
  end

endmodule

仿真结果:
在这里插入图片描述
而编译仿真uvm_class_inst.sv,从打印的信息来看,也是在模拟验证结构的创立,只不过利用了UVM类uvm_component来定义了top类,继而在创建了这个“顶层”验证结构

uvm_class_inst.sv代码

module uvm_class_inst;

  import uvm_pkg::*;
  `include "uvm_macros.svh"

  class top extends uvm_component;
    `uvm_component_utils(top)
    function new(string name = "top", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("UVM_TOP", "SV TOP creating", UVM_LOW)
    endfunction
  endclass


  initial begin
    top t; 
    `uvm_info("UVM_TOP", "test started", UVM_LOW)
    t = new("t", null);
    `uvm_info("UVM_TOP", "test finished", UVM_LOW)
  end

endmodule

仿真结果:
在这里插入图片描述
所谓的UVM验证环境指的首先是提供一个UVM的“容器”,即接下来所有的UVM对象都会放置在其中,这样也可以成为UVM的顶层,这就类似于之前SV模块实验中的顶层容器test一样。

三、UVM验证顶层与SV验证顶层的对比

编译仿真uvm_test_inst.sv文件,从打印信息看出UVM验证结构的构建经历了9个phase。

uvm_test_inst.sv代码

package test_pkg;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  class top extends uvm_test;
    `uvm_component_utils(top)
    function new(string name = "top", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("UVM_TOP", "SV TOP creating", UVM_LOW)
    endfunction
    task run_phase(uvm_phase phase);
      phase.raise_objection(this);
      `uvm_info("UVM_TOP", "test is running", UVM_LOW)
      phase.drop_objection(this);
    endtask
  endclass

endpackage

module uvm_test_inst;

  import uvm_pkg::*;
  `include "uvm_macros.svh"
  import test_pkg::*;


  initial begin
    `uvm_info("UVM_TOP", "test started", UVM_LOW)
    run_test("top");
    `uvm_info("UVM_TOP", "test finished", UVM_LOW)
  end

endmodule

仿真结果:
在这里插入图片描述

四、启动UVM验证的必要步骤

只有继承于uvm_test的类,才可以作为UVM验证环境的顶层,创建顶层验证环境,有且只能依赖于run_test(“UVM_TEST_NAME”)来传递,或者通过仿真参数传递,而不是通过构建函数new(),尽管new()可以创建一个对象,但是不能做与顶层验证环境相关的其他工作。

搭建验证框架 -> 验证组件之间的连接和通信 -> 编写测试用例,继而完成复用和覆盖率收敛

---------------------
作者:煎丶包
来源:CSDN
原文:https://blog.csdn.net/qq_39794062/article/details/113925849
版权声明:本文为作者原创文章,转载请附上博文链接!
内容解析By:CSDN,CNBLOG博客文章一键转载插件

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值