VCS工具学习笔记(5)


目录

引言

 方法

 原因

 竞争冒险条件

 仿真事件队列

 0时刻不匹配

 时序冒险

规则

实际操作


 


引言

按照视频的讲解进度,继续学习 VCS的使用。

前两篇文章:

VCS 工具学习笔记(1)

VCS工具学习笔记(2)

VCS工具学习笔记(3)

VCS工具学习笔记(4)

本文主要是 debug一些和预想功能不匹配的仿真。

本系列文章建议电脑端查看~~




 方法

 使用例子:

 原因

 竞争冒险条件

 仿真事件队列

 0时刻不匹配

 时序冒险

规则



实际操作

根据视频中的示例给出设计和仿真代码:

设计代码:

// |-------------------------------------------------------
// | Description: two stages flip-flop design and compare
// | Date:2022-11-08
// | Author:Xu Y. B.
// |-------------------------------------------------------

`timescale  1ns/1ns



module DFF_EXP (
// -------------- input / output ports specify ------------
input 							I_CLK,    
input 							I_RSTN,  // Asynchronous reset active low
input 							I_D,

output reg						O_Q	
);

// -------------- module internal signal specify ----------
reg 							R_Q1;

// -------------- module internal logic -------------------
`ifdef DEF_CORRECT
always @(posedge I_CLK or negedge I_RSTN) 
begin 
	if(~I_RSTN) 
	begin
		R_Q1<= 0;
	end 
	else 
	begin
		R_Q1 <= I_D;
	end
end

always @(posedge I_CLK or negedge I_RSTN) 
begin 
	if(~I_RSTN) begin
		O_Q<= 0;
	end 
	else 
	begin
		O_Q <= R_Q1;
	end
end

`else 
always @(posedge I_CLK or negedge I_RSTN) 
begin  
	if(~I_RSTN) begin
		R_Q1 = 0;
	end 
	else 
	begin
		R_Q1 = I_D;
	end
end

always @(posedge I_CLK or negedge I_RSTN) 
begin  
	if(~I_RSTN) begin
		O_Q = 0;
	end 
	else 
	begin
		O_Q = R_Q1;
	end
end
`endif

endmodule

仿真代码:

// -------------------------- testbench for module DFF_EXP ----------------------------
// Date:2022-11-09
// Author:Xu Y. B.	
// ------------------------------------------------------------------------------------

module TB();

// -------------- input / output ports specify ------------
reg 							I_CLK;    
reg 							I_RSTN;  // Asynchronous reset active low
reg 							I_D;
wire							O_Q;	


// clock generate
initial I_CLK <= 0;
always #5 I_CLK <= ~I_CLK;

// ctrl and input generate
initial
begin
	I_RSTN <= 1'b1;
	I_D <= 1'b0;
	repeat(5) @(posedge I_CLK);
	I_RSTN <= 1'b0;
	repeat(5) @(posedge I_CLK);
	I_RSTN <= 1'b1;
	repeat (10)
	begin
		@(posedge I_CLK);
		I_D <= ~I_D;
	end
	$finish;
end

initial
begin
`ifdef VPD_TEST
	$vcdpluson(1,INST_DFF_EXP);
`endif
end

// instantiate module
DFF_EXP INST_DFF_EXP 
( 
  .I_CLK(I_CLK), 
  .I_RSTN(I_RSTN),
  .I_D(I_D), 
  .O_Q(O_Q)
);


endmodule


makefile

.PHONY: com cov clean debug

# output file name
OUTPUT = simv_DFF

# define
VPD_SW_DEFINE = +define+VPD_TEST
FUNC_SW_DEFINE = +define+DEF_CORRECT

# code coverage command
CM = -cm line+cond+fsm+branch+tgl
CM_NAME = -cm_name $(OUTPUT)
CM_DIR = -cm_dir ./$(OUTPUT).vdb

# vpdfile name
VPD_NAME = $(OUTPUT).vpd


# compile command
VCS = vcs -full64 -cpp g++-4.8 -cc gcc-4.8 -LDFLAGS -Wl,--no-as-needed   \
	  -sverilog +v2k -timescale=1ns/1ns      \
      -debug_access+r 	             		 \
      -Mupdate								 \
      +notimingcheck			     		 \
      +nospecify			                 \
      +vcs+flush+all			             \
      $(VPD_SW_DEFINE)						 \
      -o $(OUTPUT)							 \
      -l compile.log						 
	
      # $(CM)				                 \
      # $(CM_NAME)							 \
      # $(CM_DIR)							 \
      							 
      

# simulation command
SIM = ./$(OUTPUT)							 \
      -l $(OUTPUT).log
	  # $(CM) $(CM_NAME) $(CM_DIR)	         \
	  # $(VPD_NAME)							 \
	  

# start complie
com:	
	find -name "*.v" >filelist.f 
	$(VCS) -f filelist.f


# start simulation
sim:
	$(SIM)
	mv vcdplus.vpd $(VPD_NAME)

# show the coverage
cov:
	dve -covdir -vdb &
debug:
	dve -vpd $(OUTPUT).vpd &

# start clean
clean:
	rm -rf ./csrc *.daidir *.log *.vpd *.vdb simv* *.key *race.out* *.so.*

至于操作的细节和过程和视频中的相同,此处就不再赘述。~~~

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

在路上-正出发

哈哈,多少是个心意

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值