加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

使用modelsim产生VCD文件和使用VCD文件作为激励的方法

(2010-08-04 18:05:20)
分类: verilog

下面的代码可以产生VCD文件,并保存在了counter.vcd文件中:

module counter(res, clk, out);
input res, clk;
output[7:0] out;

reg[7:0] out;

always@(posedge clk)
if(res)
   out<=0;
else
   out<=out+1;
  

endmodule

 

module dump;

reg res, clk;
wire[7:0] out;

counter counter(res, clk, out);
 
initial
begin

  $dumpfile ("counter.vcd");
  $dumpvars(0,counter.res);
  $dumpvars(0,counter.clk);
  $dumpon;
 
  res<=1; clk<=0;
  #31 res<=0;
  #1000 $stop;
  $dumpoff;
    
end

always #5 clk<=!clk;

endmodule

 

若使用counter.vcd作为激励对counter进行仿真,方法如下:

在modelsim的命令行中,输入

vsim -vcdstim counter.vcd counter

然后,再把counter进行add to wave 的操作;

然后,再点击restart按钮;

最后,点击run_all按钮即可,出现了波形。

 

产生的VCD文件格式分析:

$date
 Wed Aug 04 18:03:23 2010
$end
$version
 ModelSim Version 6.0
$end
$timescale
 1ns
$end
$scope module dump $end
$scope module counter $end
$var wire 1 ! res $end ( -------》用!表示 res信号;)
$var wire 1 " clk $end  (-------》用" 表示 clk信号;)

$upscope $end
$upscope $end
$enddefinitions $end
#0
$dumpvars
1!
0"
$end
#5
1"
#10
0"
#15
1"
#20
0"
#25
1"    
#30
0"  (-------》用" 表示 clk信号;)
#31 (-------》#后的数字表示时间;)
0!  ( -------》用!表示 res信号;)


#35
1"
#40
0"
#45
1"
#50
0"
#55
1"

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有