日常記錄(80)清理
阿新 • • 發佈:2022-03-28
本總結使用的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
外部傳值
使用\(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
rs鎖存器真值表
import和include
前者是引用,後者是展開