仿真,vcs和ncverilog 用户接口

仿真工具

1. vcs

调用方式

simv -ucli -do xxx.tcl

tcl脚本内容

# pin相关操作
#   查找某个pin, 返回{top_tb.chip.vcss}, 如果不存在则返回空.
ucli% search top_tb.chip.vss

# force时钟
ucli% force top_tb.chip.SYS_CLK 0 0ns, 1 10ns -repeat 20ns

# force bus, 中括号需要转义
ucli% force top_tb.chip.data\[7:0\] 8'hFF

#   获取某个pin的值, 得到的是'b0, 'b1, 'bz这种值
ucli% get top_tb.chip.trstn

# dump波形操作
ucli% call {$fsdbDumpfile "./test.fsdb"}
ucli% call {$fsdbDumpvars (0, top_tb.chip)}
ucli% call {$fsdbDumpon}
ucli% call {$fsdbDumpMDA} ;# dump二维数组的波形
ucli% run 100ns
ucli% call {$fsdbDumpflush}

# dump波形, 波形名称带变量
ucli% fsdbDumpfile ./wave/vcs_$env(PATT).fsdb
ucli% fsdbDumpvars 0 TB
ucli% fsdbDumpon
ucli% $fsdbDumpMDA ;# dump二维数组的波形
ucli% run 100ns
ucli% fsdbDumpflush




#获得当前仿真时间, 单位是fs
ucli% set a $now
ucli% run 100ns
ucli% puts "time=$now"; # 163100000000
ucli% puts "a=$a"     ; # 163000000000

2. ncverilog

2.1 ncsim接口

调用方式

忘了

tcl脚本内容

# pin相关操作
ncsim% find -scope top_tb.chip vss # 查找某个pin, 返回chip.vss
ncsim% force top_tb.chip.SYS_CLK 0 -after 0ns 1 -after 10ns -repeat 20ns # force时钟
ncsim% value top_tb.chip.trstn     # 获取某个pin的值
ncsim% deposit top_tb.chip.xx_reg.Q 1'b0 # 给寄存器赋初值

# dump波形操作
ncsim% set fsdbfile "./test.fsdb"
ncsim% call {$fsdbAutoSwitchDumpfile} 5000 $fsdbfile 20}
ncsim% call {$fsdbDumpvars} {0} {top_tb.chip}
ncsim% call {$fsdbDumpon}
ncsim% run 100ns
ncsim% run -absolute 200ns
ncsim% call {$fsdbDumpflush}

2.2 指定某几个inst为blackbox

不需要指定top_tb.chip层次, 在nc的仿真选项中添加:

-ncargs "-bbinst U_A/U_xx -bbinst U_B/U_yy" # 直接指定inst
-ncargs "-bblist ip0.txt -bblist ip1.txt"   # 指定通过filelist指定inst

其中ip0.txt, ip1.txt是文本文件, 每行列出一个inst.

ip0.txt:
    U_A/U_SDS0
    U_A/U_SDS1
ip1.txt:
    U_B/U_DDR0
    U_B/U_DDR1

3. cell只dump端口信号, 不dump单元内部信号

+fsdb+skip_cell_instance=2

posted @ 2021-12-01 09:54  编程驴子  阅读(1588)  评论(0编辑  收藏  举报