日常记录(80)清理

本总结使用的Makefile

default:
	vcs -sverilog -R -ntb_opts uvm-1.2 taa.sv
tbb:
	vcs -full64 -sverilog -debug_acc -R tbb.sv 
dve:
	./simv -gui &
tcc:
	vcs -full64 -sverilog -debug_acc -R tcc.sv +get_a_value=100

clean:
	rm -rf *.log csrc simv.daidir simv ucli.key vc_hdrs.h DVEfiles simv.cst *.vpd simv.vdb urgReport tags

断言

property写法像一个函数,还可以带参数。
assert的时候还需要写一个property。
rst_n为高,disable失效,才开始进行断言,否则不断言。

module tbb ();
    reg clk, rst_n;
    reg q;

    initial begin
        clk = 0;
        rst_n = 0;
        forever begin
            #10 clk = ~clk;
        end
    end

    property p1;
        @(posedge clk) disable iff(!rst_n) q==1;
    endproperty

    initial begin
        #21 rst_n = 1;
        #200 q=1;
        #800 q=0;
        $finish;
    end

    assert property(p1);
endmodule

image

外部传值

使用\(value\)plusargs的方法,内部和scanf之类的c函数类似。

module tcc ();
    initial begin
        int value;
        $value$plusargs("get_a_value=%d", value);
        $display("value is %d", value);
    end
endmodule

输出:

value is         100

vim折叠

zR打开全部
zM关闭全部
za当前位置折叠取反

UVM默认的info设置

action并不是全都打开的,如果需要记录log,则需要手动打开。
另外可以看到默认的冗余等级是MEDIUM

uvm_report_handler.svh

  // Function- initialize
  //
  // Internal method for initializing report handler.

  function void initialize();

    set_default_file(0);
    m_max_verbosity_level = UVM_MEDIUM;

    id_actions=new();
    id_verbosities=new();
    id_file_handles=new();
    sev_overrides=new();

    set_severity_action(UVM_INFO,    UVM_DISPLAY);
    set_severity_action(UVM_WARNING, UVM_DISPLAY);
    set_severity_action(UVM_ERROR,   UVM_DISPLAY | UVM_COUNT);
    set_severity_action(UVM_FATAL,   UVM_DISPLAY | UVM_EXIT);

    set_severity_file(UVM_INFO, default_file_handle);
    set_severity_file(UVM_WARNING, default_file_handle);
    set_severity_file(UVM_ERROR,   default_file_handle);
    set_severity_file(UVM_FATAL,   default_file_handle);

  endfunction

uvm的log文件写入

  • 最重要的是env的实例化应该放到前面,然后log设置要放到后面。
  • 另外就是要设置action步骤
module taa ();
    import uvm_pkg::*;

    class test_env extends uvm_env;
        `uvm_component_utils(test_env)
        
        function new(string name="test_env", uvm_component parent);
            super.new(name, parent);
        endfunction: new

        function void connect_phase(uvm_phase phase);
            `uvm_info("XXXX", $sformatf("message2"), UVM_LOW)
        endfunction:connect_phase
    endclass: test_env

    class test_base extends uvm_test;
        `uvm_component_utils(test_base)
        test_env env;
        UVM_FILE file_handler;
        
        function new(string name="test_base", uvm_component parent);
            super.new(name, parent);
        endfunction: new

        function void build_phase(uvm_phase phase);
            super.build_phase(phase);
            env = test_env::type_id::create("test_env", this);
            file_handler = $fopen("logfile.log", "w");
            set_report_id_action_hier("XXXX", UVM_DISPLAY | UVM_LOG);
            set_report_id_file_hier("XXXX", file_handler);
        endfunction: build_phase

        function void connect_phase(uvm_phase phase);
            `uvm_info("XXXX", $sformatf("message1"), UVM_LOW)
        endfunction: connect_phase

        function void final_phase(uvm_phase phase);
            $fclose(file_handler);
        endfunction:final_phase
    endclass: test_base

    initial begin
        run_test("test_base");
    end
endmodule

输出到文件:

UVM_INFO taa.sv(12) @ 0: uvm_test_top.test_env [XXXX] message2
UVM_INFO taa.sv(34) @ 0: uvm_test_top [XXXX] message1

assert和cover

image

rs锁存器真值表

image

import和include

前者是引用,后者是展开

posted @ 2022-03-28 16:37  大浪淘沙、  阅读(116)  评论(0)    收藏  举报