uvm demo

作者: Poisson_Lee | 来源:发表于2019-07-05 14:49 被阅读0次
    program uvm_hw();
    import uvm_pkg::*;
    initial begin
    `uvm_info("uvm_hw", "uvm, hello world!", UVM_NONE);
    end
    endprogram
    

    vcs -full64 -sverilog -R -ntb_opts uvm-1.1 uvm_hw.sv

    文件uvm_run_test.sv

    import uvm_pkg::*;
    `include "uvm_macros.svh"
    
    class nouse extends uvm_component;
      function new(string name, uvm_component parent =null);
        super.new(name, parent);
      endfunction
    
      `uvm_component_utils(nouse)
    
      task run_phase(uvm_phase phase);
        `uvm_info("no_use", "hello world!", UVM_NONE);
      endtask
    
    endclass
    
    program uvm_run_test();
      initial begin
        run_test();
      end
    endprogram
    
    

    vcs -full64 -sverilog -R -ntb_opts uvm-1.1 uvm_run_test.sv

    编译通过,但是仿真报错如下:


    Screenshot 2019-07-05 at 3.53.53 PM.png

    报错信息可见,在program里没有例化任何组件,或者没有注册并命令行指定执行uvm_test,会报fatal错误。

    在上面的文件的program部分做简单修改

    initial begin
      nouse inst = nouse::type_id::create("nouse_inst", null);
      run_test();
    end
    

    重新执行,组件正常运行。

    Screenshot 2019-07-05 at 4.45.00 PM.png

    如果用uvm_test的方式来执行。
    可以增加一个uvm_test扩展,如下:

    class nouse_test extends uvm_test;
      function new(string name, uvm_component parent=null);
        nouse inst;
        super.new(name, parent);
        inst = nouse::type_id::create("nouse_inst", this);
      endfunction
      `umm_component_utils(nouse_test)
    endclass
    
    

    在nouse_test里例化nouse组件,把刚才在program的initial begin块里的nouse组件的例化语句删掉。

    执行vcs -full64 -sverilog -R -ntb_opts uvm-1.1 +UVM_TESTNAME=nouse_test uvm_run_test.sv

    正常运行,结果如下:


    Screenshot 2019-07-05 at 4.59.49 PM.png

    可以看到仿真结果的差别,在于后者的输出信息里,nouse_inst前面多了一级层次结构uvm_test_top。

    也许这是最短的uvm demo例子


    Screenshot 2019-07-05 at 5.03.38 PM.png

    相关文章

      网友评论

          本文标题:uvm demo

          本文链接:https://www.haomeiwen.com/subject/pgcehctx.html