【摸魚范式】【一】UVM入門教程【文字版】


視頻版:

https://www.bilibili.com/video/av839767912

課程前准備

建議准備仿真軟件,熟悉VCS的同學可以直接使用VCS,不熟悉的同學建議直接再win平台的Questa就行了。

使用Questa前期不用打開GUI,不需要看波形,questa的圖形界面還是有點卡的。

首先來看第一節課的代碼

module lab1 ();
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  initial begin
    `uvm_info("lab1.1","hello uvm!",UVM_NONE)
  end

endmodule

從頭開始看,只要使用了UVM,就必須寫開頭的兩行。import語句導入UVM的包,而include語句則包含了一系列宏定義。由於SV的局限性,不得不借用宏的形式實現一些功能。總之,就像JAVA八股文一樣,UVM的基本書寫也是一樣的八股,但是這只是指代碼基本框架的八股,驗證背后的內容依然要與業務緊密結合。

我們遇到的第一個宏就是uvm_info,用於打印信息

uvm_info使用時需要傳遞三個參數,分別是ID, MSG, VERBOSITY。ID表示是誰發出的信息,MSG就是發出的內容,而最后的VERBOSITY則是冗余度,當冗余度小於閾值時,消息才會被打印出來。

我們可以到UVM學院的一個網站中去查找相關內容:https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/

有興趣的同學可以去自己查閱源碼,看看uvm_info宏背后都做了哪些工作。

冗余度是一個枚舉型變量,默認的等級包括

也可以直接使用具體數值。

接下來是makefile

TESTNAME ?= lab2

all: work tb sim

work:
	vlib work

tb:
	vlog -f filelist.f

sim:
	vsim lab1 -do "run -all;exit" -c -l $(TESTNAME).log -voptargs=+acc

clean:
	rm -r work
	rm *.log transcript vsim.* *.ucdb

vlib建立工作庫

vlog進行文件編譯

vsim進行仿真,-do 選項執行后面雙引號內部的命令,也可以將命令寫入一個do文件中,do文件使用tcl語言編寫,有興趣的同學可以去了解。run -all仿真時直接一直仿真,exit代表仿真結束后退出仿真器,不加exit會停在仿真命令行。-c選項讓仿真器不要打開GUI界面,-l選項讓仿真信息全部輸入到指定文件中,而最后的-voptargs=+acc是仿真器的優化選項。VCS等其他仿真器也會有類似的選項,可以自行了解。

直接make all即可執行,下面是編譯

QuestaSim-64 vlog 10.6c Compiler 2017.07 Jul 26 2017
Start time: 22:06:57 on Apr 27,2021
vlog -f filelist.f -l comp.log 
-- Compiling module lab1
-- Importing package mtiUvm.uvm_pkg (uvm-1.1d Built-in)
** Note: (vlog-2286) ./lab1.sv(3): Using implicit +incdir+E:/questasim64_10.6c/uvm-1.1d/../verilog_src/uvm-1.1d/src from import uvm_pkg

Top level modules:
	lab1
End time: 22:06:58 on Apr 27,2021, Elapsed time: 0:00:01
Errors: 0, Warnings: 0

接下來是執行仿真

# vsim lab1 -do "run -all;exit" -c -l lab2.log -voptargs="+acc" 
# Start time: 22:06:59 on Apr 27,2021
# ** Note: (vsim-3812) Design is being optimized...
# //  Questa Sim-64
# //  Version 10.6c win64 Jul 26 2017
# //
# //  Copyright 1991-2017 Mentor Graphics Corporation
# //  All Rights Reserved.
# //
# //  QuestaSim and its associated documentation contain trade
# //  secrets and commercial or financial information that are the property of
# //  Mentor Graphics Corporation and are privileged, confidential,
# //  and exempt from disclosure under the Freedom of Information Act,
# //  5 U.S.C. Section 552. Furthermore, this information
# //  is prohibited from disclosure under the Trade Secrets Act,
# //  18 U.S.C. Section 1905.
# //
# Loading sv_std.std
# Loading mtiUvm.uvm_pkg
# Loading work.lab1(fast)
# Loading mtiUvm.questa_uvm_pkg(fast)
# Loading E:/questasim64_10.6c/uvm-1.1d\win64\uvm_dpi.dll
# run -all
# ----------------------------------------------------------------
# UVM-1.1d
# (C) 2007-2013 Mentor Graphics Corporation
# (C) 2007-2013 Cadence Design Systems, Inc.
# (C) 2006-2013 Synopsys, Inc.
# (C) 2011-2013 Cypress Semiconductor Corp.
# ----------------------------------------------------------------
# 
#   ***********       IMPORTANT RELEASE NOTES         ************
# 
#   You are using a version of the UVM library that has been compiled
#   with `UVM_NO_DEPRECATED undefined.
#   See http://www.eda.org/svdb/view.php?id=3313 for more details.
# 
#   You are using a version of the UVM library that has been compiled
#   with `UVM_OBJECT_MUST_HAVE_CONSTRUCTOR undefined.
#   See http://www.eda.org/svdb/view.php?id=3770 for more details.
# 
#       (Specify +UVM_NO_RELNOTES to turn off this notice)
# 
# UVM_INFO verilog_src/questa_uvm_pkg-1.2/src/questa_uvm_pkg.sv(215) @ 0: reporter [Questa UVM] QUESTA_UVM-1.2.3
# UVM_INFO verilog_src/questa_uvm_pkg-1.2/src/questa_uvm_pkg.sv(217) @ 0: reporter [Questa UVM]  questa_uvm::init(+struct)
# UVM_INFO ./lab1.sv(6) @ 0: reporter [lab1.1] hello uvm!
# exit
# End time: 22:07:02 on Apr 27,2021, Elapsed time: 0:00:03
# Errors: 0, Warnings: 0

可以看到打印了信息# UVM_INFO ./lab1.sv(6) @ 0: reporter [lab1.1] hello uvm!

軟件:Questasim、gitbash

推薦使用gitbash,使用makefile之前要安裝makefile,教程在這里->https://www.eemaker.com/git-bash-make.html

本節代碼下載鏈接:

鏈接:https://pan.baidu.com/s/1GBhvpGaoG_BNvRZqh-4kPA

提取碼:4rcr


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM