您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > Modelsim与NCVerilog仿真理解
Modelsim/NCVerilog仿真理解一、modelsim仿真这里以交通信号灯为例介绍modelsim的仿真方法。1.建立modelsim工程,命名为traffic_light.v。2.新建和编写源代码traffic_light.v和tb_traffic_light.v。3.编译上面两个代码。4.添加波形,运行仿真,观察仿真波形。二、NCVerilog仿真1.编写代码traffic_light.v和tb_traffic_light.v.2.编写批处理文件runallcode.bat,里面的内容为TITEL%cd%ncverilog-frunfilelist.f+debug+notimingcheck+access+rwcpause3.编写文件列表文件runfilelist.f,里面包含了要仿真的代码traffic_light.v和tb_traffic_light.v.4.运行runallcode.bat,生成fscb格式的波形文件,通过debussy观察波形。三.Modelsim和NCVerilog对比NCVerilog特点多种语言:verilog/vhdl;多种等级:behavioral,rtl,gate;event-driven,cycle-based;混合信号:模拟,数字Modelsim特点由Model技术公司开发工业上最通用的仿真器之一可在Verilog和VHDL仿真对比:在rtl级或行为级,这两种仿真器都有不错的表现,速度差别不是很大但是在门级仿真,nc速度最快,modelsim要慢很多。附录代码`timescale1ns/1psmoduletraffic_light(clk,rst,state);inputclk,rst;output[1:0]state;reg[1:0]state;reg[4:0]count;parameters0=2'b0,s_green=2'b01,s_yellow=2'b10,s_red=2'b11;always@(posedgeclkorposedgerst)if(rst)beginstate=s0;count=5'd0;endelsecase(state)s0:beginstate=s_green;count=5'b0;ends_green:if(count==5'd24)beginstate=s_yellow;count=5'd0;endelsebeginstate=s_green;count=count+5'd1;ends_yellow:if(count==5'd1)beginstate=s_red;count=5'd0;endelsebeginstate=s_yellow;count=count+5'd1;ends_red:if(count==5'd14)beginstate=s_green;count=5'd0;endelsebeginstate=s_red;ount=count+5'd1;endendcaseendmodule测试代码:`timescale1ns/1psmoduletb_traffic_light();regclk,rst;wire[1:0]state;initialbeginclk=0;rst=0;#20rst=1;#50rst=0;endalways#5clk=~clk;traffic_lighttraffic_light_cmpt(.clk(clk),.rst(rst),.state(state));initialbegin$fsdbDumpfile(traffic_light.fsdb);$fsdbDumpvars(0,tb_traffic_light);#2000000$finish;endendmodule
本文标题:Modelsim与NCVerilog仿真理解
链接地址:https://www.777doc.com/doc-1811389 .html