此帖转自:
http://blog.blogchina.com/clayboy/1191284.html k5 ~- M+ O' N
6 r) U6 A1 z. J' x; y' Q ^
1.Verilog和Ncverilog命令使用库文件或库目录
, G- [7 ?1 A( x- L% v! I1 S( \$ x
ex). ncverilog -f run.f -v lib/lib.v -y lib2 +libext+.v //一般编译文件在run.f中, 库文件在lib.v中,lib2目录中的.v文件
系统自动搜索
; \' p0 p& v) y9 S 使用库文件或库目录,只编译需要的模块而不必全部编译
1 U. R* R3 Q% [2 h
* ?. Q5 K, h; |: G' C2.Verilog Testbench信号记录的系统任务:
% y7 j; a$ @7 t 1). SHM数据库可以记录在设计仿真过程中信号的变化. 它只在probes有效的时间内记录你set probe on的信号的变化.
) l- V" _) C" C: D ex). $shm_open("waves.shm"); //打开波形数据库
7 j- I! v' _# n $shm_probe(top, "AS"); // set probe on "top",
* ?) F; r1 j$ X& S/ r$ C ~: ~- C
第二个参数: A -- signals of the specific scrope
1 n- q4 ~; f* o/ D
S -- Ports of the specified scope and below, excluding library cells
$ @2 y( T% c4 H! m' ~
C -- Ports of the specified scope and below, including library cells
5 p/ E2 h/ j$ B0 ^2 C
AS -- Signals of the specified scope and below, excluding library cells
7 b: F1 W/ d% m/ u5 {
AC -- Signals of the specified scope and below, including library cells
* C4 D. f% w$ l( b0 N 还有一个 M ,表示当前scope的memories, 可以跟上面的结合使用, "AM" "AMS" "AMC"
. O( s( t6 v* w- |3 V8 i
什么都不加表示当前scope的ports;
v5 }8 [7 @7 b" ^. b& G% E $shm_close //关闭数据库
9 f& a0 X5 I- V7 @& j 2). VCD数据库也可以记录在设计仿真过程中信号的变化. 它只记录你选择的信号的变化.
0 R& G* e2 y% I V) W, ?
ex). $dumpfile("filename"); //打开数据库
: w" s" J! s; z: Q( x $dumpvars(1, top.u1); //scope = top.u1, depth = 1
; k, L9 F( J; ]6 I I( g) A# s 第一个参数表示深度, 为0时记录所有深度; 第二个参数表示scope,省略时表当前的scope.
: f2 J" c% v6 ~" y
$dumpvars; //depth = all scope = all
- ?0 a8 N/ [8 a; h: y
$dumpvars(0); //depth = all scope = current
9 p4 q$ P: @9 W% ~1 f $dumpvars(1, top.u1); //depth = 1 scope = top.u1
- M0 H2 i1 k4 |5 L& A $dumpoff //暂停记录数据改变,信号变化不写入库文件中
9 e7 R- B/ }" e% P% j r3 l2 x. ?/ B $dumpon //重新恢复记录
1 T) ]( W/ N3 B
3). Debussy fsdb数据库也可以记录信号的变化,它的优势是可以跟debussy结合,方便调试.
( H, K! F+ l- w
如果要在ncverilog仿真时,记录信号, 首先要设置debussy:
0 R3 D' i3 |) S7 u8 _% O% _
a. setenv LD_LIBRARY_PATH :$LD_LIBRARY_PATH
l9 I: R) C3 j
(path for debpli.so file (/share/PLI/nc_xl//nc_loadpli1))
$ O. u, k! l* d
b. while invoking ncverilog use the +ncloadpli1 option.
" B2 E7 u; [1 N0 j
ncverilog -f run.f +debug +ncloadpli1=debpli:deb_PLIPtr
& c) r5 N2 {$ @1 {! e' j0 |1 ^
fsdb数据库文件的记录方法,是使用$fsdbDumpfile和$fsdbDumpvars系统函数,使用方法参见VCD
7 b* ]' {5 j" s! \# `% F 注意: 在用ncverilog的时候,为了正确地记录波形,要使用参数: "+access+rw", 否则没有读写权限
5 D( |! l# {6 o2 k- v; Z- Z6 @/ E
3. ncverilog编译的顺序: ncverilog file1 file2 ....
) @+ W4 @ L$ X) X8 A& j
有时候这些文件存在依存关系,如在file2中要用到在file1中定义的变量,这时候就要注意其编译的顺序是
3 p7 b6 K" i @. N( c
从后到前,就先编译file2然后才是file2.
7 `% c5 g3 o% L: }4 {
1 V7 v1 n: w% x% F X
4. 信号的强制赋值force
8 {6 H9 n4 z h3 N6 ~6 Z 首先, force语句只能在过程语句中出现,即要在initial 或者 always 中间. 去除force 用 release 语句.
* [. g/ w( M8 [( E2 Q initial begin force sig1 = 1'b1; ... ; release sig1; end
( X; m; w$ b6 L x' T/ `
force可以对wire赋值,这时整个net都被赋值; 也可以对reg赋值.