modelsim独立仿真教程
<div class='showpostmsg'>一.GUI界面的仿真步骤1.首先把你需要仿真的设计文本和仿真文本全部放在同一个文件夹下面,注意,文件夹路径不能包含中文。
我的设计文件:counter.v
`timescale 1ns / 1ns
module counter (count, clk, reset);
output count;
input clk, reset;
reg count;
parameter tpd_reset_to_count = 3;
parameter tpd_clk_to_count = 2;
function increment;
input val;
reg i;
reg carry;
begin
increment = val;
carry = 1'b1;
/*
* Exit this loop when carry == zero, OR all bits processed
*/
for (i = 4'b0; ((carry == 4'b1) && (i <= 7));i = i+ 4'b1)
begin
increment = val ^ carry;
carry = val & carry;
end
end
endfunction
always @ (posedge clk or posedge reset)
if (reset)
count = #tpd_reset_to_count 8'h00;
else
count <= #tpd_clk_to_count increment(count);
/*****************************************************************
Use the following block to make the design synthesizable.
always @ (posedge clk or posedge reset)
if (reset)
count = 8'h00;
else
count <= count + 8'h01;
******************************************************************/
endmodule
我的仿真文件:tcounter.v
`timescale 1ns / 1ns
module test_counter;
reg clk, reset;
wire count;
counter dut (count, clk, reset);
initial // Clock generator
begin
clk = 0;
forever #10 clk = !clk;
end
initial // Test stimulus
begin
reset = 0;
#5 reset = 1;
#4 reset = 0;
end
initial
$monitor($stime,, reset,, clk,,, count);
endmodule
2.打开modelsim软件,选择“File > Change Directory”,把目录改为我们在步骤1所创建的文件夹下,如下图所示
http://www.fpgaw.com/data/attachment/forum/201704/22/104632rcl9y8mm3hcdg3h0.png
3.选择“File > New > Library”,创建一个新的工作库,如下图所示:
http://www.fpgaw.com/data/attachment/forum/201704/22/104701a1mm22tcu8efm53h.png
4.选择“Compile > Compile”,编译我们的设计文件和仿真文件,如下图所示:
http://www.fpgaw.com/data/attachment/forum/201704/22/104840vkhjhkj6mcjoldpa.png
http://www.fpgaw.com/data/attachment/forum/201704/22/105022krer5bighkkr4mph.png
5.最关键的步骤来了,那些老教程就是缺少这步骤中的关键操作,而导致没有波形输出:可视化并加载我们的设计工程,如下图所示:
http://www.fpgaw.com/data/attachment/forum/201704/22/105208ev9c4dcp49l8pqq9.png
http://www.fpgaw.com/data/attachment/forum/201704/22/105409kv3f8d533z20v828.png
http://www.fpgaw.com/data/attachment/forum/201704/22/105420ybo2icc4246l4zcc.png
6.选择软件右下方的“sim”,再鼠标右击,选择“AddTo > Wave > All items in region”,添加观测信号给波形窗口,如下图所示:
http://www.fpgaw.com/data/attachment/forum/201704/22/105742lgt3rrgqgqxjrt8f.png
7.选择软件左下方“wave”,运行仿真,如下图所示:
http://www.fpgaw.com/data/attachment/forum/201704/22/105808rc12hz3k1cqz9i3i.png
http://www.fpgaw.com/data/attachment/forum/201704/22/105813d872qutw7t3vgua7.png
以上就是GUI界面的仿真步骤了。
二.脚本方式的仿真步骤
我个人是不喜欢上述的GUI界面的仿真步骤,太罗嗦了,我喜欢更简单直接的脚本方式的仿真步骤,几行指令即可完成仿真。
下面就是几条主要指令,具体实现,大家还是看modelsim自带英语文档吧。
vlib work //建库
vmap work work //映射
vlog counter.v tcounter.v //编译文本,此指令需要建立project才能运行
vopt +acc test_counter -o testcounter_opt//可视化module
vsim testcounter_opt //加载工程
add wave * //添加观测信号
run -all //运行全部
此内容由EEWORLD论坛网友大辉哥0614原创,如需转载或用于商业用途需征得作者同意并注明出处
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>谢谢楼主分享</p>
请问modelsim仿真做完后该干什么,纯萌新,还没实践经历 标题的Perf_v是性能测评的意思吗
页:
[1]