VCS (Verilog Compile Simulator)如何使用

compiles with IEEE1364 : verilog語言的仿真基於分層的事件隊列
VCS 仿真模塊的順序(先從沒有延遲的事件開始,執行它們,然後把時間設爲0,然後按照時間順序依次執行各個時間,同一層的時間,什麼執行順序都是可以的):
(1)no delay(initial / always)
(2)set t=0
(3)active region
執行一些原語(UDP),$display,assigns,blocking assignments,nonblocking RHS
(4)inactive region (#0)
(5)Nonblocking assign region 非阻塞語句賦值
(6)monitor region ( $ strobe $ monitor ) 當變量發生變化,檢測
(7)future region 其他指定的PLI命令語句
Verilog PLI(Programming Language Interface )是一種Verilog代碼調用C/C++函數的機制。它能讓Verilog像調用一些系統調用(如 $display/ $stop/ $random)一樣調用用戶編寫的C/C++函數,這樣我們可以用C/C++語言開始自己的system task/function, 來實現用verilog不太方便的功能,並與外界建立了聯繫。

在這裏插入圖片描述
VCS 的運行方式有兩種,一種是交互模式(interactive mode),一種是批處理模式(batch
mode),兩種方式各有優劣,具體用在不同的情況下。在測試小模塊或者底層模塊,情況不
太複雜的時候,而又需要很詳細信息的時候,可以採用交互模式,交互性能更好,顯示更直
觀;當進行復雜測試而關注於整體性能,而不必去查看每個信號的時候,只需要查看所需要
關心的信號即可,這種情況可以用批處理模式

  • Interactive Simulator Controls
    步驟:RTL、TB(加入vcspluson 否則無法debug)
    直接輸入命令
    vcs souce_file -full64 +v2k debug_pp -l compile.log
    ./simv -gui -l fsm.log
    或者
    vcs souce_file -full64 +v2k debug_pp -R -gui -l
  • post-processing with VCD+ files
    編寫makefile對電路進行處理,一般用於後期的仿真

(一)編譯compile
VCS對源文件進行編譯,生成中間文件和可執行文件

  • -Mupdate (Incremental compilation (only changed files are compiled)

  • -R (Run after compilation)

  • -gui (Starts the DVE gui at runtime)

  • -l filename (set log file name)

  • -sverilog (Enable SystemVerilog language support)

  • +v2k (compile with support for verilog 2001 extensions)

  • -v lib_file (search for unresolved module reference in the lib_file)尋找設計文件中缺少的UDP或模塊(尋找設計文件中未定義但已實例引用的UDP或模塊編譯器)

  • -y lib_dir (search for unresolved module reference in files residing in directory lib_dir)

  • +libext+lib_ext (vcs 在參考庫目錄下尋找以.v和.vhd爲擴展名的文件,多個擴展名之間用“+”連接)

  • +licdir+inc_dir (search inc_dir directory for `include files)

  • -f file(File containing a list of absolute pathnames for the source_files and a subset of VCS options)

  • -o foo(Creats executable foo instead of simv)

  • -full64 (vcs 以64位模式編譯,生成64位的simv)

  • -comp64(vcs 以64位模式編譯,生成32位的simv)

  • -debug_pp (產生vpd文件,enable DVE for post-processing)

  • -debug (相對於-debug_pp,多了UCLI調試功能)

  • -debug_all (相對於-debug_all,多了單步調試功能)

  • -notice 給出詳細的編譯信息

  • -q 不在終端輸出編譯時的信息

  • +define+macrol+ 將宏macrol傳給源代碼

  • +notimingcheck 禁止時序檢查任務,改善仿真速度

  • -E echo (displays compile-time options used for the creation of the current simv executable)

  • -s (編譯之後,運行simv時,仿真時刻停止在0處)

  • +rad (開啓仿真時的radiant技術,會將代碼進行優化,會增加編譯時間)
    Improve RTL simulation performance by using the +rad compile time switch,Fast RTL-level verification can be able to Improve RTL simulation performance with good coding styles.
    good coding styles:
    (1)use synthesizable subset of verilog language
    1、Give VCS better chance of perform code optimization
    (2)raise your level of abstraction
    1、give simulator less work to do
    (3)avoid inefficient constructs
    1、switch level primitive and bidirectional
    2、strength modeling
    (4)use small stimulus blocks
    1、avoid large initial blocks(<10000 line of code)
    2、use file based stimulus (例如readmemh)

  • -timescale=<time_unit>/<time_precision>

  • +race (自動產生一個race.out 文件,列出競爭)

  • +prof (產生一個vcs.prof文件,報告CPU和memory的使用情況,可以找到關鍵路徑和memory consumption)

  • -xzcheck (當一個條件等於x、z的值,VCS給出警告信息,可以在模塊中加入$xzcheckoff 和 $xzcheckon)

  • -line (實現單步仿真,將會極大地增加運行時間)

  • -nospecify (禁止模塊路徑延遲和時序檢查,提高仿真速度)

(二)simulation
Simulation results reported via
(1) Verilog system task calls
(2) User defined PLI routines

Three general debugging methods:
(1) verilog SystemVerilog System Task calls
(2) VCS UCLI
(3) VCS DVE(GUI)

Four factors to consider:

  • simulation speed
  • signal visibility
  • signal tractability
  • usability

系統任務:

  • Debug visibility:
    (1)$ display (prints formatted message to console)
    (2)$ strobe(Like $display except printing is delayed until all events in the current time step have executed)
    (3) $ monitor (Monitor signals listed and prints formatted message whenever one of the listed signals changes)
    (4)$time (Returns current simulation time as a 64bits integer)
  • stopping simulation
    (1)$ stop (Halts simulation like a breakpoint)
    (2) $finish (Halts simulation and terminated the simulation)
  • Simulation stimulus and reference
    (1)$ readmemh/$readmemb (reads ASCII data from a disk file,each digit is hexadecimal/binary)
  • Read/Write commands:
    (1)$force [-deposit] [-freeze] [-drive] path value
    (2) $release path
    (3) $memory-read | -write nid -file filename [-radix radix][-start start_address][-end end_address]
  • 調試DVE(Discovery Visual Environment)
    (1)$dumpvars (創建一個VCD文件)
    (2) $vcdplusfile(“filename”); (指定一個vpd文件名代替默認vcdplus.vpd)
    (3) $vcdpluson(level,instance,net_or_reg) (開始創建一個vpd文件,level表示記錄的層次,0或者缺省表示所有層;instance爲模塊的例化名;net_or_reg爲net變量或reg變量,缺省時記錄所有的變量)
    (4) $vcdplusoff(instance,net_or_reg) (停止寫vpd文件)
    (5) $vcdplusautoflushon (當vcs遇到中斷時,將仿真結果寫入vpd文件中)
    (6) $vcdplusautoflushoff (關閉自動flush)
    (7) $test $plusargs (在testbench中包括該任務,可以在仿真中加入該任務的參數來控制某段代碼是否執行)
initial
	if($test$plusargs("postprocess"))
	begin
		$vcdpluson;
		#10000 $vcdplusoff;
	end
//運行時,simv+postprocess 即可執行if中的代碼,否則不執行

(三)C/C++, System C
在這裏插入圖片描述
在這裏插入圖片描述
最終可debug PLI命令語句(可以使用ctrl+c kill halt simulation, $ display 和$monitor print out to determine the cause of the problem)

(四)code coverage
1、statement or line coverage:檢測哪一行,哪一條語句沒有執行
在這裏插入圖片描述
2、toggle coverage:檢測net、reg和向量中的每一位是否都經過了0->1和1->0的跳轉
在這裏插入圖片描述
3、conditional coverage:檢測代碼的條件爲1或0是否都出現過
在這裏插入圖片描述
4、fsm coverage:檢測狀態的跳轉和哪一個狀態沒有被跳轉到,以及錯誤的狀態跳轉
在這裏插入圖片描述
5、path coverage:顯示initial和always塊中所有條件的組合是否實現
在這裏插入圖片描述
VCS Coverage Metrics
在這裏插入圖片描述

  • Batch mode:to generate coverage report file and graded test cases
    vcs -cm_pp -cm line -cm_dir directory -cm_hier hieroptions
  • GUI mode:to show and manipulate coverage data in graphical form
    vcs -cm_pp -cm line -cm_dir directory -cm_hier hieroptions -gui

vcs sourcefiles -cm <coverage_type> < other coverage options>

  • 其中-cm <coverage_type> specifies the type of coverage to collect:(The options are line、tgl、cond、fsm、path)
  • -cm_dir: to specify an alternate location and name of the coverage database
  • rename simv.cm with -o
  • -cm_hier: (configuration file,which includes/excludes parts of design for different kinds of coverage)
  • -cm_name :specifies the name of report files (instead of default cmview),usually defines testcase name for coverage database.

transport delay:小於該延遲的脈衝仍然可以通過
inertial delay:小於該延遲的脈衝無法通過,默認的sdf文件中的gates、switchs、UDP、module input port delay、和連續賦值的延遲都是慣性延遲。

發佈了65 篇原創文章 · 獲贊 5 · 訪問量 3658
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章